I'm trying to reinitialize (shutdown, restart) BLE and every method I try seems to cause an assert or crash. Is there any documentation anywhere that describes the right sequence of calls to bring down BLE after having brought it up and initialized a GATTS service?
My init process looks like this:
Code: Select all
esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
esp_bt_controller_init(&bt_cfg);
esp_bt_controller_enable(ESP_BT_MODE_BLE))
esp_bluedroid_init())
esp_bluedroid_enable())
esp_ble_gap_register_callback(gap_event_handler))
esp_ble_gatts_register_callback(gatts_event_handler))
esp_ble_gatts_app_register(0))
esp_ble_gatt_set_local_mtu(500))
esp_ble_gap_start_advertising(&adv_params);
Code: Select all
esp_ble_gap_disconnect(connected_device_address);
esp_ble_gap_stop_advertising();
esp_ble_gatts_stop_service(gl_profile.service_handle);
esp_ble_gatts_delete_service(gl_profile.service_handle);
esp_ble_gatts_app_unregister(gl_profile.gatts_if);
esp_bluedroid_disable();
esp_bluedroid_deinit();
esp_bt_controller_disable();
esp_bt_controller_deinit();
Code: Select all
assertion "config != NULL" failed: file "/Users/jason/esp/esp-idf/components/bt/bluedroid/btc/core/btc_config.c", line 312, function: btc_config_flush
abort() was called at PC 0x400f097f on core 0
0x400f097f: __assert_func at /home/jeroen/esp8266/esp32/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)
Backtrace: 0x400967fc:0x3ffb3bf0 0x400969f7:0x3ffb3c10 0x400f097f:0x3ffb3c30 0x401310f2:0x3ffb3c60 0x40131103:0x3ffb3c80 0x4011916f:0x3ffb3ca0 0x401191b4:0x3ffb3cc0 0x40119245:0x3ffb3ce0
0x400967fc: invoke_abort at /Users/jason/esp/esp-idf/components/esp32/./panic.c:648
0x400969f7: abort at /Users/jason/esp/esp-idf/components/esp32/./panic.c:648
0x400f097f: __assert_func at /home/jeroen/esp8266/esp32/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)
0x401310f2: btc_config_flush at /Users/jason/esp/esp-idf/components/bt/bluedroid/btc/core/btc_config.c:329
0x40131103: btc_config_shut_down at /Users/jason/esp/esp-idf/components/bt/bluedroid/btc/core/btc_config.c:329
0x4011916f: btc_disable_bluetooth at /Users/jason/esp/esp-idf/components/bt/bluedroid/btc/core/btc_main.c:47
0x401191b4: btc_main_call_handler at /Users/jason/esp/esp-idf/components/bt/bluedroid/btc/core/btc_main.c:105
0x40119245: btc_task at /Users/jason/esp/esp-idf/components/bt/bluedroid/btc/core/btc_task.c:101
So, can anyone point me to information about how to properly shutdown and restart BLE?
Thanks,
Jason