read method
Retrieves the value of the characteristic
Implementation
Future<List<int>> read() async {
var request = protos.ReadCharacteristicRequest.create()
..remoteId = deviceId.toString()
..characteristicUuid = uuid.toString()
..serviceUuid = serviceUuid.toString();
FlutterBlue.instance._log(LogLevel.info,
'remoteId: ${deviceId.toString()} characteristicUuid: ${uuid.toString()} serviceUuid: ${serviceUuid.toString()}');
await FlutterBlue.instance._channel
.invokeMethod('readCharacteristic', request.writeToBuffer());
return FlutterBlue.instance._methodStream
.where((m) => m.method == "ReadCharacteristicResponse")
.map((m) => m.arguments)
.map((buffer) =>
new protos.ReadCharacteristicResponse.fromBuffer(buffer))
.where((p) =>
(p.remoteId == request.remoteId) &&
(p.characteristic.uuid == request.characteristicUuid) &&
(p.characteristic.serviceUuid == request.serviceUuid))
.map((p) => p.characteristic.value)
.first
.then((d) {
_value.add(d);
return d;
});
}