8.2 Global Clock Synchronization
8.2.1 Global clock synchronization - Bootup and maintenance

The flow chart specifies the commands sequence that shall be exchanged between the Endpoint and the Amazon Sidewalk Cloud to keep the Endpoint clock synchronization. Network clock synchronization is required for messaging features as described in section 4.7. The clock is synchronized during procedures described at boot-up time and maintained throughout the operation. The maintenance of the established clock synchronization shall be done by using GET_TIME and RESP_TIME commands, each clock_sync_int. The Endpoint shall not update its clock value in case the received value does not differ more than sec_clock_drift seconds. When there is no response for the GET_TIME command then the Endpoint shall perform a next try to synchronize the clock after the clock_sync_int period which is equal to two hours. When the response for the GET_TIME command is successfully received by the Endpoint, the clock_sync_int period dynamically adapts based on the time difference between the received time in RESP_TIME and the Endpoint’s current time. This is described in section 8.2.2. There is no special procedure to handle lack of RESP_TIME.
8.2.2 Global clock synchronization - maintenance interval

fig 8.3 Time sync maintenance Interval
The next time sync interval is updated dynamically based on the difference between the current time on the Endpoint and the time in RESP_TIME
I_next = next interval from adaptive_sync_intervals_h, If T_delta <= 1 minute
I_next = I_current, If 1 minute < T_delta <= 2 minute
I_next = I_min, If T_delta >= 2 minute
I_next: Next time sync interval.I_current: Current time sync interval.I_max: Maximum time sync interval (720 hours(30 days)).I_max: Minimum time sync interval (2 hours).T_delta: Time difference between current time on Endpoint and received inRESP_TIME.
The flow chart specifies the backoff procedure followed to determine the next clock_sync_int period only in the case of successfully receiving the time from RESP_TIME. The procedure for determining the next clock_sync_int period is as follows:
- The Endpoint starts the clock synchronization process. if there is sucessful response
RESP_TIMEthenclock_sync_intperiod is set initially to first time sync interval vlue from adaptive_sync_intervals_h. - After adaptive_sync_intervals_h[0] hours clock synchronization process is attempted and if
RESP_TIMEis received and the difference between the current time and time in theRESP_TIMEis less than one minute,clock_sync_intperiod is set to next sync interval i.e. adaptive_sync_intervals_h[1]. -
successful
RESP_TIMEreception at subsequentclock_sync_intperiods would result in update ofclock_sync_intperiod as described below- Initial
clock_sync_int= adaptive_sync_intervals_h[0] - Next
clock_sync_int= adaptive_sync_intervals_h[1] - Next
clock_sync_int= adaptive_sync_intervals_h[2] - Next
clock_sync_int= adaptive_sync_intervals_h[3] and so on until last index of adaptive_sync_intervals_h.
- Initial
clock_sync_intperiod does not exceed last value ofadaptive_sync_intervals_hhours and everyadaptive_sync_intervals_h[last_idx]clock synchronization process is attempted in case of successful reception ofRESP_TIMEand the time difference between the received time in- At any step of the
clock_sync_intperiod, the difference between the current time and time in theRESP_TIMEis greater than 2 minute, theclock_sync_intperiod is reset toadaptive_sync_intervals_h[0] -
Failure to receive
RESP_TIMEin response toGET_TIMEcommand would start the Global Clock Synchronization section 8.2.3.
8.2.3 Global clock synchronization - retry

fig 8.4 Time sync - no response scenario
The flow chart specifies the commands sequence that shall be exchanged between the Endpoint and the Amazon Sidewalk Cloud to synchronize the Endpoint clock in case there is no response from the cloud for the first GET_TIME command. The procedure is included in STEP 2 and STEP 3 of section 8.1. The procedure for handling the clock synchronization failure is as follows:
- STEP 1 - The Endpoint initializes the clock synchronization process but it fails. There is no response
RESP_TIMEfor theGET_TIMEcommand forsync_resp_timeoutequal to 3 min. - STEPs 2 - 4 -
retry_countis initialized with 1 value and the nextGET_TIMEcommand is sent. When the response is not received forsync_resp_timeoutthen the activity is repeated in STEP 3 and STEP 4. Theretry_countis increased by 1 up to its maximum value andsync_resp_timeoutis equal to 3 min. When theretry_countreached its maximum value then go to STEP 5. -
STEPs 5 - 8 - the
sync_resp_timeouttime interval is increased in the subsequent steps. The Endpoint waits a longer time for the possible response from the cloud. The value of thesync_resp_timeoutis as follows in the next steps:- STEP 5 -
sync_resp_timeout= 5 min - STEP 6 -
sync_resp_timeout= 8 min - STEP 7 -
sync_resp_timeout= 10 min - STEP 8 -
sync_resp_timeout= 15 min
- STEP 5 -
-
STEP 9 - When there is still no response from the cloud then
sync_resp_timeoutis not increased. The Endpoint shall wait for a maximum value ofsync_resp_timeoutminutes for the response from the cloud for each subsequentGET_TIMEcommand. The Endpoint shall sendGET_TIMEcommand eachsync_resp_timeouttill the moment theRESP_TIMEcommand is received and the time is synchronized.