From 72bdb6e36345b476e36c710d5546c5715cc29779 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Mon, 1 Nov 2021 07:14:54 +0100 Subject: [PATCH 1/3] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++ .github/ISSUE_TEMPLATE/support.md | 22 +++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/support.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..cb00daca --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Report a bug +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Hardware information:** + - Meter: [e.g. Aidon] + - AMS reader: [e.g. Pow-U, ESP32 etc] + - M-bus adapter (if applicable): + +**Relevant firmware information:** + - Version: [e.g. 1.5.0] + - MQTT: [yes/no] + - HAN GPIO: [e.g. GPIO5] + - Temperature sensors [e.g. 3xDS18B20] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..bbcbbe7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/support.md b/.github/ISSUE_TEMPLATE/support.md new file mode 100644 index 00000000..981cfa37 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support.md @@ -0,0 +1,22 @@ +--- +name: Support +about: Request support +title: '' +labels: '' +assignees: '' + +--- + +**Describe your problem** +A clear and concise description of what the problem is. + +**Hardware information:** + - Meter: [e.g. Aidon] + - AMS reader: [e.g. Pow-U, ESP32 etc] + - M-bus adapter (if applicable): + +**Relevant firmware information:** + - Version: [e.g. 1.5.0] + - MQTT: [yes/no] + - HAN GPIO: [e.g. GPIO5] + - Temperature sensors [e.g. 3xDS18B20] From 4c92e592d63a2b4d45fe47edd5b09ad6a6bf2ad6 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Mon, 8 Nov 2021 12:05:48 +0100 Subject: [PATCH 2/3] Added support for uart_swap for ESP8266 --- src/AmsToMqttBridge.ino | 36 +++++++++++++++++++++--------------- src/web/AmsWebServer.cpp | 5 +++++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 2634e56e..8c0a4d5a 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -140,21 +140,11 @@ void setup() { bool shared = false; config.getMeterConfig(meterConfig); + Serial.flush(); + Serial.end(); if(gpioConfig.hanPin == 3) { shared = true; - switch(meterConfig.type) { - case METER_TYPE_KAMSTRUP: - case METER_TYPE_OMNIPOWER: - Serial.begin(2400, SERIAL_8N1); - break; - default: - Serial.begin(2400, SERIAL_8E1); - break; - } - } - - if(!shared) { - Serial.begin(115200); + setupHanPort(gpioConfig.hanPin, meterConfig.type); } DebugConfig debug; @@ -459,9 +449,11 @@ void setupHanPort(int pin, int newMeterType) { debugI("Setting up HAN on pin %d for meter type %d", pin, newMeterType); HardwareSerial *hwSerial = NULL; - if(pin == 3) { + if(pin == 3 || pin == 113) { hwSerial = &Serial; } + + #if defined(ESP32) if(pin == 9) { hwSerial = &Serial1; @@ -478,7 +470,9 @@ void setupHanPort(int pin, int newMeterType) { if(hwSerial != NULL) { debugD("Hardware serial"); - Serial.flush(); + hwSerial->flush(); + hwSerial->end(); + switch(newMeterType) { case METER_TYPE_KAMSTRUP: case METER_TYPE_OMNIPOWER: @@ -488,6 +482,17 @@ void setupHanPort(int pin, int newMeterType) { hwSerial->begin(2400, SERIAL_8E1); break; } + + #if defined(ESP8266) + if(pin == 3) { + debugI("Switching UART0 to pin 1 & 3"); + Serial.pins(1,3); + } else if(pin == 113) { + debugI("Switching UART0 to pin 15 & 13"); + Serial.pins(15,13); + } + #endif + hanSerial = hwSerial; } else { debugD("Software serial"); @@ -505,6 +510,7 @@ void setupHanPort(int pin, int newMeterType) { } hanSerial = swSerial; + Serial.end(); Serial.begin(115200); } diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index eb0418bc..9cb59a38 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -1211,6 +1211,11 @@ String AmsWebServer::getSerialSelectOptions(int selected) { #elif defined(ESP8266) int numGpio = 9; int gpios[] = {4,5,9,10,12,13,14,15,16}; + if(selected == 113) { + gpioOptions += ""; + } else { + gpioOptions += ""; + } #endif for(int i = 0; i < numGpio; i++) { From 254e01059482cd489fc521533d2d0fa32b285e09 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Tue, 16 Nov 2021 20:40:21 +0100 Subject: [PATCH 3/3] Fixed save crash --- src/AmsToMqttBridge.ino | 8 +++++++- src/web/AmsWebServer.cpp | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 8c0a4d5a..cd0d46b9 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -68,6 +68,7 @@ AmsMqttHandler* mqttHandler = NULL; HanReader hanReader; Stream *hanSerial; +SoftwareSerial *swSerial = NULL; GpioConfig gpioConfig; MeterConfig meterConfig; @@ -497,7 +498,12 @@ void setupHanPort(int pin, int newMeterType) { } else { debugD("Software serial"); Serial.flush(); - SoftwareSerial *swSerial = new SoftwareSerial(pin); + + if(swSerial != NULL) { + swSerial->end(); + delete swSerial; + } + swSerial = new SoftwareSerial(pin); switch(newMeterType) { case METER_TYPE_KAMSTRUP: diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index 9cb59a38..6024e887 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -191,7 +191,7 @@ void AmsWebServer::temperaturePost() { delay(1); } - if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger); + //if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger); if(config->save()) { printD("Successfully saved temperature sensors"); server.sendHeader("Location", String("/temperature"), true); @@ -1068,7 +1068,7 @@ void AmsWebServer::handleSave() { printI("Saving configuration now..."); - if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger); + //if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger); if (config->save()) { printI("Successfully saved."); if(config->isWifiChanged()) {