support icon indicating copy to clipboard operation
support copied to clipboard

Support turning on/off Bluetooth on hubs with Bluetooth button for use at competitions

Open ttn-c4plus opened this issue 2 years ago • 7 comments

Question Hello, the most important thing is the Brick always turn on Bluetooth and ready for connect when it on This is very dangerous when we join competition, because some bad guys can connect to the Robot at competition area. How can I turn on Bluetooth when click Bluetooth button on brick?

ttn-c4plus avatar Jun 22 '23 10:06 ttn-c4plus

This is not currently possible. It was discussed recently at https://github.com/orgs/pybricks/discussions/1089 and someone made a quick hack for their own use and shared it.

But it sounds like something we should consider including in the default firmware.

dlech avatar Jun 22 '23 13:06 dlech

Yeah, if it's going to true, it will be awesome..

ttn-c4plus avatar Jun 23 '23 06:06 ttn-c4plus

Here's how it might work from a user perspective.

  • Bluetooth light is activated to indicate Bluetooth state.
    • Light is blue means Bluetooth is on, light off means off.
    • Connection state is unchanged, we'd still use the center light for that to be consistent with other hubs.
  • Pressing the Bluetooth button toggles it on/off.
    • This can only be done in idle state when program is not running
    • When program is running, button is used as normal button, It won't toggle BT state and light.
    • Bluetooth is on by default.
    • The state could be made persistent by storing it in a section of the user data field.

This won't be included in release V3.3, but we can consider it for V3.4.

laurensvalk avatar Jun 30 '23 14:06 laurensvalk

I have an implementation of this in a draft pull request here: pybricks/pybricks-micropython#195. It mostly works, but I'm having trouble with the persistent storage part of it. If someone could take a look it would be appreciated!

nkarstens avatar Sep 02 '23 04:09 nkarstens

Hi Karstens,

I had clone and build with this image, but when I download it to primehub, when I press bluetooth button, nothing happen. What should I do to turn off/on the bluetooth? Thanks a lot.

https://github.com/nkarstens/pybricks-micropython/tree/bluetooth-toggle

nothingtodowu avatar Apr 15 '24 01:04 nothingtodowu

Hi Karstens,

Thanks a lot. It fiexed. You have done a great job.

nothingtodowu avatar Apr 17 '24 01:04 nothingtodowu

@nothingtodowu Thanks, glad it worked out for you!

nkarstens avatar Apr 20 '24 03:04 nkarstens