esp-nimble-cpp icon indicating copy to clipboard operation
esp-nimble-cpp copied to clipboard

ESP32S3: crash when subscribing with phone but not laptop

Open ArdenKolodner opened this issue 2 years ago • 9 comments

I have esp-nimble-cpp running on an ESP32S3 from ESP-IDF with Arduino component. I have a characteristic that should be updating and notifying about 3 times per second. I have a MacBook and iOS phone available for testing (waiting for a coworker to test this on PC/Android). When I subscribe to the characteristic from the MacBook, it works fine. When I do so from the iPhone, the ESP32S3 crashes, with the following stack trace: `assert failed: static int NimBLECharacteristic::handleGapEvent(uint16_t, uint16_t, ble_gatt_access_ctxt*, void*) NimBLECharacteristic.cpp:277 (rc == 0)

Backtrace: [...] 0x40375cde: panic_abort at [idf path]/esp-idf/components/esp_system/panic.c:402

0x4037f9ed: esp_system_abort at [idf path]/esp-idf/components/esp_system/esp_system.c:128

0x40386359: __assert_func at [idf path]/esp-idf/components/newlib/assert.c:85

0x42025357: NimBLECharacteristic::handleGapEvent(unsigned short, unsigned short, ble_gatt_access_ctxt*, void*) at [project]/components/esp-nimble-cpp-1.4.1/src/NimBLECharacteristic.cpp:277 (discriminator 1)

0x42036f54: ble_gatts_val_access at [idf path]/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_gatts.c:375

0x42036fd6: ble_gatts_chr_val_access at [idf path]/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_gatts.c:421

0x4203a69a: ble_att_svr_read at [idf path]/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_att_svr.c:398

0x4203b18a: ble_att_svr_read_handle at [idf path]/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_att_svr.c:473

0x42031fb3: ble_gattc_notify_custom at [idf path]/esp-idf/components/bt/host/nimble/nimble/nimble/host/src/ble_gattc.c:4169

0x42025224: NimBLECharacteristic::notify(unsigned char const*, unsigned int, bool) at [project]/components/esp-nimble-cpp-1.4.1/src/NimBLECharacteristic.cpp:513

0x4202523d: NimBLECharacteristic::notify(bool) at [project]/components/esp-nimble-cpp-1.4.1/src/NimBLECharacteristic.cpp:420

[my function calls inside loop()]

0x420069f9: loopTask(void*) at [idf path]/esp-idf/components/arduino/cores/esp32/main.cpp:50

0x40382c6d: vPortTaskWrapper at [idf path]/esp-idf/components/freertos/port/xtensa/port.c:131`

The crash happens with 2 different apps on the phone (LightBlue and the app I'm developing) so it seems to be something on the ESP side. Does anyone know how to fix this, or at least what's causing it? (A bit of poking around makes it seem like the ESP can't find the connection info for the phone, but I have no idea what would cause that.)

ArdenKolodner avatar Jan 05 '23 19:01 ArdenKolodner