Want to use BleakClient within bleak package
See original GitHub issueI would like to have at least BleakClient
available within bleak, in other words: move the platform-dependent imports from __init__.py
to a new module (say api.py
). __init__.py
would then import them from there, but so could other modules within bleak.
If you’re willing accept a pull request for this let me know.
The reason I want this is that I’m working on a Pythonic interface to get and put values, using 2904 descriptors to marshal and unmarshal values, plus accessor classes for services and characteristics. Hopefully you’ll eventually be able to do things like
async with PythonicBleakClient(address, timeout=10) as client:
batteryLevel = await client.services['Battery Service'].characteristics['Battery Level'].get()
But PythonicBleakClient
and the accessor classes are backend-independent, and I don’t want to put all the functionality in BaseBleakClient
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Usage — bleak 0.20.0a1 documentation - Read the Docs
One can use the BleakClient to connect to a Bluetooth device and read its model number via the asyncronous context manager like this:....
Read more >How to use the bleak.BleakClient function in bleak - Snyk
BleakClient function in bleak. To help you get started, we've selected a few bleak examples, based on popular ways it is used in...
Read more >bleak · PyPI
Bleak is a GATT client software, capable of connecting to BLE devices acting as GATT servers. It is designed to provide a asynchronous,...
Read more >Python Tutorial 1: Connect BLE : Open GoPro - GitHub Pages
This tutorial will provide a walk-through to connect to the GoPro camera via BLE using bleak.
Read more >Bleak client: problem with sending bytes to BLE device (E104 ...
I'm trying to send bytes using Python and Bleak (https://bleak.readthedocs.io/en/latest/index.html) module from PC (Windows) to Ebyte BLE ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I didn’t have time to work on Bleak for more than a year (which was quite a bit longer than anticipated:-), but I’m going to pick this one up again. I hope to have a pull request shortly (presuming real work doesn’t interfere again:-)
Plan is to create the
_api.py
with abstract classes likeAbstractBleakClient
, then import the machine-dependent classesas MachdepBleakClient
, then have a classBleakClient
inheriting from those two. The AbstractBleakClient could then be annotated with the types and documentation, I have the feeling that would address #822 and #833 too.I am in favor of this from a documentation point of view. If we do this, we can document all of the os-specific quirks in one place instead of having 5 copies of the documentation for each method (base, windows, mac, linux, android). I am also in favor of this from an intellesense point of view. The MS VS Code Python tools always pick up the Windows backend no matter which OS is actually being used.