Skip to content

NimBLE client has difficulty reconnecting after ESP32 reboot, connection only recovers after resetting the client #1180

Description

@RodrigoM11

NimBLE client has difficulty reconnecting after ESP32 reboot; connection only recovers after resetting the client
Description

I am experiencing an intermittent BLE reconnection problem using NimBLE-Arduino on an ESP32.

The client is a Pantalla Táctil Programable Capacitiva 2.8p ESP32 Táctil TFT:

The NimBLE-Arduino version running on the ESP32 is 2.5.0 by h2zero.

The transmitter/peripheral is a Seeed Studio XIAO nRF54L15.

The problem occurs intermittently when the ESP32 client is started or rebooted. In some cases, the ESP32 is unable to establish the BLE connection.

The problem is resolved by resetting or power-cycling the ESP32 client. After doing so, the connection can be established normally again.

Once the BLE connection is established, communication works perfectly.

Interestingly, if the connection is already established and I power-cycle or reset the transmitter/peripheral, the BLE connection is normally re-established successfully.

Behavior
Start the ESP32 client.
The client scans and finds the peripheral.
The client creates a NimBLEClient and connects successfully.
Communication works normally. connect() takes approximately 220 ms to establish the connection.
Reboot/reset the ESP32 client.
The client finds the peripheral again, but connect() fails. The connection attempt takes approximately 3126 ms, reaches CONNECT_TIMEOUT_MS, and then fails. The client starts scanning again.
The peripheral is found again.
Subsequent connection attempts continue to fail.
The only way to recover is to reboot or power-cycle the ESP32 client again.
However, if the BLE connection is already established and I power-cycle or reset the transmitter/peripheral, the connection is normally re-established successfully.
Important observation

The problem appears to be asymmetric:

ESP32 client rebooted: BLE reconnection may fail indefinitely until the client is rebooted/power-cycled again.
Transmitter/peripheral rebooted: BLE connection is normally re-established successfully.
Power-cycle/reset the ESP32 client: BLE connection works again.

I would appreciate any guidance on what could cause this behavior and whether there is a recommended way to handle this reconnection scenario with NimBLE-Arduino 2.5.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions