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

Multiple BLE devices packet loss. #1502

Open
13Pixel opened this issue Feb 6, 2024 · 1 comment
Open

Multiple BLE devices packet loss. #1502

13Pixel opened this issue Feb 6, 2024 · 1 comment
Labels
3rd party issue The issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itself Backend: BlueZ Issues and PRs relating to the BlueZ backend

Comments

@13Pixel
Copy link

13Pixel commented Feb 6, 2024

  • bleak version: [v0.21.1]
  • Python version: python 3.10
  • Operating System: Ubuntu 22.04.3 LTS
  • BlueZ version (bluetoothctl -v) in case of Linux: bluetoothctl: 5.64

Description

Maybe It's more of BLE issue and not this library...

I have BLE devices(ESP32) which sends data(306bytes) with notify every 40ms. MTU size on device is set to 512.
When I try to send data with one device - it works as expected - I receive all packets without data loss.

The problem appears when I try to receive data from 2 or more devices.

I run two instances of same python(with bleak) code(code is very simple - when computer gets notification that there is data - he reads it and adds data to queue, after some time - notifications stops and program prints all data in queue).

Issue is that after I start reading data from second device, I start to miss packets from first device. Data loss quite high - 40%.

What I Did

I tried to send less data (100bytes every 40ms) and I get same issue.

Tried send more data from one device (450bytes every 16ms) And data loss was 0 when I reading from only one device, so I confirmed that problem isn't with throughput.

Maybe someone had same issues and know how to fix this or have ideas what I could try, how to identify where is the problem?

Thanks you.

@dlech
Copy link
Collaborator

dlech commented Feb 6, 2024

I would suggest logging Bluetooth traffic using a sniffer to see what is going on over the airwaves. This will let you see empty packets that you can't see by logging HCI packets on the host computer.

My experience (with writing to peripherals in addition to getting notifications) is that when multiple peripherals are connected to a single adapter on the central that throughput can take a big hit because of the connection interval. BlueZ has a default connection interval of 50ms. It seems like some adapters are better than others of turning off the radio early during a connection interval. But even the "good" adapters sometimes have issues.

@dlech dlech added 3rd party issue The issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itself Backend: BlueZ Issues and PRs relating to the BlueZ backend labels Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party issue The issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itself Backend: BlueZ Issues and PRs relating to the BlueZ backend
Projects
None yet
Development

No branches or pull requests

2 participants