diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 3cd8658..cab148b 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -1945,16 +1945,16 @@ void SpanWebLog::initTime(){ if(!timeServer) return; - Serial.printf("Acquiring Time from %s (%s)... ",timeServer,timeZone); + Serial.printf("Acquiring Time from %s (%s). Waiting %d second(s) for response... ",timeServer,timeZone,waitTime/1000); configTzTime(timeZone,timeServer); struct tm timeinfo; - if(getLocalTime(&timeinfo,10000)){ + if(getLocalTime(&timeinfo,waitTime)){ strftime(bootTime,sizeof(bootTime),"%c",&timeinfo); Serial.printf("%s\n\n",bootTime); homeSpan.reserveSocketConnections(1); timeInit=true; } else { - Serial.printf("Can't access Time Server (or Time Zone improperly specified) - time-keeping not initialized!\n\n"); + Serial.printf("Can't access Time Server - time-keeping not initialized!\n\n"); } } diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 610b125..7916fa2 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -104,6 +104,7 @@ struct SpanWebLog{ // optional web status/log data boolean timeInit=false; // flag to indicate time has been initialized char bootTime[33]="Unknown"; // boot time String statusURL; // URL of status log + uint32_t waitTime=10000; // number of milliseconds to wait for initial connection to time server struct log_t { // log entry type uint64_t upTime; // number of seconds since booting @@ -228,6 +229,8 @@ struct Span{ void enableWebLog(uint16_t maxEntries=0, const char *serv=NULL, const char *tz="UTC", const char *url=DEFAULT_WEBLOG_URL){ // enable Web Logging webLog.init(maxEntries, serv, tz, url); } + + void setTimeServerTimeout(uint32_t tSec){webLog.waitTime=tSec*1000;} // sets wait time (in seconds) for optional web log time server to connect [[deprecated("Please use reserveSocketConnections(n) method instead.")]] void setMaxConnections(uint8_t n){requestedMaxCon=n;} // sets maximum number of simultaneous HAP connections diff --git a/src/Settings.h b/src/Settings.h index 0057897..9c1f345 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -100,6 +100,7 @@ #define LOG1(x) if(homeSpan.logLevel>0)Serial.print(x) #define LOG2(x) if(homeSpan.logLevel>1)Serial.print(x) + #define WEBLOG(format,...) homeSpan.webLog.addLog(format __VA_OPT__(,) __VA_ARGS__) //////////////////////////////////////////////////////