Struct anj_ntp_configuration_struct
Defined in File ntp.h
Struct Documentation
-
struct anj_ntp_configuration_struct
NTP module configuration structure. Should be filled before passing to anj_ntp_init.
Public Members
-
anj_ntp_event_callback_t *event_cb
Mandatory callback for monitoring NTP status changes.
This callback will be invoked for each status change of the NTP module.
-
void *event_cb_arg
Opaque argument that will be passed to the function configured in the event_cb field.
-
const char *ntp_server_address
NTP server address to synchronize time with. Must be a null-terminated string.
Corresponds to the
NTP server addressResource (/3415/0/1) value in the NTP object.String is copied internally, so the pointer can be freed after this function returns. It must not exceed ANJ_NTP_SERVER_ADDR_MAX_LEN characters in length.
-
const char *backup_ntp_server_address
Fallback NTP server address to use if the primary server is unreachable. Must be a null-terminated string. Optional - can be set to NULL.
Corresponds to the
Backup NTP server addressResource (/3415/0/2) in the NTP object.String is copied internally, so the pointer can be freed after this function returns. It must not exceed ANJ_NTP_SERVER_ADDR_MAX_LEN characters in length.
-
uint32_t ntp_period_hours
Defines how often (in hours) the NTP synchronization should be performed. If set to 0, periodic synchronization is disabled.
Corresponds to the
NTP periodResource (/3415/0/3) in the NTP object.If set
event_cbwill be called with status ANJ_NTP_STATUS_PERIOD_EXCEEDED when the period is exceeded. The time is counted since the last synchronization attempt, regardless of its result, or since module initialization.
-
uint16_t attempts
Defines how many NTP synchronization attempts will be made before reporting failure. If not set, single attempt will be made.
If
backup_ntp_server_addressis set, the same number of attempts will be made for the backup server after all attempts for the primary server are exhausted.
-
anj_time_duration_t response_timeout
Timeout for waiting for an NTP server response, in seconds.
This value applies to a single NTP request. If no response is received within this period, the attempt is treated as failed.
A smaller timeout reduces how long the client waits on an unresponsive or unreachable server, but increases the risk of failures on slower networks. Conversely, a very large timeout increases the chance of eventually getting a reply, but the long round-trip time may cause the resulting time adjustment to be less accurate (the clock is set based on an older response).
If not set, defaults to 5 seconds.
-
const anj_net_socket_configuration_t *net_socket_cfg
Network socket configuration to use for NTP communication. Object pointed to by this pointer can be freed after this function returns, as it is copied internally.
-
anj_ntp_event_callback_t *event_cb