mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Add NTPSERVERS to user_config_override.h
This commit is contained in:
parent
6cc646a93f
commit
e459583df1
@ -53,6 +53,9 @@
|
|||||||
/***************************************************
|
/***************************************************
|
||||||
* Timezone Settings
|
* Timezone Settings
|
||||||
**************************************************/
|
**************************************************/
|
||||||
|
#define NTPSERVER1 "pool.ntp.org"
|
||||||
|
#define NTPSERVER2 "time.nist.gov"
|
||||||
|
#define NTPSERVER3 "time.google.com"
|
||||||
#define MYTZ \
|
#define MYTZ \
|
||||||
"CET-1CEST,M3.5.0,M10.5.0/3" // A full list with possible timezones can be found here
|
"CET-1CEST,M3.5.0,M10.5.0/3" // A full list with possible timezones can be found here
|
||||||
// https://gist.github.com/alwynallan/24d96091655391107939
|
// https://gist.github.com/alwynallan/24d96091655391107939
|
||||||
|
@ -15,16 +15,40 @@
|
|||||||
#include "hasp/hasp.h"
|
#include "hasp/hasp.h"
|
||||||
#include "sys/svc/hasp_mdns.h"
|
#include "sys/svc/hasp_mdns.h"
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
#include "Preferences.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MYTZ
|
#ifndef MYTZ
|
||||||
#define MYTZ "EST5EDT,M3.2.0/2,M11.1.0"
|
#define MYTZ "EST5EDT,M3.2.0/2,M11.1.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NTPSERVER1
|
||||||
|
#define NTPSERVER1 "pool.ntp.org"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NTPSERVER2
|
||||||
|
#define NTPSERVER2 "time.nist.gov"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NTPSERVER3
|
||||||
|
#define NTPSERVER3 "time.google.com"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
// These strings must be constant and kept in memory
|
||||||
|
String mytz((char*)0);
|
||||||
|
String ntp1((char*)0);
|
||||||
|
String ntp2((char*)0);
|
||||||
|
String ntp3((char*)0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_ETHERNET > 0 || HASP_USE_WIFI > 0
|
#if HASP_USE_ETHERNET > 0 || HASP_USE_WIFI > 0
|
||||||
void networkStart(void)
|
void networkStart(void)
|
||||||
{
|
{
|
||||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
LOG_WARNING(TAG_MAIN, F("TIMEZONE: %s"), MYTZ);
|
LOG_WARNING(TAG_MAIN, F("TIMEZONE: %s"), MYTZ);
|
||||||
configTzTime(MYTZ, "pool.ntp.org", "time.nist.gov", NULL); // literal string
|
configTzTime(MYTZ, NTPSERVER1, NTPSERVER2, NTPSERVER3); // literal string
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// haspProgressVal(255); // hide
|
// haspProgressVal(255); // hide
|
||||||
@ -36,6 +60,7 @@ void networkStart(void)
|
|||||||
httpStart();
|
httpStart();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_MDNS > 0
|
#if HASP_USE_MDNS > 0
|
||||||
mdnsStart();
|
mdnsStart();
|
||||||
#endif // HASP_USE_MDNS
|
#endif // HASP_USE_MDNS
|
||||||
@ -50,6 +75,7 @@ void networkStop(void)
|
|||||||
#if HASP_USE_HTTP > 0 || HASP_USE_HTTP_ASYNC > 0
|
#if HASP_USE_HTTP > 0 || HASP_USE_HTTP_ASYNC > 0
|
||||||
httpStop();
|
httpStop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_MDNS > 0
|
#if HASP_USE_MDNS > 0
|
||||||
mdnsStop();
|
mdnsStop();
|
||||||
#endif
|
#endif
|
||||||
@ -57,6 +83,22 @@ void networkStop(void)
|
|||||||
|
|
||||||
void networkSetup()
|
void networkSetup()
|
||||||
{
|
{
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
Preferences preferences;
|
||||||
|
preferences.begin("time", false);
|
||||||
|
|
||||||
|
mytz = preferences.getString("tz", MYTZ);
|
||||||
|
ntp1 = preferences.getString("ntp1", NTPSERVER1);
|
||||||
|
ntp2 = preferences.getString("ntp2", NTPSERVER2);
|
||||||
|
ntp3 = preferences.getString("ntp3", NTPSERVER3);
|
||||||
|
|
||||||
|
LOG_WARNING(TAG_MAIN, F("TIMEZONE: %s"), mytz.c_str());
|
||||||
|
LOG_WARNING(TAG_MAIN, F("NTPSERVER: %s %s %s"), ntp1.c_str(), ntp2.c_str(), ntp3.c_str());
|
||||||
|
|
||||||
|
configTzTime(mytz.c_str(), ntp1.c_str(), ntp2.c_str(), ntp3.c_str());
|
||||||
|
preferences.end();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HASP_USE_ETHERNET > 0
|
#if HASP_USE_ETHERNET > 0
|
||||||
ethernetSetup();
|
ethernetSetup();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user