Example app in the library crashes when I try to write a value.
Can you please share the log of the crash?
Going to close this until further information is provided.
I have the same problem, using example app, if I tap the writeCharacteristic too quickly, it'll crash. => PlatformException(write_characteristic_error, writeCharacteristic failed, null) in messsage_codecs.dart , decodeEnvlope method.
I also write a test app, after call discoverServices and found the right service, writeCharacteristic immediately will cause the same error.
_characteristic = _service.characteristics.first;
_device.setNotifyValue(_characteristic, true);
_valueChangedSubscription = _device
.onValueChanged(_characteristic)
.listen((d) => _handleRxData(d));
// await Future.delayed(const Duration(milliseconds: 100));
_device.writeCharacteristic(_characteristic, _writeCmd);
Uncomment the Future.delayed line, it works without error
Is any update here?
Most helpful comment
I have the same problem, using example app, if I tap the writeCharacteristic too quickly, it'll crash. =>
PlatformException(write_characteristic_error, writeCharacteristic failed, null)in messsage_codecs.dart , decodeEnvlope method.I also write a test app, after call discoverServices and found the right service, writeCharacteristic immediately will cause the same error.
Uncomment the Future.delayed line, it works without error