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..d064e88d7c8813202fb8d9d56259d040659e43cb 100644 |
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc |
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
@@ -45,7 +45,9 @@ using device::BluetoothRemoteGattService; |
using device::BluetoothUUID; |
namespace { |
-const int kMinBtleVersion = 1; |
+enum { kMinBtleVersion = 1 }; |
+enum { kMinBtleNotifyVersion = 2 }; |
+const std::string kDescriptorCCCUUid = "2902"; |
const uint32_t kGattReadPermission = |
BluetoothGattCharacteristic::Permission::PERMISSION_READ | |
BluetoothGattCharacteristic::Permission::PERMISSION_READ_ENCRYPTED | |
@@ -257,7 +259,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( |
@@ -902,6 +928,16 @@ void ArcBluetoothBridge::WriteGattDescriptor( |
DCHECK(descriptor); |
DCHECK(descriptor->GetPermissions() & kGattWritePermission); |
+ // Chrome does not support writing to CCC Descriptor |
+ // Always return success when encounter this. |
+ // The descriptor UUID should match the format below for this. |
+ // xxxx2902-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
+ if (descriptor->GetUUID().canonical_value().substr(4, 4) == |
ortuno
2016/06/23 14:29:38
nit: Also add this change to the description.
puthik_chromium
2016/06/23 18:36:31
Done.
|
+ kDescriptorCCCUUid) { |
ortuno
2016/06/23 14:29:38
Use BluetoothRemoteGattDescriptor::ClientCharacter
puthik_chromium
2016/06/23 18:36:30
Done.
|
+ OnGattWriteDone(callback); |
+ return; |
+ } |
+ |
descriptor->WriteRemoteDescriptor( |
value->value.To<std::vector<uint8_t>>(), |
base::Bind(&ArcBluetoothBridge::OnGattWriteDone, |