OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/win/scoped_handle.h" | |
16 #include "device/bluetooth/bluetooth_export.h" | 15 #include "device/bluetooth/bluetooth_export.h" |
17 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" | 16 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" |
18 | 17 |
19 namespace device { | 18 namespace device { |
20 namespace win { | 19 namespace win { |
21 | 20 |
22 // Represents a device registry property value | 21 // Represents a device registry property value |
23 class DEVICE_BLUETOOTH_EXPORT DeviceRegistryPropertyValue { | 22 class DEVICE_BLUETOOTH_EXPORT DeviceRegistryPropertyValue { |
24 public: | 23 public: |
25 // Creates a property value instance, where |property_type| is one of REG_xxx | 24 // Creates a property value instance, where |property_type| is one of REG_xxx |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 92 |
94 base::FilePath path; | 93 base::FilePath path; |
95 std::string id; | 94 std::string id; |
96 std::string friendly_name; | 95 std::string friendly_name; |
97 BLUETOOTH_ADDRESS address; | 96 BLUETOOTH_ADDRESS address; |
98 bool visible; | 97 bool visible; |
99 bool authenticated; | 98 bool authenticated; |
100 bool connected; | 99 bool connected; |
101 }; | 100 }; |
102 | 101 |
103 // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on | |
104 // this machine. In case of error, returns false and sets |error| with an error | |
105 // message describing the problem. | |
106 // Note: This function returns an error if Bluetooth Low Energy is not supported | |
107 // on this Windows platform. | |
108 bool EnumerateKnownBluetoothLowEnergyDevices( | |
109 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, | |
110 std::string* error); | |
111 | |
112 // Enumerates the list of known Bluetooth LE GATT service devices on this | |
113 // machine (a Bluetooth LE device usually has more than one GATT | |
114 // services that each of them has a device interface on the machine). In case | |
115 // of error, returns false and sets |error| with an error message describing the | |
116 // problem. | |
117 // Note: This function returns an error if Bluetooth Low Energy is not supported | |
118 // on this Windows platform. | |
119 bool EnumerateKnownBluetoothLowEnergyGattServiceDevices( | |
120 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, | |
121 std::string* error); | |
122 | |
123 // Enumerates the list of known (i.e. cached) GATT services for a given | |
124 // Bluetooth LE device |device_path| into |services|. In case of error, returns | |
125 // false and sets |error| with an error message describing the problem. Note: | |
126 // This function returns an error if Bluetooth Low Energy is not supported on | |
127 // this Windows platform. | |
128 bool EnumerateKnownBluetoothLowEnergyServices( | |
129 const base::FilePath& device_path, | |
130 ScopedVector<BluetoothLowEnergyServiceInfo>* services, | |
131 std::string* error); | |
132 | |
133 bool DEVICE_BLUETOOTH_EXPORT | 102 bool DEVICE_BLUETOOTH_EXPORT |
134 ExtractBluetoothAddressFromDeviceInstanceIdForTesting( | 103 ExtractBluetoothAddressFromDeviceInstanceIdForTesting( |
135 const std::string& instance_id, | 104 const std::string& instance_id, |
136 BLUETOOTH_ADDRESS* btha, | 105 BLUETOOTH_ADDRESS* btha, |
137 std::string* error); | 106 std::string* error); |
138 | 107 |
| 108 // Wraps Windows APIs used to access Bluetooth Low Energy devices, providing an |
| 109 // interface that can be replaced with fakes in tests. |
| 110 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyWrapper { |
| 111 public: |
| 112 static BluetoothLowEnergyWrapper* GetInstance(); |
| 113 static void DeleteInstance(); |
| 114 static void SetInstanceForTest(BluetoothLowEnergyWrapper* instance); |
| 115 |
| 116 // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on |
| 117 // this machine. In case of error, returns false and sets |error| with an |
| 118 // error message describing the problem. |
| 119 // Note: This function returns an error if Bluetooth Low Energy is not |
| 120 // supported on this Windows platform. |
| 121 virtual bool EnumerateKnownBluetoothLowEnergyDevices( |
| 122 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, |
| 123 std::string* error); |
| 124 |
| 125 // Enumerates the list of known Bluetooth LE GATT service devices on this |
| 126 // machine (a Bluetooth LE device usually has more than one GATT |
| 127 // services that each of them has a device interface on the machine). In case |
| 128 // of error, returns false and sets |error| with an error message describing |
| 129 // the problem. |
| 130 // Note: This function returns an error if Bluetooth Low Energy is not |
| 131 // supported on this Windows platform. |
| 132 virtual bool EnumerateKnownBluetoothLowEnergyGattServiceDevices( |
| 133 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, |
| 134 std::string* error); |
| 135 |
| 136 // Enumerates the list of known (i.e. cached) GATT services for a given |
| 137 // Bluetooth LE device |device_path| into |services|. In case of error, |
| 138 // returns false and sets |error| with an error message describing the |
| 139 // problem. |
| 140 // Note: This function returns an error if Bluetooth Low Energy is not |
| 141 // supported on this Windows platform. |
| 142 virtual bool EnumerateKnownBluetoothLowEnergyServices( |
| 143 const base::FilePath& device_path, |
| 144 ScopedVector<BluetoothLowEnergyServiceInfo>* services, |
| 145 std::string* error); |
| 146 |
| 147 protected: |
| 148 BluetoothLowEnergyWrapper(); |
| 149 virtual ~BluetoothLowEnergyWrapper(); |
| 150 }; |
| 151 |
139 } // namespace win | 152 } // namespace win |
140 } // namespace device | 153 } // namespace device |
141 | 154 |
142 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ | 155 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ |
OLD | NEW |