The clock set from the home network. See wifi_ntp.h.
More...
#include "wifi_ntp.h"
#include <stdint.h>
#include <sys/time.h>
#include "esp_log.h"
#include "esp_netif_sntp.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "wall_clock.h"
|
| static int64_t | wall_now_us (void) |
| | The system time.
|
| static void | on_sync (struct timeval *tv) |
| | The answer, on the TCP/IP task, after lwIP has set the clock: the old clock is the one at the start carried on by esp_timer, which the step does not move.
|
|
static void | ntp_start (void) |
| | Start the client, which asks at once (no start-up delay, CONFIG_LWIP_SNTP_STARTUP_DELAY off).
|
|
static void | ntp_end (void) |
| | Stop the client; nothing when it never started.
|
| bool | wifi_ntp_poll (bool joined, bool lingers) |
| | Move the request on: start it on a join, log and end it on an answer or the time-out, end it when the join ends.
|
|
void | wifi_ntp_stop (void) |
| | End the request before the network interface goes: what wifi_ntp_poll(false, false) does, an answer that came first logged.
|
|
|
static const char * | TAG = "clock" |
| | The console tag of the clock's lines.
|
|
static portMUX_TYPE | s_mux = portMUX_INITIALIZER_UNLOCKED |
| | Guards the answer between the TCP/IP task and the worker.
|
|
static bool | s_answered |
| | An answer has set the clock since the start.
|
|
static int64_t | s_new_us |
| | The time the answer set, microseconds since 1970 UTC.
|
|
static int64_t | s_old_us |
| | The old clock at the answer, microseconds since 1970 UTC.
|
|
static wall_ntp_t | s_req |
| | This join's request (wall_clock.h).
|
|
static bool | s_running |
| | esp_netif_sntp_init() succeeded and no deinit followed.
|
|
static int64_t | s_base_wall_us |
| | The clock at the start, microseconds since 1970 UTC.
|
|
static int64_t | s_base_mono_us |
| | esp_timer at the start, microseconds since boot.
|
The clock set from the home network. See wifi_ntp.h.
SPDX-License-Identifier: MIT
◆ on_sync()
| void on_sync |
( |
struct timeval * | tv | ) |
|
|
static |
The answer, on the TCP/IP task, after lwIP has set the clock: the old clock is the one at the start carried on by esp_timer, which the step does not move.
- Parameters
-
| tv | The time the answer set. |
◆ wall_now_us()
| int64_t wall_now_us |
( |
void | | ) |
|
|
static |
The system time.
- Returns
- Microseconds since 1970-01-01 UTC.
◆ wifi_ntp_poll()
| bool wifi_ntp_poll |
( |
bool | joined, |
|
|
bool | lingers ) |
Move the request on: start it on a join, log and end it on an answer or the time-out, end it when the join ends.
- Parameters
-
| joined | The session holds an address on the home network. |
| lingers | The session ended joined, its radio still up, and lets the radio stay up (wa_lingers()). |
- Returns
- Whether the radio stays up for the request (wall_ntp_holds()).