Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
SNTP client module. More...
Go to the source code of this file.
Functions | |
static PACK_STRUCT_END void | sntp_request (void *arg) |
Send out an sntp request. | |
static void | sntp_process (const struct sntp_timestamps *timestamps) |
SNTP processing of received timestamp. | |
static void | sntp_initialize_request (struct sntp_msg *req) |
Initialize request struct to be sent to server. | |
static void | sntp_retry (void *arg) |
Retry: send a new request (and increase retry timeout). | |
static void | sntp_try_next_server (void *arg) |
If Kiss-of-Death is received (or another packet parsing error), try the next server or retry the current server and increase the retry timeout if only one server is available. | |
static void | sntp_recv (void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) |
UDP recv callback for the sntp pcb. | |
static void | sntp_send_request (const ip_addr_t *server_addr) |
Actually send an sntp request to a server. | |
static void | sntp_dns_found (const char *hostname, const ip_addr_t *ipaddr, void *arg) |
DNS found callback when using DNS names as server address. | |
void | sntp_init (void) |
Initialize this module. | |
void | sntp_stop (void) |
Stop this module. | |
u8_t | sntp_enabled (void) |
Get enabled state. | |
void | sntp_setoperatingmode (u8_t operating_mode) |
Sets the operating mode. | |
u8_t | sntp_getoperatingmode (void) |
Gets the operating mode. | |
u8_t | sntp_getreachability (u8_t idx) |
Gets the server reachability shift register as described in RFC 5905. | |
void | sntp_servermode_dhcp (int set_servers_from_dhcp) |
Config SNTP server handling by IP address, name, or DHCP; clear table. | |
void | sntp_setserver (u8_t idx, const ip_addr_t *server) |
Initialize one of the NTP servers by IP address. | |
void | dhcp_set_ntp_servers (u8_t num, const ip4_addr_t *server) |
Initialize one of the NTP servers by IP address, required by DHCP. | |
const ip_addr_t * | sntp_getserver (u8_t idx) |
Obtain one of the currently configured by IP address (or DHCP) NTP servers. | |
void | sntp_setservername (u8_t idx, const char *server) |
Initialize one of the NTP servers by name. | |
const char * | sntp_getservername (u8_t idx) |
Obtain one of the currently configured by name NTP servers. | |
Variables | |
static u8_t | sntp_opmode |
The operating mode. | |
static struct udp_pcb * | sntp_pcb |
The UDP pcb used by the SNTP client. | |
static u8_t | sntp_current_server |
The currently used server (initialized to 0) | |
static u32_t | sntp_retry_timeout |
Retry time, initialized with SNTP_RETRY_TIMEOUT and doubled with each retry. | |
static ip_addr_t | sntp_last_server_address |
Saves the last server address to compare with response. | |
static struct sntp_time | sntp_last_timestamp_sent |
Saves the last timestamp sent (which is sent back by the server) to compare against in response. |
Detailed Description
SNTP client module.
Definition in file lwip_sntp.c.
Function Documentation
void dhcp_set_ntp_servers | ( | u8_t | num, |
const ip4_addr_t * | server | ||
) |
Initialize one of the NTP servers by IP address, required by DHCP.
This function must exist, in other to add offered NTP servers to the NTP (or SNTP) engine.
- Parameters:
-
num the index of the NTP server to set must be < SNTP_MAX_SERVERS server IP address of the NTP server to set
Definition at line 800 of file lwip_sntp.c.
static void sntp_dns_found | ( | const char * | hostname, |
const ip_addr_t * | ipaddr, | ||
void * | arg | ||
) | [static] |
DNS found callback when using DNS names as server address.
Definition at line 579 of file lwip_sntp.c.
const char* sntp_getservername | ( | u8_t | idx ) |
Obtain one of the currently configured by name NTP servers.
- Parameters:
-
idx the index of the NTP server
- Returns:
- IP address of the indexed NTP server or NULL if the NTP server has not been configured by name (or at all)
Definition at line 860 of file lwip_sntp.c.
static void sntp_initialize_request | ( | struct sntp_msg * | req ) | [static] |
Initialize request struct to be sent to server.
Definition at line 336 of file lwip_sntp.c.
static void sntp_process | ( | const struct sntp_timestamps * | timestamps ) | [static] |
SNTP processing of received timestamp.
Definition at line 286 of file lwip_sntp.c.
static void sntp_recv | ( | void * | arg, |
struct udp_pcb * | pcb, | ||
struct pbuf * | p, | ||
const ip_addr_t * | addr, | ||
u16_t | port | ||
) | [static] |
UDP recv callback for the sntp pcb.
Definition at line 436 of file lwip_sntp.c.
static void sntp_request | ( | void * | arg ) | [static] |
Send out an sntp request.
- Parameters:
-
arg is unused (only necessary to conform to sys_timeout)
Definition at line 603 of file lwip_sntp.c.
static void sntp_retry | ( | void * | arg ) | [static] |
Retry: send a new request (and increase retry timeout).
- Parameters:
-
arg is unused (only necessary to conform to sys_timeout)
Definition at line 366 of file lwip_sntp.c.
static void sntp_send_request | ( | const ip_addr_t * | server_addr ) | [static] |
Actually send an sntp request to a server.
- Parameters:
-
server_addr resolved IP address of the SNTP server
Definition at line 540 of file lwip_sntp.c.
void sntp_servermode_dhcp | ( | int | set_servers_from_dhcp ) |
Config SNTP server handling by IP address, name, or DHCP; clear table.
- Parameters:
-
set_servers_from_dhcp enable or disable getting server addresses from dhcp
Definition at line 759 of file lwip_sntp.c.
void sntp_setservername | ( | u8_t | idx, |
const char * | server | ||
) |
Initialize one of the NTP servers by name.
- Parameters:
-
idx the index of the NTP server to set must be < SNTP_MAX_SERVERS server DNS name of the NTP server to set, to be resolved at contact time
Definition at line 844 of file lwip_sntp.c.
static void sntp_try_next_server | ( | void * | arg ) | [static] |
If Kiss-of-Death is received (or another packet parsing error), try the next server or retry the current server and increase the retry timeout if only one server is available.
(implicitly, SNTP_MAX_SERVERS > 1)
- Parameters:
-
arg is unused (only necessary to conform to sys_timeout)
Definition at line 400 of file lwip_sntp.c.
Variable Documentation
u8_t sntp_current_server [static] |
The currently used server (initialized to 0)
Definition at line 246 of file lwip_sntp.c.
ip_addr_t sntp_last_server_address [static] |
Saves the last server address to compare with response.
Definition at line 262 of file lwip_sntp.c.
struct sntp_time sntp_last_timestamp_sent [static] |
Saves the last timestamp sent (which is sent back by the server) to compare against in response.
Stored in network byte order.
Definition at line 268 of file lwip_sntp.c.
u8_t sntp_opmode [static] |
The operating mode.
Definition at line 224 of file lwip_sntp.c.
The UDP pcb used by the SNTP client.
Definition at line 227 of file lwip_sntp.c.
u32_t sntp_retry_timeout [static] |
Retry time, initialized with SNTP_RETRY_TIMEOUT and doubled with each retry.
Definition at line 254 of file lwip_sntp.c.
Generated on Tue Jul 12 2022 13:55:15 by
