espressif / esp-iot-solution

Espressif IoT Library. IoT Device Drivers, Documentations And Solutions.
Apache License 2.0
1.8k stars 740 forks source link

esp_ble_conn_mgr no disconnect event (AEGHB-663) #362

Closed AlejandroHuerta closed 1 month ago

AlejandroHuerta commented 1 month ago

Answers checklist.

IDF version.

5.2.1

Espressif SoC revision.

esp32-c3 (QFN32) v0.4

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.

esp32-c3-devkitm-1

Steps to reproduce.

  1. Build spp_server
  2. Flash to device
  3. Connect to device via another bluetooth device
  4. Disconnect via another device
  5. Observer that a connect message was outputted but not a disconnect message

Build Logs.

No response

More Information.

Here's the logs from the serial output

I (422) blecm_nimble: BLE Host Task Started I (422) blecm_nimble: No characteristic(0x2a00) found I (422) blecm_nimble: No characteristic(0x2a01) found I (422) blecm_nimble: No characteristic(0x2a05) found I (432) blecm_nimble: No characteristic(0x2b3a) found I (432) blecm_nimble: No characteristic(0x2b29) found I (442) app_main: Callback for read I (452) NimBLE: GAP procedure initiated: stop advertising.

I (452) NimBLE: GAP procedure initiated: advertise; I (462) NimBLE: disc_mode=2 I (462) NimBLE: adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256 I (472) NimBLE:

I (472) main_task: Returned from app_main() I (7882) app_main: ESP_BLE_CONN_EVENT_CONNECTED

I (17692) NimBLE: GAP procedure initiated: advertise; I (17692) NimBLE: disc_mode=2 I (17692) NimBLE: adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256 I (17702) NimBLE:

lisir233 commented 1 month ago

Hi, @AlejandroHuerta Thanks for the feedback, for some reason the disconnect event is not being reported to app_ble_conn_event_handler. as a temporary solution you can add esp_event_post(BLE_CONN_MGR_EVENTS, ESP_BLE_CONN_EVENT_DISCONNECTED, NULL, 0, portMAX_DELAY). to https://github.com/espressif/esp-iot-solution/blob/d7b07150ce726b855a4c29903eac455749a1a056/components/bluetooth/ble_conn_mgr/src/esp_nimble.c#L1803 We will fix this in a subsequent commit, thanks again for your feedback!