@@ -53,17 +53,16 @@ unsigned long getTime()
5353 return ArduinoCloud.getInternalTime ();
5454}
5555
56- void updateTimezoneInfo ()
57- {
58- ArduinoCloud.updateInternalTimezoneInfo ();
59- }
60-
6156/* *****************************************************************************
6257 CTOR/DTOR
6358 ******************************************************************************/
6459
6560ArduinoIoTCloudTCP::ArduinoIoTCloudTCP ()
6661: _state{State::ConnectPhy}
62+ , _tz_offset{0 }
63+ , _tz_offset_property{nullptr }
64+ , _tz_dst_until{0 }
65+ , _tz_dst_until_property{nullptr }
6766, _next_connection_attempt_tick{0 }
6867, _last_connection_attempt_cnt{0 }
6968, _next_device_subscribe_attempt_tick{0 }
@@ -214,9 +213,10 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
214213#endif /* OTA_ENABLED */
215214 p = new CloudWrapperString (_thing_id);
216215 _thing_id_property = &addPropertyToContainer (_device_property_container, *p, " thing_id" , Permission::ReadWrite, -1 ).writeOnDemand ();
217-
218- addPropertyReal (_tz_offset, " tz_offset" , Permission::ReadWrite).onSync (CLOUD_WINS).onUpdate (updateTimezoneInfo);
219- addPropertyReal (_tz_dst_until, " tz_dst_until" , Permission::ReadWrite).onSync (CLOUD_WINS).onUpdate (updateTimezoneInfo);
216+ p = new CloudWrapperInt (_tz_offset);
217+ _tz_offset_property = &addPropertyToContainer (_thing_property_container, *p, " tz_offset" , Permission::ReadWrite, -1 ).writeOnDemand ();
218+ p = new CloudWrapperUnsignedInt (_tz_dst_until);
219+ _tz_dst_until_property = &addPropertyToContainer (_thing_property_container, *p, " tz_dst_until" , Permission::ReadWrite, -1 ).writeOnDemand ();
220220
221221#if OTA_ENABLED
222222 _ota_cap = OTA::isCapable ();
@@ -584,13 +584,23 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
584584 _mqtt_data_request_retransmit = false ;
585585 }
586586
587+ /* Configure Time service with timezone data:
588+ * _tz_offset [offset + dst]
589+ * _tz_dst_until [posix timestamp until _tz_offset is valid]
590+ */
591+ if (_tz_offset_property->isDifferentFromCloud () || _tz_dst_until_property->isDifferentFromCloud ()) {
592+ _tz_offset_property->fromCloudToLocal ();
593+ _tz_dst_until_property->fromCloudToLocal ();
594+ _time_service.setTimeZoneData (_tz_offset, _tz_dst_until);
595+ }
596+
587597 /* Check if any properties need encoding and send them to
588598 * the cloud if necessary.
589599 */
590600 sendThingPropertiesToCloud ();
591601
592602 unsigned long const internal_posix_time = _time_service.getTime ();
593- if (internal_posix_time < _tz_dst_until) {
603+ if (internal_posix_time < _tz_dst_until) {
594604 return State::Connected;
595605 } else {
596606 return State::RequestLastValues;
0 commit comments