From 1ba21da6cbc63c0c549fb92731e25bedc482eb51 Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Thu, 4 Sep 2025 22:25:39 +0200 Subject: Unify the directory, add new analysis methods, unify the code style Signed-off-by: Filip Wandzio --- src/main.c | 68 -------------------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 src/main.c (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 790959d..0000000 --- a/src/main.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "esp_event.h" -#include "esp_log.h" -#include "esp_system.h" -#include "esp_timer.h" -#include "nvs_flash.h" - -#include "mqtt.h" -#include "wifi.h" - -static const char *TAG = "app"; - -/** - * @brief Initialize NVS flash storage, handling full or incompatible pages. - * - * @return esp_err_t ESP_OK on success, error code otherwise. - */ -static esp_err_t nvs_flash_init_check(void) -{ - esp_err_t ret = nvs_flash_init(); - if (ret == ESP_ERR_NVS_NO_FREE_PAGES || - ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { - ESP_LOGW(TAG, - "NVS partition was full or incompatible, erasing..."); - ESP_ERROR_CHECK(nvs_flash_erase()); - ret = nvs_flash_init(); - } - if (ret != ESP_OK) - ESP_LOGE(TAG, "Failed to initialize NVS (%s)", - esp_err_to_name(ret)); - return ret; -} - -/** - * @brief Application entry point. - * - * Initializes NVS, network interface, event loop, - * WiFi station, and MQTT client with proper error handling and logging. - */ -void app_main(void) -{ - esp_err_t ret = nvs_flash_init_check(); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "NVS init failed, aborting app start"); - return; - } - - ret = esp_netif_init(); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to initialize network interface (%s)", - esp_err_to_name(ret)); - return; - } - - ret = esp_event_loop_create_default(); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to create event loop (%s)", - esp_err_to_name(ret)); - return; - } - - ESP_LOGI(TAG, "Initializing WiFi in station mode"); - wifi_init_sta(); - - ESP_LOGI(TAG, "Starting MQTT client"); - mqtt_app_start(); - - ESP_LOGI(TAG, "Application setup completed"); -} -- cgit v1.2.3