7 #include "pico/stdlib.h"
8 #include "pico/cyw43_arch.h"
11 #include "lwip/pbuf.h"
14 #define NTP_SERVER "pool.ntp.org"
15 #define NTP_MSG_LEN 48
17 #define NTP_DELTA 2208988800
18 #define NTP_TEST_TIME (30 * 1000)
19 #define NTP_RESEND_TIME (10 * 1000)
24 extern volatile struct tm *
utc;
84 static void ntp_dns_found(
const char *hostname,
const ip_addr_t *ipaddr,
void *arg);
95 static void ntp_recv(
void *arg,
struct udp_pcb *pcb,
struct pbuf *p,
const ip_addr_t *addr, u16_t port);
static void ntp_result(NTP_T *state, int status, time_t *result)
NTP result.
static int64_t ntp_failed_handler(alarm_id_t id, void *user_data)
NTP failed handler.
static void ntp_dns_found(const char *hostname, const ip_addr_t *ipaddr, void *arg)
NTP DNS found.
void ntp_deinit(void)
NTP deinit.
static void ntp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
NTP recv.
volatile struct tm * current_utc
UTC time struct.
static NTP_T * ntp_init(void)
NTP init.
struct NTP_T_ NTP_T
NTP struct.
volatile struct tm * utc
UTC time struct.
static void ntp_request(NTP_T *state)
NTP request.
void ntp_update_time(void)
NTP update time.
ip_addr_t ntp_server_address
absolute_time_t ntp_test_time
alarm_id_t ntp_resend_alarm