SNTP Client API#
SNTPc_ConfigureMemSeg()#
Description#
Configures the memory segment to use when allocating control data and buffers.
Files#
sntp_client.h/sntp_client.c
Prototype#
void SNTPc_ConfigureMemSeg (MEM_SEG *p_mem_seg)Arguments#
p_mem_seg
Pointer to memory segment to use when allocating control data. DEF_NULL means general purpose heap segment.
Returned Value#
None.
Notes / Warnings#
Calling this function is optional, if it is not called, the default value will be used.
This function MUST be called before the SNTPc client is initialized via the
SNTPc_Init()function.
SNTPc_Init()#
Description#
Initializes the SNTPc Module.
Files#
sntp_client.h/sntp_client.c
Prototype#
void SNTPc_Init (RTOS_ERR *p_err)Arguments#
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
RTOS_ERR_NONERTOS_ERR_NOT_AVAILRTOS_ERR_OS_ILLEGAL_RUN_TIMERTOS_ERR_POOL_EMPTYRTOS_ERR_BLK_ALLOC_CALLBACKRTOS_ERR_SEG_OVF
Returned Value#
None.
Notes / Warnings#
None.
SNTPc_DfltCfgSet()#
Description#
Sets the default server configurations.
Files#
sntp_client.h/sntp_client.c
Prototype#
void SNTPc_DfltCfgSet (NET_PORT_NBR port_nbr,
NET_IP_ADDR_FAMILY addr_family,
CPU_INT32U rx_timeout_ms,
RTOS_ERR *p_err)Arguments#
port_nbr
Port number to use.
addr_family
Address family. Use NET_IP_ADDR_FAMILY_NONE if you are unsure.
rx_timeout_ms
Timeout, in milliseconds, for the reception.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
RTOS_ERR_NONE
Returned Value#
DEF_TRUE, if the new default server configuration is successfully set.DEF_FALSE, otherwise.
Notes / Warnings#
None.
SNTPc_ReqRemoteTime()#
Description#
Send a request to an NTP server and receive an SNTPc packet to compute.
Files#
sntp_client.h/sntp_client.c
Prototype#
void SNTPc_ReqRemoteTime (CPU_CHAR *hostname,
SNTP_PKT *p_pkt,
RTOS_ERR *p_err)Arguments#
hostname
String that contains the NTP server hostname.
p_pkt
Pointer to an SNTP_PKT variable that will contain the received SNTPc packet.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
RTOS_ERR_NONERTOS_ERR_INVALID_TYPERTOS_ERR_NET_RETRY_MAXRTOS_ERR_NET_SOCK_CLOSEDRTOS_ERR_BLK_ALLOC_CALLBACKRTOS_ERR_SEG_OVFRTOS_ERR_NOT_SUPPORTEDRTOS_ERR_NET_CONN_CLOSE_RXRTOS_ERR_OS_SCHED_LOCKEDRTOS_ERR_NOT_AVAILRTOS_ERR_FAILRTOS_ERR_NET_INVALID_ADDR_SRCRTOS_ERR_WOULD_OVFRTOS_ERR_NET_IF_LINK_DOWNRTOS_ERR_CODE_GET(err_rtnRTOS_ERR_INVALID_HANDLERTOS_ERR_WOULD_BLOCKRTOS_ERR_INVALID_STATERTOS_ERR_ABORTRTOS_ERR_TIMEOUTRTOS_ERR_NET_OP_IN_PROGRESSRTOS_ERR_TXRTOS_ERR_NOT_FOUNDRTOS_ERR_ALREADY_EXISTSRTOS_ERR_CODE_GET(local_errRTOS_ERR_NET_INVALID_CONNRTOS_ERR_NET_STR_ADDR_INVALIDRTOS_ERR_NOT_READYRTOS_ERR_POOL_EMPTYRTOS_ERR_OS_OBJ_DELRTOS_ERR_NET_ADDR_UNRESOLVEDRTOS_ERR_NET_NEXT_HOPRTOS_ERR_NET_CONN_CLOSED_FAULT
Returned Value#
None.
Notes / Warnings#
None.
SNTPc_GetRemoteTime()#
Description#
Gets the remote time (NTP timestamp) from a received NTP packet.
Files#
sntp_client.h/sntp_client.c
Prototype#
SNTP_TS SNTPc_GetRemoteTime (SNTP_PKT *p_pkt,
RTOS_ERR *p_err)Arguments#
p_pkt
Pointer to received SNTP message packet.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
RTOS_ERR_NONE
Returned Value#
NTP timestamp.
Notes / Warnings#
None.
SNTPc_GetRoundTripDly_us()#
Description#
Gets SNTP packet round trip delay from a received SNTP message packet.
Files#
sntp_client.h/sntp_client.c
Prototype#
CPU_INT32U SNTPc_GetRoundTripDly_us (SNTP_PKT *p_pkt,
RTOS_ERR *p_err)Arguments#
p_kt
Pointer to received SNTP message packet.
p_err
Pointer to the variable that will receive one of the following error code(s) from this function:
RTOS_ERR_NONE
Returned Value#
SNTP packet round trip delay in microseconds.
Notes / Warnings#
If the round trip delay is faster than the precision of the system clock, then the round trip delay is approximated to 0.
Only the integer part of the round trip delay is returned.