Good morning,
I am working with an ESP32-S3-DevKitC-1 EVM in C++.
I have defined a TaskBluetooth.hpp (And .cpp) class representing my Bluetooth task.
In the code of the task, I try to restart the advertiser every 5 secondes using the following loop :
/* Boucle Infinie de la tâche : */
while (1)
{
/* On récupère le nombre de ticks courants : */
CurrentTickCount = xTaskGetTickCount();
/* On redémarre l'advertising toutes les 5 secondes : */
if ((CurrentTickCount - TimerRestartAdv) >= TIMER_RESTART_ADV)
{
/* 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 defined just before the while (1), the code works correctly.
However, If I put this variables in the protected part of TaskBluetooth.hpp, I get the following error :
TaskBluetooth : Ble Adv Data Raw Set Completed.
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...
Do you have any idea ?
Best regards,
Thomas TRUILHE
Problem with a variable defined in the protected part of a class
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
-
- Posts: 9749
- Joined: Thu Nov 26, 2015 4:08 am
Re: Problem with a variable defined in the protected part of a class
What line does TaskBluetooth.cpp:255 point to?
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
Re: Problem with a variable defined in the protected part of a class
I have done the same test whith these lines of code :
/* Boucle Infinie de la tâche : */
while (1)
{
/* On récupère l'heure courante : */
CurrentTime = xTaskGetTickCount();
/* On regarde s'il est l'heure de redémarrer l'advertising : */
if ((CurrentTime - TimerRestartAdv) >= 5000)
{
TimerRestartAdv = CurrentTime;
/* On redémarre l'advertising : */
esp_ble_gap_start_advertising(&ble_adv_params);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
Here, everything is OK.
But if I add these lines :
if (AdvertisingSet && ScanRspSet)
esp_ble_gap_start_advertising(&ble_adv_params);
I get the same error. If seems that the problem comes from the use of the two variables AdvertisingSet and ScanRspSet.
These 2 variables are defined in my class TaskBluetooth and are public.
/* Boucle Infinie de la tâche : */
while (1)
{
/* On récupère l'heure courante : */
CurrentTime = xTaskGetTickCount();
/* On regarde s'il est l'heure de redémarrer l'advertising : */
if ((CurrentTime - TimerRestartAdv) >= 5000)
{
TimerRestartAdv = CurrentTime;
/* On redémarre l'advertising : */
esp_ble_gap_start_advertising(&ble_adv_params);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
Here, everything is OK.
But if I add these lines :
if (AdvertisingSet && ScanRspSet)
esp_ble_gap_start_advertising(&ble_adv_params);
I get the same error. If seems that the problem comes from the use of the two variables AdvertisingSet and ScanRspSet.
These 2 variables are defined in my class TaskBluetooth and are public.
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
Re: Problem with a variable defined in the protected part of a class
I have the same problem when I do something like that :
TickType_t CurrentTime = xTaskGetTickCount();
This is OK, but when I do :
TimerRestartAdv = xTaskGetTickCount();
this does not work because the TickType_t TimerRestartAdv is defined in my class TaskBluetooth...
TickType_t CurrentTime = xTaskGetTickCount();
This is OK, but when I do :
TimerRestartAdv = xTaskGetTickCount();
this does not work because the TickType_t TimerRestartAdv is defined in my class TaskBluetooth...
Who is online
Users browsing this forum: No registered users and 137 guests