mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-27 10:40:45 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcbfe4d96f | ||
|
|
b4f18de030 | ||
|
|
00d5d215cd | ||
|
|
8de5a58a6b | ||
|
|
012794e682 |
@@ -4,7 +4,7 @@ extra_configs = platformio-user.ini
|
|||||||
|
|
||||||
[common]
|
[common]
|
||||||
framework = arduino
|
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]
|
[env:hw1esp12e]
|
||||||
platform = espressif8266@2.5.1
|
platform = espressif8266@2.5.1
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
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"
|
webroot = "web"
|
||||||
srcroot = "src/web/root"
|
srcroot = "src/web/root"
|
||||||
@@ -27,12 +32,15 @@ for filename in os.listdir(webroot):
|
|||||||
with open(srcfile, encoding="utf-8") as f:
|
with open(srcfile, encoding="utf-8") as f:
|
||||||
content = f.read().replace("${version}", version)
|
content = f.read().replace("${version}", version)
|
||||||
|
|
||||||
if filename.endswith(".html"):
|
try:
|
||||||
content = html_minify(content)
|
if filename.endswith(".html"):
|
||||||
elif filename.endswith(".css"):
|
content = html_minify(content)
|
||||||
content = css_minify(content)
|
elif filename.endswith(".css"):
|
||||||
elif filename.endswith(".js") and filename != 'gaugemeter.js':
|
content = css_minify(content)
|
||||||
content = js_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:
|
with open(dstfile, "w") as dst:
|
||||||
dst.write("const char ")
|
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;
|
l2voltage = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL2)) / 10;
|
||||||
l3voltage = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL3)) / 10;
|
l3voltage = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL3)) / 10;
|
||||||
if(substituteMissing) {
|
if(substituteMissing) {
|
||||||
l2current = ((activeImportPower * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ void AmsData::extractFromKamstrup(HanReader& hanReader, int listSize, bool subst
|
|||||||
l2voltage = hanReader.getInt( (int)Kamstrup_List3Phase::VoltageL2);
|
l2voltage = hanReader.getInt( (int)Kamstrup_List3Phase::VoltageL2);
|
||||||
l3voltage = hanReader.getInt( (int)Kamstrup_List3Phase::VoltageL3);
|
l3voltage = hanReader.getInt( (int)Kamstrup_List3Phase::VoltageL3);
|
||||||
if(substituteMissing) {
|
if(substituteMissing) {
|
||||||
l2current = ((activeImportPower * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "root/delete_html.h"
|
#include "root/delete_html.h"
|
||||||
#include "root/reset_html.h"
|
#include "root/reset_html.h"
|
||||||
|
|
||||||
#include "Base64.h"
|
#include "base64.h"
|
||||||
|
|
||||||
AmsWebServer::AmsWebServer(RemoteDebug* Debug, HwTools* hw) {
|
AmsWebServer::AmsWebServer(RemoteDebug* Debug, HwTools* hw) {
|
||||||
this->debugger = Debug;
|
this->debugger = Debug;
|
||||||
@@ -97,15 +97,9 @@ bool AmsWebServer::checkSecurity(byte level) {
|
|||||||
|
|
||||||
String providedPwd = server.header("Authorization");
|
String providedPwd = server.header("Authorization");
|
||||||
providedPwd.replace("Basic ", "");
|
providedPwd.replace("Basic ", "");
|
||||||
char inputString[providedPwd.length()];
|
|
||||||
providedPwd.toCharArray(inputString, providedPwd.length()+1);
|
|
||||||
|
|
||||||
int inputStringLength = sizeof(inputString);
|
String expectedBase64 = base64::encode(expectedAuth);
|
||||||
int decodedLength = Base64.decodedLength(inputString, inputStringLength);
|
access = providedPwd.equals(expectedBase64);
|
||||||
char decodedString[decodedLength];
|
|
||||||
Base64.decode(decodedString, inputString, inputStringLength);
|
|
||||||
printD("Received auth: %s", decodedString);
|
|
||||||
access = String(decodedString).equals(expectedAuth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!access) {
|
if(!access) {
|
||||||
|
|||||||
Reference in New Issue
Block a user