Skip to content

Force sending the network configuration when it's updated via Serial #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 13 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,17 @@ 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;
#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