Skip to content

Comments

Remove auto reconnect, ConnectionStatus.Reconnecting, and discarding of device on disconnect#85

Merged
microbit-grace merged 17 commits intoappsfrom
remove-auto-reconnect
Feb 5, 2026
Merged

Remove auto reconnect, ConnectionStatus.Reconnecting, and discarding of device on disconnect#85
microbit-grace merged 17 commits intoappsfrom
remove-auto-reconnect

Conversation

@microbit-grace
Copy link
Contributor

@microbit-grace microbit-grace commented Feb 4, 2026

  • Remove auto reconnect logic and ConnectionStatus.Reconnecting status in favour of the consuming app handling reconnections where necessary.
  • Remove discarding of connection/device on disconnect in favour of the consuming app calling clearDevice. So unless the app calls clearDevice, we assume the same device is used for the connection.
  • Extend radio bridge connection timeout to 10_000ms to match Bluetooth.
  • Remove no longer needed ignoreDelegateStatus
  • Keep serial session open when connecting to allow for reconnection after switch tabs

@microbit-grace
Copy link
Contributor Author

microbit-grace commented Feb 4, 2026

This seems to break iOS pairing and then flashing. Investigating...

Update: should be fixed by 1fff6b2

@microbit-grace microbit-grace removed the request for review from microbit-matt-hillsdon February 4, 2026 10:50
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 4, 2026

Deploying microbit-connection with  Cloudflare Pages  Cloudflare Pages

Latest commit: 205fdb6
Status: ✅  Deploy successful!
Preview URL: https://307abdf1.microbit-connection.pages.dev
Branch Preview URL: https://remove-auto-reconnect.microbit-connection.pages.dev

View logs

@microbit-grace microbit-grace changed the title Remove auto reconnect logic Remove auto reconnect, ConnectionStatus.Reconnecting, and discarding of device on disconnect Feb 4, 2026
@microbit-grace microbit-grace removed the request for review from microbit-matt-hillsdon February 4, 2026 16:52
this.onPeriodicMessageReceived = undefined;
reject(new Error("Failed to receive data from remote micro:bit"));
}, 500);
}, connectTimeoutDuration);
Copy link
Contributor Author

@microbit-grace microbit-grace Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 212 to 217
async disconnect(): Promise<void> {
return this.disconnectInternal(true);
return this.disconnectInternal();
}

private async disconnectInternal(userTriggered: boolean): Promise<void> {
this.logging.log(
`Bluetooth disconnect ${userTriggered ? "(user triggered)" : "(programmatic)"}`,
);
this.duringExplicitConnectDisconnect++;
private async disconnectInternal(): Promise<void> {
this.logging.log("Bluetooth disconnect");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can collapse these now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found that knowing whether the disconnect is occurring programatically vs user triggered is quite useful. Not sure why I removed that in the first place. Have recovered it here -> 713edeb

e,
);
}
this.logging.log("Bluetooth disconnect");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we should log something different from the disconnectInternal logging to help distinguish.

Copy link
Contributor Author

@microbit-grace microbit-grace Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your original thought that it is an redundant extra logging during our discussion was somewhat correct. It does log twice (duplicating above log) when we disconnect explicitly by user/programmatically, but only logs once when the disconnect is implicit (error-related).

I have removed this logging to avoid duplication (e141be7). If there is an error-related disconnect, nothing will get logged as it is unexpected

connectTimeoutDuration
) {
await this.restartConnection();
this.callbacks.onBeforeConnectionLostDispose();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed please just ponder whether this could have a clearer name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed here --> 8bdf2a3

For the scenario where user disconnects remote for a few seconds, switches tab for a few second, and returns to the tab with the connection. Without keeping serial session open, the radio bridge connection does not reconnect.
@microbit-matt-hillsdon
Copy link
Contributor

Can you check if we still need ignoreDelegateStatus ?

@microbit-grace
Copy link
Contributor Author

microbit-grace commented Feb 5, 2026

Can you check if we still need ignoreDelegateStatus ?

Good spot, looks like it is no longer ever set as true, have removed it here --> 205fdb6

@microbit-grace microbit-grace merged commit 802344e into apps Feb 5, 2026
4 checks passed
@microbit-grace microbit-grace deleted the remove-auto-reconnect branch February 5, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants