Board: OLIMEX ESP32-GATEWAY
Core Installation/update date: 2018.12.30
IDE name: Sloeber IDE, esp32-arduino master (commit ids: 6dd8be3, 6f6ee98)
Flash Frequency: ?40Mhz?
PSRAM enabled: ?no?
Upload Speed: 115200
Computer OS: Windows 10
I am trying to implement the ESP-IDF A2DP Source example with the ESP32-arduino library but Igot 0x103 ESP_ERR_INVALID_STATE error.
void setup()
{
Serial.begin(115200); //start serial for debug
Serial.println(__func__);
Serial.println(_firmware_version); //print the firmware version to debug interface
Serial.println("-------------");
Serial.println("API Started!");
Serial.println("-------------");
// Add your initialization code here
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
esp_bt_controller_mem_release(ESP_BT_MODE_BLE);
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
ret = esp_bt_controller_init(&bt_cfg);
if (ret != ESP_OK) //this comes true with ret = 0x103
{
Serial.print("In function: ");
Serial.println(__func__);
Serial.println("initialize controller failed");
Serial.println(ret);
return;
}
.
.
.
}
What can be the problem?
Please search through old issues before posting. You cannot release BT memory unless you compile arduino as an ESP-IDF component
Also Arduino already does most of the things that you are calling up there. NVS init and BT release... read this code: https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-misc.c#L193-L212
Also Arduino has it's own API to do esp_bt_controller_init! Do not use IDF one
Thank you very much for the guidance. Now everything works like a charm!
great! :)