question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Want to use BleakClient within bleak package

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jackjansencommented, Jul 25, 2022

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 like AbstractBleakClient, then import the machine-dependent classes as MachdepBleakClient, then have a class BleakClient 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.

0reactions
dlechcommented, Feb 5, 2022

I 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.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found