diff --git a/main/main.c b/main/main.c index 41d37dd..72ed0e8 100644 --- a/main/main.c +++ b/main/main.c @@ -37,7 +37,9 @@ #include +#if CONFIG_IDF_TARGET_ESP32P4 #include "am2302_rmt.h" +#endif // GPIO assignment #define AM2302_GPIO 4 @@ -483,6 +485,7 @@ ota_end: } */} +#if CONFIG_IDF_TARGET_ESP32P4 am2302_handle_t sensor = NULL; void readTempHumid(void *pvParameter) @@ -499,7 +502,26 @@ void readTempHumid(void *pvParameter) vTaskDelay(60000 / portTICK_PERIOD_MS); } } +#include "esp_littlefs.h" +void littlefs_mount(void) +{ + esp_vfs_littlefs_conf_t conf = { + .base_path = "/littlefs", + .partition_label = "littlefs", // ← DOIT matcher partitions.csv + .format_if_mount_failed = false + }; + + esp_err_t ret = esp_vfs_littlefs_register(&conf); + + if (ret != ESP_OK) { + printf("LittleFS mount failed: %s\n", esp_err_to_name(ret)); + } else { + printf("LittleFS mounted at /littlefs\n"); + } +} + +#endif void alloc_fail(size_t size, uint32_t caps, const char * function_name){ ESP_LOGE(TAG,"fail alloc %u in %" PRIu32 " in %s", size,caps,function_name); @@ -849,24 +871,6 @@ void lightSensorTask(void *pvParameter){ } */ } -#include "esp_littlefs.h" - -void littlefs_mount(void) -{ - esp_vfs_littlefs_conf_t conf = { - .base_path = "/littlefs", - .partition_label = "littlefs", // ← DOIT matcher partitions.csv - .format_if_mount_failed = false - }; - - esp_err_t ret = esp_vfs_littlefs_register(&conf); - - if (ret != ESP_OK) { - printf("LittleFS mount failed: %s\n", esp_err_to_name(ret)); - } else { - printf("LittleFS mounted at /littlefs\n"); - } -} void app_main(void) { @@ -875,8 +879,6 @@ void app_main(void) ihm_gateway_init(); startEvtManager(); - littlefs_mount(); - boucleMeteo(); #if CONFIG_IDF_TARGET_LINUX // en mode linux on simule l'obtention de la connexion wifi @@ -885,6 +887,7 @@ void app_main(void) //drawIhm(getIHMQueueHandle()); #else + littlefs_mount(); xTaskCreate(&drawIhm,"ihm_task",10000,getIHMQueueHandle(),10,NULL); //et sinon on se connecte ESP_LOGI(TAG, "ESP_WIFI_MODE_STA"); @@ -892,6 +895,7 @@ void app_main(void) //start_wifi_logger(); #endif + boucleMeteo(); mqtt_app_start(mqtt_cb, domotic_event_group); TaskHandle_t xHandle = NULL; @@ -901,6 +905,9 @@ void app_main(void) { ESP_LOGE(TAG, "Impossiblke de creer la tache imageDownload_task %i", ret1); }*/ + + #if CONFIG_IDF_TARGET_ESP32P4 + // Configuration de la sonde Temp/Humid. am2302_config_t am2302_config = { .gpio_num = AM2302_GPIO, @@ -910,6 +917,7 @@ void app_main(void) }; ESP_ERROR_CHECK(am2302_new_sensor_rmt(&am2302_config, &rmt_config, &sensor)); xTaskCreate(&readTempHumid, "read_temp_task", 8192, NULL, 5, NULL); + #endif }