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 <unordered_map> | |
9 | |
8 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
9 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
10 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | 12 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
11 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" | 13 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" |
12 | 14 |
13 namespace device { | 15 namespace device { |
14 | 16 |
15 class BluetoothAdapterWin; | 17 class BluetoothAdapterWin; |
18 class BluetoothRemoteGattDescriptorWin; | |
16 class BluetoothRemoteGattServiceWin; | 19 class BluetoothRemoteGattServiceWin; |
17 class BluetoothTaskManagerWin; | 20 class BluetoothTaskManagerWin; |
18 | 21 |
19 // The BluetoothRemoteGattCharacteristicWin class implements | 22 // The BluetoothRemoteGattCharacteristicWin class implements |
20 // BluetoothGattCharacteristic for remote GATT services on Windows 8 and later. | 23 // BluetoothGattCharacteristic for remote GATT services on Windows 8 and later. |
21 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicWin | 24 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicWin |
22 : public BluetoothGattCharacteristic { | 25 : public BluetoothGattCharacteristic { |
23 public: | 26 public: |
24 BluetoothRemoteGattCharacteristicWin( | 27 BluetoothRemoteGattCharacteristicWin( |
25 BluetoothRemoteGattServiceWin* parent_service, | 28 BluetoothRemoteGattServiceWin* parent_service, |
(...skipping 21 matching lines...) Expand all Loading... | |
47 const ErrorCallback& error_callback) override; | 50 const ErrorCallback& error_callback) override; |
48 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, | 51 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, |
49 const base::Closure& callback, | 52 const base::Closure& callback, |
50 const ErrorCallback& error_callback) override; | 53 const ErrorCallback& error_callback) override; |
51 | 54 |
52 // Update included descriptors. | 55 // Update included descriptors. |
53 void Update(); | 56 void Update(); |
54 uint16_t GetAttributeHandle() const; | 57 uint16_t GetAttributeHandle() const; |
55 | 58 |
56 private: | 59 private: |
60 void OnGetIncludedDescriptorsCallback( | |
61 scoped_ptr<BTH_LE_GATT_DESCRIPTOR> descriptors, | |
62 uint16_t num, | |
63 HRESULT hr); | |
64 void UpdateIncludedDescriptors(PBTH_LE_GATT_DESCRIPTOR descriptors, | |
65 uint16_t num); | |
66 | |
67 // Checks if the descriptor with |uuid| and |attribute_handle| has already | |
68 // been discovered as included descriptor. | |
69 bool IsDescriptorDiscovered(BTH_LE_UUID& uuid, uint16_t attribute_handle); | |
70 | |
71 // Checks if |descriptor| still exists in this characteristic according to | |
72 // newly discovered |num| of |descriptors|. | |
73 static bool DoesDescriptorExist(PBTH_LE_GATT_DESCRIPTOR descriptors, | |
74 uint16_t num, | |
75 BluetoothRemoteGattDescriptorWin* descriptor); | |
76 | |
57 BluetoothAdapterWin* adapter_; | 77 BluetoothAdapterWin* adapter_; |
58 BluetoothRemoteGattServiceWin* parent_service_; | 78 BluetoothRemoteGattServiceWin* parent_service_; |
59 scoped_refptr<BluetoothTaskManagerWin> task_manager_; | 79 scoped_refptr<BluetoothTaskManagerWin> task_manager_; |
60 | 80 |
61 // Characteristic info from OS and used to interact with OS. | 81 // Characteristic info from OS and used to interact with OS. |
62 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info_; | 82 scoped_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info_; |
63 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 83 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
64 BluetoothUUID characteristic_uuid_; | 84 BluetoothUUID characteristic_uuid_; |
65 std::vector<uint8_t> characteristic_value_; | 85 std::vector<uint8_t> characteristic_value_; |
66 std::string characteristic_identifier_; | 86 std::string characteristic_identifier_; |
67 | 87 |
88 // The key of GattDescriptorMap is the identitfier of | |
89 // BluetoothRemoteGattDescriptorWin instance. | |
90 typedef std::unordered_map<std::string, | |
91 scoped_ptr<BluetoothRemoteGattDescriptorWin>> | |
92 GattDescriptorMap; | |
93 GattDescriptorMap included_descriptors_; | |
94 | |
95 // Flag indicates if characteristic added notification of this characteristic | |
96 // has been send out to avoid duplicate notification. | |
scheib
2016/03/01 00:06:22
sent
gogerald1
2016/03/01 17:00:13
Done.
| |
97 bool characteristic_added_notified_; | |
98 | |
68 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_; | 99 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicWin> weak_ptr_factory_; |
69 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin); | 100 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicWin); |
70 }; | 101 }; |
71 | 102 |
72 } // namespace device | 103 } // namespace device |
73 | 104 |
74 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ | 105 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_WIN_H_ |
OLD | NEW |