From 129a2650c22915bc789b6bdbc9d360bd97059e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gassmann?= Date: Sat, 28 Sep 2024 18:05:02 +0200 Subject: [+] WiFi with dpp on first setup + SNTP --- main/main.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'main/main.c') diff --git a/main/main.c b/main/main.c index 15d0f2e..f30cfdd 100644 --- a/main/main.c +++ b/main/main.c @@ -1,13 +1,45 @@ +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/event_groups.h" #include "screen.h" +#include "dpp_wifi.h" +#include "time_sntp.h" struct Screen screen; +char t[4]; + +void refresh_screen(void) +{ + obtain_time(t); + display(&screen, t); +} + +void setup_nvs() +{ + 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); +} void app_main(void) { printf("Starting up...\n"); configure_screen(&screen); printf("Screen Configured!\n"); - display(&screen, "1234"); - sleep(10); - test_screen(&screen); + setup_nvs(); + printf("NVS Flash Configured!\n"); + launch_dpp(); + printf("WiFi Configured!\n"); + set_tz("CET-1CEST,M3.5.0/2,M10.5.0/2"); + sync_time(); + printf("SNTP Configured!\n"); + + while(1){ + refresh_screen(); + sleep(2); + } } \ No newline at end of file -- cgit v1.2.3