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