diff --git a/README.md b/README.md index ac635a66a..df1026b54 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Firebase Arduino Client Library for ESP8266 and ESP32 -Google's Firebase Arduino Client Library for ESP8266 and ESP32 v2.5.3 +Google's Firebase Arduino Client Library for ESP8266 and ESP32 v2.5.4 This library supports ESP8266 and ESP32 MCU from Espressif. The following are platforms in which the libraries are also available (RTDB only). diff --git a/library.json b/library.json index 908f6b6ce..77734d1ab 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Firebase Arduino Client Library for ESP8266 and ESP32", - "version": "2.5.3", + "version": "2.5.4", "keywords": "communication, REST, esp32, esp8266, arduino", "description": "The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging.", "repository": { diff --git a/library.properties b/library.properties index 2b4ff63dc..b263f8e00 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=Firebase Arduino Client Library for ESP8266 and ESP32 -version=2.5.3 +version=2.5.4 author=Mobizt diff --git a/src/Firebase_ESP_Client.h b/src/Firebase_ESP_Client.h index 31c9fdb76..7e0399d92 100644 --- a/src/Firebase_ESP_Client.h +++ b/src/Firebase_ESP_Client.h @@ -1,17 +1,16 @@ #ifndef FIREBASE_CLIENT_VERSION -#define FIREBASE_CLIENT_VERSION "2.5.3" +#define FIREBASE_CLIENT_VERSION "2.5.4" #endif /** - * Google's Firebase ESP Client Main class, Firebase_ESP_Client.h v2.5.3 + * Google's Firebase ESP Client Main class, Firebase_ESP_Client.h v2.5.4 * * This library supports Espressif ESP8266 and ESP32 MCUs * - * Created October 6, 2021 + * Created October 7, 2021 * * Updates: - * - Add support user re-authentication. - * - Add re-authenticate example. + * - Fix issue #148 ESP32 memory leak due to RTOS stack memory release issue. * * This work is a part of Firebase ESP Client library * Copyright (c) 2021 K. Suwatchai (Mobizt) diff --git a/src/README.md b/src/README.md index 38595937e..78b1ca073 100644 --- a/src/README.md +++ b/src/README.md @@ -1,7 +1,7 @@ # Firebase Arduino Client Library for ESP8266 and ESP32 -Google's Firebase Arduino Client Library for ESP8266 and ESP32 v2.5.3 +Google's Firebase Arduino Client Library for ESP8266 and ESP32 v2.5.4 The default filessystem used in the library is flash and SD. diff --git a/src/common.h b/src/common.h index db2d884bd..2952e9ce4 100644 --- a/src/common.h +++ b/src/common.h @@ -1,6 +1,6 @@ /** - * Created September 20, 2021 + * Created October 7, 2021 * * This work is a part of Firebase ESP Client library * Copyright (c) 2021 K. Suwatchai (Mobizt) @@ -731,7 +731,6 @@ struct fb_esp_cfg_int_t TaskHandle_t resumable_upload_task_handle = NULL; TaskHandle_t functions_check_task_handle = NULL; TaskHandle_t functions_deployment_task_handle = NULL; - TaskHandle_t token_processing_task_handle = NULL; #endif }; diff --git a/src/signer/Signer.cpp b/src/signer/Signer.cpp index 664f39e1b..ea41135e3 100644 --- a/src/signer/Signer.cpp +++ b/src/signer/Signer.cpp @@ -1,9 +1,9 @@ /** - * Google's Firebase Token Generation class, Signer.cpp version 1.2.2 + * Google's Firebase Token Generation class, Signer.cpp version 1.2.3 * * This library supports Espressif ESP8266 and ESP32 * - * Created September 20, 2021 + * Created October 7, 2021 * * This work is a part of Firebase ESP Client library * Copyright (c) 2020, 2021 K. Suwatchai (Mobizt) @@ -307,102 +307,94 @@ bool Firebase_Signer::handleToken() void Firebase_Signer::tokenProcessingTask() { + #if defined(ESP32) if (config->signer.tokenTaskRunning) return; - static Firebase_Signer *_this = this; + bool ret = false; - TaskFunction_t taskCode = [](void *param) - { - _this->config->signer.tokenTaskRunning = true; + config->signer.tokenTaskRunning = true; - while (_this->_token_processing_task_enable) + while (!ret) + { + delay(0); + + if (config->signer.tokens.token_type == token_type_id_token) { - vTaskDelay(20 / portTICK_PERIOD_MS); + config->signer.lastReqMillis = millis(); - if (_this->config->signer.tokens.token_type == token_type_id_token) + if (getIdToken(false, "", "")) { - _this->config->signer.lastReqMillis = millis(); - if (_this->getIdToken(false, "", "")) - { - _this->_token_processing_task_enable = false; - _this->config->signer.attempts = 0; - break; - } + _token_processing_task_enable = false; + config->signer.attempts = 0; + ret = true; + } + else + { + if (config->signer.attempts < config->max_token_generation_retry) + config->signer.attempts++; else { - if (_this->config->signer.attempts < _this->config->max_token_generation_retry) - _this->config->signer.attempts++; - else - { - _this->ut->clearS(_this->config->signer.tokens.error.message); - _this->setTokenError(FIREBASE_ERROR_TOKEN_EXCHANGE_MAX_RETRY_REACHED); - _this->sendTokenStatusCB(); - _this->_token_processing_task_enable = false; - _this->config->signer.attempts = 0; - break; - } + ut->clearS(config->signer.tokens.error.message); + setTokenError(FIREBASE_ERROR_TOKEN_EXCHANGE_MAX_RETRY_REACHED); + sendTokenStatusCB(); + _token_processing_task_enable = false; + config->signer.attempts = 0; + ret = true; } } - else + } + else + { + if (config->signer.step == fb_esp_jwt_generation_step_begin) { - if (_this->config->signer.step == fb_esp_jwt_generation_step_begin) - { - _this->ut->setClock(_this->config->time_zone); - time_t now = time(nullptr); - _this->config->_int.fb_clock_rdy = now > _this->ut->default_ts; + ut->setClock(config->time_zone); + time_t now = time(nullptr); + config->_int.fb_clock_rdy = now > ut->default_ts; - if (_this->config->_int.fb_clock_rdy) - _this->config->signer.step = fb_esp_jwt_generation_step_encode_header_payload; - } - else if (_this->config->signer.step == fb_esp_jwt_generation_step_encode_header_payload) - { - if (_this->createJWT()) - _this->config->signer.step = fb_esp_jwt_generation_step_sign; - } - else if (_this->config->signer.step == fb_esp_jwt_generation_step_sign) + if (config->_int.fb_clock_rdy) + config->signer.step = fb_esp_jwt_generation_step_encode_header_payload; + } + else if (config->signer.step == fb_esp_jwt_generation_step_encode_header_payload) + { + if (createJWT()) + config->signer.step = fb_esp_jwt_generation_step_sign; + } + else if (config->signer.step == fb_esp_jwt_generation_step_sign) + { + if (createJWT()) + config->signer.step = fb_esp_jwt_generation_step_exchange; + } + else if (config->signer.step == fb_esp_jwt_generation_step_exchange) + { + if (requestTokens()) { - if (_this->createJWT()) - _this->config->signer.step = fb_esp_jwt_generation_step_exchange; + config->signer.attempts = 0; + _token_processing_task_enable = false; + config->signer.step = fb_esp_jwt_generation_step_begin; + ret = true; } - else if (_this->config->signer.step == fb_esp_jwt_generation_step_exchange) + else { - if (_this->requestTokens()) - { - _this->config->signer.attempts = 0; - _this->_token_processing_task_enable = false; - _this->config->signer.step = fb_esp_jwt_generation_step_begin; - break; - } + if (config->signer.attempts < config->max_token_generation_retry) + config->signer.attempts++; else { - if (_this->config->signer.attempts < _this->config->max_token_generation_retry) - _this->config->signer.attempts++; - else - { - _this->ut->clearS(_this->config->signer.tokens.error.message); - _this->setTokenError(FIREBASE_ERROR_TOKEN_EXCHANGE_MAX_RETRY_REACHED); - _this->sendTokenStatusCB(); - _this->config->signer.attempts = 0; - _this->config->signer.step = fb_esp_jwt_generation_step_begin; - break; - } + ut->clearS(config->signer.tokens.error.message); + setTokenError(FIREBASE_ERROR_TOKEN_EXCHANGE_MAX_RETRY_REACHED); + sendTokenStatusCB(); + config->signer.attempts = 0; + config->signer.step = fb_esp_jwt_generation_step_begin; + ret = true; } } } - - yield(); } - _this->config->_int.token_processing_task_handle = NULL; - _this->config->signer.tokenTaskRunning = false; - vTaskDelete(NULL); - }; - - char *taskname = ut->strP(fb_esp_pgm_str_546); - xTaskCreatePinnedToCore(taskCode, taskname, 12000, NULL, 3, &config->_int.token_processing_task_handle, 1); - ut->delS(taskname); + } + + config->signer.tokenTaskRunning = false; #elif defined(ESP8266) diff --git a/src/signer/Signer.h b/src/signer/Signer.h index 0f9cca3b7..a2d433303 100644 --- a/src/signer/Signer.h +++ b/src/signer/Signer.h @@ -1,9 +1,9 @@ /** - * Google's Firebase Token Generation class, Signer.h version 1.2.2 + * Google's Firebase Token Generation class, Signer.h version 1.2.3 * * This library supports Espressif ESP8266 and ESP32 * - * Created September 20, 2021 + * Created October 7, 2021 * * This work is a part of Firebase ESP Client library * Copyright (c) 2020, 2021 K. Suwatchai (Mobizt)