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

Non-blocking mode for LWP3Device #462

Open
dlech opened this issue Aug 30, 2021 · 0 comments
Open

Non-blocking mode for LWP3Device #462

dlech opened this issue Aug 30, 2021 · 0 comments
Labels
enhancement New feature or request platform: Powered Up Issues related to LEGO Powered Up software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: bluetooth Issues involving bluetooth

Comments

@dlech
Copy link
Member

dlech commented Aug 30, 2021

Is your feature request related to a problem? Please describe.
pybricks/pybricks-micropython#68 added a new LWP3Device class for communicating with hubs running the LEGO Wireless Protocol v3. Due to current limitations of the Pybricks Bluetooth drivers, it only operates in a blocking mode. When writing, a BLE Write With Response is performed and the method blocks until the response is received from the other hub. When reading, the method blocks until new data has been received (unless new data was already received since the last read).

Programs cannot perform some parallel tasks while these methods are blocking.

Describe the solution you'd like
The LWP3Device constructor should have a blocking=True argument. When set to False, the behavior of the read and write methods changes to follow the Python non-blocking pattern. The write method will use Write Without Response. If the Bluetooth chip is busy and the message cannot be sent right away, the method returns None. When reading, if no new messages have been received since the last read, the method returns None.

Describe alternatives you've considered
?

Additional context
The main blocker here is properly implementing Write Without Response in the Bluetooth drivers. For example, #417 indicates that there are some issues with the current implementation.

@dlech dlech added enhancement New feature or request platform: Powered Up Issues related to LEGO Powered Up topic: bluetooth Issues involving bluetooth software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) labels Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform: Powered Up Issues related to LEGO Powered Up software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: bluetooth Issues involving bluetooth
Projects
None yet
Development

No branches or pull requests

1 participant