problem with esp32 multitask #263
federico-idili
started this conversation in
General
Replies: 1 comment 4 replies
-
The stack size for the FreeRTOS task is too small for SSL and cryptographic. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
hi mobizt, thank you for this library and for your job,
I have a problem, I am using your library in a quite complex project. I did the tests with an esp32 16rom and an esp32 8rom 2ram.
Mainly if I use your library exclusively it works correct way without any problems,
while when I activate other tasks even on different cores, some times it fails to connect " Error, msg: TCP connection failed, code: -1" other reports Error task: task_1679, msg: JWT, private key signing failed, code: -111. I attach part of the code and log for better understanding
part of setup();
/////////////////BLE INIT//////////////////
#pragma region BLE INIT
BLE_Init(NVS_Matricola); //NimBLEDevice
#pragma endregion
////////////WATCHDOG///////////////
esp_task_wdt_init(TWDT_TIMEOUT_MS, true);
////////////////TASK////////////////
// Task core 1
xTaskCreatePinnedToCore(GestioneI2C, "GestioneI2C", 3096, NULL, 20, &Task_GestioneI2C, 1); // 5ms
xTaskCreatePinnedToCore(MS_Posizionamento, "MsPosizionamento", configMINIMAL_STACK_SIZE, NULL, 19, &Task_MS_Posizionamento, 1); // 5ms
xTaskCreatePinnedToCore(ReadADC, "ReadADC", 2048, NULL, 18, &Task_ReadADC, 1); // 2ms
xTaskCreatePinnedToCore(MS_ControlloVelocitaMotore, "MS_ControlloVelocitaMotore", 2048, NULL, 17, &Task_MS_ControlloVelocitaMotore, 1); // 5ms
xTaskCreatePinnedToCore(GestioneBatteria, "GestioneBatteria", configMINIMAL_STACK_SIZE, NULL, 16, &Task_GestioneBatteria, 1);
xTaskCreatePinnedToCore(GestionePannello, "GestionePannello", configMINIMAL_STACK_SIZE, NULL, 15, &Task_GestionePannello, 1);
xTaskCreatePinnedToCore(GestioneWifiFirebase, "WifiFirebase", 8192, NULL, 21, NULL, 0);
xTaskCreatePinnedToCore(RF_Decode, "RF_Decode", 3096, NULL, 20, &Task_RF_Decode, 0);
xTaskCreatePinnedToCore(BLE_ElaborazioniDatiRicevuti, "BLE_ElaborazioniDatiRicevuti", 8192, NULL, 19, NULL, 0);
xTaskCreatePinnedToCore(BLE_DeQueueTask, "BLE_DeQueueTask", 8192, NULL, 18, NULL, 0);
xTaskCreatePinnedToCore(GestioneTempo, "GestioneTempo", 2048, NULL, 15, NULL, 0);
xTaskCreatePinnedToCore(InvioLogDebug, "InvioLogDebug", 1536, NULL, 11, NULL, 0);
xTaskCreatePinnedToCore(Lampeggio, "lampeggio", configMINIMAL_STACK_SIZE, NULL, 11, NULL, 0);
xTaskCreatePinnedToCore(Riavvio, "Riavvio", 2048, NULL, 10, NULL, 0);
xTaskCreatePinnedToCore(ReadSerialDebug, "ReadSerialDebug", 2048, NULL, 10, NULL, 0);
vTaskDelay(200);
xTaskCreatePinnedToCore(MS_ModalitaOperativa, "MS_ModalitaOperativa", 4096, NULL, 15, NULL, 1);
WifiFirebase task:
void Firebase_AddSync()
{
Firebase_PathBase = "/remotecontrol/" + NVS_Matricola;
CreaAccodaLogDebug("FIREBASE", "Attivo i sincronismi sui nodi " + Firebase_PathBase + "/msg/com");
// In SSE mode (HTTP Streaming) task, you can filter the Stream events by using AsyncClientClass::setSSEFilters(),
// which the is the comma separated events.
// The event keywords supported are:
// get - To allow the http get response (first put event since stream connected).
// put - To allow the put event.
// patch - To allow the patch event.
// keep-alive - To allow the keep-alive event.
// cancel - To allow the cancel event.
// auth_revoked - To allow the auth_revoked event.
// To clear all prevousely set filter to allow all Stream events, use AsyncClientClass::setSSEFilters().
Firebase_streamClient.setSSEFilters("get,put,patch,keep-alive,cancel,auth_revoked");
// Firebase_streamClient.setSSEFilters("");
// Firebase_streamClient.setSSEFilters("put");
// The "unauthenticate" error can be occurred in this case because we don't wait
// the app to be authenticated before connecting the stream.
// This is ok as stream task will be reconnected automatically when the app is authenticated.
// The streamClient must be used for Stream only.
Firebase_RealtimeDatabase.get(Firebase_streamClient, Firebase_PathBase + "/msg/com", Firebase_ElaborazioneDati, true /* SSE mode (HTTP Streaming) */, "ElaborazioneDati");
}
void Firebase_CheckDB()
{
CreaAccodaLogDebug("FIREBASE", "Controllo se esiste in DB");
Firebase_Status = Firebase_RealtimeDatabase.exists(Firebase_aClient, Firebase_PathBase);
if (Firebase_aClient.lastError().code() == 0)
Serial.println(Firebase_Status ? "Existed" : "Not exist");
else
{
Firebase_Status = false;
Firebase.printf("Error, msg: %s, code: %d\n", Firebase_aClient.lastError().message().c_str(), Firebase_aClient.lastError().code());
}
if (Firebase_Status)
{
CreaAccodaLogDebug("FIREBASE", "DB esiste");
Firebase_FlagCreateDB = false;
}
else
{
CreaAccodaLogDebug("FIREBASE", "DB non esiste");
Firebase_FlagCreateDB = true;
}
}
bool Firebase_CreaDB()
{
object_t json, com, feedback, msg, status, sync;
object_t dataTime0, payloadEmpty, statoEmpty, owner0, temp;
JsonWriter writer;
// com -> { "dataTime": 0, "payload": "" }
writer.create(dataTime0, "dataTime", number_t(0));
writer.create(payloadEmpty, "payload", string_t(""));
writer.join(com, 2, dataTime0, payloadEmpty);
// feedback -> { "dataTime": 0, "payload": "" }
writer.join(feedback, 2, dataTime0, payloadEmpty);
// msg -> { "com": {...}, "feedback": {...} }
writer.create(dataTime0, "com", com);
writer.create(payloadEmpty, "feedback", feedback);
writer.join(temp, 2, dataTime0, payloadEmpty);
writer.create(msg, "/msg/", temp);
// status -> { "stato": "" }
writer.create(status, "/status/stato", string_t(""));
// sync -> { "dataTime": 0, "owner": 0, "stato": "" }
writer.create(dataTime0, "dataTime", number_t(0));
writer.create(owner0, "owner", number_t(0));
writer.create(statoEmpty, "stato", string_t(""));
writer.join(temp, 3, dataTime0, owner0, statoEmpty);
writer.create(sync, "/sync", temp);
writer.join(json, 3, msg, status, sync);
// Stampa per debug
Serial.println(json);
// Invia al database Firebase
Serial.println("Setting the JSON value... ");
return Firebase_RealtimeDatabase.set<object_t>(Firebase_aClient, Firebase_PathBase, json);
}
void GestioneWifiFirebase(void *arg)
{
vTaskDelay(5000);
while (1)
{
if (NVS_WifiSID != "" && Bootloader_Attivo == false)
{
switch (Wifi_MS)
{
case WifiInit:
}
}
LOG:
01/01/70 00:00:00 [BLE]: Start init Duc 53230001
01/01/70 00:00:00 [BLE]: End init
01/01/70 00:00:05 [WIFI]: Connessione a Biamino
01/01/70 00:00:07 [WIFI]: Connesso
01/01/70 00:00:07 [NTP]: Init
01/01/70 01:00:07 [NTP]: Attesa sincronizzazione
06/10/25 14:25:54 [NTP]: Sincronizzato
06/10/25 14:25:54 [FIREBASE]: Init
06/10/25 14:25:54 [FIREBASE]: Versione: 2.1.5
Event task: authTask, msg: initializing, code: 1
Event task: authTask, msg: token signing, code: 6
06/10/25 14:25:54 [FIREBASE]: Attivo i sincronismi sui nodi /remotecontrol/53230001/msg/com
Error task: task_1679, msg: JWT, private key signing failed, code: -111
Error task: task_1330, msg: JWT process timed out, code: -121
01/01/70 00:00:00 [BLE]: Start init Duc 53230001
01/01/70 00:00:00 [BLE]: End init
01/01/70 00:00:05 [WIFI]: Connessione a Biamino
01/01/70 00:00:06 [WIFI]: Connesso
01/01/70 00:00:06 [NTP]: Init
01/01/70 01:00:06 [NTP]: Attesa sincronizzazione
06/10/25 15:05:16 [NTP]: Sincronizzato
06/10/25 15:05:16 [FIREBASE]: Init
06/10/25 15:05:16 [FIREBASE]: Versione: 2.1.5
Event task: authTask, msg: initializing, code: 1
Event task: authTask, msg: token signing, code: 6
06/10/25 15:05:17 [FIREBASE]: Attivo i sincronismi sui nodi /remotecontrol/53230001/msg/com
Event task: authTask, msg: authenticating, code: 7
Debug task: authTask, msg: Connecting to server...
Event task: authTask, msg: auth request sent, code: 8
Event task: authTask, msg: connection timed out, code: -1
Event task: authTask, msg: initializing, code: 1
Event task: authTask, msg: token signing, code: 6
Event task: authTask, msg: authenticating, code: 7
Debug task: authTask, msg: Connecting to server...
Event task: authTask, msg: auth request sent, code: 8
Event task: authTask, msg: connection timed out, code: -1
...
I've tried putting a delay on task startup to change priority and core,
but mainly the problem remains and I can't figure out what it might be due to.
Could it depend on ble?
Thank you bye
Beta Was this translation helpful? Give feedback.
All reactions