Skip to content

Commit 52b0de2

Browse files
pennamandreagilardoni
authored andcommitted
ArduinoIoTCloudTCP: add state to handle network configuration
1 parent 8dc1e62 commit 52b0de2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ void ArduinoIoTCloudTCP::update()
223223
State next_state = _state;
224224
switch (_state)
225225
{
226+
case State::ConfigPhy: next_state = handle_ConfigPhy(); break;
226227
case State::ConnectPhy: next_state = handle_ConnectPhy(); break;
227228
case State::SyncTime: next_state = handle_SyncTime(); break;
228229
case State::ConnectMqttBroker: next_state = handle_ConnectMqttBroker(); break;
@@ -256,6 +257,16 @@ void ArduinoIoTCloudTCP::printDebugInfo()
256257
* PRIVATE MEMBER FUNCTIONS
257258
******************************************************************************/
258259

260+
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConfigPhy()
261+
{
262+
if (_configurator == nullptr || _configurator->poll() == NetworkConfiguratorStates::CONFIGURED)
263+
{
264+
return State::ConnectPhy;
265+
}
266+
267+
return State::ConfigPhy;
268+
}
269+
259270
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectPhy()
260271
{
261272
if (_connection->check() == NetworkConnectionState::CONNECTED)

src/ArduinoIoTCloudTCP.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
118118

119119
enum class State
120120
{
121+
ConfigPhy,
121122
ConnectPhy,
122123
SyncTime,
123124
ConnectMqttBroker,
@@ -169,6 +170,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
169170
inline String getTopic_dataout () { return ( getThingId().length() == 0) ? String("") : String("/a/t/" + getThingId() + "/e/o"); }
170171
inline String getTopic_datain () { return ( getThingId().length() == 0) ? String("") : String("/a/t/" + getThingId() + "/e/i"); }
171172

173+
State handle_ConfigPhy();
172174
State handle_ConnectPhy();
173175
State handle_SyncTime();
174176
State handle_ConnectMqttBroker();

0 commit comments

Comments
 (0)