-
Notifications
You must be signed in to change notification settings - Fork 0
Ignore delegate status on radio bridge disconnect #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing it out on CreateAI locally, it seems to have improved in that flashing the radio link micro:bit after a radio connection works ok, but flashing the remote micro:bit after radio connection still gives an error at times
It's worse because there aren't logged errors - ignore me, need to reinstall the theme... Flashing the remote micro:bit with the MakeCode program seems to work when run locally and skip flashing the remote micro:bit during the connection in CreateAI (before MakeCode). It seems to fail (most / all? of the time if you don't skip flashing). After you've successfully or unsuccessfully flashed a MakeCode program to a device, reconnecting via radio bridge in CreateAI seems to fail (all?) the time. Will test these scenarios on Windows shortly - inconclusive, see below. Edit: I know one of my V2 devices has a dodgy USB connection. I am not the best person to be testing this without getting new devices. |
MacOS. With this version I can:
|
When we start to flash the device in MakeCode, we call We then unplug the device (following the instructions) which causes a disconnected event to be picked up by the MicrobitRadioBridgeConnection delegateStatusListener. Following the same logic as the opening comment on this PR, |
Having number values don't make sense since we wouldn't respect them anyway. We're listening to serial data or we're not.
Deploying microbit-connection with
|
Latest commit: |
6373a63
|
Status: | ✅ Deploy successful! |
Preview URL: | https://044f0503.microbit-connection.pages.dev |
Branch Preview URL: | https://ignore-delegate.microbit-connection.pages.dev |
Changes need testing in Python Editor. Edit: I think this looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally on CreateAI and the Python Editor and they both work well. LGTM!
Closing in favour of #66 |
When calling disconnect on MicrobitRadioBridgeConnection,
this.serialSession?.dispose(true)
is called which removes the serialdata listener once, givingthis.addedListeners.serialdata
a value of 0. Due to the boolean passed in, we disconnect the delegate, which causes a disconnected event to be picked up by theMicrobitRadioBridgeConnection
delegateStatusListener
. This in turn callsthis.serialSession?.dispose()
for the second time, removing the serialdata listener a second time.this.addedListeners.serialdata
is now a truthy value of -1. This results in errors somewhere further in the process because a check usingthis.addedListeners.serialdata
is now doing the wrong thing.An alternative approach to fixing would be to ensure thatthis.addedListeners.serialdata
cannot be set to a negative value.This needs both approaches.
ignoreDelegateStatus
solves half a problem and makes sense to have, but unplugging the radio link device (after this disconnect) calls the same dispose code in thedelegateStatusListener
. Make the serial data listener a boolean. We don't respect the numbers of listeners at the moment anyway (i.e., removing one of many will still stop serial).