diff --git a/firmware/esp32/main/main.cpp b/firmware/esp32/main/main.cpp index b9bf9fc..a604e55 100644 --- a/firmware/esp32/main/main.cpp +++ b/firmware/esp32/main/main.cpp @@ -7,7 +7,7 @@ #include "esp_task_wdt.h" #include "wifi.hpp" -#define WATCHDOG_KEEPALIVE_TICKS pdMS_TO_TICKS(8000) +#define WATCHDOG_KEEPALIVE_MS 8000 extern EventGroupHandle_t connectivity_event_group; extern EventBits_t bits = xEventGroupGetBits(connectivity_event_group); @@ -27,8 +27,6 @@ static void watchdogTask(void *pvParameters) { ESP_ERROR_CHECK(esp_task_wdt_add(NULL)); - const TickType_t keepAlivePeriod = pdMS_TO_TICKS(WATCHDOG_KEEPALIVE_TICKS); - for(;;) { if (criticalErrorFlag) { ESP_LOGE(TAG, "Critical error flag raised. Rebooting."); @@ -38,7 +36,7 @@ static void watchdogTask(void *pvParameters) { ESP_ERROR_CHECK(esp_task_wdt_reset()); ESP_LOGV(TAG, "WDT reset"); - vTaskDelay(keepAlivePeriod); + vTaskDelay(pdMS_TO_TICKS(WATCHDOG_KEEPALIVE_MS)); } } diff --git a/firmware/esp32/main/mqtt.cpp b/firmware/esp32/main/mqtt.cpp index 88d9e80..bc9c905 100644 --- a/firmware/esp32/main/mqtt.cpp +++ b/firmware/esp32/main/mqtt.cpp @@ -7,8 +7,8 @@ #include "main.hpp" #include "i2c.hpp" -#define MQTT_TASK_TIMEOUT_TICKS pdMS_TO_TICKS(3000) -#define MQTT_TIMEOUT_TICKS pdMS_TO_TICKS(MQTT_TASK_TIMEOUT/2) +#define MQTT_TASK_TIMEOUT_MS 3000 +#define MQTT_TIMEOUT_MS MQTT_TASK_TIMEOUT_MS/2 static const char* TAG = "MQTT"; @@ -82,11 +82,11 @@ void mqttTask(void *pvParameters) { if(bits && MQTT_CONNECTED_BIT) { ESP_LOGV(TAG, "Connection estabilished"); - uint32_t task_notification = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(MQTT_TASK_TIMEOUT_TICKS)); + uint32_t task_notification = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(MQTT_TASK_TIMEOUT_MS)); if (task_notification) twi_do(global_rx_buffer); //FIXME: develop i2c libs! (this func should then call mqtt_publish() if needed) } else { ESP_LOGW(TAG, "Waiting for connection..."); - vTaskDelay(pdMS_TO_TICKS(MQTT_TIMEOUT_TICKS)); + vTaskDelay(pdMS_TO_TICKS(MQTT_TIMEOUT_MS)); } ESP_ERROR_CHECK(esp_task_wdt_reset()); diff --git a/firmware/esp32/main/wifi.cpp b/firmware/esp32/main/wifi.cpp index 8da5d36..ccfc3cc 100644 --- a/firmware/esp32/main/wifi.cpp +++ b/firmware/esp32/main/wifi.cpp @@ -8,7 +8,7 @@ #include "main.hpp" #include "wifi-credentials.h" -#define WIFI_TIMEOUT_TICKS pdMS_TO_TICKS(4500) +#define WIFI_TIMEOUT_MS 4500 static const char* TAG = "WIFI"; @@ -83,6 +83,6 @@ void wifiTask(void *pvParameters) { for(;;) { ESP_ERROR_CHECK(esp_task_wdt_reset()); ESP_LOGV(TAG, "Task reset"); - vTaskDelay(pdMS_TO_TICKS(WIFI_TIMEOUT_TICKS)); + vTaskDelay(pdMS_TO_TICKS(WIFI_TIMEOUT_MS)); } }