Skip to content

Conversation

microbit-grace
Copy link
Contributor

@microbit-grace microbit-grace commented Jul 28, 2025

Added a new configuration (deviceSelectionMode) for how a device should be selected.

DeviceSelectionMode.AlwaysAsk - Attempts to connect to known device, otherwise asks which device to connect with.
DeviceSelectionMode.UseAnyAllowed - Attempts to connect to known device, otherwise attempts to connect with any allowed devices. If that fails, asks which device to connect with.

Copy link

cloudflare-workers-and-pages bot commented Jul 29, 2025

Deploying microbit-connection with  Cloudflare Pages  Cloudflare Pages

Latest commit: 909da96
Status: ✅  Deploy successful!
Preview URL: https://220f96b2.microbit-connection.pages.dev
Branch Preview URL: https://device-connect-mode.microbit-connection.pages.dev

View logs

Copy link
Contributor

@microbit-matt-hillsdon microbit-matt-hillsdon left a comment

Choose a reason for hiding this comment

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

Added some comments.

What are/should be the consequences for the bluetooth connection?

@microbit-grace
Copy link
Contributor Author

Thanks for the comments.

What are/should be the consequences for the bluetooth connection?

I assume no consequence for bluetooth connection since we are only changing the WebUSB device fallback behaviour.

For radio connection, if the MicrobitWebUSBConnection is configured as DeviceFallbackMode.AllowedOrSelect, the micro:bit would automatically try to connect to allowed devices and if successful, would establish radio connection without having the user to select a device. I think this behaviour matches the expectation of the configuration applied. By default, MicrobitWebUSBConnection is configured as DeviceFallbackMode.Select which is more explicit in terms of what device is selected. That seems like a good default to me.

Not sure if I have missed something.

@microbit-grace microbit-grace changed the title Add device connect mode to MicrobitWebUSBConnectionOptions Add device fallback mode to MicrobitWebUSBConnectionOptions Jul 30, 2025
Copy link
Contributor

@microbit-matt-hillsdon microbit-matt-hillsdon left a comment

Choose a reason for hiding this comment

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

Minor comments and a final suggestion re name, but happy to discuss. I think it's worth the effort for something others might use.

@microbit-grace microbit-grace changed the title Add device fallback mode to MicrobitWebUSBConnectionOptions Add deviceSelectionMode to MicrobitWebUSBConnectionOptions Jul 30, 2025
@microbit-matt-hillsdon
Copy link
Contributor

I assume no consequence for bluetooth connection since we are only changing the WebUSB device fallback behaviour.

Yeah I guess I was pondering whether it should have similar logic as there's a similar notion of already having permitted access to a device. But I think fine to leave for now.

@microbit-grace microbit-grace merged commit a6dcb18 into main Jul 30, 2025
4 checks passed
@microbit-grace microbit-grace deleted the device-connect-mode branch July 30, 2025 16:29
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.

3 participants