OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_task_manager_win.h" | 5 #include "device/bluetooth/bluetooth_task_manager_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <winsock2.h> | 8 #include <winsock2.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 473 } |
474 | 474 |
475 bool BluetoothTaskManagerWin::SearchLowEnergyDevices( | 475 bool BluetoothTaskManagerWin::SearchLowEnergyDevices( |
476 ScopedVector<DeviceState>* device_list) { | 476 ScopedVector<DeviceState>* device_list) { |
477 if (!win::IsBluetoothLowEnergySupported()) | 477 if (!win::IsBluetoothLowEnergySupported()) |
478 return true; // Bluetooth LE not supported is not an error. | 478 return true; // Bluetooth LE not supported is not an error. |
479 | 479 |
480 ScopedVector<win::BluetoothLowEnergyDeviceInfo> btle_devices; | 480 ScopedVector<win::BluetoothLowEnergyDeviceInfo> btle_devices; |
481 std::string error; | 481 std::string error; |
482 bool success = | 482 bool success = |
483 win::EnumerateKnownBluetoothLowEnergyDevices(&btle_devices, &error); | 483 win::BluetoothLowEnergyHub::GetInstance() |
| 484 ->EnumerateKnownBluetoothLowEnergyDevices(&btle_devices, &error); |
484 if (!success) { | 485 if (!success) { |
485 LogPollingError(error.c_str(), 0); | 486 LogPollingError(error.c_str(), 0); |
486 return false; | 487 return false; |
487 } | 488 } |
488 | 489 |
489 for (ScopedVector<win::BluetoothLowEnergyDeviceInfo>::iterator iter = | 490 for (ScopedVector<win::BluetoothLowEnergyDeviceInfo>::iterator iter = |
490 btle_devices.begin(); | 491 btle_devices.begin(); |
491 iter != btle_devices.end(); | 492 iter != btle_devices.end(); |
492 ++iter) { | 493 ++iter) { |
493 win::BluetoothLowEnergyDeviceInfo* device_info = (*iter); | 494 win::BluetoothLowEnergyDeviceInfo* device_info = (*iter); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 } | 630 } |
630 | 631 |
631 bool BluetoothTaskManagerWin::DiscoverLowEnergyDeviceServices( | 632 bool BluetoothTaskManagerWin::DiscoverLowEnergyDeviceServices( |
632 const base::FilePath& device_path, | 633 const base::FilePath& device_path, |
633 ScopedVector<ServiceRecordState>* service_record_states) { | 634 ScopedVector<ServiceRecordState>* service_record_states) { |
634 if (!win::IsBluetoothLowEnergySupported()) | 635 if (!win::IsBluetoothLowEnergySupported()) |
635 return true; // Bluetooth LE not supported is not an error. | 636 return true; // Bluetooth LE not supported is not an error. |
636 | 637 |
637 std::string error; | 638 std::string error; |
638 ScopedVector<win::BluetoothLowEnergyServiceInfo> services; | 639 ScopedVector<win::BluetoothLowEnergyServiceInfo> services; |
639 bool success = win::EnumerateKnownBluetoothLowEnergyServices( | 640 bool success = win::BluetoothLowEnergyHub::GetInstance() |
640 device_path, &services, &error); | 641 ->EnumerateKnownBluetoothLowEnergyServices( |
| 642 device_path, &services, &error); |
641 if (!success) { | 643 if (!success) { |
642 LogPollingError(error.c_str(), 0); | 644 LogPollingError(error.c_str(), 0); |
643 return false; | 645 return false; |
644 } | 646 } |
645 | 647 |
646 for (ScopedVector<win::BluetoothLowEnergyServiceInfo>::iterator iter2 = | 648 for (ScopedVector<win::BluetoothLowEnergyServiceInfo>::iterator iter2 = |
647 services.begin(); | 649 services.begin(); |
648 iter2 != services.end(); | 650 iter2 != services.end(); |
649 ++iter2) { | 651 ++iter2) { |
650 ServiceRecordState* service_state = new ServiceRecordState(); | 652 ServiceRecordState* service_state = new ServiceRecordState(); |
651 service_state->gatt_uuid = | 653 service_state->gatt_uuid = |
652 BluetoothLowEnergyUuidToBluetoothUuid((*iter2)->uuid); | 654 BluetoothLowEnergyUuidToBluetoothUuid((*iter2)->uuid); |
653 service_record_states->push_back(service_state); | 655 service_record_states->push_back(service_state); |
654 } | 656 } |
655 return true; | 657 return true; |
656 } | 658 } |
657 | 659 |
658 } // namespace device | 660 } // namespace device |
OLD | NEW |