File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,7 @@ void ArduinoIoTCloudTCP::update()
178
178
switch (_state)
179
179
{
180
180
case State::ConnectPhy: next_state = handle_ConnectPhy (); break ;
181
+ case State::SyncTime: next_state = handle_SyncTime (); break ;
181
182
case State::ConnectMqttBroker: next_state = handle_ConnectMqttBroker (); break ;
182
183
case State::SubscribeMqttTopics: next_state = handle_SubscribeMqttTopics (); break ;
183
184
case State::RequestLastValues: next_state = handle_RequestLastValues (); break ;
@@ -215,11 +216,18 @@ void ArduinoIoTCloudTCP::setOTAStorage(OTAStorage & ota_storage)
215
216
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectPhy ()
216
217
{
217
218
if (_connection->check () == NetworkConnectionState::CONNECTED)
218
- return State::ConnectMqttBroker ;
219
+ return State::SyncTime ;
219
220
else
220
221
return State::ConnectPhy;
221
222
}
222
223
224
+ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime ()
225
+ {
226
+ unsigned long const internal_posix_time = time_service.getTime ();
227
+ DBG_VERBOSE (" ArduinoIoTCloudTCP::%s internal clock configured to posix timestamp %d" , __FUNCTION__, internal_posix_time);
228
+ return State::ConnectMqttBroker;
229
+ }
230
+
223
231
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker ()
224
232
{
225
233
if (_mqttClient.connect (_brokerAddress.c_str (), _brokerPort))
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
99
99
enum class State
100
100
{
101
101
ConnectPhy,
102
+ SyncTime,
102
103
ConnectMqttBroker,
103
104
SubscribeMqttTopics,
104
105
RequestLastValues,
@@ -148,6 +149,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
148
149
inline String getTopic_ota_in () { return String (" /a/d/" + getDeviceId () + " /ota/i" ); }
149
150
150
151
State handle_ConnectPhy ();
152
+ State handle_SyncTime ();
151
153
State handle_ConnectMqttBroker ();
152
154
State handle_SubscribeMqttTopics ();
153
155
State handle_RequestLastValues ();
You can’t perform that action at this time.
0 commit comments