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 <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/optional.h" | 16 #include "base/optional.h" |
17 #include "device/bluetooth/bluetooth_export.h" | 17 #include "device/bluetooth/bluetooth_export.h" |
18 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" | 18 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" |
19 | 19 |
20 namespace device { | 20 namespace device { |
21 namespace win { | 21 namespace win { |
22 | 22 |
| 23 // |
| 24 // Callback function signature for Bluetooth GATT events. This fixes a bug in |
| 25 // this typedef in the Windows 10.0.10586 SDK which is missing the CALLBACK |
| 26 // modifier. This corrected typedef should be used throughout Chromium except |
| 27 // when casting to the 'official' definition when calling Microsoft functions. |
| 28 // This allows Chromium to build with 10.0.14393 or later SDKs (which have the |
| 29 // fixed typedef) while doing the correct thing even when built with 10.0.10586. |
| 30 // The CALLBACK modifier affects how function parameters are cleaned up from the |
| 31 // stack and having a mismatch can lead to misalignment of the stack pointer. |
| 32 // |
| 33 typedef VOID(CALLBACK* PFNBLUETOOTH_GATT_EVENT_CALLBACK_CORRECTED)( |
| 34 _In_ BTH_LE_GATT_EVENT_TYPE EventType, |
| 35 _In_ PVOID EventOutParameter, |
| 36 _In_opt_ PVOID Context); |
| 37 |
23 // Represents a device registry property value | 38 // Represents a device registry property value |
24 class DEVICE_BLUETOOTH_EXPORT DeviceRegistryPropertyValue { | 39 class DEVICE_BLUETOOTH_EXPORT DeviceRegistryPropertyValue { |
25 public: | 40 public: |
26 // Creates a property value instance, where |property_type| is one of REG_xxx | 41 // Creates a property value instance, where |property_type| is one of REG_xxx |
27 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array | 42 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array |
28 // containing the property value and |value_size| is the number of bytes in | 43 // containing the property value and |value_size| is the number of bytes in |
29 // |value|. Note the returned instance takes ownership of the bytes in | 44 // |value|. Note the returned instance takes ownership of the bytes in |
30 // |value|. | 45 // |value|. |
31 static std::unique_ptr<DeviceRegistryPropertyValue> Create( | 46 static std::unique_ptr<DeviceRegistryPropertyValue> Create( |
32 DWORD property_type, | 47 DWORD property_type, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 virtual HRESULT WriteCharacteristicValue( | 189 virtual HRESULT WriteCharacteristicValue( |
175 base::FilePath& service_path, | 190 base::FilePath& service_path, |
176 const PBTH_LE_GATT_CHARACTERISTIC characteristic, | 191 const PBTH_LE_GATT_CHARACTERISTIC characteristic, |
177 PBTH_LE_GATT_CHARACTERISTIC_VALUE new_value); | 192 PBTH_LE_GATT_CHARACTERISTIC_VALUE new_value); |
178 | 193 |
179 // Register GATT events of |event_type| in the service with service device | 194 // Register GATT events of |event_type| in the service with service device |
180 // path |service_path|. |event_parameter| is the event's parameter. |callback| | 195 // path |service_path|. |event_parameter| is the event's parameter. |callback| |
181 // is the function to be invoked if the event happened. |context| is the input | 196 // is the function to be invoked if the event happened. |context| is the input |
182 // parameter to be given back through |callback|. |*out_handle| stores the | 197 // parameter to be given back through |callback|. |*out_handle| stores the |
183 // unique handle in OS for this registration. | 198 // unique handle in OS for this registration. |
184 virtual HRESULT RegisterGattEvents(base::FilePath& service_path, | 199 virtual HRESULT RegisterGattEvents( |
185 BTH_LE_GATT_EVENT_TYPE event_type, | 200 base::FilePath& service_path, |
186 PVOID event_parameter, | 201 BTH_LE_GATT_EVENT_TYPE event_type, |
187 PFNBLUETOOTH_GATT_EVENT_CALLBACK callback, | 202 PVOID event_parameter, |
188 PVOID context, | 203 PFNBLUETOOTH_GATT_EVENT_CALLBACK_CORRECTED callback, |
189 BLUETOOTH_GATT_EVENT_HANDLE* out_handle); | 204 PVOID context, |
| 205 BLUETOOTH_GATT_EVENT_HANDLE* out_handle); |
190 virtual HRESULT UnregisterGattEvent(BLUETOOTH_GATT_EVENT_HANDLE event_handle); | 206 virtual HRESULT UnregisterGattEvent(BLUETOOTH_GATT_EVENT_HANDLE event_handle); |
191 | 207 |
192 // Writes |descriptor| value in service with service device path | 208 // Writes |descriptor| value in service with service device path |
193 // |service_path| to |*new_value|. | 209 // |service_path| to |*new_value|. |
194 virtual HRESULT WriteDescriptorValue(base::FilePath& service_path, | 210 virtual HRESULT WriteDescriptorValue(base::FilePath& service_path, |
195 const PBTH_LE_GATT_DESCRIPTOR descriptor, | 211 const PBTH_LE_GATT_DESCRIPTOR descriptor, |
196 PBTH_LE_GATT_DESCRIPTOR_VALUE new_value); | 212 PBTH_LE_GATT_DESCRIPTOR_VALUE new_value); |
197 | 213 |
198 protected: | 214 protected: |
199 BluetoothLowEnergyWrapper(); | 215 BluetoothLowEnergyWrapper(); |
200 virtual ~BluetoothLowEnergyWrapper(); | 216 virtual ~BluetoothLowEnergyWrapper(); |
201 }; | 217 }; |
202 | 218 |
203 } // namespace win | 219 } // namespace win |
204 } // namespace device | 220 } // namespace device |
205 | 221 |
206 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ | 222 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ |
OLD | NEW |