@@ -102,6 +102,52 @@ int ArduinoIoTCloudTCP::begin(ConnectionHandler & connection, bool const enable_
102
102
return begin (enable_watchdog, _brokerAddress, _brokerPort);
103
103
}
104
104
105
+ void ArduinoIoTCloudTCP::update ()
106
+ {
107
+ /* Feed the watchdog. If any of the functions called below
108
+ * get stuck than we can at least reset and recover.
109
+ */
110
+ #if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)
111
+ watchdog_reset ();
112
+ #endif
113
+
114
+ /* Run through the state machine. */
115
+ State next_state = _state;
116
+ switch (_state)
117
+ {
118
+ case State::ConnectPhy: next_state = handle_ConnectPhy (); break ;
119
+ case State::SyncTime: next_state = handle_SyncTime (); break ;
120
+ case State::ConnectMqttBroker: next_state = handle_ConnectMqttBroker (); break ;
121
+ case State::Connected: next_state = handle_Connected (); break ;
122
+ case State::Disconnect: next_state = handle_Disconnect (); break ;
123
+ }
124
+ _state = next_state;
125
+
126
+ /* This watchdog feed is actually needed only by the RP2040 Connect because its
127
+ * maximum watchdog window is 8389 ms; despite this we feed it for all
128
+ * supported ARCH to keep code aligned.
129
+ */
130
+ #if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)
131
+ watchdog_reset ();
132
+ #endif
133
+ }
134
+
135
+ int ArduinoIoTCloudTCP::connected ()
136
+ {
137
+ return _mqttClient.connected ();
138
+ }
139
+
140
+ void ArduinoIoTCloudTCP::printDebugInfo ()
141
+ {
142
+ DEBUG_INFO (" ***** Arduino IoT Cloud - configuration info *****" );
143
+ DEBUG_INFO (" Device ID: %s" , getDeviceId ().c_str ());
144
+ DEBUG_INFO (" MQTT Broker: %s:%d" , _brokerAddress.c_str (), _brokerPort);
145
+ }
146
+
147
+ /* *****************************************************************************
148
+ * PRIVATE MEMBER FUNCTIONS
149
+ ******************************************************************************/
150
+
105
151
int ArduinoIoTCloudTCP::begin (bool const enable_watchdog, String brokerAddress, uint16_t brokerPort)
106
152
{
107
153
_brokerAddress = brokerAddress;
@@ -204,52 +250,6 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
204
250
return 1 ;
205
251
}
206
252
207
- void ArduinoIoTCloudTCP::update ()
208
- {
209
- /* Feed the watchdog. If any of the functions called below
210
- * get stuck than we can at least reset and recover.
211
- */
212
- #if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)
213
- watchdog_reset ();
214
- #endif
215
-
216
- /* Run through the state machine. */
217
- State next_state = _state;
218
- switch (_state)
219
- {
220
- case State::ConnectPhy: next_state = handle_ConnectPhy (); break ;
221
- case State::SyncTime: next_state = handle_SyncTime (); break ;
222
- case State::ConnectMqttBroker: next_state = handle_ConnectMqttBroker (); break ;
223
- case State::Connected: next_state = handle_Connected (); break ;
224
- case State::Disconnect: next_state = handle_Disconnect (); break ;
225
- }
226
- _state = next_state;
227
-
228
- /* This watchdog feed is actually needed only by the RP2040 Connect because its
229
- * maximum watchdog window is 8389 ms; despite this we feed it for all
230
- * supported ARCH to keep code aligned.
231
- */
232
- #if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)
233
- watchdog_reset ();
234
- #endif
235
- }
236
-
237
- int ArduinoIoTCloudTCP::connected ()
238
- {
239
- return _mqttClient.connected ();
240
- }
241
-
242
- void ArduinoIoTCloudTCP::printDebugInfo ()
243
- {
244
- DEBUG_INFO (" ***** Arduino IoT Cloud - configuration info *****" );
245
- DEBUG_INFO (" Device ID: %s" , getDeviceId ().c_str ());
246
- DEBUG_INFO (" MQTT Broker: %s:%d" , _brokerAddress.c_str (), _brokerPort);
247
- }
248
-
249
- /* *****************************************************************************
250
- * PRIVATE MEMBER FUNCTIONS
251
- ******************************************************************************/
252
-
253
253
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectPhy ()
254
254
{
255
255
if (_connection->check () == NetworkConnectionState::CONNECTED)
0 commit comments