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_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_DEVICE_H_ |
6 #define DEVICE_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_DEVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const std::string& characteristic_id, | 60 const std::string& characteristic_id, |
61 const ReadValueForCharacteristicCallback& callback) override; | 61 const ReadValueForCharacteristicCallback& callback) override; |
62 void WriteValueForCharacteristic( | 62 void WriteValueForCharacteristic( |
63 const std::string& service_id, | 63 const std::string& service_id, |
64 const std::string& characteristic_id, | 64 const std::string& characteristic_id, |
65 const std::vector<uint8_t>& value, | 65 const std::vector<uint8_t>& value, |
66 const WriteValueForCharacteristicCallback& callback) override; | 66 const WriteValueForCharacteristicCallback& callback) override; |
67 void GetDescriptors(const std::string& service_id, | 67 void GetDescriptors(const std::string& service_id, |
68 const std::string& characteristic_id, | 68 const std::string& characteristic_id, |
69 const GetDescriptorsCallback& callback) override; | 69 const GetDescriptorsCallback& callback) override; |
| 70 void ReadValueForDescriptor( |
| 71 const std::string& service_id, |
| 72 const std::string& characteristic_id, |
| 73 const std::string& descriptor_id, |
| 74 const ReadValueForDescriptorCallback& callback) override; |
| 75 void WriteValueForDescriptor( |
| 76 const std::string& service_id, |
| 77 const std::string& characteristic_id, |
| 78 const std::string& descriptor_id, |
| 79 const std::vector<uint8_t>& value, |
| 80 const WriteValueForDescriptorCallback& callback) override; |
70 | 81 |
71 private: | 82 private: |
72 Device(scoped_refptr<device::BluetoothAdapter> adapter, | 83 Device(scoped_refptr<device::BluetoothAdapter> adapter, |
73 std::unique_ptr<device::BluetoothGattConnection> connection); | 84 std::unique_ptr<device::BluetoothGattConnection> connection); |
74 | 85 |
75 void GetServicesImpl(const GetServicesCallback& callback); | 86 void GetServicesImpl(const GetServicesCallback& callback); |
76 | 87 |
77 mojom::ServiceInfoPtr ConstructServiceInfoStruct( | 88 mojom::ServiceInfoPtr ConstructServiceInfoStruct( |
78 const device::BluetoothRemoteGattService& service); | 89 const device::BluetoothRemoteGattService& service); |
79 | 90 |
80 void OnReadRemoteCharacteristic( | 91 void OnReadRemoteCharacteristic( |
81 const ReadValueForCharacteristicCallback& callback, | 92 const ReadValueForCharacteristicCallback& callback, |
82 const std::vector<uint8_t>& value); | 93 const std::vector<uint8_t>& value); |
83 | 94 |
84 void OnReadRemoteCharacteristicError( | 95 void OnReadRemoteCharacteristicError( |
85 const ReadValueForCharacteristicCallback& callback, | 96 const ReadValueForCharacteristicCallback& callback, |
86 device::BluetoothGattService::GattErrorCode error_code); | 97 device::BluetoothGattService::GattErrorCode error_code); |
87 | 98 |
88 void OnWriteRemoteCharacteristic( | 99 void OnWriteRemoteCharacteristic( |
89 const WriteValueForCharacteristicCallback& callback); | 100 const WriteValueForCharacteristicCallback& callback); |
90 | 101 |
91 void OnWriteRemoteCharacteristicError( | 102 void OnWriteRemoteCharacteristicError( |
92 const WriteValueForCharacteristicCallback& callback, | 103 const WriteValueForCharacteristicCallback& callback, |
93 device::BluetoothGattService::GattErrorCode error_code); | 104 device::BluetoothGattService::GattErrorCode error_code); |
94 | 105 |
| 106 void OnReadRemoteDescriptor(const ReadValueForDescriptorCallback& callback, |
| 107 const std::vector<uint8_t>& value); |
| 108 |
| 109 void OnReadRemoteDescriptorError( |
| 110 const ReadValueForDescriptorCallback& callback, |
| 111 device::BluetoothGattService::GattErrorCode error_code); |
| 112 |
| 113 void OnWriteRemoteDescriptor(const WriteValueForDescriptorCallback& callback); |
| 114 |
| 115 void OnWriteRemoteDescriptorError( |
| 116 const WriteValueForDescriptorCallback& callback, |
| 117 device::BluetoothGattService::GattErrorCode error_code); |
| 118 |
95 const std::string& GetAddress(); | 119 const std::string& GetAddress(); |
96 | 120 |
97 // The current BluetoothAdapter. | 121 // The current BluetoothAdapter. |
98 scoped_refptr<device::BluetoothAdapter> adapter_; | 122 scoped_refptr<device::BluetoothAdapter> adapter_; |
99 | 123 |
100 // The GATT connection to this device. | 124 // The GATT connection to this device. |
101 std::unique_ptr<device::BluetoothGattConnection> connection_; | 125 std::unique_ptr<device::BluetoothGattConnection> connection_; |
102 | 126 |
103 mojo::StrongBindingPtr<mojom::Device> binding_; | 127 mojo::StrongBindingPtr<mojom::Device> binding_; |
104 | 128 |
105 // The services request queue which holds callbacks that are waiting for | 129 // The services request queue which holds callbacks that are waiting for |
106 // services to be discovered for this device. | 130 // services to be discovered for this device. |
107 std::vector<base::Closure> pending_services_requests_; | 131 std::vector<base::Closure> pending_services_requests_; |
108 | 132 |
109 base::WeakPtrFactory<Device> weak_ptr_factory_; | 133 base::WeakPtrFactory<Device> weak_ptr_factory_; |
110 | 134 |
111 DISALLOW_COPY_AND_ASSIGN(Device); | 135 DISALLOW_COPY_AND_ASSIGN(Device); |
112 }; | 136 }; |
113 | 137 |
114 } // namespace bluetooth | 138 } // namespace bluetooth |
115 | 139 |
116 #endif // DEVICE_BLUETOOTH_DEVICE_H_ | 140 #endif // DEVICE_BLUETOOTH_DEVICE_H_ |
OLD | NEW |