2

i have an ESP32 and i want to use deepsleep when it's not used. Before sending it to sleep i clean up everything, so disconnect, deinitialize and disable everything i build before. But i get a crash when i try to disable bluedroid. Does anyone have an idea why this happens?

void bt_deinit() {
    
    Serial.println("Deinit AVRC");
    if (esp_avrc_ct_deinit() != ESP_OK)
        Serial.write("Failed to deinit avrc");

    Serial.println("Deinit A2DP");
    if (esp_a2d_source_deinit() != ESP_OK)
        Serial.println("Failed to deinit a2dp");

    Serial.println("disable bluedroid");
    if (esp_bluedroid_disable() != ESP_OK)
        Serial.println("Failed to disable bluedroid");

    Serial.println("Deinit bluedroid");
    if (esp_bluedroid_deinit() != ESP_OK)
        Serial.println("Failed to deinit bluedroid");

    Serial.println("Stop BT");
    if (btStop() == false)
        Serial.println("Failed to stop bt");
}

output:

Port closed
Uploading to I/O board
Opening port
Port open
Hello there!
Bluetooth init success
good night
Deinit AVRC
Deinit A2DP
disable bluedroid
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:719 (xQueueGenericSend)- assert failed!
abort() was called at PC 0x4008de6f on core 0

Backtrace: 0x40091918:0x3ffce3b0 0x40091b49:0x3ffce3d0 0x4008de6f:0x3ffce3f0 0x4013bfb6:0x3ffce430 0x4013c5f6:0x3ffce460 0x400fdbe2:0x3ffce480 0x400fdc35:0x3ffce4a0 0x400fe12e:0x3ffce4c0 0x400f6bd9:0x3ffce4e0 0x4008e559:0x3ffce510

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Hello there!
Bluetooth init success

it works fine if i just do not deinitialize everything and send him directly to sleep. But this is not the elegant way.

1
  • upvote for well presented question ... sadly I do not have the expertise to help you ..... perhaps something has not finished shutting down .... insert a delay before disabling bluedroid .... maybe it is the order of events ..... maybe stop first, then disable .... possibly the reverse order of the startup sequence
    – jsotola
    Commented Oct 27, 2020 at 18:45

1 Answer 1

1

decoded backtrace in your question is missing, one of the choices to see stack trace is https://github.com/littleyoda/EspStackTraceDecoder

i dont know exactly if this is your case or not, but calling esp_ble_gap_stop_scanning() before esp_bluedroid_deinit() possibly avoids your crash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.