Zephyr API Documentation
3.7.0
A Scalable Open Source RTOS
|
Simple Network Time Protocol API. More...
Data Structures | |
struct | sntp_time |
Time as returned by SNTP API, fractional seconds since 1 Jan 1970. More... | |
struct | sntp_ctx |
SNTP context. More... | |
Functions | |
int | sntp_init (struct sntp_ctx *ctx, struct sockaddr *addr, socklen_t addr_len) |
Initialize SNTP context. | |
int | sntp_query (struct sntp_ctx *ctx, uint32_t timeout, struct sntp_time *time) |
Perform SNTP query. | |
void | sntp_close (struct sntp_ctx *ctx) |
Release SNTP context. | |
int | sntp_simple (const char *server, uint32_t timeout, struct sntp_time *ts) |
Convenience function to query SNTP in one-shot fashion. | |
int | sntp_simple_addr (struct sockaddr *addr, socklen_t addr_len, uint32_t timeout, struct sntp_time *ts) |
Convenience function to query SNTP in one-shot fashion using a pre-initialized address struct. | |
Simple Network Time Protocol API.
void sntp_close | ( | struct sntp_ctx * | ctx | ) |
#include <zephyr/net/sntp.h>
Initialize SNTP context.
ctx | Address of sntp context. |
addr | IP address of NTP/SNTP server. |
addr_len | IP address length of NTP/SNTP server. |
#include <zephyr/net/sntp.h>
Perform SNTP query.
ctx | Address of sntp context. |
timeout | Timeout of waiting for sntp response (in milliseconds). |
time | Timestamp including integer and fractional seconds since 1 Jan 1970 (output). |
#include <zephyr/net/sntp.h>
Convenience function to query SNTP in one-shot fashion.
Convenience wrapper which calls getaddrinfo(), sntp_init(), sntp_query(), and sntp_close().
server | Address of server in format addr[:port] |
timeout | Query timeout |
ts | Timestamp including integer and fractional seconds since 1 Jan 1970 (output). |
int sntp_simple_addr | ( | struct sockaddr * | addr, |
socklen_t | addr_len, | ||
uint32_t | timeout, | ||
struct sntp_time * | ts | ||
) |
#include <zephyr/net/sntp.h>
Convenience function to query SNTP in one-shot fashion using a pre-initialized address struct.
Convenience wrapper which calls sntp_init(), sntp_query() and sntp_close().
addr | IP address of NTP/SNTP server. |
addr_len | IP address length of NTP/SNTP server. |
timeout | Query timeout |
ts | Timestamp including integer and fractional seconds since 1 Jan 1970 (output). |