removed timezone, handled via JS

This commit is contained in:
Paul
2019-08-20 19:02:01 +02:00
parent 2e54c48dc4
commit 2aae90b7cf
6 changed files with 25 additions and 33 deletions

View File

@@ -97,7 +97,6 @@ MyESP::MyESP() {
_ntp_server = strdup(MYESP_NTP_SERVER);
;
_ntp_interval = 60;
_ntp_timezone = 1;
_ntp_enabled = false;
// get the build time
@@ -232,7 +231,7 @@ void MyESP::_wifiCallback(justwifi_messages_t code, char * parameter) {
// NTP now that we have a WiFi connection
if (_ntp_enabled) {
NTP.Ntp(_ntp_server, _ntp_timezone, _ntp_interval * 60); // set up NTP server
NTP.Ntp(_ntp_server, _ntp_interval); // set up NTP server
myDebug_P(PSTR("[NTP] NTP internet time enabled via server %s"), _ntp_server);
}
@@ -1626,14 +1625,13 @@ bool MyESP::_fs_loadConfig() {
_mqtt_user = strdup(mqtt["user"] | "");
_mqtt_port = mqtt["port"] | MQTT_PORT;
_mqtt_password = strdup(mqtt["password"] | "");
_mqtt_base = strdup(mqtt["base"] | "");
_mqtt_base = strdup(mqtt["base"] | MQTT_BASE_DEFAULT);
JsonObject ntp = doc["ntp"];
_ntp_server = strdup(ntp["server"] | "");
_ntp_interval = ntp["interval"] | 60;
if (_ntp_interval == 0)
_ntp_interval = 60;
_ntp_timezone = ntp["timezone"] | 0;
_ntp_enabled = ntp["enabled"];
myDebug_P(PSTR("[FS] System settings loaded"));
@@ -1800,7 +1798,6 @@ bool MyESP::_fs_writeConfig() {
JsonObject ntp = doc.createNestedObject("ntp");
ntp["server"] = _ntp_server;
ntp["interval"] = _ntp_interval;
ntp["timezone"] = _ntp_timezone;
ntp["enabled"] = _ntp_enabled;
bool ok = fs_saveConfig(root); // save it
@@ -2695,7 +2692,6 @@ void MyESP::_sendTime() {
JsonObject root = doc.to<JsonObject>();
root["command"] = "gettime";
root["epoch"] = now();
root["timezone"] = _ntp_timezone;
char buffer[100];
size_t len = serializeJson(root, buffer);
@@ -2742,7 +2738,7 @@ void MyESP::_bootupSequence() {
// write a log message if we're not using NTP, otherwise wait for the internet time to arrive
if (!_ntp_enabled) {
_writeEvent("INFO", "sys", "System booted", "(elapsed time shown)");
_writeEvent("INFO", "sys", "System booted", "");
}
}
}

View File

@@ -78,6 +78,7 @@ extern struct rst_info resetInfo;
#define MQTT_TOPIC_RESTART "restart"
#define MQTT_WILL_ONLINE_PAYLOAD "online" // for last will & testament payload
#define MQTT_WILL_OFFLINE_PAYLOAD "offline" // for last will & testament payload
#define MQTT_BASE_DEFAULT "home" // default MQTT prefix to topics
#define MQTT_RETAIN false
#define MQTT_KEEPALIVE 60 // 1 minute
#define MQTT_QOS 1
@@ -457,7 +458,6 @@ class MyESP {
void _webResetAllPage();
// ntp
uint8_t _ntp_timezone;
char * _ntp_server;
uint8_t _ntp_interval;
bool _ntp_enabled;

View File

@@ -5,17 +5,14 @@
#include "Ntp.h"
char * NtpClient::TimeServerName;
int8_t NtpClient::timezone;
time_t NtpClient::syncInterval;
IPAddress NtpClient::timeServer;
AsyncUDP NtpClient::udpListener;
byte NtpClient::NTPpacket[NTP_PACKET_SIZE];
void ICACHE_FLASH_ATTR NtpClient::Ntp(const char * server, int8_t tz, time_t syncSecs) {
void ICACHE_FLASH_ATTR NtpClient::Ntp(const char * server, time_t syncMins) {
TimeServerName = strdup(server);
timezone = tz;
syncInterval = syncSecs;
syncInterval = syncMins * 60; // convert to seconds
WiFi.hostByName(TimeServerName, timeServer);
setSyncProvider(getNtpTime);
setSyncInterval(syncInterval);

View File

@@ -16,12 +16,11 @@
class NtpClient {
public:
void ICACHE_FLASH_ATTR Ntp(const char * server, int8_t tz, time_t syncSecs);
void ICACHE_FLASH_ATTR Ntp(const char * server, time_t syncMins);
ICACHE_FLASH_ATTR virtual ~NtpClient();
static char * TimeServerName;
static IPAddress timeServer;
static int8_t timezone;
static time_t syncInterval;
static AsyncUDP udpListener;

View File

@@ -1,6 +1,6 @@
#define APP_NAME "EMS-ESP"
#define APP_VERSION "1.9.0b3"
#define APP_VERSION "1.9.0b4"
#define APP_HOSTNAME "ems-esp"
#define APP_URL "https://github.com/proddy/EMS-ESP"
#define APP_UPDATEURL "https://api.github.com/repos/proddy/EMS-ESP/releases/latest"