espressif / esp-idf

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

Bludroid BLE stacke sends false signals in multi-connect scenario (IDFGH-13322) #14245

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?

We have a BLE as a central. To it we have connected in the same time 6 peripherals. Now a message for a specific peripheral should be forwared ontly to that peripheral.

What is the actual behavior?

What we see instead is that the same signal is forwarded to all devices. This is not once , this happens a lot This only happens for connect and disconnect signals. What i mean Peripheral 5 gets connected, then the connect signal is forwarded to all 6 connected devices. If Peripheral 4 gets disconnected, the disconnect signal is sent to all devices. The not intended devices do not disconnect. This creates a very slow system with long time to re-connect the peripheral: Sample log: I (76059) NPI_BT_CL_SGG: c8 f0 9e 52 1f 2a  I (76064) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, GATTInterface_u8= 4, conn_id = 0  I (76072) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, remote_bda: c8:f0:9e:52:1f:2a I (76080) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, GATTInterface_u8= 5, conn_id = 0  I (76088) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, remote_bda: c8:f0:9e:52:1f:2a I (76096) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, GATTInterface_u8= 6, conn_id = 0  I (76104) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, remote_bda: c8:f0:9e:52:1f:2a I (76112) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, GATTInterface_u8= 7, conn_id = 0  I (76120) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, remote_bda: c8:f0:9e:52:1f:2a I (76128) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, GATTInterface_u8= 8, conn_id = 0  I (76136) NPI_BT_CL_SGG: ESP_GATTC_CONNECT_EVT, remote_bda: c8:f0:9e:52:1f:2a

You see the message is forwarded for all GATTInterface_u8. Not just one.

Int he same log we also see:

lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1) W (107835) BT_HCI: DiscCmpl evt: hdl=3, rsn=0x3e W (107835) BT_APPL: gattc_conn_cb: if=3 st=0 id=771 rsn=0x3e W (107842) BT_APPL: gattc_co0nn_cb: if=4 st=0 id=772 rsn=0x3e W (107846) BT_APPL: gattc_conn_cb: if=5 st=00 id=773 rsn=0x3e W (107853) BT_APPL: gattc_conn_cb: if=6 st=0 id=7704 rsn=0x3e W (107859) BT_APPL: gattc_conn_cb: if=7 st=0 id=775 rsn=0x3e W (107865) BT_APPL: gattc_conn_cb: if=8 st=0 id=776 rsn=0x3e I (107873) NPI_BT_CL_SGG: ESP_GATTC_DISCONNECT_EVT GATTInterface_u8=3 I (107895) NPI_BT_CL_SGG: Start scan called! 0000005F BT(I (107896) NPI_BT_CL_SGG: ESP_GATTC_DISCONNECT_EVT GATTInterface_u8=4 I (107935) NPI_BT_CL_SGG: ESP_GATTC_DISCONNECT_EVT GATTInterface_u8=5

I (107955) NPI_BT_CL_SGG: ESP_GATTC_DISCONNECT_EVT GATTInterface_u8=6

I (107973) NPI_BT_CL_SGG: ESP_GATTC_OPEN_EVT conn_id: 0, GATTInterface_u8: 6, status: 133 E (107977) NPI_BT_CL_SGG: connect device failed, status 133 I (107983) NPI_BT_CL_SGG: ESP_GATTC_DISCONNECT_EVT GATTInterface_u8=7

I (108027) NPI_BT_CL_SGG: ESP_GATTC_DISCONNECT_EVT GATTInterface_u8=8

Steps to reproduce.

  1. Setup ESP32 as BLE central, bonding, OutofBandPairing, Security level 3.
  2. Setup 6 Peripherals bonding, OOB, Security Level 3.
  3. Attempt to connect each device.
  4. Either at connection or at disconnection this happens. ...

Debug Logs.

i can not add the full log on public domain,

More Information.

we build an earlier version of this problem earlier. with an early esp-idf. and whitout out of band pairing. Maybe these are not the root cause but we have this system working.

esp-cjh commented 1 month ago

@sergiutigu Could you please provide the sdkconfig and completed log files?

esp-cjh commented 1 month ago

@sergiutigu Due to the implementation of bluedroid, the GATTC connect and disconnect events will be reported to all GATTC profiles. It is recommended to register only one GATTC APP and handle the GATTC connect and disconnect events according to the remote address.