@@ -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)
@@ -482,7 +487,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig()
482
487
return State::SubscribeDeviceTopic;
483
488
}
484
489
}
485
-
486
490
return State::WaitDeviceConfig;
487
491
}
488
492
@@ -496,16 +500,13 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
496
500
return State::ConnectPhy;
497
501
}
498
502
499
- if (getThingIdOutdatedFlag () )
503
+ if (_deviceSubscribedToThing == true )
500
504
{
501
- if (_deviceSubscribedToThing == true )
502
- {
503
- /* Unsubscribe from old things topics and go oi with a new subsctiption */
504
- _mqttClient.unsubscribe (_shadowTopicIn);
505
- _mqttClient.unsubscribe (_dataTopicIn);
505
+ /* Unsubscribe from old things topics and go oi with a new subsctiption */
506
+ _mqttClient.unsubscribe (_shadowTopicIn);
507
+ _mqttClient.unsubscribe (_dataTopicIn);
506
508
507
- _deviceSubscribedToThing = false ;
508
- }
509
+ _deviceSubscribedToThing = false ;
509
510
}
510
511
511
512
updateThingTopics ();
@@ -701,7 +702,6 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
701
702
CBORDecoder::decode (_device_property_container, (uint8_t *)bytes, length);
702
703
_last_device_subscribe_cnt = 0 ;
703
704
_next_device_subscribe_attempt_tick = 0 ;
704
- _next_state = State::CheckDeviceConfig;
705
705
}
706
706
707
707
/* Topic for user input data */
0 commit comments