How to turn off wifi and start BLE scan
Posted: Thu Mar 14, 2019 5:08 am
Hi,
What is correct way to use Wifi and BLE ? I have an application where I need wifi and periodically need to turn on BLE to scan ibeacons.
I tried to use the ble_ibeacon example under esp-idf/examples/bluetooth , but it always crashes when it tries to release the controller memory ( esp_bt_controller_mem_release() ) . The ibeacon demo example works standalone . However it doesnt with when we need to turn off wifi , initialize ble/bt, scan for beacon.
I'm using latest esp-idf code ( v3.3-beta2-60-g86c9b6354 )
===Code snippet=========================
ESP_ERROR_CHECK(esp_wifi_stop() );
ESP_ERROR_CHECK(esp_wifi_deinit() );
ESP_ERROR_CHECK(nvs_flash_init());
ESP_ERROR_CHECK(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);
ble_ibeacon_init();
/* set scan parameters */
#if (IBEACON_MODE == IBEACON_RECEIVER)
ESP_LOGW(TAG, "IBEACON_MODE: IBEACON_RECEIVER \n");
esp_ble_gap_set_scan_params(&ble_scan_params);
ESP_LOGW(TAG, "Initialize Wifi again \n");
wifi_init_sta();
=====
abort() was called at PC 0x40108acb on core 0
0x40108acb: app_main at 19Mar12/esp-avs-sdk/examples/ble_ibeacon/main/ibeacon_demo.c:975 (discriminator 2)
ELF file SHA256: 318f883c12abc674faabce3dc22693803511dbb428187f3fb4bf9992338a5923
Backtrace: 0x4009094b:0x3ffd32f0 0x40090ad1:0x3ffd3310 0x40108acb:0x3ffd3330 0x400d0ad8:0x3ffd33d0
0x4009094b: invoke_abort at 19Mar12/esp-idf/components/esp32/panic.c:136
0x40090ad1: abort at 19Mar12/esp-idf/components/esp32/panic.c:171
0x40108acb: app_main at 19Mar12/esp-avs-sdk/examples/ble_ibeacon/main/ibeacon_demo.c:975 (discriminator 2)
0x400d0ad8: main_task at 19Mar12/esp-idf/components/esp32/cpu_start.c:530
====================
Thanks,
Kiran.
What is correct way to use Wifi and BLE ? I have an application where I need wifi and periodically need to turn on BLE to scan ibeacons.
I tried to use the ble_ibeacon example under esp-idf/examples/bluetooth , but it always crashes when it tries to release the controller memory ( esp_bt_controller_mem_release() ) . The ibeacon demo example works standalone . However it doesnt with when we need to turn off wifi , initialize ble/bt, scan for beacon.
I'm using latest esp-idf code ( v3.3-beta2-60-g86c9b6354 )
===Code snippet=========================
ESP_ERROR_CHECK(esp_wifi_stop() );
ESP_ERROR_CHECK(esp_wifi_deinit() );
ESP_ERROR_CHECK(nvs_flash_init());
ESP_ERROR_CHECK(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);
ble_ibeacon_init();
/* set scan parameters */
#if (IBEACON_MODE == IBEACON_RECEIVER)
ESP_LOGW(TAG, "IBEACON_MODE: IBEACON_RECEIVER \n");
esp_ble_gap_set_scan_params(&ble_scan_params);
ESP_LOGW(TAG, "Initialize Wifi again \n");
wifi_init_sta();
=====
abort() was called at PC 0x40108acb on core 0
0x40108acb: app_main at 19Mar12/esp-avs-sdk/examples/ble_ibeacon/main/ibeacon_demo.c:975 (discriminator 2)
ELF file SHA256: 318f883c12abc674faabce3dc22693803511dbb428187f3fb4bf9992338a5923
Backtrace: 0x4009094b:0x3ffd32f0 0x40090ad1:0x3ffd3310 0x40108acb:0x3ffd3330 0x400d0ad8:0x3ffd33d0
0x4009094b: invoke_abort at 19Mar12/esp-idf/components/esp32/panic.c:136
0x40090ad1: abort at 19Mar12/esp-idf/components/esp32/panic.c:171
0x40108acb: app_main at 19Mar12/esp-avs-sdk/examples/ble_ibeacon/main/ibeacon_demo.c:975 (discriminator 2)
0x400d0ad8: main_task at 19Mar12/esp-idf/components/esp32/cpu_start.c:530
====================
Thanks,
Kiran.