Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
|
|
4.1.99 |
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 *ts) |
Perform SNTP query. | |
int | sntp_recv_response (struct sntp_ctx *ctx, uint32_t timeout, struct sntp_time *ts) |
Attempt to receive an SNTP response after issuing a query. | |
void | sntp_close (struct sntp_ctx *ctx) |
Release SNTP context. | |
int | sntp_init_async (struct sntp_ctx *ctx, struct sockaddr *addr, socklen_t addr_len, const struct net_socket_service_desc *service) |
Initialise SNTP context for async operation. | |
int | sntp_send_async (struct sntp_ctx *ctx) |
Send the SNTP query. | |
int | sntp_read_async (struct net_socket_service_event *event, struct sntp_time *ts) |
Read the result of the SNTP query. | |
void | sntp_close_async (const struct net_socket_service_desc *service) |
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 | ) |
void sntp_close_async | ( | const struct net_socket_service_desc * | service | ) |
#include <zephyr/net/sntp.h>
Release SNTP context.
service | Socket service defined by NET_SOCKET_SERVICE_SYNC_DEFINE |
#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. |
int sntp_init_async | ( | struct sntp_ctx * | ctx, |
struct sockaddr * | addr, | ||
socklen_t | addr_len, | ||
const struct net_socket_service_desc * | service ) |
#include <zephyr/net/sntp.h>
Initialise SNTP context for async operation.
Asynchronous operation is powered by CONFIG_NET_SOCKETS_SERVICE
.
ctx | Address of sntp context. |
addr | IP address of NTP/SNTP server. |
addr_len | IP address length of NTP/SNTP server. |
service | Socket service defined by NET_SOCKET_SERVICE_SYNC_DEFINE |
#include <zephyr/net/sntp.h>
Perform SNTP query.
ctx | Address of sntp context. |
timeout | Timeout of waiting for sntp response (in milliseconds). |
ts | Timestamp including integer and fractional seconds since 1 Jan 1970 (output). |
int sntp_read_async | ( | struct net_socket_service_event * | event, |
struct sntp_time * | ts ) |
#include <zephyr/net/sntp.h>
Read the result of the SNTP query.
Must be called from the callback attached to the net_socket_service_desc context.
event | Event pointer extracted from the service work callback |
ts | Timestamp including integer and fractional seconds since 1 Jan 1970 (output). |
#include <zephyr/net/sntp.h>
Attempt to receive an SNTP response after issuing a query.
ctx | Address of sntp context. |
timeout | Timeout of waiting for sntp response (in milliseconds). |
ts | Timestamp including integer and fractional seconds since 1 Jan 1970 (output). |
int sntp_send_async | ( | struct sntp_ctx * | ctx | ) |
#include <zephyr/net/sntp.h>
Send the SNTP query.
ctx | Address of sntp context. |
#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). |