Skip to content

Commit 20831f5

Browse files
committed
ArduinoIoTCloudTCP: Use isTimeValid() to check NTP time
1 parent ef6b3a6 commit 20831f5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ArduinoIoTCloudTCP.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,13 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectPhy()
328328

329329
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime()
330330
{
331-
#pragma GCC diagnostic push
332-
#pragma GCC diagnostic ignored "-Wunused-variable"
333-
unsigned long const internal_posix_time = _time_service.getTime();
334-
#pragma GCC diagnostic pop
335-
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s internal clock configured to posix timestamp %d", __FUNCTION__, internal_posix_time);
336-
return State::ConnectMqttBroker;
331+
if (TimeServiceClass::isTimeValid(getTime()))
332+
{
333+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s internal clock configured to posix timestamp %d", __FUNCTION__, getTime());
334+
return State::ConnectMqttBroker;
335+
}
336+
337+
return State::ConnectPhy;
337338
}
338339

339340
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()

0 commit comments

Comments
 (0)