Chapter 2. API Reference
function is registered via sntp_set_time_sync_notification_cb(), it will be called following time synchroniza-
tion.
Parameters
• tv: Time received from SNTP server.
void
sntp_set_sync_mode(sntp_sync_mode_t
Set the sync mode.
Allowable two mode: SNTP_SYNC_MODE_IMMED and SNTP_SYNC_MODE_SMOOTH.
Parameters
• sync_mode: Sync mode.
sntp_sync_mode_t
sntp_get_sync_mode(void)
Get set sync mode.
Return SNTP_SYNC_MODE_IMMED: Update time immediately. SNTP_SYNC_MODE_SMOOTH:
Smooth time updating.
sntp_sync_status_t
sntp_get_sync_status(void)
Get status of time sync.
After the update is completed, the status will be returned as SNTP_SYNC_STATUS_COMPLETED. After
that, the status will be reset to SNTP_SYNC_STATUS_RESET. If the update operation is not completed yet,
the status will be SNTP_SYNC_STATUS_RESET. If a smooth mode was chosen and the synchronization is
still continuing (adjtime works), then it will be SNTP_SYNC_STATUS_IN_PROGRESS.
Return SNTP_SYNC_STATUS_RESET: Reset status. SNTP_SYNC_STATUS_COMPLETED: Time is
synchronized. SNTP_SYNC_STATUS_IN_PROGRESS: Smooth time sync in progress.
void
sntp_set_sync_status(sntp_sync_status_t
Set status of time sync.
Parameters
• sync_status: status of time sync (see sntp_sync_status_t)
void
sntp_set_time_sync_notification_cb(sntp_sync_time_cb_t
Set a callback function for time synchronization notification.
Parameters
• callback: a callback function
void sntp_set_sync_interval(uint32_t interval_ms)
Set the sync interval of SNTP operation.
Note: SNTPv4 RFC 4330 enforces a minimum sync interval of 15 seconds. This sync interval will be used in
the next attempt update time throught SNTP. To apply the new sync interval call the sntp_restart() function,
otherwise, it will be applied after the last interval expired.
Parameters
• interval_ms: The sync interval in ms. It cannot be lower than 15 seconds, otherwise 15 seconds
will be set.
uint32_t sntp_get_sync_interval(void)
Get the sync interval of SNTP operation.
Return the sync interval
bool sntp_restart(void)
Restart SNTP.
Return True - Restart False - SNTP was not initialized yet
Type Definitions
typedef void (*sntp_sync_time_cb_t)(struct timeval *tv)
SNTP callback function for notifying about time sync event.
Espressif Systems
sync_mode)
sync_status)
1053
Submit Document Feedback
callback)
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?