espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.35k stars 7.21k forks source link

BLE running randomly disconnet when receiving Params_update (IDFGH-13402) #14309

Open sergiutigu opened 1 month ago

sergiutigu commented 1 month ago

Answers checklist.

IDF version.

v4.3

Espressif SoC revision.

ESP32

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

custom board

Power Supply used.

USB

What is the expected behavior?

The ESP32 is running as a BLE central. We do mage to re-connect to the bonded peripheral: 00000003 NPI_BT_RC(10): ESP_GAP_BLE_AUTH_CMPL_EVT 00000003 NPI_BT_RC(10): remote BD_ADDR: cc:c8:2a:6b:aa:62 00000003 NPI_BT_RC(10): address type = 1 00000003 NPI_BT_RC(10): pair status = success

We also manage to receive some data from the peripheral before the Update parameters: 00000003 NPI_BT_RC(10): ESP_GATTC_NOTIFY_EVT 00000003 BT_RC(4): Data: MSB 0x00100000 LSB 00000003 MDH_MACI(4): BT DATA FW ! 00000003 NPI_BT_RC(10): ESP_GATTC_NOTIFY_EVT 00000003 BT_RC(4): Data: MSB 0x00000000 LSB 00000003 MDH_MACI(4): BT DATA FW !

Then the Update paramteres happneds. Here we should remain connected like below: <\r>0000000E NPI_BT_RC(10): update connection params status = 0, min_int = 0, max_int = 0,conn_int = 12,latency = 32, timeout = 150<\n> <\r>0000000E NPI_BT_RC(10): ESP_GATTC_NOTIFY_EVT, receive notify value: 3f8165e0<\n> <\r>0000000E BT_RC(4): Data: MSB 0x10000000 LSB<\n> <\r>0000000F NPI_BT_RC(10): ESP_GATTC_NOTIFY_EVT, receive notify value: 3f8165e0<\n> <\r>0000000F BT_RC(4): Data: MSB 0x00000000 LSB<\n> <\r>00000010 NPI_BT_RC(10): ESP_GATTC_NOTIFY_EVT, receive notify value: 3f8165e0<\n> <\r>00000010 BT_RC(4): Data: MSB 0x00100000 LSB<\n>

What is the actual behavior?

This is the actual behaviour in the failing ase: <\r>660E7800 NPI_BT_RC(10): ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT<\n> <\r>660E7800 NPI_BT_RC(10): update connection params status = 0, min_int = 0, max_int = 0,conn_int = 12,latency = 32, timeout = 150<\n> <\r>660E7800 NPI_BT_RC(10): ESP_GATTC_NOTIFY_EVT, receive notify value: 3f812ffc<\n> <\r>660E7800 BT_RC(4): Data: MSB 0x00100000 LSB<\n> <\r>660E7801 NPI_BT_RC(10): ESP_GATTC_NOTIFY_EVT, receive notify value: 3f812ffc<\n> <\r>660E7801 BT_RC(4): Data: MSB 0x00000000 LSB<\n> <\r><27>[0;33mW (122498) BT_HCI: DiscCmpl evt: hdl=0, rsn=0x8<27>[0m<\r><\n>

<27>[0;33mW (122499) **BT_APPL: gattc_conn_cb: if=3 st=0 id=3 rsn=0x8<27>[0m<\r><\n>** 660E7803 NPI_BT_RC(10): ESP_GATTC_DISCONNECT_EVT, reason = 0x8<\n> <\r>660E7803 BT_RC(4): Data: MSB 0x00000000 LSB<\n> <\r>660E7803 NPI_BT_RC(10): ESP_GATTC_CLOSE_EVT, conn_id = 0, status = 0, reason = 0x8<\n> This always happens immediately after: ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT. ### Steps to reproduce. 1. ESP32 as a BLE central. 2. Connect and bond a perhiperal. 3. Reset the ESP32. 4. The BLE Central will re-connect . 5. The ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT arrives. 6. The disconnect happnes. ... ### Debug Logs. Logs provided in bug descpription. ### More Information. This issue appera 10% cases and causes the remote control to loose conectivity to the appliance. The reconnects happens roughly after 15 seconds. During this time the user can not use the appliance. We need support to resolve this issue since from the application side , i don't know what we can do
esp-zhp commented 1 month ago

@sergiutigu From the log (status = 0, min_int = 0, max_int = 0, conn_int = 12, latency = 32, timeout = 150), we can see that the connection interval is 15ms, the latency is 32, and the timeout is 1500ms. This means that the formula timeout / (1 + latency) * interval results in approximately 3, indicating only three opportunities to receive a packet. If there is significant interference in the air, the likelihood of disconnection increases. Therefore, I recommend increasing the timeout, for example, to 3000ms.