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/Kconfig.projbuild | 31 +++++++++++++++++++++++++++++++ main/main.c | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 3 deletions(-) (limited to 'main') diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 18b0727..4ff3093 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -145,4 +145,35 @@ menu "Configuration of the Nixie Screen" help Pin number for N3_P3. + config ESP_DPP_LISTEN_CHANNEL_LIST + string "DPP Listen channel list" + default "6" + help + DPP Bootstrapping listen channels separated by commas. + + config ESP_DPP_BOOTSTRAPPING_KEY + string "Bootstrapping key" + help + 64 hex digits (or 32 bytes) of raw private key for DPP Bootstrapping. + + config ESP_DPP_DEVICE_INFO + string "Additional Device Info" + help + Additional ancillary information to be included in QR Code. + + config SNTP_TIME_SERVER + string "SNTP server name" + default "pool.ntp.org" + help + Hostname of the main SNTP server. + + choice SNTP_TIME_SYNC_METHOD + prompt "Time synchronization method" + default SNTP_TIME_SYNC_METHOD_IMMED + help + Time synchronization method. + + config SNTP_TIME_SYNC_METHOD_IMMED + bool "update time immediately when received" + endchoice endmenu \ No newline at end of file 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