@@ -64,6 +64,11 @@ extern "C" unsigned long getTime()
6464 return ArduinoCloud.getInternalTime ();
6565}
6666
67+ extern " C" void updateTimezoneInfo ()
68+ {
69+ ArduinoCloud.updateInternalTimezoneInfo ();
70+ }
71+
6772/* *****************************************************************************
6873 CTOR/DTOR
6974 ******************************************************************************/
@@ -243,6 +248,9 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
243248 addPropertyReal (_ota_req, " OTA_REQ" , Permission::ReadWrite).onSync (CLOUD_WINS);
244249#endif /* OTA_ENABLED */
245250
251+ addPropertyReal (_tz_offset, " tz_offset" , Permission::ReadWrite).onSync (CLOUD_WINS).onUpdate (updateTimezoneInfo);
252+ addPropertyReal (_tz_dst_until, " tz_dst_until" , Permission::ReadWrite).onSync (CLOUD_WINS).onUpdate (updateTimezoneInfo);
253+
246254#if OTA_STORAGE_PORTENTA_QSPI
247255 #define BOOTLOADER_ADDR (0x8000000 )
248256 uint32_t bootloader_data_offset = 0x1F000 ;
@@ -527,7 +535,12 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
527535 */
528536 sendPropertiesToCloud ();
529537
530- return State::Connected;
538+ unsigned long const internal_posix_time = _time_service.getTime ();
539+ if (internal_posix_time < _tz_dst_until) {
540+ return State::Connected;
541+ } else {
542+ return State::RequestLastValues;
543+ }
531544 }
532545}
533546
@@ -555,6 +568,7 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
555568 DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s [%d] last values received" , __FUNCTION__, millis ());
556569 CBORDecoder::decode (_property_container, (uint8_t *)bytes, length, true );
557570 sendPropertiesToCloud ();
571+ _time_service.setTimeZoneData (_tz_offset, _tz_dst_until);
558572 execCloudEventCallback (ArduinoIoTCloudEvent::SYNC);
559573 _last_sync_request_cnt = 0 ;
560574 _last_sync_request_tick = 0 ;
0 commit comments