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 <windows.h> | 8 #include <windows.h> |
9 #include <setupapi.h> | 9 #include <setupapi.h> |
10 // #include <bthledef.h> | 10 // #include <bthledef.h> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 namespace device { | 47 namespace device { |
48 namespace win { | 48 namespace win { |
49 | 49 |
50 // Represents a device registry property value | 50 // Represents a device registry property value |
51 class DeviceRegistryPropertyValue { | 51 class DeviceRegistryPropertyValue { |
52 public: | 52 public: |
53 // Creates a property value instance, where |property_type| is one of REG_xxx | 53 // Creates a property value instance, where |property_type| is one of REG_xxx |
54 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array | 54 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array |
55 // containing the propery value and |value_size| is the number of bytes in | 55 // containing the propery value and |value_size| is the number of bytes in |
56 // |value|. Note the returned instance takes ownership of |value| array. | 56 // |value|. Note the returned instance takes ownership of the bytes in |
| 57 // |value|. |
57 static scoped_ptr<DeviceRegistryPropertyValue> Create( | 58 static scoped_ptr<DeviceRegistryPropertyValue> Create( |
58 DWORD property_type, | 59 DWORD property_type, |
59 scoped_ptr<uint8_t[]> value, | 60 scoped_ptr<uint8_t[]> value, |
60 size_t value_size); | 61 size_t value_size); |
61 ~DeviceRegistryPropertyValue(); | 62 ~DeviceRegistryPropertyValue(); |
62 | 63 |
63 // Returns the vaue type a REG_xxx value (e.g. REG_SZ, REG_DWORD, ...) | 64 // Returns the vaue type a REG_xxx value (e.g. REG_SZ, REG_DWORD, ...) |
64 DWORD property_type() const { return property_type_; } | 65 DWORD property_type() const { return property_type_; } |
65 | 66 |
66 std::string AsString() const; | 67 std::string AsString() const; |
67 DWORD AsDWORD() const; | 68 DWORD AsDWORD() const; |
68 | 69 |
69 private: | 70 private: |
70 DeviceRegistryPropertyValue(DWORD property_type, | 71 DeviceRegistryPropertyValue(DWORD property_type, |
71 scoped_ptr<uint8_t[]> value, | 72 scoped_ptr<uint8_t[]> value, |
72 size_t value_size); | 73 size_t value_size); |
73 | 74 |
74 DWORD property_type_; | 75 DWORD property_type_; |
75 scoped_ptr<uint8_t[]> value_; | 76 scoped_ptr<uint8_t[]> value_; |
76 size_t value_size_; | 77 size_t value_size_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(DeviceRegistryPropertyValue); | 79 DISALLOW_COPY_AND_ASSIGN(DeviceRegistryPropertyValue); |
79 }; | 80 }; |
80 | 81 |
| 82 // Represents the value associated to a DEVPROPKEY. |
| 83 class DevicePropertyValue { |
| 84 public: |
| 85 // Creates a property value instance, where |property_type| is one of |
| 86 // DEVPROP_TYPE_xxx value type , |value| is a byte array containing the |
| 87 // propery value and |value_size| is the number of bytes in |value|. Note the |
| 88 // returned instance takes ownership of the bytes in |value|. |
| 89 DevicePropertyValue(DEVPROPTYPE property_type, |
| 90 scoped_ptr<uint8_t[]> value, |
| 91 size_t value_size); |
| 92 |
| 93 DEVPROPTYPE property_type() const { return property_type_; } |
| 94 |
| 95 uint32_t AsUint32() const; |
| 96 |
| 97 private: |
| 98 DEVPROPTYPE property_type_; |
| 99 scoped_ptr<uint8_t[]> value_; |
| 100 size_t value_size_; |
| 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(DevicePropertyValue); |
| 103 }; |
| 104 |
81 // Returns true only on Windows platforms supporting Bluetooth Low Energy. | 105 // Returns true only on Windows platforms supporting Bluetooth Low Energy. |
82 bool IsBluetoothLowEnergySupported(); | 106 bool IsBluetoothLowEnergySupported(); |
83 | 107 |
84 struct BluetoothLowEnergyDeviceInfo { | 108 struct BluetoothLowEnergyDeviceInfo { |
85 BluetoothLowEnergyDeviceInfo() { address.ullLong = BLUETOOTH_NULL_ADDRESS; } | 109 BluetoothLowEnergyDeviceInfo(); |
| 110 ~BluetoothLowEnergyDeviceInfo(); |
86 | 111 |
87 base::FilePath path; | 112 base::FilePath path; |
88 std::string id; | 113 std::string id; |
89 std::string friendly_name; | 114 std::string friendly_name; |
90 BLUETOOTH_ADDRESS address; | 115 BLUETOOTH_ADDRESS address; |
| 116 bool connected; |
91 }; | 117 }; |
92 | 118 |
93 // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on | 119 // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on |
94 // this machine. In case of error, returns false and sets |error| with an error | 120 // this machine. In case of error, returns false and sets |error| with an error |
95 // message describing the problem. | 121 // message describing the problem. |
96 // Note: This function returns an error if Bluetooth Low Energy is not supported | 122 // Note: This function returns an error if Bluetooth Low Energy is not supported |
97 // on this Windows platform. | 123 // on this Windows platform. |
98 bool EnumerateKnownBluetoothLowEnergyDevices( | 124 bool EnumerateKnownBluetoothLowEnergyDevices( |
99 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, | 125 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, |
100 std::string* error); | 126 std::string* error); |
101 | 127 |
102 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting( | 128 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting( |
103 const std::string& instance_id, | 129 const std::string& instance_id, |
104 BLUETOOTH_ADDRESS* btha, | 130 BLUETOOTH_ADDRESS* btha, |
105 std::string* error); | 131 std::string* error); |
106 | 132 |
107 } // namespace win | 133 } // namespace win |
108 } // namespace device | 134 } // namespace device |
109 | 135 |
110 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ | 136 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ |
OLD | NEW |