Disabling & Re-enabling BLE

paddy_b
Posts: 11
Joined: Wed Jun 06, 2018 2:00 pm

Disabling & Re-enabling BLE

Postby paddy_b » Thu Nov 28, 2019 9:51 am

I have an application which uses BLE and want to place the ESP into light sleep.
I know it's not possible to maintain any BLE activity in light sleep mode, but should it be possible to disable bluetooth and re-enable the same configuration later, without having to re-initialise everything?

Calling:

Code: Select all

esp_bluedroid_disable();
esp_bt_controller_disable();
then later calling

Code: Select all

esp_bluedroid_enable();
esp_bt_controller_enable();
appears to work, but a following call to esp_ble_gatts_start_service (which works fine beforehand) results in this:

Code: Select all

EASSERT_PARAM(512 0), in rwble.c at line 235
Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC      : 0x40083482  PS      : 0x00060034  A0      : 0x800873c4  A1      : 0x3ffbe290
0x40083482: r_assert_param at ??:?

A2      : 0x00000001  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x60008054
A6      : 0x3ffbdbe4  A7      : 0x60008050  A8      : 0x8008347d  A9      : 0x3ffbe270
A10     : 0x00000004  A11     : 0x00000000  A12     : 0x6000804c  A13     : 0xffffffff  
A14     : 0x00000000  A15     : 0xfffffffc  SAR     : 0x00000004  EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000  LBEG    : 0x400833b5  LEND    : 0x400833bc  LCOUNT  : 0x00000000  
0x400833b5: r_assert_param at ??:?

0x400833bc: r_assert_param at ??:?

Core 0 was running in ISR context:
EPC1    : 0x400d52ed  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x40083482
0x400d52ed: uart_tx_char at C:/esp-idf/components/vfs/vfs_uart.c:155 (discriminator 1)

0x40083482: r_assert_param at ??:?


ELF file SHA256: 44356a8a8d6afefcc17ea27558b53d2b3a7be3d3d38f1f3ff03ac3f644eab01f

Backtrace: 0x4008347f:0x3ffbe290 0x400873c1:0x3ffbe2b0 0x40087faf:0x3ffbe2d0 0x40082c45:0x3ffbe2f0 0x400d52ea:0x3ffd6320 0x400d5fc9:0x3ffd6340 0x400d4ee9:0x3ffd6360 0x4000bd83:0x3ffd6380 |<-CORRUPTED
0x4008347f: r_assert_param at ??:?

0x400873c1: r_rwble_isr at ??:?

0x40087faf: r_rwbtdm_isr_wrapper at intc.c:?

0x40082c45: _xt_lowint1 at C:/esp-idf/components/freertos/xtensa_vectors.S:1153

0x400d52ea: uart_tx_char at C:/esp-idf/components/vfs/vfs_uart.c:155 (discriminator 1)

0x400d5fc9: uart_write at C:/esp-idf/components/vfs/vfs_uart.c:204

0x400d4ee9: esp_vfs_write at C:/esp-idf/components/vfs/vfs.c:420 (discriminator 4)


Core 1 register dump:
PC      : 0x401507ce  PS      : 0x00060b34  A0      : 0x800d4221  A1      : 0x3ffbd530  
0x401507ce: esp_pm_impl_waiti at C:/esp-idf/components/esp32/pm_esp32.c:486

A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x80000001
A6      : 0x00000003  A7      : 0x00060023  A8      : 0x800d3cb2  A9      : 0x3ffbd500
A10     : 0x00000000  A11     : 0x00000001  A12     : 0x80092196  A13     : 0x3ffbd440  
A14     : 0x00000003  A15     : 0x00060023  SAR     : 0x00000000  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

ELF file SHA256: 44356a8a8d6afefcc17ea27558b53d2b3a7be3d3d38f1f3ff03ac3f644eab01f

Backtrace: 0x401507cb:0x3ffbd530 0x400d421e:0x3ffbd550 0x40093cd1:0x3ffbd570 0x40091f91:0x3ffbd590
0x401507cb: esp_pm_impl_waiti at C:/esp-idf/components/esp32/pm_esp32.c:484

0x400d421e: esp_vApplicationIdleHook at C:/esp-idf/components/esp_common/src/freertos_hooks.c:63

0x40093cd1: prvIdleTask at C:/esp-idf/components/freertos/tasks.c:3382 (discriminator 1)

0x40091f91: vPortTaskWrapper at C:/esp-idf/components/freertos/port.c:143
Last edited by paddy_b on Mon Dec 02, 2019 2:45 pm, edited 1 time in total.

mikemoy
Posts: 599
Joined: Fri Jan 12, 2018 9:10 pm

Re: Disabling & Re-enabling BLE

Postby mikemoy » Fri Nov 29, 2019 5:28 am

Have a look at this thread
viewtopic.php?f=2&t=13275

paddy_b
Posts: 11
Joined: Wed Jun 06, 2018 2:00 pm

Re: Disabling & Re-enabling BLE

Postby paddy_b » Mon Dec 02, 2019 2:51 pm

Thanks for your reply... didn't really have anything in common as far as I could tell.

I've got the functionality I need working now more or less, but I pretty much have to restart from scratch.
It seems some things persist (GATT & GAP callbacks only need registering once at the start) but others don't (esp_ble_gatts_app_register, esp_ble_gap_config_adv_data_raw, esp_ble_gatts_create_attr_tab).

I'm still not sure why esp_bt_controller_init and esp_bt_controller_enable (and disable/deinit, and equivalents for bluedroid) are separate functions, if they can only be used together. I expect I'm missing something.

Hopefully someone from Espressif can enlighten me.

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: Disabling & Re-enabling BLE

Postby chegewara » Tue Dec 03, 2019 5:20 am

Maybe this is not about esp-idf structure, but recently I found this video on yt. On this screenshot you can see how controller is separated from host:
Screenshot_20191203-061554_YouTube.jpg
Screenshot_20191203-061554_YouTube.jpg (678.32 KiB) Viewed 7345 times
And here is video:
https://youtu.be/DAk38x2ou3s

Who is online

Users browsing this forum: Alexa [Bot], spenderIng and 114 guests