From e79a0585f07dc8b54ff8df26aaf4ebd15482f055 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Fri, 28 Aug 2020 19:58:33 +0200 Subject: [PATCH] Some changes during testing --- src/AmsConfiguration.cpp | 2 ++ src/AmsToMqttBridge.ino | 22 +++++++++++----------- src/web/AmsWebServer.cpp | 5 +++++ web/ntp.html | 2 +- web/temperature_none.html | 1 + 5 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 web/temperature_none.html diff --git a/src/AmsConfiguration.cpp b/src/AmsConfiguration.cpp index 184f80d2..4682ce98 100644 --- a/src/AmsConfiguration.cpp +++ b/src/AmsConfiguration.cpp @@ -1005,6 +1005,7 @@ void AmsConfiguration::print(Print* debugger) debugger->printf("fuseSize: %i\r\n", this->getMainFuse()); debugger->printf("productionCapacity: %i\r\n", this->getProductionCapacity()); debugger->printf("Substitute missing: %s\r\n", this->isSubstituteMissing() ? "Yes" : "No"); + Serial.flush(); debugger->printf("HAN pin: %i\r\n", this->getHanPin()); debugger->printf("LED pin: %i\r\n", this->getLedPin()); @@ -1015,6 +1016,7 @@ void AmsConfiguration::print(Print* debugger) debugger->printf("LED inverted: %s\r\n", this->isLedRgbInverted() ? "Yes" : "No"); debugger->printf("AP pin: %i\r\n", this->getApPin()); debugger->printf("Temperature pin: %i\r\n", this->getTempSensorPin()); + Serial.flush(); debugger->printf("Vcc pin: %i\r\n", this->getVccPin()); debugger->printf("Vcc multiplier: %f\r\n", this->getVccMultiplier()); diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 5662958f..cc5c7883 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -158,14 +158,6 @@ void setup() { #endif } - uint8_t c = config.getTempSensorCount(); - for(int i = 0; i < c; i++) { - TempSensorConfig* tsc = config.getTempSensorConfig(i); - hw.confTempSensor(tsc->address, tsc->name, tsc->common); - Debug.print("Sensor name: "); - Debug.println(tsc->name); - } - double vcc = hw.getVcc(); if (Debug.isActive(RemoteDebug::INFO)) { @@ -255,11 +247,11 @@ void setup() { if(config.hasConfig()) { if(Debug.isActive(RemoteDebug::INFO)) config.print(&Debug); + WiFi_connect(); if(config.isNtpEnable()) { configTime(config.getNtpOffset(), config.getNtpSummerOffset(), config.getNtpServer()); sntp_servermode_dhcp(config.isNtpDhcp() ? 1 : 0); } - WiFi_connect(); } else { if(Debug.isActive(RemoteDebug::INFO)) { debugI("No configuration, booting AP"); @@ -389,8 +381,12 @@ void loop() { debugI("IP: %s", WiFi.localIP().toString().c_str()); } if(strlen(config.getWifiHostname()) > 0 && config.isMdnsEnable()) { - MDNS.begin(config.getWifiHostname()); - MDNS.addService("http", "tcp", 80); + debugD("mDNS is enabled, using host: %s", config.getWifiHostname()); + if(MDNS.begin(config.getWifiHostname())) { + MDNS.addService("http", "tcp", 80); + } else { + debugE("Failed to set up mDNS!"); + } } } if(config.isNtpChanged()) { @@ -911,6 +907,10 @@ void WiFi_connect() { dns1.fromString(config.getWifiDns1()); dns2.fromString(config.getWifiDns2()); WiFi.config(ip, gw, sn, dns1, dns2); + } else { +#if defined(ESP32) + WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); // Workaround to make DHCP hostname work for ESP32 +#endif } if(strlen(config.getWifiHostname()) > 0) { #if defined(ESP8266) diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index 9d6a8816..4862cfd7 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -24,6 +24,7 @@ #include "root/reset_html.h" #include "root/temperature_head_html.h" #include "root/temperature_row_html.h" +#include "root/temperature_none_html.h" #include "root/temperature_foot_html.h" #include "base64.h" @@ -151,6 +152,10 @@ void AmsWebServer::temperature() { html += row; } + if(c == 0) { + html += String((const __FlashStringHelper*) TEMPERATURE_NONE_HTML); + } + if(start > 0 || end < c) { html += "
"; if(start > 0) { diff --git a/web/ntp.html b/web/ntp.html index 5428708d..232a1985 100644 --- a/web/ntp.html +++ b/web/ntp.html @@ -4,7 +4,7 @@
NTP
-
+
Timezone diff --git a/web/temperature_none.html b/web/temperature_none.html new file mode 100644 index 00000000..e03e50d3 --- /dev/null +++ b/web/temperature_none.html @@ -0,0 +1 @@ +
No temperature sensors is configured or found
\ No newline at end of file