BLE AND BLUETOOTH MODE SWITCHING ISSUE IN RUNTIME

sathish
Posts: 7
Joined: Sat Jan 11, 2020 7:23 am

BLE AND BLUETOOTH MODE SWITCHING ISSUE IN RUNTIME

Postby sathish » Sat Jan 25, 2020 9:46 am

Hai,
In esp32 , i am using bluetooth and ble (dual mode ) ..now i need to switch the both modes.
at first it should be in ble mode then if interrupt occurs it should switch for dual mode (ble+bluettooth) for a particular time ...then switch back to ble mode ...is it possible to switch modes ??

i tried to initialize the ble mode at first then disabled the ble mode after that changing the mode to BTDM (DUAL MODE) but it is not switch over ..shows the error as follwes ...

E (293) BLE_CONFIG: configBleEnable initialize controller failed: ESP_ERR_INVALID_STATE

int ble_enable()
{
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s initialize controller failed: %s\n", func,
esp_err_to_name(ret));
return 1;
}
if(value ==1)
{
if ((ret = esp_bt_controller_enable(ESP_BT_MODE_BLE)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s enable controller failed: %s\n", func,
esp_err_to_name(ret));
return 1;
}
}
else if(value == 10)
{
if ((ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM)) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s enable controller failed: %s\n", func,
esp_err_to_name(ret));
return 1;
}
}
}
////***********disable mode **************/
int configBleDisable() {

ESP_LOGI(SPP_TAG, "Disabling Bluetooth");

if ((ret = esp_bluedroid_disable()) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s disable bluedroid failed: %s\n", func,
esp_err_to_name(ret));
return 1;
}

if ((ret = esp_bluedroid_deinit()) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s deinitialize bluedroid failed: %s\n", func,
esp_err_to_name(ret));
return 1;
}

if ((ret = esp_bt_controller_disable()) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s disable controller failed: %s\n", func,
esp_err_to_name(ret));
return 1;
}

if ((ret = esp_bt_controller_deinit()) != ESP_OK) {
ESP_LOGE(SPP_TAG, "%s deinitialize controller failed: %s\n", func,
esp_err_to_name(ret));
return 1;
}

esp_bt_mem_release(ESP_BT_MODE_BLE);

return 0;
}
can you please tell me how to switch modes???

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 100 guests