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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 bool EnumerateKnownBluetoothLowEnergyDevices( | 71 bool EnumerateKnownBluetoothLowEnergyDevices( |
72 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, | 72 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, |
73 std::string* error) override; | 73 std::string* error) override; |
74 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices( | 74 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices( |
75 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, | 75 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, |
76 std::string* error) override; | 76 std::string* error) override; |
77 bool EnumerateKnownBluetoothLowEnergyServices( | 77 bool EnumerateKnownBluetoothLowEnergyServices( |
78 const base::FilePath& device_path, | 78 const base::FilePath& device_path, |
79 ScopedVector<BluetoothLowEnergyServiceInfo>* services, | 79 ScopedVector<BluetoothLowEnergyServiceInfo>* services, |
80 std::string* error) override; | 80 std::string* error) override; |
| 81 HRESULT ReadIncludedServicesOfAService( |
| 82 base::FilePath& service_path, |
| 83 const PBTH_LE_GATT_SERVICE service, |
| 84 scoped_ptr<BTH_LE_GATT_SERVICE>* out_included_services, |
| 85 USHORT* out_counts) override; |
| 86 HRESULT ReadCharacteristicsOfAService( |
| 87 base::FilePath& service_path, |
| 88 const PBTH_LE_GATT_SERVICE service, |
| 89 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>* out_included_characteristics, |
| 90 USHORT* out_counts) override; |
81 | 91 |
82 BLEDevice* SimulateBLEDevice(std::string device_name, | 92 BLEDevice* SimulateBLEDevice(std::string device_name, |
83 BLUETOOTH_ADDRESS device_address); | 93 BLUETOOTH_ADDRESS device_address); |
84 BLEDevice* GetSimulatedBLEDevice(std::string device_address); | 94 BLEDevice* GetSimulatedBLEDevice(std::string device_address); |
85 BLEGattService* SimulateBLEGattService(BLEDevice* device, std::string uuid); | 95 |
| 96 // Note: |parent_service| == nullptr if simulated service is a primary |
| 97 // service. |
| 98 BLEGattService* SimulateBLEGattService(BLEDevice* device, |
| 99 BLEGattService* parent_service, |
| 100 const BTH_LE_UUID& uuid); |
| 101 |
| 102 // Note: |parent_service| == nullptr if removed service is a primary |
| 103 // service. |
| 104 void SimulateBLEGattServiceRemove(BLEDevice* device, |
| 105 BLEGattService* parent_service, |
| 106 std::string attribute_handle); |
| 107 |
| 108 // Note: |chain_of_att_handle| contains the attribute handles of the services |
| 109 // in order from primary service to target service. The last item in |
| 110 // |chain_of_att_handle| is the target service's attribute handle. |
| 111 BLEGattService* GetSimulatedGattService( |
| 112 BLEDevice* device, |
| 113 const std::vector<std::string>& chain_of_att_handle); |
| 114 BLEGattCharacteristic* SimulateCharacterisc( |
| 115 std::string device_address, |
| 116 BLEGattService* parent_service, |
| 117 const BTH_LE_GATT_CHARACTERISTIC& characteristic); |
| 118 void SimulateCharacteriscRemove(BLEGattService* parent_service, |
| 119 std::string attribute_handle); |
86 | 120 |
87 private: | 121 private: |
88 // Generate an unique attribute handle on |device_address|. | 122 // Generate an unique attribute handle on |device_address|. |
89 USHORT GenerateAUniqueAttributeHandle(std::string device_address); | 123 USHORT GenerateAUniqueAttributeHandle(std::string device_address); |
90 | 124 |
91 // Generate device path for the BLE device with |device_address|. | 125 // Generate device path for the BLE device with |device_address|. |
92 base::string16 GenerateBLEDevicePath(std::string device_address); | 126 base::string16 GenerateBLEDevicePath(std::string device_address); |
93 | 127 |
94 // Generate GATT service device path of the service with | 128 // Generate GATT service device path of the service with |
95 // |service_attribute_handle|. |resident_device_path| is the BLE device this | 129 // |service_attribute_handle|. |resident_device_path| is the BLE device this |
96 // GATT service belongs to. | 130 // GATT service belongs to. |
97 base::string16 GenerateBLEGattServiceDevicePath( | 131 base::string16 GenerateBLEGattServiceDevicePath( |
98 base::string16 resident_device_path, | 132 base::string16 resident_device_path, |
99 USHORT service_attribute_handle); | 133 USHORT service_attribute_handle); |
100 | 134 |
101 // Extract device address from the device |path| generated by | 135 // Extract device address from the device |path| generated by |
102 // GenerateBLEDevicePath or GenerateBLEGattServiceDevicePath. | 136 // GenerateBLEDevicePath or GenerateBLEGattServiceDevicePath. |
103 base::string16 ExtractDeviceAddressFromDevicePath(base::string16 path); | 137 base::string16 ExtractDeviceAddressFromDevicePath(base::string16 path); |
104 | 138 |
105 // Extract service attribute handle from the |path| generated by | 139 // Extract service attribute handles from the |path| generated by |
106 // GenerateBLEGattServiceDevicePath. | 140 // GenerateBLEGattServiceDevicePath. |
107 base::string16 ExtractServiceAttributeHandleFromDevicePath( | 141 std::vector<std::string> ExtractServiceAttributeHandlesFromDevicePath( |
108 base::string16 path); | 142 base::string16 path); |
109 | 143 |
110 // The canonical BLE device address string format is the | 144 // The canonical BLE device address string format is the |
111 // BluetoothDevice::CanonicalizeAddress. | 145 // BluetoothDevice::CanonicalizeAddress. |
112 std::string BluetoothAddressToCanonicalString(const BLUETOOTH_ADDRESS& btha); | 146 std::string BluetoothAddressToCanonicalString(const BLUETOOTH_ADDRESS& btha); |
113 | 147 |
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. | 148 // Table to store allocated attribute handle for a device. |
118 BLEAttributeHandleTable attribute_handle_table_; | 149 BLEAttributeHandleTable attribute_handle_table_; |
119 BLEDevicesMap simulated_devices_; | 150 BLEDevicesMap simulated_devices_; |
120 }; | 151 }; |
121 | 152 |
122 } // namespace win | 153 } // namespace win |
123 } // namespace device | 154 } // namespace device |
124 | 155 |
125 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ | 156 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_FAKE_H_ |
OLD | NEW |