@@ -58,11 +58,6 @@ void updateTimezoneInfo()
5858 ArduinoCloud.updateInternalTimezoneInfo ();
5959}
6060
61- void setThingIdOutdated ()
62- {
63- ArduinoCloud.setThingIdOutdatedFlag ();
64- }
65-
6661/* *****************************************************************************
6762 CTOR/DTOR
6863 ******************************************************************************/
@@ -218,7 +213,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
218213 addPropertyToContainer (_device_property_container, *p, " OTA_REQ" , Permission::ReadWrite, -1 );
219214#endif /* OTA_ENABLED */
220215 p = new CloudWrapperString (_thing_id);
221- addPropertyToContainer (_device_property_container, *p, " thing_id" , Permission::ReadWrite, -1 ).onUpdate (setThingIdOutdated );
216+ _thing_id_property = & addPropertyToContainer (_device_property_container, *p, " thing_id" , Permission::ReadWrite, -1 ).writeOnDemand ( );
222217
223218 addPropertyReal (_tz_offset, " tz_offset" , Permission::ReadWrite).onSync (CLOUD_WINS).onUpdate (updateTimezoneInfo);
224219 addPropertyReal (_tz_dst_until, " tz_dst_until" , Permission::ReadWrite).onSync (CLOUD_WINS).onUpdate (updateTimezoneInfo);
@@ -409,7 +404,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig()
409404 return State::Disconnect;
410405 }
411406
412- if (getThingIdOutdatedFlag ())
407+ if (_thing_id_property-> isDifferentFromCloud ())
413408 {
414409 return State::CheckDeviceConfig;
415410 }
@@ -445,7 +440,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
445440
446441 updateThingTopics ();
447442
448- if (deviceNotAttached () )
443+ if (_thing_id. length () == 0 )
449444 {
450445 /* Configuration received but device not attached. Wait: 40s */
451446 unsigned long attach_retry_delay = (1 << _last_device_attach_cnt) * AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms;
@@ -468,7 +463,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeThingTopics()
468463 return State::Disconnect;
469464 }
470465
471- if (getThingIdOutdatedFlag ())
466+ if (_thing_id_property-> isDifferentFromCloud ())
472467 {
473468 return State::CheckDeviceConfig;
474469 }
@@ -524,7 +519,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_RequestLastValues()
524519 return State::Disconnect;
525520 }
526521
527- if (getThingIdOutdatedFlag ())
522+ if (_thing_id_property-> isDifferentFromCloud ())
528523 {
529524 return State::CheckDeviceConfig;
530525 }
@@ -567,7 +562,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
567562 /* We are connected so let's to our stuff here. */
568563 else
569564 {
570- if (getThingIdOutdatedFlag ())
565+ if (_thing_id_property-> isDifferentFromCloud ())
571566 {
572567 return State::CheckDeviceConfig;
573568 }
@@ -762,12 +757,12 @@ int ArduinoIoTCloudTCP::write(String const topic, byte const data[], int const l
762757
763758void ArduinoIoTCloudTCP::updateThingTopics ()
764759{
760+ _thing_id_property->fromCloudToLocal ();
761+
765762 _shadowTopicOut = getTopic_shadowout ();
766763 _shadowTopicIn = getTopic_shadowin ();
767764 _dataTopicOut = getTopic_dataout ();
768765 _dataTopicIn = getTopic_datain ();
769-
770- clrThingIdOutdatedFlag ();
771766}
772767
773768/* *****************************************************************************
0 commit comments