From ed268d1b631e9c4ae2d02fa69591dfbe996dba04 Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 18 Aug 2023 00:23:40 +0200 Subject: [PATCH] 0.7.35 * fixed timestamp for alarms send over MqTT * auto-patch of `AsyncWebServer` #834, #1036 * Update documentation in Git regarding `ESP8266` default NRF24 pin assignments --- Getting_Started.md | 10 +++++----- README.md | 6 +++++- patches/AsyncWeb_Prometheus.patch | 13 +++++++++++++ scripts/applyPatches.py | 20 ++++++++++++++++++++ src/CHANGES.md | 5 +++++ src/platformio.ini | 3 ++- src/publisher/pubMqtt.h | 6 ++++-- 7 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 patches/AsyncWeb_Prometheus.patch create mode 100644 scripts/applyPatches.py diff --git a/Getting_Started.md b/Getting_Started.md index deaea252a..f6a89ddef 100644 --- a/Getting_Started.md +++ b/Getting_Started.md @@ -1,4 +1,4 @@ -## Overview + ## Overview On this page, you'll find detailed instructions on how to wire the module of a Wemos D1 mini or ESP32 to the radio module, as well as how to flash it with the latest firmware. This information will enable you to communicate with compatible inverters. @@ -122,11 +122,11 @@ This is an example wiring using a Wemos D1 mini.
##### Schematic -![Schematic](doc/AhoyWemos_Schaltplan.jpg) +![Schematic](https://ahoydtu.de/img/fritzing/esp8266_nrf_sch.png) ##### Symbolic view -![Symbolic](doc/AhoyWemos_Steckplatine.jpg) +![Symbolic](https://ahoydtu.de/img/fritzing/esp8266_nrf.png) #### ESP8266 wiring example on 30pin Lolin NodeMCU v3 @@ -146,11 +146,11 @@ Example wiring for a 38pin ESP32 module ##### Schematic -![Schematic](doc/Wiring_ESP32_Schematic.png) +![Schematic](https://ahoydtu.de/img/fritzing/esp32-38_nrf_sch.png) ##### Symbolic view -![Symbolic](doc/Wiring_ESP32_Symbol.png) +![Symbolic](https://ahoydtu.de/img/fritzing/esp32-38_nrf.png) ##### ESP32 GPIO settings diff --git a/README.md b/README.md index 3efb9f34f..f774b568e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa] [![Ahoy Dev Build][dev-action-badge]][dev-action-link] +[![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa] +[![Ahoy Build][release-action-badge]][release-action-link] [![Ahoy Dev Build][dev-action-badge]][dev-action-link] This work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa]. @@ -9,6 +10,9 @@ This work is licensed under a [cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png [cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg +[release-action-badge]: https://github.com/lumapu/ahoy/actions/workflows/compile_release.yml/badge.svg +[release-action-link]: https://github.com/lumapu/ahoy/actions/workflows/compile_release.yml + [dev-action-badge]: https://github.com/lumapu/ahoy/actions/workflows/compile_development.yml/badge.svg [dev-action-link]: https://github.com/lumapu/ahoy/actions/workflows/compile_development.yml diff --git a/patches/AsyncWeb_Prometheus.patch b/patches/AsyncWeb_Prometheus.patch new file mode 100644 index 000000000..7fb9209a0 --- /dev/null +++ b/patches/AsyncWeb_Prometheus.patch @@ -0,0 +1,13 @@ +diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp +index 22a549f..e0b36b3 100644 +--- a/src/WebResponses.cpp ++++ b/src/WebResponses.cpp +@@ -318,7 +318,7 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u + free(buf); + return 0; + } +- outLen = sprintf_P((char*)buf+headLen, PSTR("%x"), readLen) + headLen; ++ outLen = sprintf_P((char*)buf+headLen, PSTR("%04x"), readLen) + headLen; + while(outLen < headLen + 4) buf[outLen++] = ' '; + buf[outLen++] = '\r'; + buf[outLen++] = '\n'; diff --git a/scripts/applyPatches.py b/scripts/applyPatches.py new file mode 100644 index 000000000..d63fa1a1e --- /dev/null +++ b/scripts/applyPatches.py @@ -0,0 +1,20 @@ +import os +import subprocess +Import("env") + +def applyPatch(libName, patchFile): + os.chdir('.pio/libdeps/' + env['PIOENV'] + '/' + libName) + + process = subprocess.run(['git', 'apply', '--reverse', '--check', '../../../../' + patchFile], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + if (process.returncode == 0): + print('\'' + patchFile + '\' already applied') + else: + process = subprocess.run(['git', 'apply', '../../../../' + patchFile]) + if (process.returncode == 0): + print('\'' + patchFile + '\' applied') + else: + print('applying \'' + patchFile + '\' failed') + + +# list of patches to apply (relative to /src) +applyPatch("ESP Async WebServer", "../patches/AsyncWeb_Prometheus.patch") diff --git a/src/CHANGES.md b/src/CHANGES.md index 07ac880bc..c55031483 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,10 @@ # Development Changes +## 0.7.35 - 2023-08-17 +* fixed timestamp for alarms send over MqTT +* auto-patch of `AsyncWebServer` #834, #1036 +* Update documentation in Git regarding `ESP8266` default NRF24 pin assignments + ## 0.7.34 - 2023-08-16 * fixed timezone offset of alarms * added `AC` and `DC` to `/live` #1098 diff --git a/src/platformio.ini b/src/platformio.ini index 8abf8e81f..28c477837 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -21,6 +21,7 @@ monitor_speed = 115200 extra_scripts = pre:../scripts/auto_firmware_version.py pre:web/html/convert.py + pre:../scripts/applyPatches.py lib_deps = https://github.com/yubox-node-org/ESPAsyncWebServer @@ -183,4 +184,4 @@ build_flags = -std=gnu++17 build_unflags = -std=gnu++11 monitor_filters = - time ; Add timestamp with milliseconds for each new line \ No newline at end of file + time ; Add timestamp with milliseconds for each new line diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 3dd55ef63..095d6c195 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -500,6 +500,8 @@ class PubMqtt { void sendAlarmData() { Inverter<> *iv; + uint32_t localTime = gTimezone.toLocal(*mUtcTimestamp); + uint32_t lastMidnight = gTimezone.toUTC(localTime - (localTime % 86400)); // last midnight local time for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { if(!mSendAlarm[i]) continue; @@ -527,11 +529,11 @@ class PubMqtt { publish(mSubTopic, mVal, true); snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d/start", iv->config->name, j); - snprintf(mVal, 40, "%d", iv->lastAlarm[j].start); + snprintf(mVal, 40, "%d", iv->lastAlarm[j].start + lastMidnight); publish(mSubTopic, mVal, true); snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/alarm/%d/end", iv->config->name, j); - snprintf(mVal, 40, "%d", iv->lastAlarm[j].end); + snprintf(mVal, 40, "%d", iv->lastAlarm[j].end + lastMidnight); publish(mSubTopic, mVal, true); yield(); }