diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index fb235e02..d075fb11 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -361,6 +361,14 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph) setTimeZone(zerlegt[1]); } + if ((toUpper(zerlegt[0]) == "TIMESERVER") && (zerlegt.size() > 1)) + { + string zw = "Set TimeZone: " + zerlegt[1]; + reset_servername(zerlegt[1]); + } + + + if ((toUpper(zerlegt[0]) == "SETUPMODE") && (zerlegt.size() > 1)) { if (toUpper(zerlegt[1]) == "TRUE") diff --git a/code/components/jomjol_time_sntp/time_sntp.cpp b/code/components/jomjol_time_sntp/time_sntp.cpp index da746ebd..bebde2cd 100644 --- a/code/components/jomjol_time_sntp/time_sntp.cpp +++ b/code/components/jomjol_time_sntp/time_sntp.cpp @@ -1,11 +1,5 @@ #include "time_sntp.h" -/* LwIP SNTP example - This example code is in the Public Domain (or CC0 licensed, at your option.) - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ #include #include #include @@ -17,25 +11,19 @@ #include "esp_log.h" #include "esp_attr.h" #include "esp_sleep.h" -// #include "nvs_flash.h" -// #include "protocol_examples_common.h" #include "esp_sntp.h" #include "ClassLogFile.h" static const char *TAG = "sntp"; -RTC_DATA_ATTR int boot_count = 0; - bool setTimeAlwaysOnReboot = true; static void obtain_time(void); static void initialize_sntp(void); - void time_sync_notification_cb(struct timeval *tv) { -// LogFile.WriteToFile("Notification of a time synchronization event"); ESP_LOGI(TAG, "Notification of a time synchronization event"); } @@ -54,9 +42,6 @@ std::string gettimestring(const char * frm) void setup_time() { - ++boot_count; - ESP_LOGI(TAG, "Boot count: %d", boot_count); - time_t now; struct tm timeinfo; time(&now); @@ -72,8 +57,6 @@ void setup_time() char strftime_buf[64]; setTimeZone("CET-1CEST,M3.5.0,M10.5.0/3"); -// setTimeZone("Europe/Berlin"); -// setTimeZone("Asia/Tokyo"); localtime_r(&now, &timeinfo); strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo); @@ -97,9 +80,6 @@ void setTimeZone(std::string _tzstring) static void obtain_time(void) { -// initialize_sntp(); - - // wait for time to be set time_t now = 0; struct tm timeinfo = {}; int retry = 0; @@ -110,23 +90,28 @@ static void obtain_time(void) ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count); vTaskDelay(2000 / portTICK_PERIOD_MS); } - if (retry == retry_count) { -// LogFile.WriteToFile("Time Synchzronisation nicht erfolgreich ..."); - } - else - { -// LogFile.WriteToFile("Time erfolgreich ..."); - } time(&now); localtime_r(&now, &timeinfo); } +void reset_servername(std::string _servername) +{ + printf("Set SNTP-Server: %s\n", _servername.c_str()); + sntp_stop(); + sntp_setoperatingmode(SNTP_OPMODE_POLL); + sntp_setservername(0, _servername.c_str()); + sntp_init(); + obtain_time(); + std::string zw = gettimestring("%Y%m%d-%H%M%S"); + printf("Time ist %s\n", zw.c_str()); +} + static void initialize_sntp(void) { ESP_LOGI(TAG, "Initializing SNTP"); sntp_setoperatingmode(SNTP_OPMODE_POLL); - sntp_setservername(0, "pool.ntp.org"); + sntp_setservername(0, "xx_pool.ntp.org"); // sntp_set_time_sync_notification_cb(time_sync_notification_cb); sntp_init(); } \ No newline at end of file diff --git a/code/components/jomjol_time_sntp/time_sntp.h b/code/components/jomjol_time_sntp/time_sntp.h index 3238e68a..930bfa35 100644 --- a/code/components/jomjol_time_sntp/time_sntp.h +++ b/code/components/jomjol_time_sntp/time_sntp.h @@ -15,4 +15,5 @@ void setup_time(void); std::string gettimestring(const char * frm); -void setTimeZone(std::string _tzstring); \ No newline at end of file +void setTimeZone(std::string _tzstring); +void reset_servername(std::string _servername); \ No newline at end of file diff --git a/code/main/version.cpp b/code/main/version.cpp index 77a9f738..1eb559c6 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="9971c82"; +const char* GIT_REV="7e4f83c"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling-reduce-sd-use"; -const char* BUILD_TIME="2020-12-23 10:06"; \ No newline at end of file +const char* BUILD_TIME="2020-12-24 15:56"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index 77a9f738..1eb559c6 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="9971c82"; +const char* GIT_REV="7e4f83c"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling-reduce-sd-use"; -const char* BUILD_TIME="2020-12-23 10:06"; \ No newline at end of file +const char* BUILD_TIME="2020-12-24 15:56"; \ No newline at end of file