NTP improvements
This commit is contained in:
22
src/main.cpp
22
src/main.cpp
@@ -29,8 +29,7 @@
|
||||
#include "RestartReason.h"
|
||||
#include "EspMillis.h"
|
||||
#include "NimBLEDevice.h"
|
||||
#include <time.h>
|
||||
#include "esp_sntp.h"
|
||||
#include "esp_netif_sntp.h"
|
||||
|
||||
/*
|
||||
#ifdef DEBUG_NUKIHUB
|
||||
@@ -827,9 +826,22 @@ void setup()
|
||||
|
||||
if(preferences->getBool(preference_update_time, false))
|
||||
{
|
||||
sntp_set_sync_interval(12 * 60 * 60 * 1000UL);
|
||||
sntp_set_time_sync_notification_cb(cbSyncTime);
|
||||
configTime(0, 0, "pool.ntp.org");
|
||||
esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG(preferences->getString(preference_time_server, "pool.ntp.org").c_str());
|
||||
config.start = false;
|
||||
config.server_from_dhcp = true;
|
||||
config.renew_servers_after_new_IP = true;
|
||||
config.index_of_first_server = 1;
|
||||
|
||||
if (network->networkDeviceType() == NetworkDeviceType::WiFi)
|
||||
{
|
||||
config.ip_event_to_renew = IP_EVENT_STA_GOT_IP;
|
||||
}
|
||||
else
|
||||
{
|
||||
config.ip_event_to_renew = IP_EVENT_ETH_GOT_IP;
|
||||
}
|
||||
config.sync_cb = cbSyncTime;
|
||||
esp_netif_sntp_init(&config);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user