phetsims / paper-land

Build and explore multimodal web interactives with pieces of paper!
https://phetsims.github.io/paper-land/
MIT License
10 stars 1 forks source link

[BUG] If paper is detected before BLE connection, PP errors and cannot use micro:bit UART #249

Closed brettfiedler closed 3 weeks ago

brettfiedler commented 3 weeks ago

image

This error appears when a paper is detected (like microcontroller-ble-demos > microbit-ble-demos > UART to IO Pins (LEDs) with Markers). When connecting to the microbit via "Connect to BLE", the connection is successful by all metrics on both PP side and micro:bit side, but the micro:bit does not seem to read anything sent over UART.

Solution:

Can we catch this and try to start the service again when we're connected? Or perhaps we should never even try to connect to the service until we're connected to a device?

brettfiedler commented 3 weeks ago

This isn't a dealbreaker, but it is an extra step if you need to disconnect the micro:bit for any reason (e.g., updating its code or switching power supplies)

jessegreenberg commented 3 weeks ago

To easily reproduce:

1) Create a project that writes to the controller with UUART. 2) Put a program in front of the camera with this component. 3) THEN, connect to BLE. 4) Paper Playground WILL send data to the microbit, but nothing happens and no error occurs.

brettfiedler commented 3 weeks ago

A good test case: Simple UART Example in microcontroller-ble-demos > microbit-ble-demos. Use the microbit-playper-bridge-v2.hex file.

jessegreenberg commented 3 weeks ago

OK, this should be resolved. This was my fault. There is a map of characteristics that have in-progress writes. If a write is in-progress we try to avoid sending another. If there is an error writing to the charactersitic (like before the BLE device is connected), the characteristic was not removed from the map. So from then on it was impossible to write to the characteristic.

jessegreenberg commented 3 weeks ago

This has been merged into main, closing.