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

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

Issue 2085083002: arc: bluetooth: Implement Gatt notify (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/arc/common/bluetooth.mojom » ('j') | components/arc/common/bluetooth.mojom » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/bluetooth/arc_bluetooth_bridge.cc
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc
index 45228c0379ccf23323cfdf50c117b724f27ca508..5d2d9a8eb3bc24568fa0fd6088dbf3b51b551c6b 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -46,6 +46,7 @@ using device::BluetoothUUID;
namespace {
const int kMinBtleVersion = 1;
+const int kMinBtleNotifyVersion = 2;
ortuno 2016/06/21 23:23:06 enum { kMinBtleNotifyVersion = 2 }; Context: http
puthik_chromium 2016/06/23 02:53:34 Done.
const uint32_t kGattReadPermission =
BluetoothGattCharacteristic::Permission::PERMISSION_READ |
BluetoothGattCharacteristic::Permission::PERMISSION_READ_ENCRYPTED |
@@ -257,7 +258,31 @@ void ArcBluetoothBridge::GattCharacteristicValueChanged(
BluetoothAdapter* adapter,
BluetoothRemoteGattCharacteristic* characteristic,
const std::vector<uint8_t>& value) {
- // Placeholder for GATT client functionality
+ if (!HasBluetoothInstance())
+ return;
+
+ if (arc_bridge_service()->bluetooth_version() < kMinBtleNotifyVersion) {
+ LOG(WARNING) << "Bluetooth instance is too old and does not support notify";
+ return;
+ }
+ BluetoothRemoteGattService* service = characteristic->GetService();
+ BluetoothDevice* device = service->GetDevice();
+ mojom::BluetoothAddressPtr address =
+ mojom::BluetoothAddress::From(device->GetAddress());
+ mojom::BluetoothGattServiceIDPtr service_id =
+ mojom::BluetoothGattServiceID::New();
+ service_id->is_primary = service->IsPrimary();
+ service_id->id = mojom::BluetoothGattID::New();
+ service_id->id->inst_id = ConvertGattIdentifierToId(service->GetIdentifier());
+ service_id->id->uuid = mojom::BluetoothUUID::From(service->GetUUID());
+
+ mojom::BluetoothGattIDPtr char_id = mojom::BluetoothGattID::New();
+ char_id->inst_id = ConvertGattIdentifierToId(characteristic->GetIdentifier());
+ char_id->uuid = mojom::BluetoothUUID::From(characteristic->GetUUID());
+
+ arc_bridge_service()->bluetooth_instance()->OnGattNotify(
+ std::move(address), std::move(service_id), std::move(char_id),
+ true /* is_notify */, mojo::Array<uint8_t>::From(value));
}
void ArcBluetoothBridge::GattDescriptorValueChanged(
« no previous file with comments | « no previous file | components/arc/common/bluetooth.mojom » ('j') | components/arc/common/bluetooth.mojom » ('J')

Powered by Google App Engine
This is Rietveld 408576698