-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Allow Bluetooth to be toggled off/on with Bluetooth button. #247
Conversation
The code: if pressed then user_program_start(true) made it read as if this call was starting the code on pressing the button, which isn't quite what this is doing. So rename to make this clearer, since we'll be adding a similar routine for the Bluetooth button UI.
It doesn't take that many bytes and it helps keep the code much cleaner.
Using advertising as the debounce state only applies when Bluetooth is enabled.
Being not-connected naturally extends to USB when we add it.
This is less fragile than starting and stopping the process.
This reverts 8c8340b. At this point, we don't need an extra status flag. Bluetooth is the only communication method, and we can't communicate a status if it is disabled. So we can avoid changing the protocol for now. We can add appropriate flags if we add USB support, in which case communicating the active connection type may make sense.
395315f
to
3e29eb3
Compare
In rare occasions it can get stuck at the bottom of the This seems odd as it would have traversed this path too all the time so far when running a really short program. Or maybe we just haven't noticed it before?
|
I have a question that if I want set bluetooth off by default, how to change this? Thanks. |
You no longer need to use builds from this pull request. You can use the nightly build which already includes this feature. The setting also persists. So Bluetooth will still be off when you reboot the hub. |
Thanks a lot. |
Implements toggling Bluetooth on and off with the Bluetooth button on Spike Prime and Mindstorms Robot Inventor.
See pybricks/support#1615 for context, use cases, and user interface considerations.
This is a slightly more minimalist approach compared to #195. It adds
PBIO_PYBRICKS_STATUS_BLUETOOTH_BLE_ENABLED
to the protocol instead ofPBIO_PYBRICKS_STATUS_BLUETOOTH_BUTTON_PRESSED
andPBIO_PYBRICKS_STATUS_BLUETOOTH_SHUTDOWN
.The
hmi
is implemented similar to the existing code for the start/stop program button, and separated from the actual Bluetooth start/stop logic. Thehmi
may request a Bluetooth toggle, but it is up tosys/bluetooth
whether to do anything with that. This prevents Bluetooth from being toggled if is currently being used or while a program is running.The
PBIO_PYBRICKS_STATUS_BLUETOOTH_BLE_ENABLED
flag is only used for raising exceptions when the user tries to create remote peripheral or broadcast/observe.Persistency is a separate task that can be added later. This was holding up previous merges, but we should be able to get started without it.
Thanks to everyone for asking about this feature and thanks to @nkarstens for creating #195!