ukBaz / BLE_GATT

Python package for using BlueZ D-Bus API to create a Client
MIT License
29 stars 5 forks source link

asyncio support #4

Closed koenvervloesem closed 3 years ago

koenvervloesem commented 3 years ago

This is a very nice library, just wrote a simple BLE Find Me Locator with it in a few lines of code!

I was just wondering if you are considering adding Python asyncio support. For a simple script it doesn't matter that (for instance) a connect is blocking. But if I want to use this library in a bigger project, for instance connecting to multiple peripherals, processing MQTT messages and so on, asyncio support would be handy to be able to run other parts of the program while it's waiting on coroutines finishing.

Or isn't this the intended goal of the library?

ukBaz commented 3 years ago

The library as it is now uses GLib event loop to do asynchronous notifications from devices. You could add things into that loop if you wished.

However, asynchronous apps aren't the primary goal of this library. The goal was for the library to be simple to use, have good code test coverage, and the tests that could be run on a CI server.

If BLE and asyncio are what you want, then I would point you towards https://github.com/hbldh/bleak.

koenvervloesem commented 3 years ago

I already implemented my toy example with bleak too. I was just exploring a couple of libraries before settling on one, and I found BLE_GATT exceptionally clear and clean, but for my use case it wouldn't be the best choice indeed. It wasn't really clear for me what direction this library would be going in, so thanks for clearing this up!