|
|
@@ -63,8 +63,8 @@ bool setup_time()
|
|
|
|
|
|
// Is time set? If not, tm_year will be (1970 - 1900).
|
|
|
if (!getTimeIsSet()) {
|
|
|
- ESP_LOGI(TAG, "Time is not set yet. Getting time over NTP.");
|
|
|
initialize_sntp();
|
|
|
+ LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Time is not set yet. Getting time over NTP server " + std::string(sntp_getservername(0)));
|
|
|
if (!obtain_time()) {
|
|
|
success = false;
|
|
|
}
|
|
|
@@ -103,9 +103,9 @@ static bool obtain_time(void)
|
|
|
bool success = true;
|
|
|
|
|
|
time(&now);
|
|
|
- localtime_r(&now, &timeinfo);
|
|
|
+ localtime_r(&now, &timeinfo);
|
|
|
|
|
|
- ESP_LOGI(TAG, "Waiting until we get a time from the NTP server...");
|
|
|
+ LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Waiting until we get a time from the NTP server " + std::string(sntp_getservername(0)));
|
|
|
while (true) {
|
|
|
retry++;
|
|
|
|
|
|
@@ -118,7 +118,7 @@ static bool obtain_time(void)
|
|
|
sntp_sync_status_t status = sntp_get_sync_status();
|
|
|
logNtpStatus(status);
|
|
|
if (status == SNTP_SYNC_STATUS_COMPLETED) {
|
|
|
- ESP_LOGI(TAG, "Time is synced with NTP Server");
|
|
|
+ LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Time is synced with NTP Server " + std::string(sntp_getservername(0)));
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
@@ -146,10 +146,10 @@ void logNtpStatus(sntp_sync_status_t status) {
|
|
|
|
|
|
void reset_servername(std::string _servername)
|
|
|
{
|
|
|
- ESP_LOGD(TAG, "Set SNTP-Server: %s", _servername.c_str());
|
|
|
sntp_stop();
|
|
|
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
|
|
sntp_setservername(0, _servername.c_str());
|
|
|
+ LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Set SNTP-Server to " + std::string(sntp_getservername(0)));
|
|
|
sntp_init();
|
|
|
obtain_time();
|
|
|
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|