![]() |
Pico Led Controller 1.0.3
A project to control LEDs using Raspberry Pi Pico W
|
#include <string.h>#include <time.h>#include "pico/stdlib.h"#include "pico/cyw43_arch.h"#include "lwip/dns.h"#include "lwip/pbuf.h"#include "lwip/udp.h"Go to the source code of this file.
Data Structures | |
| struct | NTP_T_ |
| NTP struct. More... | |
Macros | |
| #define | NTP_SERVER "pool.ntp.org" |
| #define | NTP_MSG_LEN 48 |
| #define | NTP_PORT 123 |
| #define | NTP_DELTA 2208988800 |
| #define | NTP_TEST_TIME (30 * 1000) |
| #define | NTP_RESEND_TIME (10 * 1000) |
Typedefs | |
| typedef struct NTP_T_ | NTP_T |
| NTP struct. | |
Functions | |
| 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_request (NTP_T *state) |
| NTP request. | |
| static void | ntp_dns_found (const char *hostname, const ip_addr_t *ipaddr, void *arg) |
| NTP DNS found. | |
| static void | ntp_recv (void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) |
| NTP recv. | |
| static NTP_T * | ntp_init (void) |
| NTP init. | |
| void | ntp_deinit (void) |
| NTP deinit. | |
| void | ntp_update_time (void) |
| NTP update time. | |
Variables | |
| volatile struct tm * | utc |
| UTC time struct. | |
| volatile struct tm * | current_utc |
| UTC time struct. | |
| void ntp_deinit | ( | void | ) |
|
static |
NTP DNS found.
Function handles the NTP DNS found.
| hostname | hostname |
| ipaddr | IP address |
| arg | argument |
|
static |
NTP failed handler.
NTP DNS found.
Function handles the NTP failed handler.
| id | alarm ID |
| user_data | user data |
Function handles the NTP DNS found.
| hostname | hostname |
| ipaddr | IP address |
| arg | argument |
|
static |
NTP init.
Function initializes the NTP.
|
static |
NTP recv.
Function receives the NTP response.
| arg | argument |
| pcb | UDP PCB |
| p | pbuf |
| addr | IP address |
| port | port |
|
static |
NTP request.
Function sends the NTP request.
| state | NTP state |
|
static |
NTP result.
Function handles the NTP result.
| state | NTP state |
| status | status |
| result | result |
| void ntp_update_time | ( | void | ) |
NTP update time.
Function updates the NTP time.
Definition at line 123 of file ntp.c.
References NTP_T_::dns_request_sent, ntp_dns_found(), ntp_failed_handler(), ntp_init(), ntp_request(), NTP_T_::ntp_resend_alarm, NTP_RESEND_TIME, ntp_result(), NTP_SERVER, NTP_T_::ntp_server_address, and NTP_T_::ntp_test_time.
Referenced by init().
|
extern |
UTC time struct.
Struct for the last checked UTC time.
Definition at line 14 of file ntp.c.
Referenced by ntp_result().
|
extern |
UTC time struct.
Struct for the UTC time of program start.
Definition at line 13 of file ntp.c.
Referenced by ntp_deinit(), ntp_result(), and ssi_handler().