-
Notifications
You must be signed in to change notification settings - Fork 339
Open
Labels
3rd party issueThe issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itselfThe issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itselfBackend: WinRTIssues or PRs relating to the WinRT backendIssues or PRs relating to the WinRT backend
Description
Background
I have a custom BLE device with a known address that I would like to connect to using bleak. Using uart_service.py, I am able to connect to the device when its advertising interval is set to 500ms. However, when its advertising interval is 10240ms, uart_service.py always failed to connect to the BLE device.
Description of issue
uart_service.py
Since I know the address and the characteristics, I have slightly modified the uart_service.py to the following:
target_address = "f5:f5:22:22:33:44"
UART_TX_CHAR_UUID = "e09abcdef..."
UART_RX_CHAR_UUID = "e09abcdef..."
...
async with BleakClient(target_address, disconnected_callback=handle_disconnect, timeout=100) as client:
await client.start_notify(UART_TX_CHAR_UUID, handle_rx)
print("Connected, start typing and press ENTER...")
...
Case 1: Adv_int = 500ms
- Launch script with
python .\uart_service.py - After 1-5 seconds passed...
Connected, start typing and press ENTER...- At this point, I can type into the terminal and the communication with the BLE device characteristics works perfectly.
Case 2: Adv_int = 10240ms
- Launch script with
python .\uart_service.py - After 10-102 seconds passed...
- Exception raised:
raise BleakError(f"{fail_msg}: Unreachable")
bleak.exc.BleakError: Could not get GATT services: Unreachable
My Intuition
This seem to be an advertising interval dependent issue. Increasing timeout parameter from the default 10s to 100s did not help to solve it. In both cases, I have verified that the BLE device is advertising at the correct interval using a nRF Connect app on my phone.
Metadata
Metadata
Assignees
Labels
3rd party issueThe issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itselfThe issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itselfBackend: WinRTIssues or PRs relating to the WinRT backendIssues or PRs relating to the WinRT backend