From 20ce79ef34bcf7672d16d49dc9f9697c4b70e865 Mon Sep 17 00:00:00 2001 From: Gregg Date: Wed, 2 Mar 2022 21:41:06 -0600 Subject: [PATCH] Added check to ensure time server is available If not, homeSpan.timeServer is reset to NULL --- src/HomeSpan.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 9c2b6d4..98bc563 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "HomeSpan.h" #include "HAP.h" @@ -562,10 +563,14 @@ void Span::checkConnect(){ if(timeServer){ Serial.printf("Acquiring Time from %s... ",timeServer,timeZone); configTzTime(timeZone,timeServer); - getLocalTime(&timeinfo); - char c[65]; - strftime(c,64,"%a %b %e %Y %I:%M:%S %p",&timeinfo); - Serial.printf("%s (%s)\n\n",c,timeZone); + if(getLocalTime(&timeinfo)){ + char c[65]; + strftime(c,64,"%a %b %e %Y %I:%M:%S %p",&timeinfo); + Serial.printf("%s (%s)\n\n",c,timeZone); + } else { + Serial.printf("Can't access Time Server - time-keeping disabled!\n\n"); + timeServer=NULL; + } } Serial.printf("Starting HAP Server on port %d supporting %d simultaneous HomeKit Controller Connections...\n",tcpPortNum,maxConnections);