Skip to content

Commit b6f51ee

Browse files
committed
Execute handle_CheckDeviceConfig() only on thing_id changes ignoring other messages on device topic
1 parent d576482 commit b6f51ee

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ void ArduinoIoTCloudTCP::update()
326326
#endif
327327

328328

329+
if(getThingIdOutdatedFlag()) {
330+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s Thing id outdated, reconfiguring...", __FUNCTION__);
331+
_state = State::CheckDeviceConfig;
332+
}
333+
329334
/* Run through the state machine. */
330335
State next_state = _state;
331336
switch (_state)
@@ -476,7 +481,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig()
476481
return State::SubscribeDeviceTopic;
477482
}
478483
}
479-
480484
return State::WaitDeviceConfig;
481485
}
482486

@@ -490,16 +494,13 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
490494
return State::ConnectPhy;
491495
}
492496

493-
if(getThingIdOutdatedFlag())
497+
if(_deviceSubscribedToThing == true)
494498
{
495-
if(_deviceSubscribedToThing == true)
496-
{
497-
/* Unsubscribe from old things topics and go on with a new subsctiption */
498-
_mqttClient.unsubscribe(_shadowTopicIn);
499-
_mqttClient.unsubscribe(_dataTopicIn);
499+
/* Unsubscribe from old things topics and go on with a new subsctiption */
500+
_mqttClient.unsubscribe(_shadowTopicIn);
501+
_mqttClient.unsubscribe(_dataTopicIn);
500502

501-
_deviceSubscribedToThing = false;
502-
}
503+
_deviceSubscribedToThing = false;
503504
}
504505

505506
updateThingTopics();
@@ -716,7 +717,6 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
716717
CBORDecoder::decode(_device_property_container, (uint8_t*)bytes, length);
717718
_last_device_subscribe_cnt = 0;
718719
_next_device_subscribe_attempt_tick = 0;
719-
_state = State::CheckDeviceConfig;
720720
}
721721

722722
/* Topic for user input data */

0 commit comments

Comments
 (0)