@@ -327,11 +327,16 @@ void ArduinoIoTCloudTCP::update()
327
327
/* Check if the state has changed in message handler */
328
328
if (_next_state != State::Invalid)
329
329
{
330
- DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s state changed in message handler" , __FUNCTION__);
330
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s State changed in message handler... " , __FUNCTION__);
331
331
_state = _next_state;
332
332
_next_state = State::Invalid;
333
333
}
334
334
335
+ if (getThingIdOutdatedFlag ()) {
336
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s Thing id outdated, reconfiguring..." , __FUNCTION__);
337
+ _state = State::CheckDeviceConfig;
338
+ }
339
+
335
340
/* Run through the state machine. */
336
341
State next_state = _state;
337
342
switch (_state)
@@ -483,7 +488,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig()
483
488
return State::SubscribeDeviceTopic;
484
489
}
485
490
}
486
-
487
491
return State::WaitDeviceConfig;
488
492
}
489
493
@@ -497,16 +501,13 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
497
501
return State::ConnectPhy;
498
502
}
499
503
500
- if (getThingIdOutdatedFlag () )
504
+ if (_deviceSubscribedToThing == true )
501
505
{
502
- if (_deviceSubscribedToThing == true )
503
- {
504
- /* Unsubscribe from old things topics and go oi with a new subsctiption */
505
- _mqttClient.unsubscribe (_shadowTopicIn);
506
- _mqttClient.unsubscribe (_dataTopicIn);
506
+ /* Unsubscribe from old things topics and go oi with a new subsctiption */
507
+ _mqttClient.unsubscribe (_shadowTopicIn);
508
+ _mqttClient.unsubscribe (_dataTopicIn);
507
509
508
- _deviceSubscribedToThing = false ;
509
- }
510
+ _deviceSubscribedToThing = false ;
510
511
}
511
512
512
513
updateThingTopics ();
@@ -702,7 +703,6 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
702
703
CBORDecoder::decode (_device_property_container, (uint8_t *)bytes, length);
703
704
_last_device_subscribe_cnt = 0 ;
704
705
_next_device_subscribe_attempt_tick = 0 ;
705
- _next_state = State::CheckDeviceConfig;
706
706
}
707
707
708
708
/* Topic for user input data */
0 commit comments