Skip to content

Fix: Use sketch compile time if no connection is available for estimating system time. #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/utility/time/TimeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ unsigned long TimeService::getTime()

unsigned long TimeService::getRemoteTime()
{
if(_con_hdl == nullptr) return 0;
if(_con_hdl == nullptr)
return EPOCH_AT_COMPILE_TIME;

/* At first try to see if a valid time can be obtained
* using the network time available via the connection
Expand All @@ -112,7 +113,12 @@ unsigned long TimeService::getRemoteTime()
return ntp_time;
}

return 0;
/* Return the epoch timestamp at compile time as a last
* line of defense. Otherwise the certificate expiration
* date is wrong and we'll be unable to establish a connection
* to the server.
*/
return EPOCH_AT_COMPILE_TIME;
}

bool TimeService::isTimeValid(unsigned long const time)
Expand Down