Untitled diff

Created Diff never expires
16 删除
总计
删除
单词
总计
删除
要继续使用此功能,请升级到
Diffchecker logo
Diffchecker Pro
31
11 添加
总计
添加
单词
总计
添加
要继续使用此功能,请升级到
Diffchecker logo
Diffchecker Pro
25
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));
}
}