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

two_devices.py example is incorrect #1288

Closed
ukBaz opened this issue Apr 25, 2023 · 0 comments · Fixed by #1369
Closed

two_devices.py example is incorrect #1288

ukBaz opened this issue Apr 25, 2023 · 0 comments · Fixed by #1369
Labels
Documentation Issues or PRs relating to RTD or documentation

Comments

@ukBaz
Copy link

ukBaz commented Apr 25, 2023

  • bleak version: development
  • Python version: any
  • Operating System: any
  • BlueZ version (bluetoothctl -v) in case of Linux:

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

This was raised as an issue on Stackoverflow:
https://stackoverflow.com/q/76101907/7721752

I'm opening this issue here to help ensure it gets fixed at source.

What I Did

It is preferable if an issue contains a Miminal Workable Example.
This will otherwise be one of the first questions you will get as a response.

It is also preferable if that example is not dependent on a specific peripheral device, but can be run and
reproduced with other BLE peripherals as well.

python two_devices.py

Exception has occurred: ValueError
a coroutine was expected, got <_GatheringFuture pending>
  File "path to file", line 39, in <module>
    "F0CBEBD3-299B-4139-A9FC-44618C720157",
ValueError: a coroutine was expected, got <_GatheringFuture pending>

Logs

Include any relevant logs here.

Logs are essential to understand what is going on behind the scenes.

See https://bleak.readthedocs.io/en/latest/troubleshooting.html for information on how to collect debug logs.

If you receive an OS error (WinError, BleakDBusError, NSError, etc.), Wireshark logs of Bluetooth packets are required to understand the issue!

@dlech dlech added the Documentation Issues or PRs relating to RTD or documentation label Jul 19, 2023
dlech added a commit that referenced this issue Jul 19, 2023
This fixes several issues with the implementation. Notably, on Linux
trying to scan and connect to two devices at the same time results in:

    bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress

This is worked around by using an asyncio.Lock to ensure only one scan
and connect is called at a time.

Fixes: #1036

Also fixes error due to main() not being a coroutine:

    ValueError: a coroutine was expected, got <_GatheringFuture pending>

Fixes: #1288

Finally, command line args are added to make it easy to run the example
without modifying the code.
dlech added a commit that referenced this issue Jul 20, 2023
This fixes several issues with the implementation. Notably, on Linux
trying to scan and connect to two devices at the same time results in:

    bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress

This is worked around by using an asyncio.Lock to ensure only one scan
and connect is called at a time.

Fixes: #1036

Also fixes error due to main() not being a coroutine:

    ValueError: a coroutine was expected, got <_GatheringFuture pending>

Fixes: #1288

Finally, command line args are added to make it easy to run the example
without modifying the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues or PRs relating to RTD or documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants