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

Consider asyncio bleak backend as gatttool replacement #304

Open
xloem opened this issue Jan 6, 2021 · 6 comments
Open

Consider asyncio bleak backend as gatttool replacement #304

xloem opened this issue Jan 6, 2021 · 6 comments

Comments

@xloem
Copy link

xloem commented Jan 6, 2021

https://github.com/hbldh/bleak is a cross-platform bluetooth interface using python's asyncio infrastructure. The use of asyncio provides for more flexibility for the user. The bleak api has native python implementations for linux, windows, and osx, requiring no calling out to other processes or asking the user for root access.

@xloem
Copy link
Author

xloem commented Jan 11, 2021

I basically implemented this here: https://github.com/alexandrebarachant/muse-lsl/pull/148/files

Here it is with the pump loop automatically run in a separate thread: alexandrebarachant/muse-lsl@6336053

@peplin
Copy link
Owner

peplin commented Feb 20, 2021

Bleak looks great! @xloem I'm curious, what value do you see in adding PyGATT as a wrapper? I'm not actively maintaining this project anymore and haven't found anyone interested in picking it up, so I'm wondering if the best course of action is to consider it deprecated and redirect people to bleak instead.

@xloem
Copy link
Author

xloem commented Feb 21, 2021

[Edit: sorry thought this was a different project]. That sounds okay. In muse-lsl I was just a new visitor, so I don't know what all the users, forks, and maintainers need in order to retain compatibility. It was pretty obvious from the codebase that people had been used to using pygatt for some time. And as mentioned in that PR I've only tested bleak on Linux, and one of the devs may have found a bug with it.

@peplin peplin changed the title Consider asyncio bleak backend Consider asyncio bleak backend as gatttool replacement Feb 21, 2021
@Yuribtr
Copy link

Yuribtr commented Jul 17, 2021

Well, I tried Bleak for some months in production (connection to GoPro cameras) and can say that I saw strange behavior of BleakClient. It's method write_gatt_char doesn't guarantee that command was successfully send to device. BleakClient needs about 10-30 retries to send command. Sometimes it is doesn't work at all, but native gattool console utility works like a charm. So I decided to try pygatt.
At present I have scanning, pairing and trust functions made with bluetoothctl, the last part will be sending commands function via pygatt, and Bleak will be dropped out from my project.

@xloem
Copy link
Author

xloem commented Jul 17, 2021

Hey that's a great report but why are you mentioning it here instead of the bleak project? Did you open an issue so they can learn of it and fix it?

EDIT: I see you are saying pygatt still has value. As a user of bleak I'd really appreciate it if you'd open an issue so they can fix it some day.

@Yuribtr
Copy link

Yuribtr commented Jul 17, 2021

Hey that's a great report but why are you mentioning it here instead of the bleak project? Did you open an issue so they can learn of it and fix it?

Yep, this is good idea, maybe I will have time to describe this bug with enough details.

EDIT: I see you are saying pygatt still has value.

Correct! This was my main intention to say that pygatt might be useful in some scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants