From 6354e937fba94a2baafdb437c34c05d8910dddf1 Mon Sep 17 00:00:00 2001 From: Arthur Roberts Date: Wed, 25 Oct 2023 20:02:24 +0100 Subject: [PATCH] Task management still not working The DHT task (or whatever is called later) isn't actually re-entering (I think that's the right term?) --- main/main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/main/main.c b/main/main.c index bc6b98a..2babc1d 100644 --- a/main/main.c +++ b/main/main.c @@ -7,13 +7,14 @@ #include #include #include "freertos/FreeRTOS.h" -//#include "freertos/projdefs.h" +#include "freertos/projdefs.h" #include "freertos/projdefs.h" #include "freertos/task.h" #include "dht22.h" #include "esp_log.h" #include "esp_wifi.h" #include "portmacro.h" +#include "nvs_flash.h" static const char *TAG = "YASPAM"; @@ -49,6 +50,7 @@ void save_measurements() { pdFALSE, pdFALSE, portMAX_DELAY); + if (bits & SENSOR_DHT22_BIT) { deci_percent rh = dht22_relative_humidity(); deci_degrees_c temp = dht22_temperature(); @@ -57,6 +59,7 @@ void save_measurements() { ESP_LOGI(TAG, "Saved DHT data"); xEventGroupClearBitsFromISR(s_monitor_event_group, SENSOR_DHT22_BIT); } + if (bits & SENSOR_PMS5003_BIT) { ESP_LOGI(TAG, "Saved PMS data"); // TODO @@ -93,12 +96,20 @@ void read_from_dht22() { if (xResult) { portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); } - vTaskDelay(pdMS_TO_TICKS(3000)); // TODO: make this a config check + ESP_LOGI(TAG, "Hello"); + vTaskDelay(pdMS_TO_TICKS(500)); // TODO: make this a config check } } void app_main(void) { + esp_err_t 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); + s_monitor_event_group = xEventGroupCreate(); xTaskCreate(read_from_dht22,