diff --git a/platformio.ini b/platformio.ini index a4987a50..4b403457 100755 --- a/platformio.ini +++ b/platformio.ini @@ -4,7 +4,7 @@ extra_configs = platformio-user.ini [common] framework = arduino -lib_deps = HanReader@1.0.1, ArduinoJson@6.14.1, MQTT@2.4.7, DallasTemperature@3.8.1, EspSoftwareSerial@6.7.1, Base64@1.0.0, RemoteDebug@3.0.5, Time@1.6, NTPClient@3.1.0 +lib_deps = HanReader@1.0.1, ArduinoJson@6.14.1, MQTT@2.4.7, DallasTemperature@3.8.1, EspSoftwareSerial@6.7.1, Base64@1.0.0, RemoteDebug@3.0.5, Time@1.6 [env:hw1esp12e] platform = espressif8266@2.3.3 diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 688f1a53..8516d27e 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -22,7 +22,7 @@ #include #include #include -#include +#include #if defined(ESP8266) ADC_MODE(ADC_VCC); @@ -48,9 +48,6 @@ HwTools hw; DNSServer dnsServer; -WiFiUDP ntpUDP; -NTPClient timeClient(ntpUDP, "pool.ntp.org", 3600, 60000); - AmsConfiguration config; RemoteDebug Debug; @@ -235,7 +232,8 @@ void setup() { if(config.hasConfig()) { if(Debug.isActive(RemoteDebug::INFO)) config.print(&Debug); WiFi_connect(); - timeClient.begin(); + configTime(TZ_Europe_Oslo, "pool.ntp.org"); + //sntp_servermode_dhcp(0); // 0: disable obtaining SNTP servers from DHCP (enabled by default) } else { if(Debug.isActive(RemoteDebug::INFO)) { debugI("No configuration, booting AP"); @@ -327,8 +325,6 @@ void loop() { errorBlink(); } - timeClient.update(); - if (strlen(config.getMqttHost()) > 0) { mqtt.loop(); delay(10); // Needed to preserve power. After adding this, the voltage is super smooth on a HAN powered device @@ -840,8 +836,6 @@ void MQTT_connect() { if(config.isMqttSsl()) { debugI("MQTT SSL is configured"); - if(!timeClient.update()) debugW("NTP time is not ready"); - secureClient = new WiFiClientSecure(); #if defined(ESP8266) secureClient->setBufferSizes(512, 512); @@ -881,8 +875,9 @@ void MQTT_connect() { #if defined(ESP8266) if(secureClient) { - debugD("Setting NTP time for secure MQTT connection"); - secureClient->setX509Time(timeClient.getEpochTime()); + time_t epoch = time(nullptr); + debugD("Setting NTP time %i for secure MQTT connection", epoch); + secureClient->setX509Time(epoch); } #endif diff --git a/web/application.js b/web/application.js index c8cd5d8b..07178a51 100644 --- a/web/application.js +++ b/web/application.js @@ -69,6 +69,12 @@ $(function() { $('#authSecurity').trigger('change'); + // For file upload + $('#fileUploadField').on('change',function(){ + var fileName = $(this).val(); + $(this).next('.custom-file-label').html(fileName); + }) + switch(window.location.pathname) { case '/config-meter': $('#config-meter-link').addClass('active'); diff --git a/web/foot.html b/web/foot.html index 775a564c..84288e50 100644 --- a/web/foot.html +++ b/web/foot.html @@ -2,6 +2,8 @@ + + diff --git a/web/upload.html b/web/upload.html index a7e34af9..4b95147b 100644 --- a/web/upload.html +++ b/web/upload.html @@ -7,16 +7,10 @@ Upload
- - + +
-