Skip to content
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

[Bug] Bluetooth may remain disabled after running short program #1667

Open
laurensvalk opened this issue Jun 6, 2024 · 1 comment
Open
Labels
bug Something isn't working hub: primehub/inventorhub Issues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hub topic: bluetooth Issues involving bluetooth

Comments

@laurensvalk
Copy link
Member

Describe the bug
While working on pybricks/pybricks-micropython#247 (comment) I noticed that sometimes Bluetooth would not come back on on Prime Hub.

It turns out this was already the case in the stable firmware such as 3.5.0.

This isn't entirely an edge case, either. Sometimes an offline program will fail due to an immediate exception such as a motor not being plugged in. When connecting to fix the issue, sometimes the hub won't appear in Pybricks Code.

To reproduce

  • Add the following empty program that does nothing.
# comment
# The main program starts here.
  • Disconnect from Pybricks Code
  • Hammer the start button a lot of times.

Keep an eye on the Chrome scan window, or keep NRF connect open and occasionally refresh.

The hub will appear in a connectable state (blinking), but not advertise.

Expected behavior
Work normally.

Screenshots
There is a saying that a picture is worth a 1000 words. Screenshots really help to identify and solve problems.

Additional context

Since it's so rare, it's been hard to identify for sure, but I think this is where it gets stuck in pbsys/bluetooth:

        // reset Bluetooth chip
        pbsys_status_light_bluetooth_set_color(PBIO_COLOR_GREEN); // debug light
        pbdrv_bluetooth_power_on(false);
        PROCESS_WAIT_WHILE(pbdrv_bluetooth_is_ready());             // light can get stuck staying green
        pbsys_status_light_bluetooth_set_color(PBIO_COLOR_RED); // debug light

Now that we know this easier reproduction scenario, maybe we can find out for sure.

@laurensvalk laurensvalk added bug Something isn't working hub: primehub/inventorhub Issues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hub topic: bluetooth Issues involving bluetooth labels Jun 6, 2024
@laurensvalk
Copy link
Member Author

laurensvalk commented Jun 6, 2024

Waiting a while and pressing the start button a few times again later seems to get it out of that state. Maybe some broadcast event gets it unstuck? (Possibly, yes: status change or program start/stop broadcasts an event).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hub: primehub/inventorhub Issues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hub topic: bluetooth Issues involving bluetooth
Projects
None yet
Development

No branches or pull requests

1 participant