BLE peripheral examples disconnect immediately after connecting
Posted: Sat Oct 11, 2025 9:13 pm
I'm trying to run some basic BLE operations... and I found even the example apps bleprph, blehr, and NimBLE_Connection are not working correctly. The code is not modified (other than some start up logs), I'm using an esp32c6 and am able to see the broadcast in the nRF app. However, when I try to connect, I immediately get disconnected. What's weird is that the first couple times I use blehr, it worked fine. I was able to to connect and turn on/off the LED. But now all of the apps exhibit this same disconnect problem. I've tried two separate boards and they both do the same thing, so I don't think it's a hardware issue. Clearly some things are working because I can see the advertisements. I just can't connect.
Here's an example of the basic logs:
Interestingly, when I turn on some debug longs, this is what I see:
Here's an example of the basic logs:
I (14597) NimBLE: advertise complete; reason=0
I (14597) NimBLE: GAP procedure initiated: extended advertise; instance=0
I (14807) NimBLE: connection failed; status=19
I (14807) NimBLE:
I (14807) NimBLE: ogf=0x08, ocf=0x0022, hci_err=0x202 : BLE_ERR_UNK_CONN_ID (Unknown Connection Identifier)
I (14807) NimBLE: disconnect; reason=531
I (14817) NimBLE: handle=0 our_ota_addr_type=0 our_ota_addr=
I (14817) NimBLE: 40:4c:ca:5d:d9:4a
I (14827) NimBLE: our_id_addr_type=0 our_id_addr=
I (14827) NimBLE: 40:4c:ca:5d:d9:4a
I (14827) NimBLE: peer_ota_addr_type=1 peer_ota_addr=
I (14837) NimBLE: 68:46:e7:1c:66:bb
I (14837) NimBLE: peer_id_addr_type=1 peer_id_addr=
I (14847) NimBLE: 68:46:e7:1c:66:bb
I (14847) NimBLE: conn_itvl=24 conn_latency=0 supervision_timeout=72 encrypted=0 authenticated=0 bonded=0
I (14857) NimBLE:
I (19417) NimBLE: advertise complete; reason=0
I (19417) NimBLE: GAP procedure initiated: extended advertise; instance=0
I (19607) NimBLE: connection failed; status=19
I (19607) NimBLE:
I (19607) NimBLE: ogf=0x08, ocf=0x0022, hci_err=0x202 : BLE_ERR_UNK_CONN_ID (Unknown Connection Identifier)
Interestingly, when I turn on some debug longs, this is what I see:
Has anyone else experienced this? Any thoughts?I (484) BLE_INIT: Using main XTAL as clock source, chip ver: 1
I (484) BLE_INIT: ble controller commit:[898f73c]
I (494) BLE_INIT: Bluetooth MAC: 40:4c:ca:5d:d9:4a
I (494) phy_init: phy_version 341,a6c8fe6,Jul 30 2025,18:34:11
I (574) phy: libbtbb version: a945109, Jul 30 2025, 18:34:25
I (574) NimBLE_BLE_PRPH: BLE Host Task Started
I (584) NimBLE: Device Address:
I (584) NimBLE: 40:4c:ca:5d:d9:4a
I (584) NimBLE:
I (584) NimBLE: GAP procedure initiated: extended advertise; instance=0
I (584) uart: queue free spaces: 8
I (594) main_task: Returned from app_main()
assert failed: ble_hs_conn_find_assert ble_hs_conn.c:328 (conn != ((void *)0))
Core 0 register dump:
--- Stack dump detected
MEPC : 0x4080e8f0 RA : 0x4080e8ae SP : 0x40829920 GP : 0x40816e74
--- 0x4080e8f0: panic_abort at /Users/myhome/opt/esp-idf/components/esp_system/panic.c:483
--- 0x4080e8ae: esp_vApplicationTickHook at /Users/myhome/opt/esp-idf/components/esp_system/freertos_hooks.c:31
TP : 0x40829bc0 T0 : 0x37363534 T1 : 0x7271706f T2 : 0x33323130
S0/FP : 0x00000079 S1 : 0x00000001 A0 : 0x4082995c A1 : 0x40817ed5
A2 : 0x00000001 A3 : 0x00000029 A4 : 0x00000001 A5 : 0x4081a000
A6 : 0x0000000c A7 : 0x76757473 S2 : 0x00000009 S3 : 0x40829a7e
S4 : 0x40817ed4 S5 : 0x00000000 S6 : 0x00000000 S7 : 0x00000000
S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x6e6d6c6b T4 : 0x6a696867 T5 : 0x66656463 T6 : 0x62613938
MSTATUS : 0x00001881 MTVEC : 0x40800001 MCAUSE : 0x00000002 MTVAL : 0x00000000
--- 0x40800001: _vector_table at /Users/myhome/opt/esp-idf/components/riscv/vectors_intc.S:54
MHARTID : 0x00000000
--- Backtrace:
add symbol table from file "/Users/myhome/projects/Hardware/esp32/Examples/bleprph/build/bootloader/bootloader.elf"
panic_abort (details=details@entry=0x4082995c "assert failed: ble_hs_conn_find_assert ble_hs_conn.c:328 (conn != ((void *)0))") at /Users/myhome/opt/esp-idf/components/esp_system/panic.c:483
483 asm("unimp"); // should be an invalid operation on RISC-V targets
#0 panic_abort (details=details@entry=0x4082995c "assert failed: ble_hs_conn_find_assert ble_hs_conn.c:328 (conn != ((void *)0))") at /Users/myhome/opt/esp-idf/components/esp_system/panic.c:483
#1 0x4080e8ae in esp_system_abort (details=details@entry=0x4082995c "assert failed: ble_hs_conn_find_assert ble_hs_conn.c:328 (conn != ((void *)0))") at /Users/myhome/opt/esp-idf/components/esp_system/port/esp_system_chip.c:87
#2 0x4081428a in __assert_func (file=file@entry=0x42087fa3 "", line=line@entry=328, func=<optimized out>, func@entry=0x4209077c <__func__.4> "", expr=expr@entry=0x42084678 "") at /Users/myhome/opt/esp-idf/components/newlib/src/assert.c:80
#3 0x42025b54 in ble_hs_conn_find_assert (conn_handle=conn_handle@entry=0) at /Users/myhome/opt/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_conn.c:328
#4 0x42011f5e in ble_sm_ltk_req_rx (ev=0x40823dfa) at /Users/myhome/opt/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_sm.c:1478
#5 0x4201437e in ble_hs_hci_evt_le_lt_key_req (subevent=<optimized out>, data=<optimized out>, len=<optimized out>) at /Users/myhome/opt/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_hci_evt.c:1249
#6 0x4201368e in ble_hs_hci_evt_le_meta (event_code=<optimized out>, data=0x40823dfa, len=13) at /Users/myhome/opt/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_hci_evt.c:471
#7 0x420144e8 in ble_hs_hci_evt_process (ev=ev@entry=0x40823df8) at /Users/myhome/opt/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_hci_evt.c:1345
#8 0x420129ee in ble_hs_event_rx_hci_ev (ev=0x4081a3d4 <ble_hs_hci_os_event_buf>) at /Users/myhome/opt/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:547
#9 0x40802158 in npl_freertos_event_run (ev=<optimized out>) at /Users/myhome/opt/esp-idf/components/bt/porting/npl/freertos/src/npl_os_freertos.c:405
#10 0x40801cd0 in ble_npl_event_run (ev=0x4081a3d4 <ble_hs_hci_os_event_buf>) at /Users/myhome/opt/esp-idf/components/bt/porting/npl/freertos/include/nimble/nimble_npl_os.h:175
#11 nimble_port_run () at /Users/myhome/opt/esp-idf/components/bt/host/nimble/nimble/porting/nimble/src/nimble_port.c:313
#12 0x4200d9c6 in bleprph_host_task (param=<error reading variable: value has been optimized out>) at /Users/myhome/projects/Hardware/esp32/Examples/bleprph/main/main.c:550
#13 0x4080fcd6 in vPortTaskWrapper (pxCode=<optimized out>, pvParameters=<optimized out>) at /Users/myhome/opt/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:255
ELF file SHA256: 3b901b682
Rebooting...