mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-14 14:24:34 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcbfe4d96f | ||
|
|
b4f18de030 | ||
|
|
00d5d215cd | ||
|
|
8de5a58a6b | ||
|
|
012794e682 | ||
|
|
38eb2d8c19 |
@@ -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
|
||||
lib_deps = HanReader@1.0.1, ArduinoJson@6.14.1, MQTT@2.4.7, DallasTemperature@3.8.1, EspSoftwareSerial@6.7.1, RemoteDebug@3.0.5, Time@1.6
|
||||
|
||||
[env:hw1esp12e]
|
||||
platform = espressif8266@2.5.1
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from css_html_js_minify import html_minify, js_minify, css_minify
|
||||
|
||||
try:
|
||||
from css_html_js_minify import html_minify, js_minify, css_minify
|
||||
except:
|
||||
print("WARN: Unable to load minifier")
|
||||
|
||||
|
||||
webroot = "web"
|
||||
srcroot = "src/web/root"
|
||||
@@ -26,13 +31,16 @@ for filename in os.listdir(webroot):
|
||||
|
||||
with open(srcfile, encoding="utf-8") as f:
|
||||
content = f.read().replace("${version}", version)
|
||||
|
||||
if filename.endswith(".html"):
|
||||
content = html_minify(content)
|
||||
elif filename.endswith(".css"):
|
||||
content = css_minify(content)
|
||||
elif filename.endswith(".js") and filename != 'gaugemeter.js':
|
||||
content = js_minify(content)
|
||||
|
||||
try:
|
||||
if filename.endswith(".html"):
|
||||
content = html_minify(content)
|
||||
elif filename.endswith(".css"):
|
||||
content = css_minify(content)
|
||||
elif filename.endswith(".js") and filename != 'gaugemeter.js':
|
||||
content = js_minify(content)
|
||||
except:
|
||||
print("WARN: Unable to minify")
|
||||
|
||||
with open(dstfile, "w") as dst:
|
||||
dst.write("const char ")
|
||||
|
||||
@@ -169,7 +169,7 @@ void AmsData::extractFromAidon(HanReader& hanReader, int listSize, bool substitu
|
||||
l2voltage = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL2)) / 10;
|
||||
l3voltage = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL3)) / 10;
|
||||
if(substituteMissing) {
|
||||
l2current = ((activeImportPower * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ void AmsData::extractFromKamstrup(HanReader& hanReader, int listSize, bool subst
|
||||
l2voltage = hanReader.getInt( (int)Kamstrup_List3Phase::VoltageL2);
|
||||
l3voltage = hanReader.getInt( (int)Kamstrup_List3Phase::VoltageL3);
|
||||
if(substituteMissing) {
|
||||
l2current = ((activeImportPower * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "root/delete_html.h"
|
||||
#include "root/reset_html.h"
|
||||
|
||||
#include "Base64.h"
|
||||
#include "base64.h"
|
||||
|
||||
AmsWebServer::AmsWebServer(RemoteDebug* Debug, HwTools* hw) {
|
||||
this->debugger = Debug;
|
||||
@@ -97,15 +97,9 @@ bool AmsWebServer::checkSecurity(byte level) {
|
||||
|
||||
String providedPwd = server.header("Authorization");
|
||||
providedPwd.replace("Basic ", "");
|
||||
char inputString[providedPwd.length()];
|
||||
providedPwd.toCharArray(inputString, providedPwd.length()+1);
|
||||
|
||||
int inputStringLength = sizeof(inputString);
|
||||
int decodedLength = Base64.decodedLength(inputString, inputStringLength);
|
||||
char decodedString[decodedLength];
|
||||
Base64.decode(decodedString, inputString, inputStringLength);
|
||||
printD("Received auth: %s", decodedString);
|
||||
access = String(decodedString).equals(expectedAuth);
|
||||
String expectedBase64 = base64::encode(expectedAuth);
|
||||
access = providedPwd.equals(expectedBase64);
|
||||
}
|
||||
|
||||
if(!access) {
|
||||
|
||||
Reference in New Issue
Block a user