Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ void ArduinoIoTCloudTCP::update()
switch (_state)
{
case State::ConfigPhy: next_state = handle_ConfigPhy(); break;
case State::UpdatePhy: next_state = handle_UpdatePhy(); break;
case State::Init: next_state = handle_Init(); break;
case State::ConnectPhy: next_state = handle_ConnectPhy(); break;
case State::SyncTime: next_state = handle_SyncTime(); break;
Expand All @@ -240,7 +241,7 @@ void ArduinoIoTCloudTCP::update()
*/
#if NETWORK_CONFIGURATOR_ENABLED
if(_configurator != nullptr && _state > State::Init && _configurator->update() == NetworkConfiguratorStates::UPDATING_CONFIG){
_state = State::ConfigPhy;
_state = State::UpdatePhy;
}
#endif

Expand Down Expand Up @@ -316,6 +317,19 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConfigPhy()
#endif
}

ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_UpdatePhy()
{
#if NETWORK_CONFIGURATOR_ENABLED
if(_configurator->update() == NetworkConfiguratorStates::CONFIGURED) {
_configurator->disconnectAgent();
return State::Disconnect;
}
return State::UpdatePhy;
#else
return State::Init;
#endif
}

ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Init()
{
/* Setup broker TLS client */
Expand Down
2 changes: 2 additions & 0 deletions src/ArduinoIoTCloudTCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
enum class State
{
ConfigPhy,
UpdatePhy,
Init,
ConnectPhy,
SyncTime,
Expand Down Expand Up @@ -178,6 +179,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
inline String getTopic_datain () { return ( getThingId().length() == 0) ? String("") : String("/a/t/" + getThingId() + "/e/i"); }

State handle_ConfigPhy();
State handle_UpdatePhy();
State handle_Init();
State handle_ConnectPhy();
State handle_SyncTime();
Expand Down
Loading