Untitled diff
31 linhas
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));
}
}