esp-idf: [TW#26501] LE Connection fail rate 10-15% after enabling BT Modem sleep

Environment

  • Development Kit: [none]
  • Core (if using chip or module): [ESP32]
  • IDF version: 93b588a0cf7dca19ea02c08e3773ecf8e908ed45
  • Development Env: [Make]
  • Operating System: [Windows]
  • Power Supply: [USB]

Problem Description

After enabling Bluetooth Modem sleep we see a lot more LE Connect failures between ESP32’s. 10-15% of LE create connection fails. We are not using bluedroid. I have attached the HCI log which you can see all sent/received HCI commands.

The scenario looks like this: ESP32 Central: (Full log here acl_connect_fail.zip)

Received LE Create Connection (status: pending)
Received LE Connection Complete (status: success)
Received LE Disconnect Complete  (status: 0x3e Failed to be established)

ESP32 Peripheral: EMPTY - No Connection Events at all received from the Bluetooth controller

All connection parameters can be seen in the HCI LOG I have attached.

Edit: From what I have seen the last few days it seems as it’s a little more likely to happen the first connect after both devices where reset.

Expected Behavior

I know that it’s normal for BLE to every once in a while get a quick disconnect after a connection. However 10-15% seems a little much?

Actual Behavior

Less failed LE Create Connection.

Steps to repropduce

I have not tried this with example applications yet, but our application does not do much other than below.

  1. Normal LE Connect from ESP32 central to ESP32 Peripheral (Both with BT Modem sleep enabled)
  2. Repeat until my scenario explained above is reached. 10+ tries required. Sometimes more are needed.

Debug Logs

ESP32 Central acl_connect_fail.zip

Other items if possible

Dual mode BLE/Classic The application and Bluetooth stack is running on core 1 BT Controller is running on 0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 26 (2 by maintainers)

Most upvoted comments

@jakkra,

Let me try to answer your first two questions. Here I think there is a difference in the definition between “connection creation” and “connection establishment”, according to Bluetooth Core Spec(v5.0).

As to the connection setup procedure, the spec says,

After the initiator sends a CONNECTION_IND_PDU on the primary advertising channel ..., the
Link Layer is in the Connecion State in the Master Role. The master shall reset the Link
Layer connection supervision timer T_LLconnSupervision. The Link Layer shall notify the
Host that the connection has been created...
The Link Layer enters the Connection State when an initiator sends a CONNECT_REQ PDU on
the primary advertising channel from an initiator ...

After entering the Connection State, the connection is considered to be created. The
connection is not considered to be established at this point. A connection is only
considered to be established once a data channel packet has been received from the
peer device.
If the Link Layer connection supervision timer reaches 6 * connInterval before the connection
is established, the connection shall be considered lost. This enables fast termination of
connections that fail to establish

As to the HCI event LE_Connection_Complete, the core spec says:

The LE Connection Complete event indicates to both of the Hosts forming the
connection that a new connection has been created. Upon the creation of the
connection a Connection_Handle shall be assigned by the Controller, and
passed to the Host in this event. If the connection creation fails this event shall
be provided to the Host that had issued the LE_Create_Connection command.

This event indicates to the Host which issued a LE_Create_Connection
command and received a Command Status event if the connection creation
failed or was successful.

Coming back to the HCI error code "CONNECTION FAILED TO BE ESTABLISHED(0x3E):

The Connection Failed to be Established error code indicates that the LL intiated
a connection but the connection has failed to established.

My explanation for this case is, for the initiator, the connection succeeds in “connection creation” but fails in “connection establishment”, therefore results in a Disconnect event with error code (0x3e) following the LE_Connection_Complete event. The process may be that the CONN_REQ PDU has been sent by the initiator, but the advertiser fails to receive the packet, and then link supervision timer on the initiator expires. This also explains why the periperhal side does not get an LE_Connection_Complete event at all.