-
but I'm hesitant to make changes here as I can't reproduce it. If you were willing to give it a try a PR would be awesome though.
Sadly I cannot reproduce it either. It does happen to me sometimes but I did not trace it to something specific, mostly it just works. And when it does not work reloading IDE works or it otherwise goes away soon (for no apparent reason). I only know simple disconnect and reconnect in IDE does not help in this case.
As for the error handling- what could work in this case:
- fall back to 20 and retry if it was not already 20
- if it already is 20 then disconnect.
- fall back to 20 and retry if it was not already 20
Thanks! Ok, so that's one for Mediatek. @parasquid it'd be amazingly helpful if you could try the other adaptor - that would rule out a great deal of things!
@fanoush as far as I can tell from the initial post on https://forum.espruino.com/conversations/387281/ we get a
NotSupportedError: GATT operation failed for unknown reason.
from https://github.com/espruino/EspruinoTools/blob/master/core/serial_web_bluetooth.js#L226And that function does trigger a disconnect - so it is possible that we could trap the error there, and then split the write up into 20 byte chunks.
It could maybe even set
setMaxPacketLength(NORDIC_DEFAULT_TX_LENGTH)
and change where setMaxPacketLength is called above to ensure it never tries to send >20 byte packets.... but I'm hesitant to make changes here as I can't reproduce it. If you were willing to give it a try a PR would be awesome though.