diff --git a/Kconfig b/Kconfig index 5d6fa1c..ba932ab 100644 --- a/Kconfig +++ b/Kconfig @@ -84,11 +84,23 @@ menu "WebGUIApp" bool "Enabled SNTP time update" default y - config WEBGUIAPP_SNTP_HOST - string "URL of SNTP server" + config WEBGUIAPP_SNTP_HOST_1 + string "URL of SNTP server 1" + default "1.pool.ntp.org" + help + URL of SNTP server + + config WEBGUIAPP_SNTP_HOST_2 + string "URL of SNTP server 2" default "2.pool.ntp.org" help - URL of firmware file for OTA update + URL of SNTP server + + config WEBGUIAPP_SNTP_HOST_3 + string "URL of SNTP server 3" + default "3.pool.ntp.org" + help + URL of SNTP server config WEBGUIAPP_SNTP_AUTOUPDATE_PERIOD int "SNTP autoupdate period in seconds" diff --git a/include/WebGUIAppMain.h b/include/WebGUIAppMain.h index 1de696e..32d20d6 100644 --- a/include/WebGUIAppMain.h +++ b/include/WebGUIAppMain.h @@ -66,6 +66,8 @@ { int TimeZone; char SntpServerAdr[33]; + char SntpServer2Adr[33]; + char SntpServer3Adr[33]; struct { char b1 :1; diff --git a/src/HTTPPostSystem.c b/src/HTTPPostSystem.c index a129521..bc53847 100644 --- a/src/HTTPPostSystem.c +++ b/src/HTTPPostSystem.c @@ -397,6 +397,10 @@ static HTTP_IO_RESULT HTTPPostServicesSettings(httpd_req_t *req, char *PostData) } httpd_query_key_value(PostData, "tsr", GetSysConf()->sntpClient.SntpServerAdr, sizeof(GetSysConf()->sntpClient.SntpServerAdr)); + httpd_query_key_value(PostData, "tsr2", GetSysConf()->sntpClient.SntpServer2Adr, + sizeof(GetSysConf()->sntpClient.SntpServer2Adr)); + httpd_query_key_value(PostData, "tsr3", GetSysConf()->sntpClient.SntpServer3Adr, + sizeof(GetSysConf()->sntpClient.SntpServer3Adr)); /*MQTT Test button handlers*/ if (httpd_query_key_value(PostData, "mqtttest1", tmp, 6) == ESP_OK) diff --git a/src/HTTPPrintSystem.c b/src/HTTPPrintSystem.c index 76973fb..3e0bd4a 100644 --- a/src/HTTPPrintSystem.c +++ b/src/HTTPPrintSystem.c @@ -617,6 +617,14 @@ void HTTPPrint_tmsrv(char *VarData, void *arg) { snprintf(VarData, MAX_DYNVAR_LENGTH, "%s", GetSysConf()->sntpClient.SntpServerAdr); } +void HTTPPrint_tmsrv2(char *VarData, void *arg) +{ + snprintf(VarData, MAX_DYNVAR_LENGTH, "%s", GetSysConf()->sntpClient.SntpServer2Adr); +} +void HTTPPrint_tmsrv3(char *VarData, void *arg) +{ + snprintf(VarData, MAX_DYNVAR_LENGTH, "%s", GetSysConf()->sntpClient.SntpServer3Adr); +} static void HTTPPrint_freeram(char *VarData, void *arg) { @@ -821,6 +829,8 @@ dyn_var_handler_t HANDLERS_ARRAY[] = { /*SNTP*/ { "sntpen", sizeof("sntpen") - 1, &HTTPPrint_sntpen }, { "tmsrv", sizeof("tmsrv") - 1, &HTTPPrint_tmsrv }, + { "tmsrv2", sizeof("tmsrv2") - 1, &HTTPPrint_tmsrv2 }, + { "tmsrv3", sizeof("tmsrv3") - 1, &HTTPPrint_tmsrv3 }, { "freeram", sizeof("freeram") - 1, &HTTPPrint_freeram }, { "minram", sizeof("minram") - 1, &HTTPPrint_minram }, diff --git a/src/SNTP.c b/src/SNTP.c index f619ee0..c0b7a43 100644 --- a/src/SNTP.c +++ b/src/SNTP.c @@ -68,7 +68,9 @@ static void time_sync_notification_cb(struct timeval *tv) static void initialize_sntp(void) { sntp_setoperatingmode(SNTP_OPMODE_POLL); - sntp_setservername(0, "pool.ntp.org"); + sntp_setservername(0, GetSysConf()->sntpClient.SntpServerAdr); + sntp_setservername(1, GetSysConf()->sntpClient.SntpServerAdr); + sntp_setservername(2, GetSysConf()->sntpClient.SntpServerAdr); sntp_set_sync_interval(6*3600*1000); sntp_set_time_sync_notification_cb(time_sync_notification_cb); sntp_init(); diff --git a/src/WebGUIAppMain.c b/src/WebGUIAppMain.c index 5d3bd87..20f997e 100644 --- a/src/WebGUIAppMain.c +++ b/src/WebGUIAppMain.c @@ -353,8 +353,12 @@ esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*) &C memcpy(Conf->mqttStation[1].UserPass, CONFIG_WEBGUIAPP_MQTT_PASSWORD, sizeof(CONFIG_WEBGUIAPP_MQTT_PASSWORD)); #endif #endif - memcpy(Conf->sntpClient.SntpServerAdr, CONFIG_WEBGUIAPP_SNTP_HOST, - sizeof(CONFIG_WEBGUIAPP_SNTP_HOST)); + memcpy(Conf->sntpClient.SntpServerAdr, CONFIG_WEBGUIAPP_SNTP_HOST_1, + sizeof(CONFIG_WEBGUIAPP_SNTP_HOST_1)); + memcpy(Conf->sntpClient.SntpServer2Adr, CONFIG_WEBGUIAPP_SNTP_HOST_2, + sizeof(CONFIG_WEBGUIAPP_SNTP_HOST_2)); + memcpy(Conf->sntpClient.SntpServer3Adr, CONFIG_WEBGUIAPP_SNTP_HOST_3, + sizeof(CONFIG_WEBGUIAPP_SNTP_HOST_3)); Conf->sntpClient.Flags1.bIsGlobalEnabled = CONFIG_WEBGUIAPP_SNTP_AUTOUPDATE_ENABLE; Conf->sntpClient.TimeZone = CONFIG_WEBGUIAPP_SNTP_TIMEZONE;