mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-29 03:14:58 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f5af6b274 | ||
|
|
7886ce668e | ||
|
|
0f4848c872 | ||
|
|
6911d203ca | ||
|
|
e96b5bbf1b |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -15,12 +15,10 @@ jobs:
|
|||||||
- name: Check out code from repo
|
- name: Check out code from repo
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
- name: Get release version for filenames
|
- name: Get release version for filenames
|
||||||
id: release_tag
|
|
||||||
env:
|
env:
|
||||||
GITHUB_REF: ${{ github.ref }}
|
GITHUB_REF: ${{ github.ref }}
|
||||||
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
|
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
|
||||||
- name: Get release version for code
|
- name: Get release version for code
|
||||||
id: release_tag
|
|
||||||
env:
|
env:
|
||||||
GITHUB_REF: ${{ github.ref }}
|
GITHUB_REF: ${{ github.ref }}
|
||||||
run: echo ::set-env name=GITHUB_TAG::$(echo ${GITHUB_REF##*/})
|
run: echo ::set-env name=GITHUB_TAG::$(echo ${GITHUB_REF##*/})
|
||||||
|
|||||||
@@ -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
|
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]
|
[env:hw1esp12e]
|
||||||
platform = espressif8266@2.3.3
|
platform = espressif8266@2.3.3
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ void setup() {
|
|||||||
if(config.hasConfig()) {
|
if(config.hasConfig()) {
|
||||||
config.load();
|
config.load();
|
||||||
}
|
}
|
||||||
#if DEBUG_MODE
|
|
||||||
#if HW_ROARFRED
|
#if HW_ROARFRED
|
||||||
if(config.getMeterType() == 3) {
|
if(config.getMeterType() == 3) {
|
||||||
Serial.begin(2400, SERIAL_8N1);
|
Serial.begin(2400, SERIAL_8N1);
|
||||||
@@ -70,21 +69,12 @@ void setup() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(config.hasConfig()) {
|
if(config.hasConfig() && config.isDebugSerial()) {
|
||||||
Debug.begin(config.getWifiHostname(), (uint8_t) config.getDebugLevel());
|
|
||||||
if(config.getAuthSecurity() > 0) {
|
|
||||||
Debug.setPassword(config.getAuthPassword());
|
|
||||||
}
|
|
||||||
Debug.setSerialEnabled(config.isDebugSerial());
|
Debug.setSerialEnabled(config.isDebugSerial());
|
||||||
if(!config.isDebugTelnet()) {
|
|
||||||
Debug.stop();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
#if DEBUG_MODE
|
#if DEBUG_MODE
|
||||||
Debug.begin("localhost", RemoteDebug::DEBUG);
|
|
||||||
Debug.setSerialEnabled(true);
|
Debug.setSerialEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -96,7 +86,7 @@ void setup() {
|
|||||||
debugI("Voltage: %.2fV", vcc);
|
debugI("Voltage: %.2fV", vcc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vcc > 0 && vcc < 3.1) {
|
if (vcc > 2.5 && vcc < 3.25) { // Only sleep if voltage is realistic and too low
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) {
|
if(Debug.isActive(RemoteDebug::INFO)) {
|
||||||
debugI("Votltage is too low, sleeping");
|
debugI("Votltage is too low, sleeping");
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
@@ -119,7 +109,16 @@ void setup() {
|
|||||||
WiFi.softAPdisconnect(true);
|
WiFi.softAPdisconnect(true);
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
|
|
||||||
if(SPIFFS.begin()) {
|
bool spiffs = false;
|
||||||
|
#if defined(ESP32)
|
||||||
|
debugD("ESP32 SPIFFS");
|
||||||
|
spiffs = SPIFFS.begin(true);
|
||||||
|
#else
|
||||||
|
debugD("ESP8266 SPIFFS");
|
||||||
|
spiffs = SPIFFS.begin();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(spiffs) {
|
||||||
bool flashed = false;
|
bool flashed = false;
|
||||||
if(SPIFFS.exists("/firmware.bin")) {
|
if(SPIFFS.exists("/firmware.bin")) {
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) debugI("Found firmware");
|
if(Debug.isActive(RemoteDebug::INFO)) debugI("Found firmware");
|
||||||
@@ -297,10 +296,18 @@ void loop() {
|
|||||||
|
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
wifiConnected = false;
|
wifiConnected = false;
|
||||||
|
Debug.stop();
|
||||||
WiFi_connect();
|
WiFi_connect();
|
||||||
} else {
|
} else {
|
||||||
if(!wifiConnected) {
|
if(!wifiConnected) {
|
||||||
wifiConnected = true;
|
wifiConnected = true;
|
||||||
|
if(config.getAuthSecurity() > 0) {
|
||||||
|
Debug.setPassword(config.getAuthPassword());
|
||||||
|
}
|
||||||
|
Debug.begin(config.getWifiHostname(), (uint8_t) config.getDebugLevel());
|
||||||
|
if(!config.isDebugTelnet()) {
|
||||||
|
Debug.stop();
|
||||||
|
}
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) {
|
if(Debug.isActive(RemoteDebug::INFO)) {
|
||||||
debugI("Successfully connected to WiFi!");
|
debugI("Successfully connected to WiFi!");
|
||||||
debugI("IP: %s", WiFi.localIP().toString().c_str());
|
debugI("IP: %s", WiFi.localIP().toString().c_str());
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
#include "HwTools.h"
|
#include "HwTools.h"
|
||||||
|
|
||||||
double HwTools::getVcc() {
|
double HwTools::getVcc() {
|
||||||
|
double volts = 0.0;
|
||||||
#if defined(ARDUINO_ESP8266_WEMOS_D1MINI)
|
#if defined(ARDUINO_ESP8266_WEMOS_D1MINI)
|
||||||
return (((double) ESP.getVcc()) / 900); // This board has a voltage divider on VCC. Yes, 900 is correct
|
volts = (((double) ESP.getVcc()) / 900.0); // This board has a voltage divider on VCC.
|
||||||
|
#elif defined(ARDUINO_LOLIN_D32)
|
||||||
|
volts = (analogRead(GPIO_NUM_35) / 4095.0) * 3.3 * 2.25; // We are actually reading battery voltage here
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
#if defined(ESP_VCC_CALIB_FACTOR)
|
volts = ((double) ESP.getVcc()) / 1024.0;
|
||||||
return ((double) ESP.getVcc()) / 1024 * ESP_VCC_CALIB_FACTOR;
|
#endif
|
||||||
#else
|
|
||||||
return ((double) ESP.getVcc()) / 1024;
|
#if defined(ESP_VCC_CALIB_FACTOR)
|
||||||
#endif
|
return volts * ESP_VCC_CALIB_FACTOR;
|
||||||
|
#else
|
||||||
|
return volts;
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double HwTools::getTemperature() {
|
double HwTools::getTemperature() {
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ public:
|
|||||||
int getWifiRssi();
|
int getWifiRssi();
|
||||||
|
|
||||||
HwTools() {
|
HwTools() {
|
||||||
|
#if defined(ARDUINO_LOLIN_D32)
|
||||||
|
pinMode(GPIO_NUM_35, INPUT);
|
||||||
|
#endif
|
||||||
oneWire = new OneWire(TEMP_SENSOR_PIN);
|
oneWire = new OneWire(TEMP_SENSOR_PIN);
|
||||||
tempSensor = new DallasTemperature(this->oneWire);
|
tempSensor = new DallasTemperature(this->oneWire);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -248,6 +248,9 @@ void AmsWebServer::configMqttHtml() {
|
|||||||
html.replace("${config.mqttUser}", config->getMqttUser());
|
html.replace("${config.mqttUser}", config->getMqttUser());
|
||||||
html.replace("${config.mqttPassword}", config->getMqttPassword());
|
html.replace("${config.mqttPassword}", config->getMqttPassword());
|
||||||
html.replace("${config.mqttPayloadFormat}", String(config->getMqttPayloadFormat()));
|
html.replace("${config.mqttPayloadFormat}", String(config->getMqttPayloadFormat()));
|
||||||
|
for(int i = 0; i<2; i++) {
|
||||||
|
html.replace("${config.mqttPayloadFormat" + String(i) + "}", config->getMqttPayloadFormat() == i ? "selected" : "");
|
||||||
|
}
|
||||||
|
|
||||||
server.setContentLength(html.length());
|
server.setContentLength(html.length());
|
||||||
server.send(200, "text/html", html);
|
server.send(200, "text/html", html);
|
||||||
@@ -496,7 +499,9 @@ void AmsWebServer::handleSave() {
|
|||||||
if(config->getAuthSecurity() > 0) {
|
if(config->getAuthSecurity() > 0) {
|
||||||
config->setAuthUser(server.arg("authUser"));
|
config->setAuthUser(server.arg("authUser"));
|
||||||
config->setAuthPassword(server.arg("authPassword"));
|
config->setAuthPassword(server.arg("authPassword"));
|
||||||
|
debugger->setPassword(config->getAuthPassword());
|
||||||
} else {
|
} else {
|
||||||
|
debugger->setPassword("");
|
||||||
config->clearAuth();
|
config->clearAuth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -505,12 +510,15 @@ void AmsWebServer::handleSave() {
|
|||||||
config->setDebugTelnet(server.hasArg("debugTelnet") && server.arg("debugTelnet") == "true");
|
config->setDebugTelnet(server.hasArg("debugTelnet") && server.arg("debugTelnet") == "true");
|
||||||
config->setDebugSerial(server.hasArg("debugSerial") && server.arg("debugSerial") == "true");
|
config->setDebugSerial(server.hasArg("debugSerial") && server.arg("debugSerial") == "true");
|
||||||
config->setDebugLevel(server.arg("debugLevel").toInt());
|
config->setDebugLevel(server.arg("debugLevel").toInt());
|
||||||
|
|
||||||
debugger->stop();
|
debugger->stop();
|
||||||
debugger->begin(config->getWifiHostname(), (uint8_t) config->getDebugLevel());
|
|
||||||
if(config->getAuthSecurity() > 0) {
|
if(config->getAuthSecurity() > 0) {
|
||||||
debugger->setPassword(config->getAuthPassword());
|
debugger->setPassword(config->getAuthPassword());
|
||||||
|
} else {
|
||||||
|
debugger->setPassword("");
|
||||||
}
|
}
|
||||||
debugger->setSerialEnabled(config->isDebugSerial());
|
debugger->setSerialEnabled(config->isDebugSerial());
|
||||||
|
debugger->begin(config->getWifiHostname(), (uint8_t) config->getDebugLevel());
|
||||||
if(!config->isDebugTelnet()) {
|
if(!config->isDebugTelnet()) {
|
||||||
debugger->stop();
|
debugger->stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
<form method="post" action="/save">
|
<form method="post" action="/save">
|
||||||
<input type="hidden" name="sysConfig" value="true"/>
|
<input type="hidden" name="sysConfig" value="true"/>
|
||||||
<div class="my-3 p-3 bg-white rounded shadow">
|
<div class="my-3 p-3 bg-white rounded shadow">
|
||||||
|
<div class="alert alert-warning">!!WARNING!!<br/>Remote debugging is considered insecure and should not be left enabled when not debugging</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label><input type="checkbox" name="debugTelnet" value="true" ${config.debugTelnet}/> Telnet debugger</label>
|
<label><input type="checkbox" name="debugTelnet" value="true" ${config.debugTelnet}/> Telnet debugger</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user