Comments (4)
Can you try to connect to two devices in macOS using two different terminals and see if that works. If so, then there is a limitation in the bleak macOS backend that needs to be documented.
See this for similar problem: https://stackoverflow.com/questions/34787976/how-can-i-implement-core-bluetooth-functionality-for-multiple-devices
from bleak.
It took me a while 😀 I did what you said. Bleak connects correctly to two devices at two different terminals. Unfortunately with one terminal, just like in my example, it stops before
async with BleakClient(address, loop=loop) as client:.
On Windows everything works perfect.
from bleak.
Ok. I will add a note about this in the documentation for the time being. This issue is beyond the scope of my available time to address.
from bleak.
This is solved in the last develop
branch commit and will be available on PyPI in version 0.7.0.
The following code should now work:
from bleak import BleakClient
import asyncio
notify_uuid = "0000{0:x}-0000-1000-8000-00805f9b34fb".format(0xffe1)
def callback(sender, data):
print(sender, data)
def run(addresses):
loop = asyncio.get_event_loop()
tasks = asyncio.gather(
*(connect_to_device(address, loop) for address in addresses)
)
loop.run_until_complete(tasks)
async def connect_to_device(address, loop):
print("starting", address, "loop")
async with BleakClient(address, loop=loop, timeout=10.0) as client:
print("connect to", address)
try:
await client.start_notify(notify_uuid, callback)
await asyncio.sleep(10.0, loop=loop)
await client.stop_notify(notify_uuid)
except Exception as e:
print(e)
print("disconnect from", address)
if __name__ == "__main__":
run(["B9EA5233-37EF-4DD6-87A8-2A875E821C46", "F0CBEBD3-299B-4139-A9FC-44618C720157" ])
from bleak.
Related Issues (20)
- Add option to supress thread is not MTA exception HOT 4
- macOS 10.14 returns empty list after discovery HOT 2
- Service UUID filter does not apply to dict of discovered devices. HOT 1
- How do I decode bytearray for power data HOT 1
- NSLocalizedDescription The request is not supported
- List adapters and specify which adapter to use? HOT 2
- WinError The operation was canceled by the user HOT 3
- Asyncio task hang during connection attempt HOT 1
- bleak data reading rate through notification with one uuid (57 samples per second ) and with 2 uuid subscribe (72 samples per second which is 36 sample of each uuid)
- unable to use start_notify HOT 6
- Bleak Version is not supporting in the win11 HOT 11
- Bleak issue of time to display data
- Connect bleak client to GATT Server running in MicroPython on ESP32
- On Raspberry pi bleakscanner scanning not working :BleakDBusError[org.bluez.Error.InProgress] Operation already in progress . HOT 6
- Changing Lego Remote Handset name ... HOT 1
- Unable to write to the device using bleak library through write_gatt
- cannot connect again unless reboot HOT 7
- Android permissions HOT 2
- Set Target Inclination doesn't work
- Immediate disconnect after successful connection With esp as server and raspi as client
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bleak.