Include Files
Wherever you want to use µC/SNTPc, you should include the following header:
Include file | Description |
---|---|
Source/sntp-c.h | Contains SNTPc API definitions |
Module initialization
µC/SNTPc does not require to be initialized. Although, if you want to use the µC/DNSc or µC/CLK features , make sure those modules are properly initialized.
Get time from NTP server
To retrieve the time from a ntp server, SNTPc_ReqRemoteTime must be call first. This will return a SNTP packet that can be computed by the function SNTPc_GetRemoteTime to retrieve the correct time. Since the SNTP packet is only use to know the offset between the local and the server NTP time, there is no time requierement for
Function name | Description |
---|---|
SNTPc_ReqRemoteTime() | Transmit a SNTP request to a NTP server and receive the answer. Return the SNTP packet received. |
SNTPc_GetRemoteTime() | From a SNTP packet, compute the time in NTP format. |
SNTPc_GetRoundTripDly_us() | From a SNTP packet, compute round trip delay in us. |
Shell reference
Prerequisite
µC/TCP-IP command module.
Include Files
Wherever you want to use initialize the command in µC/Shell, you should include the following header:
Include file | Description |
---|---|
Cmd/sntp-c_cmd.h | Contains SNTPc Command definitions |
API
Function name | Description |
---|---|
SNTPcCmd_Init() | Function to load SNTP client command into shell. |
Command reference
Command | Description | Argument | Usage example |
---|---|---|---|
sntp_get | Request time from a SNTP server. | -4 <ipv4_address> (use IPv4 server address) -6 <ipv6_address> (use IPv6 server address) -d <domain_name> (use Domain name to get server address) | sntp_get -d sntp.server.com |
sntp_help | Print help | none | sntp_help |