Good afternoon,
I am working with an ESP32-S3-DevKitC-1 EVM and I would like to implement BLE stack.
I am working with C++, so I have created a Bluetooth Task which should enable the BLE.
However, I get problems using the Bluedroid BLE Stack :
At beginning I just wanted my device to advertise.
1) I have activated the Bluetooth using sdkconfig file.
2) In My TaskBluetooth.hpp file, I have included the following files :
#include "nvs_flash.h"
#include "esp_bt.h"
#include "esp_gap_ble_api.h"
#include "esp_gattc_api.h"
#include "esp_gatt_defs.h"
#include "esp_bt_main.h"
#include "esp_bt_defs.h"
3) In my TaskBluetooth.cpp file, in the main code of the TaskBluetooth, I have written the following lines :
ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
// Initialisation du contrôleur BT : */
ret = esp_bt_controller_init(&bt_cfg);
if (ret) {
printf("TaskBluetooth : Fail to initialise controller.\n");
}
// Choix du Mode BLE au niveau du contrôleur BT : */
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
if (ret) {
printf("TaskBluetooth : Fail to enable controller.\n");
}
/* Initialisation de Bluedroid : */
ret = esp_bluedroid_init();
if (ret) {
printf("TaskBluetooth : Fail to initialise Bluedroid.\n");
}
/* Activation de Bluedroid : */
ret = esp_bluedroid_enable();
if (ret) {
printf("TaskBluetooth : Fail to enable Bluedroid.\n");
}
When I compile the program, I get the following errors and I don't know why.
I know that i need to register a callback after that I start the advertising but my program does not work at the moment.
DO you have any idea please?
undefined reference to `gl_bta_adv_data_ptr' ProtoFS22 line 0, external location: c:\espressif\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\xtensa-esp32s3-elf\bin\ld.exe: esp-idf\bt\libbt.a(btc_task.c.obj) C/C++ Problem
undefined reference to `gl_bta_scan_rsp_data_ptr' ProtoFS22 line 0, external location: c:\espressif\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\xtensa-esp32s3-elf\bin\ld.exe: esp-idf\bt\libbt.a(btc_task.c.obj) C/C++ Problem
Problem with BLE implementation under ESP-IDF (ESP32-S3)
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
Re: Problem with BLE implementation under ESP-IDF (ESP32-S3)
I solved this problem with not checking the option "Dynamic allocation for BT/BLE stack" in sdkconfig.
However, I have now a new problem :
When I call the method :esp_ble_gap_config_adv_data_raw from my TaskBluetooth.cpp file,
I get the following error at the end of compilation :
undefined reference to `esp_ble_gap_config_adv_data_raw' ProtoFS22 line 0, external location: c:\espressif\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\xtensa-esp32s3-elf\bin\ld.exe: esp-idf\main\libmain.a(TaskBluetooth.cpp.obj) C/C++ Problem
undefined reference to `esp_ble_gap_config_adv_data_raw' TaskBluetooth.cpp /ProtoFS22/main/Tasks line 178 C/C++ Problem
However the .h file is included in my project. Could you help ?
However, I have now a new problem :
When I call the method :esp_ble_gap_config_adv_data_raw from my TaskBluetooth.cpp file,
I get the following error at the end of compilation :
undefined reference to `esp_ble_gap_config_adv_data_raw' ProtoFS22 line 0, external location: c:\espressif\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\xtensa-esp32s3-elf\bin\ld.exe: esp-idf\main\libmain.a(TaskBluetooth.cpp.obj) C/C++ Problem
undefined reference to `esp_ble_gap_config_adv_data_raw' TaskBluetooth.cpp /ProtoFS22/main/Tasks line 178 C/C++ Problem
However the .h file is included in my project. Could you help ?
Re: Problem with BLE implementation under ESP-IDF (ESP32-S3)
The function esp_ble_gap_config_adv_data_raw is under the flag BLE_42_FEATURE_SUPPORT . I suspect, may be, you don't have the flag enabled ?
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
Re: Problem with BLE implementation under ESP-IDF (ESP32-S3)
Yes Indeed, the flag was not enabled in sdkconfig.
I just checked the flag and compiled the application again.
Now I do not have the error anymore !! Thank you !
How do you know that this function was under BLE_42_FEATURE_SUPPORT features ?
Best regards
I just checked the flag and compiled the application again.
Now I do not have the error anymore !! Thank you !
How do you know that this function was under BLE_42_FEATURE_SUPPORT features ?
Best regards
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
Re: Problem with BLE implementation under ESP-IDF (ESP32-S3)
Thank you for your help, now I manage to advertise using the ESP32S3-DevKit-C-1 EVM.
However, I still have a problem.
I would like my advertiser to be restarted every 5s.
I have a class TaskBluetooth representing my Bluetooth Task.
In the code of the Bluetooth task, I have written these few lines :
while (1)
{
/* On récupère le nombre de ticks courants : */
CurrentTickCount = xTaskGetTickCount();
printf("%lu\n", CurrentTickCount);
printf("%lu\n", TimerRestartAdv);
/* On redémarre l'advertising toutes les 5 secondes : */
if ((CurrentTickCount - TimerRestartAdv) >= 5000)
{
/* On note la nouvelle heure de redémarrage : */
TimerRestartAdv = CurrentTickCount;
/* On redémarre l'advertising : */
esp_ble_gap_start_advertising(&ble_adv_params);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
If TickType_t CurrentTickCount is declared just before the while (1), in the same function, everything is ok and the advertiser is restarted every 5s.
However, If I put the Ticktype_t CurrentTickCount in the protected part of my TaskBluetooth.hpp, the code does not want to run anymore. I get this kind of error :
------------------------------------------------------
TaskBluetooth : Ble ScanRsp Data Raw Set Completed.
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x42009a65 PS : 0x00060e30 A0 : 0x82009aa0 A1 : 0x3fcec520
0x42009a65: TaskBluetooth::fcnt_BluetoothMainLoop() at C:/Users/ttruilhe/eclipse-workspace/ProtoFS22/main/Tasks/TaskBluetooth.cpp:255
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3fce9f04 A5 : 0x00000001
A6 : 0x00060023 A7 : 0x00000000 A8 : 0x82009a65 A9 : 0x3fcec500
A10 : 0x000000ad A11 : 0xffffffff A12 : 0x3fcec53e A13 : 0x00000015
A14 : 0x00140005 A15 : 0x02010000 SAR : 0x00000010 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000008 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0xffffffff
Backtrace: 0x42009a62:0x3fcec520 0x42009a9d:0x3fcec5c0 0x40381a05:0x3fcec5e0
0x42009a62: TaskBluetooth::fcnt_BluetoothMainLoop() at C:/Users/ttruilhe/eclipse-workspace/ProtoFS22/main/Tasks/TaskBluetooth.cpp:255
0x42009a9d: TaskBluetooth::fcnt_TaskWrapper(void*) at C:/Users/ttruilhe/eclipse-workspace/ProtoFS22/main/Tasks/TaskBluetooth.cpp:99
0x40381a05: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.0/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:151
ELF file SHA256: fcc5591769cf5fb6
Rebooting...
Could you please have any idea about that ? best regards,
However, I still have a problem.
I would like my advertiser to be restarted every 5s.
I have a class TaskBluetooth representing my Bluetooth Task.
In the code of the Bluetooth task, I have written these few lines :
while (1)
{
/* On récupère le nombre de ticks courants : */
CurrentTickCount = xTaskGetTickCount();
printf("%lu\n", CurrentTickCount);
printf("%lu\n", TimerRestartAdv);
/* On redémarre l'advertising toutes les 5 secondes : */
if ((CurrentTickCount - TimerRestartAdv) >= 5000)
{
/* On note la nouvelle heure de redémarrage : */
TimerRestartAdv = CurrentTickCount;
/* On redémarre l'advertising : */
esp_ble_gap_start_advertising(&ble_adv_params);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
If TickType_t CurrentTickCount is declared just before the while (1), in the same function, everything is ok and the advertiser is restarted every 5s.
However, If I put the Ticktype_t CurrentTickCount in the protected part of my TaskBluetooth.hpp, the code does not want to run anymore. I get this kind of error :
------------------------------------------------------
TaskBluetooth : Ble ScanRsp Data Raw Set Completed.
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x42009a65 PS : 0x00060e30 A0 : 0x82009aa0 A1 : 0x3fcec520
0x42009a65: TaskBluetooth::fcnt_BluetoothMainLoop() at C:/Users/ttruilhe/eclipse-workspace/ProtoFS22/main/Tasks/TaskBluetooth.cpp:255
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3fce9f04 A5 : 0x00000001
A6 : 0x00060023 A7 : 0x00000000 A8 : 0x82009a65 A9 : 0x3fcec500
A10 : 0x000000ad A11 : 0xffffffff A12 : 0x3fcec53e A13 : 0x00000015
A14 : 0x00140005 A15 : 0x02010000 SAR : 0x00000010 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000008 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0xffffffff
Backtrace: 0x42009a62:0x3fcec520 0x42009a9d:0x3fcec5c0 0x40381a05:0x3fcec5e0
0x42009a62: TaskBluetooth::fcnt_BluetoothMainLoop() at C:/Users/ttruilhe/eclipse-workspace/ProtoFS22/main/Tasks/TaskBluetooth.cpp:255
0x42009a9d: TaskBluetooth::fcnt_TaskWrapper(void*) at C:/Users/ttruilhe/eclipse-workspace/ProtoFS22/main/Tasks/TaskBluetooth.cpp:99
0x40381a05: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.0/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:151
ELF file SHA256: fcc5591769cf5fb6
Rebooting...
Could you please have any idea about that ? best regards,
Who is online
Users browsing this forum: ok-home and 99 guests