write method
Writes the value of a descriptor
Implementation
Future<Null> write(List<int> value) async {
var request = protos.WriteDescriptorRequest.create()
..remoteId = deviceId.toString()
..descriptorUuid = uuid.toString()
..characteristicUuid = characteristicUuid.toString()
..serviceUuid = serviceUuid.toString()
..value = value;
await FlutterBlue.instance._channel
.invokeMethod('writeDescriptor', request.writeToBuffer());
return FlutterBlue.instance._methodStream
.where((m) => m.method == "WriteDescriptorResponse")
.map((m) => m.arguments)
.map((buffer) => new protos.WriteDescriptorResponse.fromBuffer(buffer))
.where((p) =>
(p.request.remoteId == request.remoteId) &&
(p.request.descriptorUuid == request.descriptorUuid) &&
(p.request.characteristicUuid == request.characteristicUuid) &&
(p.request.serviceUuid == request.serviceUuid))
.first
.then((w) => w.success)
.then((success) => (!success)
? throw new Exception('Failed to write the descriptor')
: null)
.then((_) => _value.add(value))
.then((_) => null);
}