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

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: Add bug for CCC descriptor 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') | no next file with comments »
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..17a596e6734702615b13bfd9a89fc4cf48cb6d88 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,15 @@ void ArcBluetoothBridge::WriteGattDescriptor(
DCHECK(descriptor);
DCHECK(descriptor->GetPermissions() & kGattWritePermission);
+ // Chrome does not support writing to CCC Descriptor
+ // Always return success when encounter this.
palmer 2016/06/27 19:25:42 These 2 comment lines don't seem to agree — it's u
puthik_chromium 2016/06/27 19:55:07 Done.
+ // TODO(http://crbug.com/622832)
+ if (descriptor->GetUUID() ==
+ BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()) {
+ OnGattWriteDone(callback);
+ return;
+ }
+
descriptor->WriteRemoteDescriptor(
value->value.To<std::vector<uint8_t>>(),
base::Bind(&ArcBluetoothBridge::OnGattWriteDone,
« no previous file with comments | « no previous file | components/arc/common/bluetooth.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698