You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Toggle Bluetooth with Bluetooth button. #1615
The cleanest way to resolve this would be to disable bluetooth (at least temporarily). It seems to me that this is one of the few things which are actually better with the lego firmeware which only enables bluetooth after the dedicated hardware button is pressed.
Default behavior: Bluetooth on with every boot, same as now.
Bluetooth can only be toggled while the user program is not running. Otherwise the button could not be used in user programs.
Bluetooth can only be toggled while the robot is not connected to the computer. (Open question. Thoughts? Or should pressing it forcefully disconnect?)
Suggestions for color indications:
Blue: Bluetooth on/active.
Red: Bluetooth off/inactive**
** Thoughts? I was thinking a red color is more explicit than off, more easily communicated to judges, preventing cheating by using an older firmware. But if you say light off is better, we could do that.
Scope: only for SPIKE Prime and Robot Inventor? Is this also needed for SPIKE Essential?
Alternate ideas, Bluetooth on for coding, but no RC
If I'm understanding it right, the above has no technical utility, but it's to satisfy robot competition rules.
If that's the case, would it make sense to allow coding, but just disable all in-program Bluetooth features like remote control and broadcasting/observing?
After Boot: Bluetooth is off (this also has the advantage that nobody could steal the connection without physical access to the robot), the light could be off or red - I would prefer off.
Toggle on to accept connection by long-press, then blink blue
After connection is established, light is constantly blue
I do understand, that in a home setting, turning bluetooth on automatically is convenient, but actually as you still have to press the connect button in the Pybricks software on the computer and could show some message there (as you already do right now, if no device is found / the user cancels). The message could ask you to switch on the robot and long-press the bluetooth button (and still provide help to install the firmware). It is not a big deal to force the user to do another button press on the robot. Every user switching from the Lego software is already used to that. And once you are connected, you stay connected.
Alternate ideas, Bluetooth on for coding, but no RC
The main reason for this rule is NOT that they want to prevent remote controlling the robot, but to prevent that you might switch the program.
There is a randomization for each run in the competition and for some objects you don't know where they are placed. The program is supposed to handle all of these situations by recognizing them (or possibly have some mechanical measures that work for all cases). There is a countdown and the robot has to be placed on the parking area before the countdown runs out with the program for the next run on it. This is where the robots should be turned off or have Bluetooth disabled. After the robot check, the actual randomisation is revealed and this is the time where a cheating team might change the program on their robot (or a malicious team might delete the program on your robot).
So "Bluetooth on for coding, but no RC" is not an option.
Scope: only for SPIKE Prime and Robot Inventor? Is this also needed for SPIKE Essential?
I personally would not care about Spike Essential, I have never seen them in a competition.
Bluetooth can only be toggled while the robot is not connected to the computer. (Open question. Thoughts? Or should pressing it forcefully disconnect?)
That would be fine, maybe disconnecting from the computer should simply lead to the state "Bluetooth off".
I think the best experience will be to save the setting to persistent storage. The kids can program it for the months leading to the competition without forgetting to enable it, and then they can take it to competitions without worrying about forgetting to disable it.
My preference would be red = off and blue = on. With this approach it will be hardest to make a mistake and not notice that you are in the wrong state. I'd be fine with no light = off as well, if others feel strongly.
In the meantime I have been to some WRO competitions either as a coach or in some countries I have the honor to be head judging the WRO competition.
As for the SPIKE/RI sets Bluetooth is always on even with the stock firmware, therefore turning bluetooth off is not really an immediate need anymore in my opinion.
There are a few points for best competition experience left still, some connected with BT.
additional BT authentication step plus remember BT connected devices/last connected device (similarly to SPIKE or EV3 stock firmware)
a) idea for implementation: SPIKE is only discoverable for a short time (i.e. 30 sec) when e.g. BT button was long pressed, other than that BT is on, but cannot be connected by new devices
b) any previously connected device (or for sake of simplification the last connected device) can connect as today
animation misleading judges - when device is not connected the main button is animating in blue - giving pybricks-unaware judges that either a program is running already or BT is connected -- no big idea from my side how to resolve this, probably teams need to explain it to the judges every time
as a judge I would highly appreciate to see a BT connection indication similar to the stock firmware (BT button blue light on) - as today I have no real means to check if the brick (with pybricks) is really not connected and RC controlled
Thanks everyone for the input! Combing all that with the base suggestion, it seems like the following gets quite close to most what you'd need:
Bluetooth is on by default, same as now (no breaking change).
Toggle Bluetooth on/off with button.
Bluetooth light: blue is on, red is off.
We can reserve other colors for other future behaviors, if we ever want them (e.g green = coding but no RC).
Make it persistent after reboot. So you can achieve off-on-boot, for judge review. Judges also see the visual indicator.
Spike Prime / Robot Inventor only.
Regarding suggestions such as long-press / additional BT authentication step / enabling discovery, I think we would rather avoid those, especially since you could now achieve off-on-boot as above. Already, discoverability is disabled once a connection is established.
I think bluetooth on/off with a simple button/light is easier to understand for kids.
I'm not a big fan of the separate discoverability button press in the official app. In my opinion that's too many different clicks, mouse moves, and buttons on the hub just to establish a connection.
Bluetooth is on by default, same as now (no breaking change).
Toggle Bluetooth on/off with button.
Bluetooth light: blue is on, red is off.
We can reserve other colors for other future behaviors, if we ever want them (e.g green = coding but no RC).
Make it persistent after reboot. So you can achieve off-on-boot, for judge review. Judges also see the visual indicator.
Spike Prime / Robot Inventor only.
I used the branch from Nate Karstens implementing exactly this behavior with two WRO teams in the preparation and the event, and this was easy and intuitive for the kids to use (and I believe this fulfills the WRO rules).
@laurensvalk in the discussion on the PR you mentioned that there were still some things that you were figuring out regarding persistent settings. Do you have any more information on that?
This could serve as a practical starting point for (teams in need) now, but I'm open to reconsidering the UI on Prime Hub now that we have this, possibly deviating from the other hubs. Maybe it's the Bluetooth light that should blink, for example.
The setting is not persistent for now, but this should probably not hold back the rest of it.
Was expecting a link to the build, but I assume you mean build 3380.
If I hurry I can just do it before I go assist on a course "HELP, I have a smartphone" 😄
Did a quick test and did not see the previous problem.
Thought I saw something strange but the same test on RobotInventor at 3.5.0 does the same.
For the curious
run a program (for me: tools try_movehub_on_prime.py)
normal stop from the app and disconnect from the app
stop the hub so the program gets saved
without (re)connecting to the app start the program (button press)
within seconds the hub shuts down on it's own; Battery is at voltage: 6.955 V
As said both this build 3380 prime and 3.5.0 RobotInvenotor do it.
Program is garbage fiddling to get movehub randint with a lot of printing.
Will try later to get a smaller program. But that is another issue then.
Yes, we had to do that to work around issues with OS Bluetooth stacks caching the GATT attributes that change when the firmware is changed. Things just work better when it is acting like it is connecting to a new device every time.
Yes, we had to do that to work around issues with OS Bluetooth stacks caching the GATT attributes that change when the firmware is changed. Things just work better when it is acting like it is connecting to a new device every time.
Is there any chance to reconsider this?
Checking the web bluetooth developments we already have several routes to reconnect to a previously allowed device. This would significantly improve the user experience of pybricks code IDE.
I have played around with the code and checked this approach using navigator.bluetooth.getDevices() - it seemed quite flawless from IDE perspective yielding to a potentially small amount of changes.
Yes, we had to do that to work around issues with OS Bluetooth stacks caching the GATT attributes that change when the firmware is changed. Things just work better when it is acting like it is connecting to a new device every time.
Is there any chance to reconsider this?
Maybe when pybricks/pybricks-micropython#246 is a bit more polished, Bluetooth is probably as complete as it gets. So if we're happy with all the Bluetooth features and agree not to change them anymore, I suppose we could consider that again at some point.
Activity
laurensvalk commentedon Apr 28, 2024
Also requested by @Kermit647 @afarago @ttn-c4plus @nkarstens and others. See also pybricks/pybricks-micropython#195.
laurensvalk commentedon Apr 28, 2024
Some ideas for the user experience:
Suggestions for color indications:
** Thoughts? I was thinking a red color is more explicit than off, more easily communicated to judges, preventing cheating by using an older firmware. But if you say light off is better, we could do that.
Scope: only for SPIKE Prime and Robot Inventor? Is this also needed for SPIKE Essential?
Alternate ideas, Bluetooth on for coding, but no RC
If I'm understanding it right, the above has no technical utility, but it's to satisfy robot competition rules.
If that's the case, would it make sense to allow coding, but just disable all in-program Bluetooth features like remote control and broadcasting/observing?
ggramlich commentedon Apr 28, 2024
As @laurensvalk asked for feedback:
This video "WRO Robo-Check" is provided to inform the German judges.
https://www.youtube.com/watch?v=xQGuZWgKVKo
If you want to optimize for WRO compatibility, it would be best to resemble this behavior:
I do understand, that in a home setting, turning bluetooth on automatically is convenient, but actually as you still have to press the connect button in the Pybricks software on the computer and could show some message there (as you already do right now, if no device is found / the user cancels). The message could ask you to switch on the robot and long-press the bluetooth button (and still provide help to install the firmware). It is not a big deal to force the user to do another button press on the robot. Every user switching from the Lego software is already used to that. And once you are connected, you stay connected.
The main reason for this rule is NOT that they want to prevent remote controlling the robot, but to prevent that you might switch the program.
There is a randomization for each run in the competition and for some objects you don't know where they are placed. The program is supposed to handle all of these situations by recognizing them (or possibly have some mechanical measures that work for all cases). There is a countdown and the robot has to be placed on the parking area before the countdown runs out with the program for the next run on it. This is where the robots should be turned off or have Bluetooth disabled. After the robot check, the actual randomisation is revealed and this is the time where a cheating team might change the program on their robot (or a malicious team might delete the program on your robot).
So "Bluetooth on for coding, but no RC" is not an option.
I personally would not care about Spike Essential, I have never seen them in a competition.
That would be fine, maybe disconnecting from the computer should simply lead to the state "Bluetooth off".
nkarstens commentedon Apr 28, 2024
I think the best experience will be to save the setting to persistent storage. The kids can program it for the months leading to the competition without forgetting to enable it, and then they can take it to competitions without worrying about forgetting to disable it.
My preference would be red = off and blue = on. With this approach it will be hardest to make a mistake and not notice that you are in the wrong state. I'd be fine with no light = off as well, if others feel strongly.
afarago commentedon Apr 28, 2024
In the meantime I have been to some WRO competitions either as a coach or in some countries I have the honor to be head judging the WRO competition.
As for the SPIKE/RI sets Bluetooth is always on even with the stock firmware, therefore turning bluetooth off is not really an immediate need anymore in my opinion.
There are a few points for best competition experience left still, some connected with BT.
a) idea for implementation: SPIKE is only discoverable for a short time (i.e. 30 sec) when e.g. BT button was long pressed, other than that BT is on, but cannot be connected by new devices
b) any previously connected device (or for sake of simplification the last connected device) can connect as today
laurensvalk commentedon Apr 29, 2024
Thanks everyone for the input! Combing all that with the base suggestion, it seems like the following gets quite close to most what you'd need:
We can reserve other colors for other future behaviors, if we ever want them (e.g green = coding but no RC).
Regarding suggestions such as long-press / additional BT authentication step / enabling discovery, I think we would rather avoid those, especially since you could now achieve off-on-boot as above. Already, discoverability is disabled once a connection is established.
I think bluetooth on/off with a simple button/light is easier to understand for kids.
I'm not a big fan of the separate discoverability button press in the official app. In my opinion that's too many different clicks, mouse moves, and buttons on the hub just to establish a connection.
m7thon commentedon Apr 30, 2024
I used the branch from Nate Karstens implementing exactly this behavior with two WRO teams in the preparation and the event, and this was easy and intuitive for the kids to use (and I believe this fulfills the WRO rules).
nkarstens commentedon Apr 30, 2024
To be clear, pybricks/pybricks-micropython#195 does not support persistent settings yet.
@laurensvalk in the discussion on the PR you mentioned that there were still some things that you were figuring out regarding persistent settings. Do you have any more information on that?
laurensvalk commentedon May 3, 2024
I've opened an issue for it in #1622
afarago commentedon May 4, 2024
Could we consider having 3 BT modes?
Though kids are nice it would be a disaster if during the competition anyone would connect to your hub when doing the programming / testing part.
(You know the analogy - in the IoT abbreviation the letter "s" stands for security)
laurensvalk commentedon Jun 4, 2024
pybricks/pybricks-micropython#247 implements the following. See the rationale in that PR for some of the technical details.
This could serve as a practical starting point for (teams in need) now, but I'm open to reconsidering the UI on Prime Hub now that we have this, possibly deviating from the other hubs. Maybe it's the Bluetooth light that should blink, for example.
The setting is not persistent for now, but this should probably not hold back the rest of it.
toggle.mp4
14 remaining items
BertLindeman commentedon Jun 5, 2024
Was expecting a link to the build, but I assume you mean build 3380.
If I hurry I can just do it before I go assist on a course "HELP, I have a smartphone" 😄
BertLindeman commentedon Jun 5, 2024
Did a quick test and did not see the previous problem.
Thought I saw something strange but the same test on RobotInventor at 3.5.0 does the same.
For the curious
As said both this build 3380 prime and 3.5.0 RobotInvenotor do it.
Program is garbage fiddling to get movehub randint with a lot of printing.
Will try later to get a smaller program. But that is another issue then.
laurensvalk commentedon Jun 6, 2024
Work in progress demo with persistency after reboot:
persistent.mp4
laurensvalk commentedon Jun 7, 2024
This has now been implemented! Thanks everyone for pushing for this.
If you want to try it out before we release a new beta, just follow these instructions. That page includes a link to the latest build.
afarago commentedon Jul 1, 2024
Is this normal that every time I toggle the bluetooth off and on I see a "new" device witha seemingly random MAC address?
At the moment as due to browser bluetooth API limitation there is no autoconnect - it does not make a difference, yet seems odd.
dlech commentedon Jul 1, 2024
Yes, we had to do that to work around issues with OS Bluetooth stacks caching the GATT attributes that change when the firmware is changed. Things just work better when it is acting like it is connecting to a new device every time.
afarago commentedon Jul 11, 2024
Is there any chance to reconsider this?
Checking the web bluetooth developments we already have several routes to reconnect to a previously allowed device. This would significantly improve the user experience of pybricks code IDE.
I have played around with the code and checked this approach using
navigator.bluetooth.getDevices()- it seemed quite flawless from IDE perspective yielding to a potentially small amount of changes.laurensvalk commentedon Jul 11, 2024
Maybe when pybricks/pybricks-micropython#246 is a bit more polished, Bluetooth is probably as complete as it gets. So if we're happy with all the Bluetooth features and agree not to change them anymore, I suppose we could consider that again at some point.
dlech commentedon Jul 11, 2024
This issue is closed, so I would highly recommend to start a new issue so that this discussion does not get lost and forgotten.
zoligyenge commentedon Oct 2, 2024
Hello the latest page link appears broken. Could you please post the new link to the latest builds?
Thanks
dlech commentedon Oct 2, 2024
https://pybricks.com/learn/getting-started/install-pybricks/#trying-the-nightly-version-optional