Skip to content

Advertising interval dependent issue: Could not get GATT services: Unreachable #1866

@DaGigabyte

Description

@DaGigabyte

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

  1. Launch script with python .\uart_service.py
  2. After 1-5 seconds passed...
  3. Connected, start typing and press ENTER...
  4. At this point, I can type into the terminal and the communication with the BLE device characteristics works perfectly.

Case 2: Adv_int = 10240ms

  1. Launch script with python .\uart_service.py
  2. After 10-102 seconds passed...
  3. 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

No one assigned

    Labels

    3rd party issueThe 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 backend

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions