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

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: Add more code comment 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 void GetGattDB(mojom::BluetoothAddressPtr remote_addr) override;
149 void ReadGattCharacteristic(
150 mojom::BluetoothAddressPtr remote_addr,
151 mojom::BluetoothGattServiceIDPtr service_id,
152 mojom::BluetoothGattIDPtr char_id,
153 const ReadGattCharacteristicCallback& callback) override;
154 void WriteGattCharacteristic(
155 mojom::BluetoothAddressPtr remote_addr,
156 mojom::BluetoothGattServiceIDPtr service_id,
157 mojom::BluetoothGattIDPtr char_id,
158 mojom::BluetoothGattValuePtr value,
159 const WriteGattCharacteristicCallback& callback) override;
160 void ReadGattDescriptor(mojom::BluetoothAddressPtr remote_addr,
161 mojom::BluetoothGattServiceIDPtr service_id,
162 mojom::BluetoothGattIDPtr char_id,
163 mojom::BluetoothGattIDPtr desc_id,
164 const ReadGattDescriptorCallback& callback) override;
165 void WriteGattDescriptor(
166 mojom::BluetoothAddressPtr remote_addr,
167 mojom::BluetoothGattServiceIDPtr service_id,
168 mojom::BluetoothGattIDPtr char_id,
169 mojom::BluetoothGattIDPtr desc_id,
170 mojom::BluetoothGattValuePtr value,
171 const WriteGattDescriptorCallback& callback) override;
172 void RegisterForGattNotification(
173 mojom::BluetoothAddressPtr remote_addr,
174 mojom::BluetoothGattServiceIDPtr service_id,
175 mojom::BluetoothGattIDPtr char_id,
176 const RegisterForGattNotificationCallback& callback) override;
177 void DeregisterForGattNotification(
178 mojom::BluetoothAddressPtr remote_addr,
179 mojom::BluetoothGattServiceIDPtr service_id,
180 mojom::BluetoothGattIDPtr char_id,
181 const DeregisterForGattNotificationCallback& callback) override;
182 void ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr,
183 const ReadRemoteRssiCallback& callback) override;
184
139 // Chrome observer callbacks 185 // Chrome observer callbacks
140 void OnPoweredOn( 186 void OnPoweredOn(
141 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 187 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
142 void OnPoweredOff( 188 void OnPoweredOff(
143 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 189 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
144 void OnPoweredError( 190 void OnPoweredError(
145 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 191 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
146 void OnDiscoveryStarted( 192 void OnDiscoveryStarted(
147 std::unique_ptr<device::BluetoothDiscoverySession> session); 193 std::unique_ptr<device::BluetoothDiscoverySession> session);
148 void OnDiscoveryStopped(); 194 void OnDiscoveryStopped();
149 void OnDiscoveryError(); 195 void OnDiscoveryError();
150 void OnPairing(mojom::BluetoothAddressPtr addr) const; 196 void OnPairing(mojom::BluetoothAddressPtr addr) const;
151 void OnPairedDone(mojom::BluetoothAddressPtr addr) const; 197 void OnPairedDone(mojom::BluetoothAddressPtr addr) const;
152 void OnPairedError( 198 void OnPairedError(
153 mojom::BluetoothAddressPtr addr, 199 mojom::BluetoothAddressPtr addr,
154 device::BluetoothDevice::ConnectErrorCode error_code) const; 200 device::BluetoothDevice::ConnectErrorCode error_code) const;
155 void OnForgetDone(mojom::BluetoothAddressPtr addr) const; 201 void OnForgetDone(mojom::BluetoothAddressPtr addr) const;
156 void OnForgetError(mojom::BluetoothAddressPtr addr) const; 202 void OnForgetError(mojom::BluetoothAddressPtr addr) const;
157 203
204 void OnGattConnected(
205 mojom::BluetoothAddressPtr addr,
206 std::unique_ptr<device::BluetoothGattConnection> connection) const;
207 void OnGattConnectError(
208 mojom::BluetoothAddressPtr addr,
209 device::BluetoothDevice::ConnectErrorCode error_code) const;
210 void OnGattDisconnected(mojom::BluetoothAddressPtr addr) const;
211
212 void OnStartLEListenDone(const StartLEListenCallback& callback,
213 scoped_refptr<device::BluetoothAdvertisement> adv);
214 void OnStartLEListenError(
215 const StartLEListenCallback& callback,
216 device::BluetoothAdvertisement::ErrorCode error_code);
217
218 void OnStopLEListenDone(const StopLEListenCallback& callback);
219 void OnStopLEListenError(
220 const StopLEListenCallback& callback,
221 device::BluetoothAdvertisement::ErrorCode error_code);
222
223 using GattReadCallback = mojo::Callback<void(mojom::BluetoothGattValuePtr)>;
224 void OnGattReadDone(const GattReadCallback& callback,
225 const std::vector<uint8_t>& result) const;
226 void OnGattReadError(
227 const GattReadCallback& callback,
228 device::BluetoothGattService::GattErrorCode error_code) const;
229
230 using GattWriteCallback = mojo::Callback<void(mojom::BluetoothGattStatus)>;
231 void OnGattWriteDone(const GattWriteCallback& callback) const;
232 void OnGattWriteError(
233 const GattWriteCallback& callback,
234 device::BluetoothGattService::GattErrorCode error_code) const;
235
236 void OnGattNotifyStartDone(
237 const RegisterForGattNotificationCallback& callback,
238 const std::string char_string_id,
239 std::unique_ptr<device::BluetoothGattNotifySession> notify_session);
240 void OnGattNotifyStartError(
241 const RegisterForGattNotificationCallback& callback,
242 device::BluetoothGattService::GattErrorCode error_code) const;
243 void OnGattNotifyStopDone(
244 const DeregisterForGattNotificationCallback& callback) const;
245
158 private: 246 private:
159 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( 247 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties(
160 mojom::BluetoothPropertyType type, 248 mojom::BluetoothPropertyType type,
161 device::BluetoothDevice* device) const; 249 device::BluetoothDevice* device) const;
162 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( 250 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties(
163 mojom::BluetoothPropertyType type) const; 251 mojom::BluetoothPropertyType type) const;
252 mojo::Array<uint8_t> GetAdvData(device::BluetoothDevice* device) const;
Luis Héctor Chávez 2016/06/01 21:12:03 GetAdvertisingData.
164 253
165 void SendCachedDevicesFound() const; 254 void SendCachedDevicesFound() const;
166 bool HasBluetoothInstance() const; 255 bool HasBluetoothInstance() const;
167 256
257 device::BluetoothRemoteGattCharacteristic* FindGattCharacteristic(
258 mojom::BluetoothAddressPtr remote_addr,
259 mojom::BluetoothGattServiceIDPtr service_id,
260 mojom::BluetoothGattIDPtr char_id) const;
261
262 device::BluetoothRemoteGattDescriptor* FindGattDescriptor(
263 mojom::BluetoothAddressPtr remote_addr,
264 mojom::BluetoothGattServiceIDPtr service_id,
265 mojom::BluetoothGattIDPtr char_id,
266 mojom::BluetoothGattIDPtr desc_id) const;
267
168 // Propagates the list of paired device to Android. 268 // Propagates the list of paired device to Android.
169 void SendCachedPairedDevices() const; 269 void SendCachedPairedDevices() const;
170 270
171 mojo::Binding<mojom::BluetoothHost> binding_; 271 mojo::Binding<mojom::BluetoothHost> binding_;
172 272
173 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; 273 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
274 scoped_refptr<device::BluetoothAdvertisement> advertisment_;
174 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; 275 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
276 std::map<std::string, std::unique_ptr<device::BluetoothGattNotifySession>>
277 notification_session_;
175 278
176 // WeakPtrFactory to use for callbacks. 279 // WeakPtrFactory to use for callbacks.
177 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; 280 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
178 281
179 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); 282 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge);
180 }; 283 };
181 284
182 } // namespace arc 285 } // namespace arc
183 286
184 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 287 #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