- Replace C function pointers with C++ `std::function` in `Thread`, `Timer` and `DispatcherThread` - Rename `SystemEvent`-related functions - WiFi: fix auto-connect when WiFi disconnects from bad signal - WiFi: fix auto-connect when WiFi fails to auto-connect - WiFi: implement disconnect() when tapping connected WiFi ap in WiFi management app
35 lines
631 B
C++
35 lines
631 B
C++
#include "Tactility/network/NtpPrivate.h"
|
|
|
|
#ifdef ESP_PLATFORM
|
|
#include <Tactility/kernel/SystemEvents.h>
|
|
#include <Tactility/TactilityCore.h>
|
|
#include <esp_netif_sntp.h>
|
|
#include <esp_sntp.h>
|
|
#endif
|
|
|
|
#define TAG "ntp"
|
|
|
|
namespace tt::network::ntp {
|
|
|
|
#ifdef ESP_PLATFORM
|
|
|
|
static void onTimeSynced(struct timeval* tv) {
|
|
TT_LOG_I(TAG, "Time synced (%llu)", tv->tv_sec);
|
|
kernel::publishSystemEvent(kernel::SystemEvent::Time);
|
|
}
|
|
|
|
void init() {
|
|
esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG("pool.ntp.org");
|
|
config.sync_cb = onTimeSynced;
|
|
esp_netif_sntp_init(&config);
|
|
}
|
|
|
|
#else
|
|
|
|
void init() {
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|