Not being able to turn on the bluetooth

TheRochVoices
Posts: 2
Joined: Wed Jul 26, 2017 12:15 pm

Not being able to turn on the bluetooth

Postby TheRochVoices » Wed Jul 26, 2017 12:27 pm

I am advertising data using bluetooth on ESP32. I am using this project as a reference - https://github.com/pcbreflux/espressif/ ... pp_ibeacon . This is my app_main() code:

Code: Select all

int app_main()
{
    esp_err_t ret;

    esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
    ret = esp_bt_controller_init(&bt_cfg);
    if (ret) {
        ESP_LOGE(GATTS_TAG, "%s initialize controller failed\n", __func__);
        return 1;
    }

    ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
    if (ret) {
        ESP_LOGE(GATTS_TAG, "%s enable controller failed\n", __func__);
        return 1;
    }
    xTaskCreatePinnedToCore(&bleAdvtTask, "bleAdvtTask", 2048, NULL, 5, NULL, 0);
    return 0;
}
The code works just fine on IDF. Since my whole project is made on Arduino I copied this code and libraries associated with it to my Arduino code. I made some changes like calling the app_main() in the setup() fucntion. The code is getting uploaded but the line

Code: Select all

 esp_bt_controller_enable(ESP_BT_MODE_BTDM) 
is returning 0/false in this case. Even after turning the bluetooth on in "make menuconfig" menu, I am still stuck at "app_main enable controller failed".

f.h-f.s.
Posts: 216
Joined: Thu Dec 08, 2016 2:53 pm

Re: Not being able to turn on the bluetooth

Postby f.h-f.s. » Thu Jul 27, 2017 1:19 pm

Have a look at:

Code: Select all

esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
Its return type is esp_err_t:

Code: Select all

#define ESP_OK          0
This would be correct:

Code: Select all

	
	if (esp_bt_controller_enable(ESP_BT_MODE_BTDM) != ESP_OK)
		ESP_LOGE(TAG,"Error");

Who is online

Users browsing this forum: Baidu [Spider] and 96 guests