Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Side by Side Diff: device/bluetooth/bluetooth_low_energy_win_fake.cc

Issue 1728163006: Implement BluetoothRemoteGattCharacteristicWin::GetDescriptors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 scoped_ptr<GattDescriptor> descriptor(new GattDescriptor());
308 descriptor->descriptor_info.reset(new BTH_LE_GATT_DESCRIPTOR[1]);
309 descriptor->descriptor_info->DescriptorUuid = uuid;
310 descriptor->descriptor_info->AttributeHandle =
311 GenerateAUniqueAttributeHandle(device_address);
312 characteristic->included_descriptors[std::to_string(
313 descriptor->descriptor_info->AttributeHandle)] = std::move(descriptor);
314 }
315
316 GattCharacteristic*
317 BluetoothLowEnergyWrapperFake::GetSimulatedGattCharacteristic(
318 base::FilePath& service_path,
319 const PBTH_LE_GATT_CHARACTERISTIC characteristic) {
320 base::string16 device_address =
321 ExtractDeviceAddressFromDevicePath(service_path.value());
322 BLEDevice* target_device = GetSimulatedBLEDevice(
323 std::string(device_address.begin(), device_address.end()));
324 if (target_device == nullptr)
325 return nullptr;
326 const std::vector<std::string> service_att_handles =
327 ExtractServiceAttributeHandlesFromDevicePath(service_path.value());
328 GattService* target_service =
329 GetSimulatedGattService(target_device, service_att_handles);
330 if (target_service == nullptr)
331 return nullptr;
332 GattCharacteristic* target_characteristic = GetSimulatedGattCharacteristic(
333 target_service, std::to_string(characteristic->AttributeHandle));
334 return target_characteristic;
335 }
336
268 USHORT BluetoothLowEnergyWrapperFake::GenerateAUniqueAttributeHandle( 337 USHORT BluetoothLowEnergyWrapperFake::GenerateAUniqueAttributeHandle(
269 std::string device_address) { 338 std::string device_address) {
270 scoped_ptr<std::set<USHORT>>& set_of_ushort = 339 scoped_ptr<std::set<USHORT>>& set_of_ushort =
271 attribute_handle_table_[device_address]; 340 attribute_handle_table_[device_address];
272 if (set_of_ushort) { 341 if (set_of_ushort) {
273 USHORT max_attribute_handle = *set_of_ushort->rbegin(); 342 USHORT max_attribute_handle = *set_of_ushort->rbegin();
274 if (max_attribute_handle < 0xFFFF) { 343 if (max_attribute_handle < 0xFFFF) {
275 USHORT new_attribute_handle = max_attribute_handle + 1; 344 USHORT new_attribute_handle = max_attribute_handle + 1;
276 set_of_ushort->insert(new_attribute_handle); 345 set_of_ushort->insert(new_attribute_handle);
277 return new_attribute_handle; 346 return new_attribute_handle;
(...skipping 15 matching lines...) Expand all
293 new_set->insert(smallest_att_handle); 362 new_set->insert(smallest_att_handle);
294 set_of_ushort.reset(new_set); 363 set_of_ushort.reset(new_set);
295 return smallest_att_handle; 364 return smallest_att_handle;
296 } 365 }
297 366
298 base::string16 BluetoothLowEnergyWrapperFake::GenerateBLEDevicePath( 367 base::string16 BluetoothLowEnergyWrapperFake::GenerateBLEDevicePath(
299 std::string device_address) { 368 std::string device_address) {
300 return base::string16(device_address.begin(), device_address.end()); 369 return base::string16(device_address.begin(), device_address.end());
301 } 370 }
302 371
303 base::string16 BluetoothLowEnergyWrapperFake::GenerateBLEGattServiceDevicePath( 372 base::string16 BluetoothLowEnergyWrapperFake::GenerateGattServiceDevicePath(
304 base::string16 resident_device_path, 373 base::string16 resident_device_path,
305 USHORT service_attribute_handle) { 374 USHORT service_attribute_handle) {
306 std::string sub_path = std::to_string(service_attribute_handle); 375 std::string sub_path = std::to_string(service_attribute_handle);
307 return resident_device_path + L"/" + 376 return resident_device_path + L"/" +
308 base::string16(sub_path.begin(), sub_path.end()); 377 base::string16(sub_path.begin(), sub_path.end());
309 } 378 }
310 379
311 base::string16 380 base::string16
312 BluetoothLowEnergyWrapperFake::ExtractDeviceAddressFromDevicePath( 381 BluetoothLowEnergyWrapperFake::ExtractDeviceAddressFromDevicePath(
313 base::string16 path) { 382 base::string16 path) {
(...skipping 30 matching lines...) Expand all
344 std::string BluetoothLowEnergyWrapperFake::BluetoothAddressToCanonicalString( 413 std::string BluetoothLowEnergyWrapperFake::BluetoothAddressToCanonicalString(
345 const BLUETOOTH_ADDRESS& btha) { 414 const BLUETOOTH_ADDRESS& btha) {
346 std::string result = base::StringPrintf( 415 std::string result = base::StringPrintf(
347 "%02X:%02X:%02X:%02X:%02X:%02X", btha.rgBytes[5], btha.rgBytes[4], 416 "%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]); 417 btha.rgBytes[3], btha.rgBytes[2], btha.rgBytes[1], btha.rgBytes[0]);
349 return result; 418 return result;
350 } 419 }
351 420
352 } // namespace win 421 } // namespace win
353 } // namespace device 422 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_win_fake.h ('k') | device/bluetooth/bluetooth_remote_gatt_characteristic_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698