See attached sample. I have tested it using the Android "Serial Bluetooth Terminal" app. Sometimes when the client disconnects, the sendAccel fiber stops running (the numbers stop) though microbit hasn't crashed because the letters keep going. It may take a few attempts. It happens more easily if the showText fiber is paused by pressing A. It doesn't restart when the client reconnects.
I suspect send() gets stuck waiting for the the event from on_confirmation() which may not arrive if the client disconnects. This seems to be confirmed by adding serial trace before fiber_wake_on_event() and after schedule().
Just to clarify, I originally saw this issue with hex files from MakeCode. The point of the C++ sample was to confirm that the issue was independent of MakeCode, that it was stuck and not crashed etc.
uart-sample.zip
See attached sample. I have tested it using the Android "Serial Bluetooth Terminal" app. Sometimes when the client disconnects, the sendAccel fiber stops running (the numbers stop) though microbit hasn't crashed because the letters keep going. It may take a few attempts. It happens more easily if the showText fiber is paused by pressing A. It doesn't restart when the client reconnects.
I suspect send() gets stuck waiting for the the event from on_confirmation() which may not arrive if the client disconnects. This seems to be confirmed by adding serial trace before fiber_wake_on_event() and after schedule().