setNotifyValue method
Sets notifications or indications for the value of a specified characteristic
Implementation
Future<bool> setNotifyValue(bool notify) async {
var request = protos.SetNotificationRequest.create()
..remoteId = deviceId.toString()
..serviceUuid = serviceUuid.toString()
..characteristicUuid = uuid.toString()
..enable = notify;
await FlutterBlue.instance._channel
.invokeMethod('setNotification', request.writeToBuffer());
return FlutterBlue.instance._methodStream
.where((m) => m.method == "SetNotificationResponse")
.map((m) => m.arguments)
.map((buffer) => new protos.SetNotificationResponse.fromBuffer(buffer))
.where((p) =>
(p.remoteId == request.remoteId) &&
(p.characteristic.uuid == request.characteristicUuid) &&
(p.characteristic.serviceUuid == request.serviceUuid))
.first
.then((p) => new BluetoothCharacteristic.fromProto(p.characteristic))
.then((c) {
_updateDescriptors(c.descriptors);
return (c.isNotifying == notify);
});
}