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..ae78c5e8e39aca02b158f1c860158a3dbb077cc8 100644 |
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc |
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
@@ -45,7 +45,8 @@ using device::BluetoothRemoteGattService; |
using device::BluetoothUUID; |
namespace { |
-const int kMinBtleVersion = 1; |
+enum { kMinBtleVersion = 1 }; |
+enum { kMinBtleNotifyVersion = 2 }; |
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( |
@@ -902,6 +927,14 @@ void ArcBluetoothBridge::WriteGattDescriptor( |
DCHECK(descriptor); |
DCHECK(descriptor->GetPermissions() & kGattWritePermission); |
+ // Chrome does not support writing to CCC Descriptor |
+ // Always return success when encounter this. |
+ if (descriptor->GetUUID() == |
rkc
2016/06/23 19:36:38
This is definitely going to break behavior in some
|
+ BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()) { |
+ OnGattWriteDone(callback); |
+ return; |
+ } |
+ |
descriptor->WriteRemoteDescriptor( |
value->value.To<std::vector<uint8_t>>(), |
base::Bind(&ArcBluetoothBridge::OnGattWriteDone, |