OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ |
7 | 7 |
8 #include "device/bluetooth/bluetooth_low_energy_win.h" | 8 #include "device/bluetooth/bluetooth_low_energy_win.h" |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptor_info; | 61 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptor_info; |
62 scoped_ptr<BTH_LE_GATT_DESCRIPTOR_VALUE> value; | 62 scoped_ptr<BTH_LE_GATT_DESCRIPTOR_VALUE> value; |
63 }; | 63 }; |
64 | 64 |
65 // Fake implementation of BluetoothLowEnergyWrapper. Used for BluetoothTestWin. | 65 // Fake implementation of BluetoothLowEnergyWrapper. Used for BluetoothTestWin. |
66 class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper { | 66 class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper { |
67 public: | 67 public: |
68 BluetoothLowEnergyWrapperFake(); | 68 BluetoothLowEnergyWrapperFake(); |
69 ~BluetoothLowEnergyWrapperFake() override; | 69 ~BluetoothLowEnergyWrapperFake() override; |
70 | 70 |
| 71 bool IsBluetoothLowEnergySupported() override; |
71 bool EnumerateKnownBluetoothLowEnergyDevices( | 72 bool EnumerateKnownBluetoothLowEnergyDevices( |
72 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, | 73 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, |
73 std::string* error) override; | 74 std::string* error) override; |
74 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices( | 75 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices( |
75 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, | 76 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, |
76 std::string* error) override; | 77 std::string* error) override; |
77 bool EnumerateKnownBluetoothLowEnergyServices( | 78 bool EnumerateKnownBluetoothLowEnergyServices( |
78 const base::FilePath& device_path, | 79 const base::FilePath& device_path, |
79 ScopedVector<BluetoothLowEnergyServiceInfo>* services, | 80 ScopedVector<BluetoothLowEnergyServiceInfo>* services, |
80 std::string* error) override; | 81 std::string* error) override; |
| 82 HRESULT ReadCharacteristicsOfAService( |
| 83 base::FilePath& service_path, |
| 84 const PBTH_LE_GATT_SERVICE service, |
| 85 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>* out_included_characteristics, |
| 86 USHORT* out_counts) override; |
81 | 87 |
82 BLEDevice* SimulateBLEDevice(std::string device_name, | 88 BLEDevice* SimulateBLEDevice(std::string device_name, |
83 BLUETOOTH_ADDRESS device_address); | 89 BLUETOOTH_ADDRESS device_address); |
84 BLEDevice* GetSimulatedBLEDevice(std::string device_address); | 90 BLEDevice* GetSimulatedBLEDevice(std::string device_address); |
85 BLEGattService* SimulateBLEGattService(BLEDevice* device, std::string uuid); | 91 |
| 92 // Note: |parent_service| may be nullptr to indicate a primary service. |
| 93 BLEGattService* SimulateBLEGattService(BLEDevice* device, |
| 94 BLEGattService* parent_service, |
| 95 const BTH_LE_UUID& uuid); |
| 96 |
| 97 // Note: |parent_service| may be nullptr to indicate a primary service. |
| 98 void SimulateBLEGattServiceRemoved(BLEDevice* device, |
| 99 BLEGattService* parent_service, |
| 100 std::string attribute_handle); |
| 101 |
| 102 // Note: |chain_of_att_handle| contains the attribute handles of the services |
| 103 // in order from primary service to target service. The last item in |
| 104 // |chain_of_att_handle| is the target service's attribute handle. |
| 105 BLEGattService* GetSimulatedGattService( |
| 106 BLEDevice* device, |
| 107 const std::vector<std::string>& chain_of_att_handle); |
| 108 BLEGattCharacteristic* SimulateBLEGattCharacterisc( |
| 109 std::string device_address, |
| 110 BLEGattService* parent_service, |
| 111 const BTH_LE_GATT_CHARACTERISTIC& characteristic); |
| 112 void SimulateBLEGattCharacteriscRemove(BLEGattService* parent_service, |
| 113 std::string attribute_handle); |
86 | 114 |
87 private: | 115 private: |
88 // Generate an unique attribute handle on |device_address|. | 116 // Generate an unique attribute handle on |device_address|. |
89 USHORT GenerateAUniqueAttributeHandle(std::string device_address); | 117 USHORT GenerateAUniqueAttributeHandle(std::string device_address); |
90 | 118 |
91 // Generate device path for the BLE device with |device_address|. | 119 // Generate device path for the BLE device with |device_address|. |
92 base::string16 GenerateBLEDevicePath(std::string device_address); | 120 base::string16 GenerateBLEDevicePath(std::string device_address); |
93 | 121 |
94 // Generate GATT service device path of the service with | 122 // Generate GATT service device path of the service with |
95 // |service_attribute_handle|. |resident_device_path| is the BLE device this | 123 // |service_attribute_handle|. |resident_device_path| is the BLE device this |
96 // GATT service belongs to. | 124 // GATT service belongs to. |
97 base::string16 GenerateBLEGattServiceDevicePath( | 125 base::string16 GenerateBLEGattServiceDevicePath( |
98 base::string16 resident_device_path, | 126 base::string16 resident_device_path, |
99 USHORT service_attribute_handle); | 127 USHORT service_attribute_handle); |
100 | 128 |
101 // Extract device address from the device |path| generated by | 129 // Extract device address from the device |path| generated by |
102 // GenerateBLEDevicePath or GenerateBLEGattServiceDevicePath. | 130 // GenerateBLEDevicePath or GenerateBLEGattServiceDevicePath. |
103 base::string16 ExtractDeviceAddressFromDevicePath(base::string16 path); | 131 base::string16 ExtractDeviceAddressFromDevicePath(base::string16 path); |
104 | 132 |
105 // Extract service attribute handle from the |path| generated by | 133 // Extract service attribute handles from the |path| generated by |
106 // GenerateBLEGattServiceDevicePath. | 134 // GenerateBLEGattServiceDevicePath. |
107 base::string16 ExtractServiceAttributeHandleFromDevicePath( | 135 std::vector<std::string> ExtractServiceAttributeHandlesFromDevicePath( |
108 base::string16 path); | 136 base::string16 path); |
109 | 137 |
110 // The canonical BLE device address string format is the | 138 // The canonical BLE device address string format is the |
111 // BluetoothDevice::CanonicalizeAddress. | 139 // BluetoothDevice::CanonicalizeAddress. |
112 std::string BluetoothAddressToCanonicalString(const BLUETOOTH_ADDRESS& btha); | 140 std::string BluetoothAddressToCanonicalString(const BLUETOOTH_ADDRESS& btha); |
113 | 141 |
114 // The canonical UUID string format is device::BluetoothUUID.value(). | |
115 BTH_LE_UUID CanonicalStringToBTH_LE_UUID(std::string uuid); | |
116 | |
117 // Table to store allocated attribute handle for a device. | 142 // Table to store allocated attribute handle for a device. |
118 BLEAttributeHandleTable attribute_handle_table_; | 143 BLEAttributeHandleTable attribute_handle_table_; |
119 BLEDevicesMap simulated_devices_; | 144 BLEDevicesMap simulated_devices_; |
120 }; | 145 }; |
121 | 146 |
122 } // namespace win | 147 } // namespace win |
123 } // namespace device | 148 } // namespace device |
124 | 149 |
125 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ | 150 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ |
OLD | NEW |