Added homeSpan.setTimeServerTimeout(uint32_t tSec);
Sets timeout when connecting to Time Server (default is 10 seconds if not specified)
This commit is contained in:
parent
2787966c48
commit
e3b9ed99cb
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in New Issue