Merge pull request #76 from atlej68/dev-1.3.0-test

dev-1.3.0-testing: Timezone for esp32 and minor domoticz fix.
This commit is contained in:
Gunnar Skjold
2020-05-22 17:22:54 +02:00
committed by GitHub
3 changed files with 31 additions and 42 deletions

View File

@@ -22,7 +22,19 @@
#include <ArduinoJson.h>
#include <MQTT.h>
#include <DNSServer.h>
// Tz.h does not exist for esp32, need to include time.h, timezone offsets to be given given in sec.
#define NTP_SERVER "pool.ntp.org" // put your local NTP server here
#if defined(ESP8266)
#include <TZ.h>
#define MYTZ TZ_Europe_Oslo
#elif defined(ESP32)
#include <time.h>
#define TZ 1 // (utc+) TZ in hours
#define DST_MN 60 // use 60mn for summer time in some countries
#define GMT_OFFSET_SEC 3600 * TZ // Do not change here...
#define DAYLIGHT_OFFSET_SEC 60 * DST_MN // Do not change here...
#endif
#if defined(ESP8266)
ADC_MODE(ADC_VCC);
@@ -232,7 +244,11 @@ void setup() {
if(config.hasConfig()) {
if(Debug.isActive(RemoteDebug::INFO)) config.print(&Debug);
WiFi_connect();
configTime(TZ_Europe_Oslo, "pool.ntp.org");
#if defined(ESP8266)
configTime(MYTZ, NTP_SERVER);
#elif defined(ESP32)
configTime(GMT_OFFSET_SEC, DAYLIGHT_OFFSET_SEC, NTP_SERVER);
#endif
//sntp_servermode_dhcp(0); // 0: disable obtaining SNTP servers from DHCP (enabled by default)
} else {
if(Debug.isActive(RemoteDebug::INFO)) {