Browse Source

Option to build without NTP support

fastled
Xose Pérez 7 years ago
parent
commit
ce907eb2ee
12 changed files with 3004 additions and 2977 deletions
  1. +1
    -1
      code/espurna/config/all.h
  2. +1
    -0
      code/espurna/config/arduino.h
  3. +6
    -0
      code/espurna/config/general.h
  4. +0
    -1
      code/espurna/config/prototypes.h
  5. BIN
      code/espurna/data/index.html.gz
  6. +12
    -5
      code/espurna/espurna.ino
  7. +3
    -1
      code/espurna/mqtt.ino
  8. +4
    -0
      code/espurna/ntp.ino
  9. +2954
    -2953
      code/espurna/static/index.html.gz.h
  10. +17
    -12
      code/espurna/web.ino
  11. +5
    -3
      code/espurna/wifi.ino
  12. +1
    -1
      code/html/index.html

+ 1
- 1
code/espurna/config/all.h View File

@ -1,9 +1,9 @@
#include "version.h" #include "version.h"
#include "arduino.h" #include "arduino.h"
#include "prototypes.h"
#include "hardware.h" #include "hardware.h"
#include "general.h" #include "general.h"
#include "sensors.h" #include "sensors.h"
#include "prototypes.h"
/* /*
If you want to modify the stock configuration but you don't want to touch If you want to modify the stock configuration but you don't want to touch


+ 1
- 0
code/espurna/config/arduino.h View File

@ -56,6 +56,7 @@
//#define INFLUXDB_SUPPORT 0 //#define INFLUXDB_SUPPORT 0
//#define MDNS_SUPPORT 0 //#define MDNS_SUPPORT 0
//#define NOFUSS_SUPPORT 1 //#define NOFUSS_SUPPORT 1
//#define NTP_SUPPORT 0
//#define RF_SUPPORT 1 //#define RF_SUPPORT 1
//#define SPIFFS_SUPPORT 1 //#define SPIFFS_SUPPORT 1
//#define TERMINAL_SUPPORT 0 //#define TERMINAL_SUPPORT 0


+ 6
- 0
code/espurna/config/general.h View File

@ -285,7 +285,9 @@ PROGMEM const char* const custom_reset_string[] = {
// MDNS // MDNS
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef MDNS_SUPPORT
#define MDNS_SUPPORT 1 // Enable MDNS by default #define MDNS_SUPPORT 1 // Enable MDNS by default
#endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// SPIFFS // SPIFFS
@ -455,6 +457,10 @@ PROGMEM const char* const custom_reset_string[] = {
// NTP // NTP
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef NTP_SUPPORT
#define NTP_SUPPORT 1 // Build with NTP support by default
#endif
#define NTP_SERVER "pool.ntp.org" // Default NTP server #define NTP_SERVER "pool.ntp.org" // Default NTP server
#define NTP_TIME_OFFSET 1 // Default timezone offset (GMT+1) #define NTP_TIME_OFFSET 1 // Default timezone offset (GMT+1)
#define NTP_DAY_LIGHT true // Enable daylight time saving by default #define NTP_DAY_LIGHT true // Enable daylight time saving by default


+ 0
- 1
code/espurna/config/prototypes.h View File

@ -1,5 +1,4 @@
#include <Arduino.h> #include <Arduino.h>
#include <functional>
#include <NtpClientLib.h> #include <NtpClientLib.h>
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
#include <AsyncMqttClient.h> #include <AsyncMqttClient.h>


BIN
code/espurna/data/index.html.gz View File


+ 12
- 5
code/espurna/espurna.ino View File

@ -42,7 +42,10 @@ void heartbeat() {
unsigned long uptime_seconds = uptime_overflows * (UPTIME_OVERFLOW / 1000) + (last_uptime / 1000); unsigned long uptime_seconds = uptime_overflows * (UPTIME_OVERFLOW / 1000) + (last_uptime / 1000);
unsigned int free_heap = ESP.getFreeHeap(); unsigned int free_heap = ESP.getFreeHeap();
DEBUG_MSG_P(PSTR("[MAIN] Time: %s\n"), (char *) ntpDateTime().c_str());
#if NTP_SUPPORT
DEBUG_MSG_P(PSTR("[MAIN] Time: %s\n"), (char *) ntpDateTime().c_str());
#endif
if (!mqttConnected()) { if (!mqttConnected()) {
DEBUG_MSG_P(PSTR("[MAIN] Uptime: %ld seconds\n"), uptime_seconds); DEBUG_MSG_P(PSTR("[MAIN] Uptime: %ld seconds\n"), uptime_seconds);
DEBUG_MSG_P(PSTR("[MAIN] Free heap: %d bytes\n"), free_heap); DEBUG_MSG_P(PSTR("[MAIN] Free heap: %d bytes\n"), free_heap);
@ -123,9 +126,9 @@ void hardwareSetup() {
#if DEBUG_SERIAL_SUPPORT #if DEBUG_SERIAL_SUPPORT
DEBUG_PORT.begin(SERIAL_BAUDRATE); DEBUG_PORT.begin(SERIAL_BAUDRATE);
if (customReset() == CUSTOM_RESET_HARDWARE) {
#if DEBUG_ESP_WIFI
DEBUG_PORT.setDebugOutput(true); DEBUG_PORT.setDebugOutput(true);
}
#endif
#elif defined(SERIAL_BAUDRATE) #elif defined(SERIAL_BAUDRATE)
Serial.begin(SERIAL_BAUDRATE); Serial.begin(SERIAL_BAUDRATE);
#endif #endif
@ -242,12 +245,14 @@ void setup() {
wifiSetup(); wifiSetup();
otaSetup(); otaSetup();
mqttSetup(); mqttSetup();
ntpSetup();
#ifdef ITEAD_SONOFF_RFBRIDGE #ifdef ITEAD_SONOFF_RFBRIDGE
rfbSetup(); rfbSetup();
#endif #endif
#if NTP_SUPPORT
ntpSetup();
#endif
#if I2C_SUPPORT #if I2C_SUPPORT
i2cSetup(); i2cSetup();
#endif #endif
@ -296,12 +301,14 @@ void loop() {
wifiLoop(); wifiLoop();
otaLoop(); otaLoop();
mqttLoop(); mqttLoop();
ntpLoop();
#ifdef ITEAD_SONOFF_RFBRIDGE #ifdef ITEAD_SONOFF_RFBRIDGE
rfbLoop(); rfbLoop();
#endif #endif
#if NTP_SUPPORT
ntpLoop();
#endif
#if TERMINAL_SUPPORT #if TERMINAL_SUPPORT
settingsLoop(); settingsLoop();
#endif #endif


+ 3
- 1
code/espurna/mqtt.ino View File

@ -91,7 +91,9 @@ void _mqttFlush() {
mqtt_message_t element = _mqtt_queue[i]; mqtt_message_t element = _mqtt_queue[i];
root[element.topic] = element.message; root[element.topic] = element.message;
} }
if (ntpConnected()) root[MQTT_TOPIC_TIME] = ntpDateTime();
#if NTP_SUPPORT
if (ntpConnected()) root[MQTT_TOPIC_TIME] = ntpDateTime();
#endif
root[MQTT_TOPIC_HOSTNAME] = getSetting("hostname"); root[MQTT_TOPIC_HOSTNAME] = getSetting("hostname");
root[MQTT_TOPIC_IP] = getIP(); root[MQTT_TOPIC_IP] = getIP();


+ 4
- 0
code/espurna/ntp.ino View File

@ -6,6 +6,8 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
*/ */
#if NTP_SUPPORT
#include <TimeLib.h> #include <TimeLib.h>
#include <NtpClientLib.h> #include <NtpClientLib.h>
#include <WiFiClient.h> #include <WiFiClient.h>
@ -66,3 +68,5 @@ void ntpSetup() {
void ntpLoop() { void ntpLoop() {
now(); now();
} }
#endif // NTP_SUPPORT

+ 2954
- 2953
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 17
- 12
code/espurna/web.ino View File

@ -18,12 +18,12 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
#if WEB_EMBEDDED #if WEB_EMBEDDED
#include "static/index.html.gz.h" #include "static/index.html.gz.h"
#endif
#endif // WEB_EMBEDDED
#if ASYNC_TCP_SSL_ENABLED & WEB_SSL_ENABLED #if ASYNC_TCP_SSL_ENABLED & WEB_SSL_ENABLED
#include "static/server.cer.h" #include "static/server.cer.h"
#include "static/server.key.h" #include "static/server.key.h"
#endif
#endif // ASYNC_TCP_SSL_ENABLED & WEB_SSL_ENABLED
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -302,7 +302,9 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
setSetting(key, value); setSetting(key, value);
save = changed = true; save = changed = true;
if (key.startsWith("mqtt")) changedMQTT = true; if (key.startsWith("mqtt")) changedMQTT = true;
if (key.startsWith("ntp")) changedNTP = true;
#if NTP_SUPPORT
if (key.startsWith("ntp")) changedNTP = true;
#endif
} }
} }
@ -369,9 +371,9 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
} }
// Check if we should reconfigure NTP connection // Check if we should reconfigure NTP connection
if (changedNTP) {
ntpConnect();
}
#if NTP_SUPPORT
if (changedNTP) ntpConnect();
#endif
} }
@ -420,12 +422,15 @@ void _wsStart(uint32_t client_id) {
root["network"] = getNetwork(); root["network"] = getNetwork();
root["deviceip"] = getIP(); root["deviceip"] = getIP();
root["ntpStatus"] = ntpConnected();
root["ntpServer1"] = getSetting("ntpServer1", NTP_SERVER);
root["ntpServer2"] = getSetting("ntpServer2");
root["ntpServer3"] = getSetting("ntpServer3");
root["ntpOffset"] = getSetting("ntpOffset", NTP_TIME_OFFSET).toInt();
root["ntpDST"] = getSetting("ntpDST", NTP_DAY_LIGHT).toInt() == 1;
#if NTP_SUPPORT
root["ntpVisible"] = 1;
root["ntpStatus"] = ntpConnected();
root["ntpServer1"] = getSetting("ntpServer1", NTP_SERVER);
root["ntpServer2"] = getSetting("ntpServer2");
root["ntpServer3"] = getSetting("ntpServer3");
root["ntpOffset"] = getSetting("ntpOffset", NTP_TIME_OFFSET).toInt();
root["ntpDST"] = getSetting("ntpDST", NTP_DAY_LIGHT).toInt() == 1;
#endif
root["mqttStatus"] = mqttConnected(); root["mqttStatus"] = mqttConnected();
root["mqttServer"] = getSetting("mqttServer", MQTT_SERVER); root["mqttServer"] = getSetting("mqttServer", MQTT_SERVER);


+ 5
- 3
code/espurna/wifi.ino View File

@ -236,9 +236,11 @@ void wifiSetup() {
#endif #endif
// NTP connection reset // NTP connection reset
if (code == MESSAGE_CONNECTED) {
ntpConnect();
}
#if NTP_SUPPORT
if (code == MESSAGE_CONNECTED) {
ntpConnect();
}
#endif
// Manage POW // Manage POW
#if HLW8012_SUPPORT #if HLW8012_SUPPORT


+ 1
- 1
code/html/index.html View File

@ -99,7 +99,7 @@
<a href="#" class="pure-menu-link" data="panel-mqtt">MQTT</a> <a href="#" class="pure-menu-link" data="panel-mqtt">MQTT</a>
</li> </li>
<li class="pure-menu-item">
<li class="pure-menu-item module module-ntp">
<a href="#" class="pure-menu-link" data="panel-ntp">NTP</a> <a href="#" class="pure-menu-link" data="panel-ntp">NTP</a>
</li> </li>


Loading…
Cancel
Save