Skip to content

Commit 4ee7129

Browse files
committed
Avoid retrieving time from network if connection is not ready
1 parent 451d57d commit 4ee7129

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utility/time/TimeService.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ unsigned long TimeService::getRemoteTime()
213213
/* If no valid network time is available try to obtain the
214214
* time via NTP next.
215215
*/
216-
unsigned long const ntp_time = NTPUtils::getTime(_con_hdl->getUDP());
217-
if(isTimeValid(ntp_time)) {
218-
return ntp_time;
216+
if(_con_hdl->getStatus() == NetworkConnectionState::CONNECTED) {
217+
unsigned long const ntp_time = NTPUtils::getTime(_con_hdl->getUDP());
218+
if(isTimeValid(ntp_time)) {
219+
return ntp_time;
220+
}
219221
}
220222
#endif
221223

0 commit comments

Comments
 (0)