Flutter_blue: Example App crashes on write to a characteristic

Created on 7 Jun 2018  路  4Comments  路  Source: pauldemarco/flutter_blue

Example app in the library crashes when I try to write a value.

waiting for customer response

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.

      _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

All 4 comments

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?

Was this page helpful?
0 / 5 - 0 ratings