OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_REMOTE_GATT_CHARACTERISTIC_WIN_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 | 10 |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
13 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | |
14 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" | 13 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" |
| 14 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 15 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
15 | 16 |
16 namespace device { | 17 namespace device { |
17 | 18 |
18 class BluetoothAdapterWin; | 19 class BluetoothAdapterWin; |
19 class BluetoothRemoteGattDescriptorWin; | 20 class BluetoothRemoteGattDescriptorWin; |
20 class BluetoothRemoteGattServiceWin; | 21 class BluetoothRemoteGattServiceWin; |
21 class BluetoothTaskManagerWin; | 22 class BluetoothTaskManagerWin; |
22 | 23 |
23 // The BluetoothRemoteGattCharacteristicWin class implements | 24 // The BluetoothRemoteGattCharacteristicWin class implements |
24 // BluetoothGattCharacteristic for remote GATT services on Windows 8 and later. | 25 // BluetoothRemoteGattCharacteristic for remote GATT services on Windows 8 and |
| 26 // later. |
25 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicWin | 27 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicWin |
26 : public BluetoothGattCharacteristic { | 28 : public BluetoothRemoteGattCharacteristic { |
27 public: | 29 public: |
28 BluetoothRemoteGattCharacteristicWin( | 30 BluetoothRemoteGattCharacteristicWin( |
29 BluetoothRemoteGattServiceWin* parent_service, | 31 BluetoothRemoteGattServiceWin* parent_service, |
30 BTH_LE_GATT_CHARACTERISTIC* characteristic_info, | 32 BTH_LE_GATT_CHARACTERISTIC* characteristic_info, |
31 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner); | 33 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner); |
32 ~BluetoothRemoteGattCharacteristicWin() override; | 34 ~BluetoothRemoteGattCharacteristicWin() override; |
33 | 35 |
34 // Override BluetoothGattCharacteristic interfaces. | 36 // Override BluetoothRemoteGattCharacteristic interfaces. |
35 std::string GetIdentifier() const override; | 37 std::string GetIdentifier() const override; |
36 BluetoothUUID GetUUID() const override; | 38 BluetoothUUID GetUUID() const override; |
37 bool IsLocal() const override; | |
38 std::vector<uint8_t>& GetValue() const override; | 39 std::vector<uint8_t>& GetValue() const override; |
39 BluetoothGattService* GetService() const override; | 40 BluetoothRemoteGattService* GetService() const override; |
40 Properties GetProperties() const override; | 41 Properties GetProperties() const override; |
41 Permissions GetPermissions() const override; | 42 Permissions GetPermissions() const override; |
42 bool IsNotifying() const override; | 43 bool IsNotifying() const override; |
43 std::vector<BluetoothGattDescriptor*> GetDescriptors() const override; | 44 std::vector<BluetoothRemoteGattDescriptor*> GetDescriptors() const override; |
44 BluetoothGattDescriptor* GetDescriptor( | 45 BluetoothRemoteGattDescriptor* GetDescriptor( |
45 const std::string& identifier) const override; | 46 const std::string& identifier) const override; |
46 bool AddDescriptor(BluetoothGattDescriptor* descriptor) override; | |
47 bool UpdateValue(const std::vector<uint8_t>& value) override; | |
48 void StartNotifySession(const NotifySessionCallback& callback, | 47 void StartNotifySession(const NotifySessionCallback& callback, |
49 const ErrorCallback& error_callback) override; | 48 const ErrorCallback& error_callback) override; |
50 void ReadRemoteCharacteristic(const ValueCallback& callback, | 49 void ReadRemoteCharacteristic(const ValueCallback& callback, |
51 const ErrorCallback& error_callback) override; | 50 const ErrorCallback& error_callback) override; |
52 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, | 51 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, |
53 const base::Closure& callback, | 52 const base::Closure& callback, |
54 const ErrorCallback& error_callback) override; | 53 const ErrorCallback& error_callback) override; |
55 | 54 |
56 // Update included descriptors. | 55 // Update included descriptors. |
57 void Update(); | 56 void Update(); |
(...skipping 15 matching lines...) Expand all Loading... |
73 // Checks if |descriptor| still exists in this characteristic according to | 72 // Checks if |descriptor| still exists in this characteristic according to |
74 // newly discovered |num| of |descriptors|. | 73 // newly discovered |num| of |descriptors|. |
75 static bool DoesDescriptorExist(PBTH_LE_GATT_DESCRIPTOR descriptors, | 74 static bool DoesDescriptorExist(PBTH_LE_GATT_DESCRIPTOR descriptors, |
76 uint16_t num, | 75 uint16_t num, |
77 BluetoothRemoteGattDescriptorWin* descriptor); | 76 BluetoothRemoteGattDescriptorWin* descriptor); |
78 | 77 |
79 void OnReadRemoteCharacteristicValueCallback( | 78 void OnReadRemoteCharacteristicValueCallback( |
80 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> value, | 79 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> value, |
81 HRESULT hr); | 80 HRESULT hr); |
82 void OnWriteRemoteCharacteristicValueCallback(HRESULT hr); | 81 void OnWriteRemoteCharacteristicValueCallback(HRESULT hr); |
83 BluetoothGattService::GattErrorCode HRESULTToGattErrorCode(HRESULT hr); | 82 BluetoothRemoteGattService::GattErrorCode HRESULTToGattErrorCode(HRESULT hr); |
84 void OnGattCharacteristicValueChanged( | 83 void OnGattCharacteristicValueChanged( |
85 std::unique_ptr<std::vector<uint8_t>> new_value); | 84 std::unique_ptr<std::vector<uint8_t>> new_value); |
86 void GattEventRegistrationCallback(PVOID event_handle, HRESULT hr); | 85 void GattEventRegistrationCallback(PVOID event_handle, HRESULT hr); |
87 void ClearIncludedDescriptors(); | 86 void ClearIncludedDescriptors(); |
88 | 87 |
89 BluetoothRemoteGattServiceWin* parent_service_; | 88 BluetoothRemoteGattServiceWin* parent_service_; |
90 scoped_refptr<BluetoothTaskManagerWin> task_manager_; | 89 scoped_refptr<BluetoothTaskManagerWin> task_manager_; |
91 | 90 |
92 // Characteristic info from OS and used to interact with OS. | 91 // Characteristic info from OS and used to interact with OS. |
93 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info_; | 92 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // GATT event handle returned by GattEventRegistrationCallback. | 124 // GATT event handle returned by GattEventRegistrationCallback. |
126 PVOID gatt_event_handle_; | 125 PVOID gatt_event_handle_; |
127 | 126 |
128 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_; | 127 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_; |
129 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin); | 128 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin); |
130 }; | 129 }; |
131 | 130 |
132 } // namespace device | 131 } // namespace device |
133 | 132 |
134 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ | 133 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ |
OLD | NEW |