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

Unified Diff: components/arc/bluetooth/arc_bluetooth_bridge.h

Issue 2101283003: arc: bluetooth: Implement Gatt server request to read/write (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gs2
Patch Set: run error_callback if offset < 0 Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/arc/bluetooth/arc_bluetooth_bridge.h
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.h b/components/arc/bluetooth/arc_bluetooth_bridge.h
index d1912fbcb0d56b693bb1af26c3dcc6ea5b8f0bd6..73e96b5cd338470df7d15f5b0e8b50b76b5afba1 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.h
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.h
@@ -40,8 +40,21 @@ class ArcBluetoothBridge
public device::BluetoothLocalGattService::Delegate,
public mojom::BluetoothHost {
public:
+ // Store callback functions for Gatt Server request read / write
+ template <class SuccessCallback>
+ struct GattServerCallbacks {
+ GattServerCallbacks() = default;
+ GattServerCallbacks(const SuccessCallback& success_callback,
+ const ErrorCallback& error_callback)
+ : success_callback(success_callback), error_callback(error_callback) {}
+ SuccessCallback success_callback;
+ ErrorCallback error_callback;
+ };
+
using GattStatusCallback = base::Callback<void(mojom::BluetoothGattStatus)>;
using GattReadCallback = base::Callback<void(mojom::BluetoothGattValuePtr)>;
+ using GattServerReadCallbacks = GattServerCallbacks<ValueCallback>;
+ using GattServerWriteCallbacks = GattServerCallbacks<base::Closure>;
explicit ArcBluetoothBridge(ArcBridgeService* bridge_service);
~ArcBluetoothBridge() override;
@@ -121,6 +134,20 @@ class ArcBluetoothBridge
const std::vector<uint8_t>& value) override;
// Overridden from device::BluetoothLocalGattService::Delegate
+ template <class LocalGattAttribute>
+ void OnGattAttributeReadRequest(const device::BluetoothDevice* device,
+ const LocalGattAttribute* gatt_attr,
+ int offset,
+ const GattServerReadCallbacks& callbacks);
Luis Héctor Chávez 2016/07/19 01:49:17 override?
puthik_chromium 2016/07/19 22:21:47 Function defined in wrong place. Fixed. On{Charact
+
+ template <class LocalGattAttribute>
+ void OnGattAttributeWriteRequest(
+ const device::BluetoothDevice* device,
+ const LocalGattAttribute* gatt_attr,
+ const std::vector<uint8_t>& value,
+ int offset,
+ const GattServerWriteCallbacks& callbacks) override;
+
void OnCharacteristicReadRequest(
const device::BluetoothDevice* device,
const device::BluetoothLocalGattCharacteristic* characteristic,
@@ -365,6 +392,8 @@ class ArcBluetoothBridge
template <class LocalGattAttribute>
int32_t CreateGattAttributeHandle(LocalGattAttribute* gatt_attr);
+ int32_t CreateGattReadTransaction(const GattServerReadCallbacks& callbacks);
+ int32_t CreateGattWriteTransaction(const GattServerWriteCallbacks& callbacks);
mojo::Binding<mojom::BluetoothHost> binding_;
@@ -375,10 +404,14 @@ class ArcBluetoothBridge
notification_session_;
// Map from android int handle to Chrome (BlueZ) string identifier.
std::map<int32_t, std::string> gatt_identifier_;
+ // Map from Chrome (BlueZ) string identifier to android int handle.
+ std::map<std::string, int32_t> gatt_handle_;
Luis Héctor Chávez 2016/07/19 01:49:17 std::unordered_map?
puthik_chromium 2016/07/19 22:21:47 Done.
// Store last GattCharacteristic added to each GattService for GattServer.
std::map<int32_t, int32_t> last_characteristic_;
// Running number for handle to give to Android side.
int32_t gatt_server_attr_handle = 0;
+ std::map<int32_t, GattServerReadCallbacks> gatt_server_read_callbacks_;
+ std::map<int32_t, GattServerWriteCallbacks> gatt_server_write_callbacks_;
// WeakPtrFactory to use for callbacks.
base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
« 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