Untitled diff

Created Diff never expires
16 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
31 lines
11 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
25 lines
Interface per object:
As opposed to:


interface Service {
interface GattRemoteServer {
GetCharacteristic(CharacteristicId id);
GetServices() => (array<ServiceInfo> services);
GetCharacteristics() =>
GetCharacteristicsForService(ServiceId id) =>
(array<CharacteristicInfo> characteristics);
(array<CharacteristicInfo> characteristics);
}
}


How Web Bluetooth would use it:
How Web Bluetooth would use it:


// BluetoothRemoteGATTService.cpp
// BluetoothRemoteGATTService.cpp
GetCharacteristic(String uuid) {
GetCharacteristic(String uuid) {
service_->GetCharacteristics(base::Bind(&OnGetCharacteristics, this, uuid,
gatt_->GetCharacteristicsForService(base::Bind(&OnGetCharacteristics, this,
...));
uuid, ...));
});
}


OnGetCharacteristics(uuid, characteristics, promise) {
OnGetCharacteristics(uuid, characteristics, promise) {
for (characteristic : characteristics) {
for (characteristic : characteristics) {
if (characteristic->uuid == uuid) {
if (characteristic->uuid == uuid) {
service_->GetCharacteristic(base::Bind(&OnGetCharacteristic, this, uuid,
promise.resolve(new BluetoothRemoteGATTCharacteristic(characteristic));
characteristic->id, promise));
return;
}
}
}
}
}
promise.reject("Not Found Error");

OnGetCharacteristic(uuid, id, characteristic, promise) {
promise.resolve(new BluetoothRemoteGATTCharacteristic(id, uuid));
}
}