Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.h

Issue 1927803002: arc: bluetooth: Add gatt client functionality (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile warning Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 5 #ifndef COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map>
10 #include <memory> 11 #include <memory>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "components/arc/arc_bridge_service.h" 15 #include "components/arc/arc_bridge_service.h"
15 #include "components/arc/arc_service.h" 16 #include "components/arc/arc_service.h"
16 #include "components/arc/common/bluetooth.mojom.h" 17 #include "components/arc/common/bluetooth.mojom.h"
17 #include "device/bluetooth/bluetooth_adapter.h" 18 #include "device/bluetooth/bluetooth_adapter.h"
18 #include "device/bluetooth/bluetooth_adapter_factory.h" 19 #include "device/bluetooth/bluetooth_adapter_factory.h"
19 #include "device/bluetooth/bluetooth_device.h" 20 #include "device/bluetooth/bluetooth_device.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void StartDiscovery() override; 130 void StartDiscovery() override;
130 void CancelDiscovery() override; 131 void CancelDiscovery() override;
131 132
132 void CreateBond(mojom::BluetoothAddressPtr addr, int32_t transport) override; 133 void CreateBond(mojom::BluetoothAddressPtr addr, int32_t transport) override;
133 void RemoveBond(mojom::BluetoothAddressPtr addr) override; 134 void RemoveBond(mojom::BluetoothAddressPtr addr) override;
134 void CancelBond(mojom::BluetoothAddressPtr addr) override; 135 void CancelBond(mojom::BluetoothAddressPtr addr) override;
135 136
136 void GetConnectionState(mojom::BluetoothAddressPtr addr, 137 void GetConnectionState(mojom::BluetoothAddressPtr addr,
137 const GetConnectionStateCallback& callback) override; 138 const GetConnectionStateCallback& callback) override;
138 139
140 // Bluetooth Mojo host interface - Bluetooth Gatt Client functions
141 void StartLEScan() override;
142 void StopLEScan() override;
143 void ConnectLEDevice(mojom::BluetoothAddressPtr remote_addr) override;
144 void DisconnectLEDevice(mojom::BluetoothAddressPtr remote_addr) override;
145 void StartLEListen(const StartLEListenCallback& callback) override;
146 void StopLEListen(const StopLEListenCallback& callback) override;
147 void SearchService(mojom::BluetoothAddressPtr remote_addr) override;
148
149 int ConvertGattIdentifierToId(const std::string identifier) const;
150 template <class T>
151 mojom::BluetoothGattDBElementPtr CreateGattDBElement(
152 const mojom::BluetoothGattDBAttributeType type,
153 const T* GattObject) const;
154 void GetGattDB(mojom::BluetoothAddressPtr remote_addr) override;
155 void ReadGattCharacteristic(
156 mojom::BluetoothAddressPtr remote_addr,
157 mojom::BluetoothGattServiceIDPtr service_id,
158 mojom::BluetoothGattIDPtr char_id,
159 const ReadGattCharacteristicCallback& callback) override;
160 void WriteGattCharacteristic(
161 mojom::BluetoothAddressPtr remote_addr,
162 mojom::BluetoothGattServiceIDPtr service_id,
163 mojom::BluetoothGattIDPtr char_id,
164 mojom::BluetoothGattValuePtr value,
165 const WriteGattCharacteristicCallback& callback) override;
166 void ReadGattDescriptor(mojom::BluetoothAddressPtr remote_addr,
167 mojom::BluetoothGattServiceIDPtr service_id,
168 mojom::BluetoothGattIDPtr char_id,
169 mojom::BluetoothGattIDPtr desc_id,
170 const ReadGattDescriptorCallback& callback) override;
171 void WriteGattDescriptor(
172 mojom::BluetoothAddressPtr remote_addr,
173 mojom::BluetoothGattServiceIDPtr service_id,
174 mojom::BluetoothGattIDPtr char_id,
175 mojom::BluetoothGattIDPtr desc_id,
176 mojom::BluetoothGattValuePtr value,
177 const WriteGattDescriptorCallback& callback) override;
178 void RegisterForGattNotification(
179 mojom::BluetoothAddressPtr remote_addr,
180 mojom::BluetoothGattServiceIDPtr service_id,
181 mojom::BluetoothGattIDPtr char_id,
182 const RegisterForGattNotificationCallback& callback) override;
183 void DeregisterForGattNotification(
184 mojom::BluetoothAddressPtr remote_addr,
185 mojom::BluetoothGattServiceIDPtr service_id,
186 mojom::BluetoothGattIDPtr char_id,
187 const DeregisterForGattNotificationCallback& callback) override;
188 void ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr,
189 const ReadRemoteRssiCallback& callback) override;
190
139 // Chrome observer callbacks 191 // Chrome observer callbacks
140 void OnPoweredOn( 192 void OnPoweredOn(
141 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 193 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
142 void OnPoweredOff( 194 void OnPoweredOff(
143 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 195 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
144 void OnPoweredError( 196 void OnPoweredError(
145 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 197 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
146 void OnDiscoveryStarted( 198 void OnDiscoveryStarted(
147 std::unique_ptr<device::BluetoothDiscoverySession> session); 199 std::unique_ptr<device::BluetoothDiscoverySession> session);
148 void OnDiscoveryStopped(); 200 void OnDiscoveryStopped();
149 void OnDiscoveryError(); 201 void OnDiscoveryError();
150 void OnPairing(mojom::BluetoothAddressPtr addr) const; 202 void OnPairing(mojom::BluetoothAddressPtr addr) const;
151 void OnPairedDone(mojom::BluetoothAddressPtr addr) const; 203 void OnPairedDone(mojom::BluetoothAddressPtr addr) const;
152 void OnPairedError( 204 void OnPairedError(
153 mojom::BluetoothAddressPtr addr, 205 mojom::BluetoothAddressPtr addr,
154 device::BluetoothDevice::ConnectErrorCode error_code) const; 206 device::BluetoothDevice::ConnectErrorCode error_code) const;
155 void OnForgetDone(mojom::BluetoothAddressPtr addr) const; 207 void OnForgetDone(mojom::BluetoothAddressPtr addr) const;
156 void OnForgetError(mojom::BluetoothAddressPtr addr) const; 208 void OnForgetError(mojom::BluetoothAddressPtr addr) const;
157 209
210 void OnGattConnectStateChanged(mojom::BluetoothAddressPtr addr,
211 bool connected) const;
212 void OnGattConnected(
213 mojom::BluetoothAddressPtr addr,
214 std::unique_ptr<device::BluetoothGattConnection> connection) const;
215 void OnGattConnectError(
216 mojom::BluetoothAddressPtr addr,
217 device::BluetoothDevice::ConnectErrorCode error_code) const;
218 void OnGattDisconnected(mojom::BluetoothAddressPtr addr) const;
219
220 void OnStartLEListenDone(const StartLEListenCallback& callback,
221 scoped_refptr<device::BluetoothAdvertisement> adv);
222 void OnStartLEListenError(
223 const StartLEListenCallback& callback,
224 device::BluetoothAdvertisement::ErrorCode error_code);
225
226 void OnStopLEListenDone(const StopLEListenCallback& callback);
227 void OnStopLEListenError(
228 const StopLEListenCallback& callback,
229 device::BluetoothAdvertisement::ErrorCode error_code);
230
231 using GattReadCallback = mojo::Callback<void(mojom::BluetoothGattValuePtr)>;
232 void OnGattReadDone(const GattReadCallback& callback,
233 const std::vector<uint8_t>& result) const;
234 void OnGattReadError(
235 const GattReadCallback& callback,
236 device::BluetoothGattService::GattErrorCode error_code) const;
237
238 using GattWriteCallback = mojo::Callback<void(mojom::BluetoothGattStatus)>;
239 void OnGattWriteDone(const GattWriteCallback& callback) const;
240 void OnGattWriteError(
241 const GattWriteCallback& callback,
242 device::BluetoothGattService::GattErrorCode error_code) const;
243
244 void OnGattNotifyStartDone(
245 const RegisterForGattNotificationCallback& callback,
246 const std::string char_string_id,
247 std::unique_ptr<device::BluetoothGattNotifySession> notify_session);
248 void OnGattNotifyStartError(
249 const RegisterForGattNotificationCallback& callback,
250 device::BluetoothGattService::GattErrorCode error_code) const;
251 void OnGattNotifyStopDone(
252 const DeregisterForGattNotificationCallback& callback) const;
253
158 private: 254 private:
159 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( 255 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties(
160 mojom::BluetoothPropertyType type, 256 mojom::BluetoothPropertyType type,
161 device::BluetoothDevice* device) const; 257 device::BluetoothDevice* device) const;
162 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( 258 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties(
163 mojom::BluetoothPropertyType type) const; 259 mojom::BluetoothPropertyType type) const;
260 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData(
261 device::BluetoothDevice* device) const;
164 262
165 void SendCachedDevicesFound() const; 263 void SendCachedDevicesFound() const;
166 bool HasBluetoothInstance() const; 264 bool HasBluetoothInstance() const;
167 265
266 template <class T>
267 T* FindGattObjectFromUuid(const std::vector<T*> objs,
268 const device::BluetoothUUID uuid) const;
269 device::BluetoothRemoteGattCharacteristic* FindGattCharacteristic(
270 mojom::BluetoothAddressPtr remote_addr,
271 mojom::BluetoothGattServiceIDPtr service_id,
272 mojom::BluetoothGattIDPtr char_id) const;
273
274 device::BluetoothRemoteGattDescriptor* FindGattDescriptor(
275 mojom::BluetoothAddressPtr remote_addr,
276 mojom::BluetoothGattServiceIDPtr service_id,
277 mojom::BluetoothGattIDPtr char_id,
278 mojom::BluetoothGattIDPtr desc_id) const;
279
168 // Propagates the list of paired device to Android. 280 // Propagates the list of paired device to Android.
169 void SendCachedPairedDevices() const; 281 void SendCachedPairedDevices() const;
170 282
171 mojo::Binding<mojom::BluetoothHost> binding_; 283 mojo::Binding<mojom::BluetoothHost> binding_;
172 284
173 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; 285 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
286 scoped_refptr<device::BluetoothAdvertisement> advertisment_;
174 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; 287 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
288 std::map<std::string, std::unique_ptr<device::BluetoothGattNotifySession>>
289 notification_session_;
175 290
176 // WeakPtrFactory to use for callbacks. 291 // WeakPtrFactory to use for callbacks.
177 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; 292 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
178 293
179 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); 294 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge);
180 }; 295 };
181 296
182 } // namespace arc 297 } // namespace arc
183 298
184 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 299 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
OLDNEW
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698