pybricks / pybricks-projects

Example programs for Pybricks
MIT License
94 stars 42 forks source link

Decoding hub broadcast signals on the computer #73

Open pbochynski opened 1 year ago

pbochynski commented 1 year ago

Added example of how to decode hub broadcast data with bleak library. Resolves the first part of this issue: https://github.com/pybricks/support/issues/800 It requires a patch for the experimental firmware that sends the proper message length.

laurensvalk commented 1 year ago

Thank you!

I think we will be able to look at this after we release V3.2, so it may be a while before it gets merged.

dlech commented 1 year ago

One thing to consider here is that Bleak is doing active scanning. So this should probably come with a warning that if you leave the script running a long time, it can drain the batteries of any other BLE devices you have in the neighborhood. It is possible to do passive scanning with Bleak to avoid this on Windows and Linux (Linux requires new enough BlueZ, kernel and manual configuration).

laurensvalk commented 9 months ago

The broadcasting feature is now part of the release and has undergone a few small changes since this PR was made.

If you'd like to update the sample program or the PR, feel free to let us know.

pbochynski commented 9 months ago

@laurensvalk If you still see the value in this PR, I can adapt the PR to the new release.

laurensvalk commented 9 months ago

Sure, that would be awesome!

If you have any other MicroPython boards (pico, pyboard, etc), another nice project would be to let those broadcast/scan just like the LEGO hubs. This could make it easy to integrate LEGO with other IoT stuff.