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 #include "device/bluetooth/bluetooth_low_energy_win_fake.h" | 5 #include "device/bluetooth/bluetooth_low_energy_win_fake.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" | 8 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 const char kPlatformNotSupported[] = | 11 const char kPlatformNotSupported[] = |
12 "Bluetooth Low energy is only supported on Windows 8 and later."; | 12 "Bluetooth Low energy is only supported on Windows 8 and later."; |
13 } // namespace | 13 } // namespace |
14 | 14 |
15 namespace device { | 15 namespace device { |
16 namespace win { | 16 namespace win { |
17 | 17 |
18 BLEDevice::BLEDevice() {} | 18 BLEDevice::BLEDevice() {} |
19 BLEDevice::~BLEDevice() {} | 19 BLEDevice::~BLEDevice() {} |
20 | 20 |
21 BLEGattService::BLEGattService() {} | 21 GattService::GattService() {} |
22 BLEGattService::~BLEGattService() {} | 22 GattService::~GattService() {} |
23 | 23 |
24 BLEGattCharacteristic::BLEGattCharacteristic() {} | 24 GattCharacteristic::GattCharacteristic() {} |
25 BLEGattCharacteristic::~BLEGattCharacteristic() {} | 25 GattCharacteristic::~GattCharacteristic() {} |
26 | 26 |
27 BLEGattDescriptor::BLEGattDescriptor() {} | 27 GattDescriptor::GattDescriptor() {} |
28 BLEGattDescriptor::~BLEGattDescriptor() {} | 28 GattDescriptor::~GattDescriptor() {} |
29 | 29 |
30 BluetoothLowEnergyWrapperFake::BluetoothLowEnergyWrapperFake() {} | 30 BluetoothLowEnergyWrapperFake::BluetoothLowEnergyWrapperFake() {} |
31 BluetoothLowEnergyWrapperFake::~BluetoothLowEnergyWrapperFake() {} | 31 BluetoothLowEnergyWrapperFake::~BluetoothLowEnergyWrapperFake() {} |
32 | 32 |
33 bool BluetoothLowEnergyWrapperFake::IsBluetoothLowEnergySupported() { | 33 bool BluetoothLowEnergyWrapperFake::IsBluetoothLowEnergySupported() { |
34 return true; | 34 return true; |
35 } | 35 } |
36 | 36 |
37 bool BluetoothLowEnergyWrapperFake::EnumerateKnownBluetoothLowEnergyDevices( | 37 bool BluetoothLowEnergyWrapperFake::EnumerateKnownBluetoothLowEnergyDevices( |
38 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, | 38 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, |
(...skipping 19 matching lines...) Expand all Loading... | |
58 if (!IsBluetoothLowEnergySupported()) { | 58 if (!IsBluetoothLowEnergySupported()) { |
59 *error = kPlatformNotSupported; | 59 *error = kPlatformNotSupported; |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
63 for (auto& device : simulated_devices_) { | 63 for (auto& device : simulated_devices_) { |
64 for (auto& service : device.second->primary_services) { | 64 for (auto& service : device.second->primary_services) { |
65 BluetoothLowEnergyDeviceInfo* device_info = | 65 BluetoothLowEnergyDeviceInfo* device_info = |
66 new BluetoothLowEnergyDeviceInfo(); | 66 new BluetoothLowEnergyDeviceInfo(); |
67 *device_info = *(device.second->device_info); | 67 *device_info = *(device.second->device_info); |
68 base::string16 path = GenerateBLEGattServiceDevicePath( | 68 base::string16 path = GenerateGattServiceDevicePath( |
69 device.second->device_info->path.value(), | 69 device.second->device_info->path.value(), |
70 service.second->service_info->AttributeHandle); | 70 service.second->service_info->AttributeHandle); |
71 device_info->path = base::FilePath(path); | 71 device_info->path = base::FilePath(path); |
72 devices->push_back(device_info); | 72 devices->push_back(device_info); |
73 } | 73 } |
74 } | 74 } |
75 return true; | 75 return true; |
76 } | 76 } |
77 | 77 |
78 bool BluetoothLowEnergyWrapperFake::EnumerateKnownBluetoothLowEnergyServices( | 78 bool BluetoothLowEnergyWrapperFake::EnumerateKnownBluetoothLowEnergyServices( |
(...skipping 21 matching lines...) Expand all Loading... | |
100 for (auto& primary_service : it_d->second->primary_services) { | 100 for (auto& primary_service : it_d->second->primary_services) { |
101 BluetoothLowEnergyServiceInfo* service_info = | 101 BluetoothLowEnergyServiceInfo* service_info = |
102 new BluetoothLowEnergyServiceInfo(); | 102 new BluetoothLowEnergyServiceInfo(); |
103 service_info->uuid = primary_service.second->service_info->ServiceUuid; | 103 service_info->uuid = primary_service.second->service_info->ServiceUuid; |
104 service_info->attribute_handle = | 104 service_info->attribute_handle = |
105 primary_service.second->service_info->AttributeHandle; | 105 primary_service.second->service_info->AttributeHandle; |
106 services->push_back(service_info); | 106 services->push_back(service_info); |
107 } | 107 } |
108 } else { | 108 } else { |
109 // Return corresponding GATT service for BLE GATT service device. | 109 // Return corresponding GATT service for BLE GATT service device. |
110 BLEGattService* target_service = | 110 GattService* target_service = |
111 GetSimulatedGattService(it_d->second.get(), service_attribute_handles); | 111 GetSimulatedGattService(it_d->second.get(), service_attribute_handles); |
112 BluetoothLowEnergyServiceInfo* service_info = | 112 BluetoothLowEnergyServiceInfo* service_info = |
113 new BluetoothLowEnergyServiceInfo(); | 113 new BluetoothLowEnergyServiceInfo(); |
114 service_info->uuid = target_service->service_info->ServiceUuid; | 114 service_info->uuid = target_service->service_info->ServiceUuid; |
115 service_info->attribute_handle = | 115 service_info->attribute_handle = |
116 target_service->service_info->AttributeHandle; | 116 target_service->service_info->AttributeHandle; |
117 services->push_back(service_info); | 117 services->push_back(service_info); |
118 } | 118 } |
119 | 119 |
120 return true; | 120 return true; |
121 } | 121 } |
122 | 122 |
123 HRESULT BluetoothLowEnergyWrapperFake::ReadCharacteristicsOfAService( | 123 HRESULT BluetoothLowEnergyWrapperFake::ReadCharacteristicsOfAService( |
124 base::FilePath& service_path, | 124 base::FilePath& service_path, |
125 const PBTH_LE_GATT_SERVICE service, | 125 const PBTH_LE_GATT_SERVICE service, |
126 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>* out_included_characteristics, | 126 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>* out_included_characteristics, |
127 USHORT* out_counts) { | 127 USHORT* out_counts) { |
128 base::string16 device_address = | 128 base::string16 device_address = |
129 ExtractDeviceAddressFromDevicePath(service_path.value()); | 129 ExtractDeviceAddressFromDevicePath(service_path.value()); |
130 const std::vector<std::string> service_att_handles = | 130 const std::vector<std::string> service_att_handles = |
131 ExtractServiceAttributeHandlesFromDevicePath(service_path.value()); | 131 ExtractServiceAttributeHandlesFromDevicePath(service_path.value()); |
132 BLEGattService* target_service = GetSimulatedGattService( | 132 GattService* target_service = GetSimulatedGattService( |
133 GetSimulatedBLEDevice( | 133 GetSimulatedBLEDevice( |
134 std::string(device_address.begin(), device_address.end())), | 134 std::string(device_address.begin(), device_address.end())), |
135 service_att_handles); | 135 service_att_handles); |
136 if (target_service == nullptr) | 136 if (target_service == nullptr) |
137 return HRESULT_FROM_WIN32(ERROR_NOT_FOUND); | 137 return HRESULT_FROM_WIN32(ERROR_NOT_FOUND); |
138 | 138 |
139 std::size_t number_of_included_characteristic = | 139 std::size_t number_of_included_characteristic = |
140 target_service->included_characteristics.size(); | 140 target_service->included_characteristics.size(); |
141 if (number_of_included_characteristic) { | 141 if (number_of_included_characteristic) { |
142 *out_counts = (USHORT)number_of_included_characteristic; | 142 *out_counts = (USHORT)number_of_included_characteristic; |
143 out_included_characteristics->reset( | 143 out_included_characteristics->reset( |
144 new BTH_LE_GATT_CHARACTERISTIC[number_of_included_characteristic]); | 144 new BTH_LE_GATT_CHARACTERISTIC[number_of_included_characteristic]); |
145 std::size_t i = 0; | 145 std::size_t i = 0; |
146 for (const auto& cha : target_service->included_characteristics) { | 146 for (const auto& cha : target_service->included_characteristics) { |
147 out_included_characteristics->get()[i] = | 147 out_included_characteristics->get()[i] = |
148 *(cha.second->characteristic_info); | 148 *(cha.second->characteristic_info); |
149 i++; | 149 i++; |
150 } | 150 } |
151 return S_OK; | 151 return S_OK; |
152 } | 152 } |
153 return HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS); | 153 return HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS); |
154 } | 154 } |
155 | 155 |
156 HRESULT BluetoothLowEnergyWrapperFake::ReadDescriptorsOfACharacteristic( | |
157 base::FilePath& service_path, | |
158 const PBTH_LE_GATT_CHARACTERISTIC characteristic, | |
159 scoped_ptr<BTH_LE_GATT_DESCRIPTOR>* out_included_descriptors, | |
160 USHORT* out_counts) { | |
161 GattCharacteristic* target_characteristic = | |
162 GetSimulatedGattCharacteristic(service_path, characteristic); | |
163 if (target_characteristic == nullptr) | |
164 return HRESULT_FROM_WIN32(ERROR_NOT_FOUND); | |
165 | |
166 std::size_t number_of_included_descriptors = | |
167 target_characteristic->included_descriptors.size(); | |
168 PBTH_LE_GATT_DESCRIPTOR win_descriptors_info = | |
169 new BTH_LE_GATT_DESCRIPTOR[number_of_included_descriptors]; | |
170 *out_counts = USHORT(number_of_included_descriptors); | |
171 std::size_t i = 0; | |
172 for (const auto& d : target_characteristic->included_descriptors) { | |
173 win_descriptors_info[i] = *(d.second->descriptor_info); | |
174 i++; | |
175 } | |
176 out_included_descriptors->reset(win_descriptors_info); | |
177 return S_OK; | |
178 } | |
179 | |
156 BLEDevice* BluetoothLowEnergyWrapperFake::SimulateBLEDevice( | 180 BLEDevice* BluetoothLowEnergyWrapperFake::SimulateBLEDevice( |
157 std::string device_name, | 181 std::string device_name, |
158 BLUETOOTH_ADDRESS device_address) { | 182 BLUETOOTH_ADDRESS device_address) { |
159 BLEDevice* device = new BLEDevice(); | 183 BLEDevice* device = new BLEDevice(); |
160 BluetoothLowEnergyDeviceInfo* device_info = | 184 BluetoothLowEnergyDeviceInfo* device_info = |
161 new BluetoothLowEnergyDeviceInfo(); | 185 new BluetoothLowEnergyDeviceInfo(); |
162 std::string string_device_address = | 186 std::string string_device_address = |
163 BluetoothAddressToCanonicalString(device_address); | 187 BluetoothAddressToCanonicalString(device_address); |
164 device_info->path = | 188 device_info->path = |
165 base::FilePath(GenerateBLEDevicePath(string_device_address)); | 189 base::FilePath(GenerateBLEDevicePath(string_device_address)); |
166 device_info->friendly_name = device_name; | 190 device_info->friendly_name = device_name; |
167 device_info->address = device_address; | 191 device_info->address = device_address; |
168 device->device_info.reset(device_info); | 192 device->device_info.reset(device_info); |
169 simulated_devices_[string_device_address] = make_scoped_ptr(device); | 193 simulated_devices_[string_device_address] = make_scoped_ptr(device); |
170 return device; | 194 return device; |
171 } | 195 } |
172 | 196 |
173 BLEDevice* BluetoothLowEnergyWrapperFake::GetSimulatedBLEDevice( | 197 BLEDevice* BluetoothLowEnergyWrapperFake::GetSimulatedBLEDevice( |
174 std::string device_address) { | 198 std::string device_address) { |
175 BLEDevicesMap::iterator it_d = simulated_devices_.find(device_address); | 199 BLEDevicesMap::iterator it_d = simulated_devices_.find(device_address); |
176 if (it_d == simulated_devices_.end()) | 200 if (it_d == simulated_devices_.end()) |
177 return nullptr; | 201 return nullptr; |
178 return it_d->second.get(); | 202 return it_d->second.get(); |
179 } | 203 } |
180 | 204 |
181 BLEGattService* BluetoothLowEnergyWrapperFake::SimulateBLEGattService( | 205 GattService* BluetoothLowEnergyWrapperFake::SimulateGattService( |
182 BLEDevice* device, | 206 BLEDevice* device, |
183 BLEGattService* parent_service, | 207 GattService* parent_service, |
184 const BTH_LE_UUID& uuid) { | 208 const BTH_LE_UUID& uuid) { |
185 CHECK(device); | 209 CHECK(device); |
186 | 210 |
187 BLEGattService* service = new BLEGattService(); | 211 GattService* service = new GattService(); |
188 PBTH_LE_GATT_SERVICE service_info = new BTH_LE_GATT_SERVICE[1]; | 212 PBTH_LE_GATT_SERVICE service_info = new BTH_LE_GATT_SERVICE[1]; |
189 std::string string_device_address = | 213 std::string string_device_address = |
190 BluetoothAddressToCanonicalString(device->device_info->address); | 214 BluetoothAddressToCanonicalString(device->device_info->address); |
191 service_info->AttributeHandle = | 215 service_info->AttributeHandle = |
192 GenerateAUniqueAttributeHandle(string_device_address); | 216 GenerateAUniqueAttributeHandle(string_device_address); |
193 service_info->ServiceUuid = uuid; | 217 service_info->ServiceUuid = uuid; |
194 service->service_info.reset(service_info); | 218 service->service_info.reset(service_info); |
195 | 219 |
196 if (parent_service) { | 220 if (parent_service) { |
197 parent_service | 221 parent_service |
198 ->included_services[std::to_string(service_info->AttributeHandle)] = | 222 ->included_services[std::to_string(service_info->AttributeHandle)] = |
199 make_scoped_ptr(service); | 223 make_scoped_ptr(service); |
200 } else { | 224 } else { |
201 device->primary_services[std::to_string(service_info->AttributeHandle)] = | 225 device->primary_services[std::to_string(service_info->AttributeHandle)] = |
202 make_scoped_ptr(service); | 226 make_scoped_ptr(service); |
203 } | 227 } |
204 return service; | 228 return service; |
205 } | 229 } |
206 | 230 |
207 void BluetoothLowEnergyWrapperFake::SimulateBLEGattServiceRemoved( | 231 void BluetoothLowEnergyWrapperFake::SimulateGattServiceRemoved( |
208 BLEDevice* device, | 232 BLEDevice* device, |
209 BLEGattService* parent_service, | 233 GattService* parent_service, |
210 std::string attribute_handle) { | 234 std::string attribute_handle) { |
211 if (parent_service) { | 235 if (parent_service) { |
212 parent_service->included_services.erase(attribute_handle); | 236 parent_service->included_services.erase(attribute_handle); |
213 } else { | 237 } else { |
214 device->primary_services.erase(attribute_handle); | 238 device->primary_services.erase(attribute_handle); |
215 } | 239 } |
216 } | 240 } |
217 | 241 |
218 BLEGattService* BluetoothLowEnergyWrapperFake::GetSimulatedGattService( | 242 GattService* BluetoothLowEnergyWrapperFake::GetSimulatedGattService( |
219 BLEDevice* device, | 243 BLEDevice* device, |
220 const std::vector<std::string>& chain_of_att_handle) { | 244 const std::vector<std::string>& chain_of_att_handle) { |
221 // First, find the root primary service. | 245 // First, find the root primary service. |
222 BLEGattServicesMap::iterator it_s = | 246 GattServicesMap::iterator it_s = |
223 device->primary_services.find(chain_of_att_handle[0]); | 247 device->primary_services.find(chain_of_att_handle[0]); |
224 if (it_s == device->primary_services.end()) | 248 if (it_s == device->primary_services.end()) |
225 return nullptr; | 249 return nullptr; |
226 | 250 |
227 // Iteratively follow the chain of included service attribute handles to find | 251 // Iteratively follow the chain of included service attribute handles to find |
228 // the target service. | 252 // the target service. |
229 for (std::size_t i = 1; i < chain_of_att_handle.size(); i++) { | 253 for (std::size_t i = 1; i < chain_of_att_handle.size(); i++) { |
230 std::string included_att_handle = std::string( | 254 std::string included_att_handle = std::string( |
231 chain_of_att_handle[i].begin(), chain_of_att_handle[i].end()); | 255 chain_of_att_handle[i].begin(), chain_of_att_handle[i].end()); |
232 BLEGattServicesMap::iterator it_i = | 256 GattServicesMap::iterator it_i = |
233 it_s->second->included_services.find(included_att_handle); | 257 it_s->second->included_services.find(included_att_handle); |
234 if (it_i == it_s->second->included_services.end()) | 258 if (it_i == it_s->second->included_services.end()) |
235 return nullptr; | 259 return nullptr; |
236 it_s = it_i; | 260 it_s = it_i; |
237 } | 261 } |
238 return it_s->second.get(); | 262 return it_s->second.get(); |
239 } | 263 } |
240 | 264 |
241 BLEGattCharacteristic* | 265 GattCharacteristic* BluetoothLowEnergyWrapperFake::SimulateGattCharacterisc( |
242 BluetoothLowEnergyWrapperFake::SimulateBLEGattCharacterisc( | |
243 std::string device_address, | 266 std::string device_address, |
244 BLEGattService* parent_service, | 267 GattService* parent_service, |
245 const BTH_LE_GATT_CHARACTERISTIC& characteristic) { | 268 const BTH_LE_GATT_CHARACTERISTIC& characteristic) { |
246 CHECK(parent_service); | 269 CHECK(parent_service); |
247 | 270 |
248 BLEGattCharacteristic* win_characteristic = new BLEGattCharacteristic(); | 271 GattCharacteristic* win_characteristic = new GattCharacteristic(); |
249 PBTH_LE_GATT_CHARACTERISTIC win_characteristic_info = | 272 PBTH_LE_GATT_CHARACTERISTIC win_characteristic_info = |
250 new BTH_LE_GATT_CHARACTERISTIC[1]; | 273 new BTH_LE_GATT_CHARACTERISTIC[1]; |
251 *win_characteristic_info = characteristic; | 274 *win_characteristic_info = characteristic; |
252 (win_characteristic->characteristic_info).reset(win_characteristic_info); | 275 (win_characteristic->characteristic_info).reset(win_characteristic_info); |
253 win_characteristic->characteristic_info->AttributeHandle = | 276 win_characteristic->characteristic_info->AttributeHandle = |
254 GenerateAUniqueAttributeHandle(device_address); | 277 GenerateAUniqueAttributeHandle(device_address); |
255 parent_service->included_characteristics[std::to_string( | 278 parent_service->included_characteristics[std::to_string( |
256 win_characteristic->characteristic_info->AttributeHandle)] = | 279 win_characteristic->characteristic_info->AttributeHandle)] = |
257 make_scoped_ptr(win_characteristic); | 280 make_scoped_ptr(win_characteristic); |
258 return win_characteristic; | 281 return win_characteristic; |
259 } | 282 } |
260 | 283 |
261 void BluetoothLowEnergyWrapperFake::SimulateBLEGattCharacteriscRemove( | 284 void BluetoothLowEnergyWrapperFake::SimulateGattCharacteriscRemove( |
262 BLEGattService* parent_service, | 285 GattService* parent_service, |
263 std::string attribute_handle) { | 286 std::string attribute_handle) { |
264 CHECK(parent_service); | 287 CHECK(parent_service); |
265 parent_service->included_characteristics.erase(attribute_handle); | 288 parent_service->included_characteristics.erase(attribute_handle); |
266 } | 289 } |
267 | 290 |
291 GattCharacteristic* | |
292 BluetoothLowEnergyWrapperFake::GetSimulatedGattCharacteristic( | |
293 GattService* parent_service, | |
294 std::string attribute_handle) { | |
295 CHECK(parent_service); | |
296 GattCharacteristicsMap::iterator it = | |
297 parent_service->included_characteristics.find(attribute_handle); | |
298 if (it != parent_service->included_characteristics.end()) | |
299 return it->second.get(); | |
300 return nullptr; | |
301 } | |
302 | |
303 void BluetoothLowEnergyWrapperFake::SimulateGattDescriptor( | |
304 std::string device_address, | |
305 GattCharacteristic* characteristic, | |
306 const BTH_LE_UUID& uuid) { | |
307 GattDescriptor* descriptor = new GattDescriptor(); | |
scheib
2016/03/01 00:06:22
Create into a scoped ptr, and then std::move it in
gogerald1
2016/03/01 17:00:13
Done.
| |
308 BTH_LE_GATT_DESCRIPTOR* win_descriptors_info = new BTH_LE_GATT_DESCRIPTOR[1]; | |
309 win_descriptors_info->DescriptorUuid = uuid; | |
310 win_descriptors_info->AttributeHandle = | |
311 GenerateAUniqueAttributeHandle(device_address); | |
312 descriptor->descriptor_info.reset(win_descriptors_info); | |
313 characteristic->included_descriptors[std::to_string( | |
314 win_descriptors_info->AttributeHandle)] = make_scoped_ptr(descriptor); | |
315 } | |
316 | |
317 GattCharacteristic* | |
318 BluetoothLowEnergyWrapperFake::GetSimulatedGattCharacteristic( | |
319 base::FilePath& service_path, | |
320 const PBTH_LE_GATT_CHARACTERISTIC characteristic) { | |
321 base::string16 device_address = | |
322 ExtractDeviceAddressFromDevicePath(service_path.value()); | |
323 BLEDevice* target_device = GetSimulatedBLEDevice( | |
324 std::string(device_address.begin(), device_address.end())); | |
325 if (target_device == nullptr) | |
326 return nullptr; | |
327 const std::vector<std::string> service_att_handles = | |
328 ExtractServiceAttributeHandlesFromDevicePath(service_path.value()); | |
329 GattService* target_service = | |
330 GetSimulatedGattService(target_device, service_att_handles); | |
331 if (target_service == nullptr) | |
332 return nullptr; | |
333 GattCharacteristic* target_characteristic = GetSimulatedGattCharacteristic( | |
334 target_service, std::to_string(characteristic->AttributeHandle)); | |
335 return target_characteristic; | |
336 } | |
337 | |
268 USHORT BluetoothLowEnergyWrapperFake::GenerateAUniqueAttributeHandle( | 338 USHORT BluetoothLowEnergyWrapperFake::GenerateAUniqueAttributeHandle( |
269 std::string device_address) { | 339 std::string device_address) { |
270 scoped_ptr<std::set<USHORT>>& set_of_ushort = | 340 scoped_ptr<std::set<USHORT>>& set_of_ushort = |
271 attribute_handle_table_[device_address]; | 341 attribute_handle_table_[device_address]; |
272 if (set_of_ushort) { | 342 if (set_of_ushort) { |
273 USHORT max_attribute_handle = *set_of_ushort->rbegin(); | 343 USHORT max_attribute_handle = *set_of_ushort->rbegin(); |
274 if (max_attribute_handle < 0xFFFF) { | 344 if (max_attribute_handle < 0xFFFF) { |
275 USHORT new_attribute_handle = max_attribute_handle + 1; | 345 USHORT new_attribute_handle = max_attribute_handle + 1; |
276 set_of_ushort->insert(new_attribute_handle); | 346 set_of_ushort->insert(new_attribute_handle); |
277 return new_attribute_handle; | 347 return new_attribute_handle; |
(...skipping 15 matching lines...) Expand all Loading... | |
293 new_set->insert(smallest_att_handle); | 363 new_set->insert(smallest_att_handle); |
294 set_of_ushort.reset(new_set); | 364 set_of_ushort.reset(new_set); |
295 return smallest_att_handle; | 365 return smallest_att_handle; |
296 } | 366 } |
297 | 367 |
298 base::string16 BluetoothLowEnergyWrapperFake::GenerateBLEDevicePath( | 368 base::string16 BluetoothLowEnergyWrapperFake::GenerateBLEDevicePath( |
299 std::string device_address) { | 369 std::string device_address) { |
300 return base::string16(device_address.begin(), device_address.end()); | 370 return base::string16(device_address.begin(), device_address.end()); |
301 } | 371 } |
302 | 372 |
303 base::string16 BluetoothLowEnergyWrapperFake::GenerateBLEGattServiceDevicePath( | 373 base::string16 BluetoothLowEnergyWrapperFake::GenerateGattServiceDevicePath( |
304 base::string16 resident_device_path, | 374 base::string16 resident_device_path, |
305 USHORT service_attribute_handle) { | 375 USHORT service_attribute_handle) { |
306 std::string sub_path = std::to_string(service_attribute_handle); | 376 std::string sub_path = std::to_string(service_attribute_handle); |
307 return resident_device_path + L"/" + | 377 return resident_device_path + L"/" + |
308 base::string16(sub_path.begin(), sub_path.end()); | 378 base::string16(sub_path.begin(), sub_path.end()); |
309 } | 379 } |
310 | 380 |
311 base::string16 | 381 base::string16 |
312 BluetoothLowEnergyWrapperFake::ExtractDeviceAddressFromDevicePath( | 382 BluetoothLowEnergyWrapperFake::ExtractDeviceAddressFromDevicePath( |
313 base::string16 path) { | 383 base::string16 path) { |
(...skipping 30 matching lines...) Expand all Loading... | |
344 std::string BluetoothLowEnergyWrapperFake::BluetoothAddressToCanonicalString( | 414 std::string BluetoothLowEnergyWrapperFake::BluetoothAddressToCanonicalString( |
345 const BLUETOOTH_ADDRESS& btha) { | 415 const BLUETOOTH_ADDRESS& btha) { |
346 std::string result = base::StringPrintf( | 416 std::string result = base::StringPrintf( |
347 "%02X:%02X:%02X:%02X:%02X:%02X", btha.rgBytes[5], btha.rgBytes[4], | 417 "%02X:%02X:%02X:%02X:%02X:%02X", btha.rgBytes[5], btha.rgBytes[4], |
348 btha.rgBytes[3], btha.rgBytes[2], btha.rgBytes[1], btha.rgBytes[0]); | 418 btha.rgBytes[3], btha.rgBytes[2], btha.rgBytes[1], btha.rgBytes[0]); |
349 return result; | 419 return result; |
350 } | 420 } |
351 | 421 |
352 } // namespace win | 422 } // namespace win |
353 } // namespace device | 423 } // namespace device |
OLD | NEW |