feat: Implement HTTP server with static file serving from LittleFS, system APIs, and network connectivity management.
This commit is contained in:
@@ -5,10 +5,12 @@
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/gpio_num.h"
|
||||
|
||||
|
||||
// Project headers
|
||||
#include "appstate.hpp"
|
||||
#include "types.hpp"
|
||||
@@ -28,7 +30,33 @@ extern "C" void app_main()
|
||||
|
||||
httpd_handle_t web_server = NULL;
|
||||
|
||||
ESP_ERROR_CHECK(nvs_flash_init());
|
||||
esp_err_t err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND)
|
||||
{
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
err = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(err);
|
||||
|
||||
nvs_handle_t my_handle;
|
||||
if (nvs_open("storage", NVS_READWRITE, &my_handle) == ESP_OK)
|
||||
{
|
||||
err = nvs_get_u8(my_handle, "www_part", &g_Active_WWW_Partition);
|
||||
if (err != ESP_OK && err != ESP_ERR_NVS_NOT_FOUND)
|
||||
{
|
||||
printf("Error reading www_part from NVS: %s\n", esp_err_to_name(err));
|
||||
}
|
||||
if (g_Active_WWW_Partition > 1)
|
||||
{
|
||||
g_Active_WWW_Partition = 0;
|
||||
}
|
||||
nvs_close(my_handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error opening NVS handle!\n");
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
setup_led();
|
||||
|
||||
Reference in New Issue
Block a user