Skip to content

Commit

Permalink
Merge branch 'main' of github.com:modem-man-gmx/ahoy
Browse files Browse the repository at this point in the history
  • Loading branch information
modem-man-gmx committed Jan 15, 2023
2 parents c8b1b0a + 1a435b4 commit 1d8100f
Show file tree
Hide file tree
Showing 18 changed files with 287 additions and 172 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compile_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: python convert.py

- name: Run PlatformIO
run: pio run -d src --environment esp8266-release --environment esp8285-release --environment esp8266-nokia5110 --environment esp8266-ssd1306 --environment esp32-wroom32-release --environment esp32-wroom32-nokia5110 --environment esp32-wroom32-ssd1306
run: pio run -d src --environment esp8266-release --environment esp8285-release --environment esp8266-nokia5110 --environment esp8266-ssd1306 --environment esp8266-sh1106 --environment esp32-wroom32-release --environment esp32-wroom32-nokia5110 --environment esp32-wroom32-ssd1306 --environment esp32-wroom32-sh1106

- name: Rename Binary files
id: rename-binary-files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compile_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: python convert.py

- name: Run PlatformIO
run: pio run -d src --environment esp8266-release --environment esp8285-release --environment esp8266-nokia5110 --environment esp8266-ssd1306 --environment esp32-wroom32-release --environment esp32-wroom32-nokia5110 --environment esp32-wroom32-ssd1306
run: pio run -d src --environment esp8266-release --environment esp8285-release --environment esp8266-nokia5110 --environment esp8266-ssd1306 --environment esp8266-sh1106 --environment esp32-wroom32-release --environment esp32-wroom32-nokia5110 --environment esp32-wroom32-ssd1306 --environment esp32-wroom32-sh1106

- name: Rename Binary files
id: rename-binary-files
Expand Down
2 changes: 2 additions & 0 deletions User_Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The AhoyDTU will publish on the following topics
| `uptime` | 73630 | uptime in seconds | false |
| `version` | 0.5.61 | current installed verison of AhoyDTU | true |
| `wifi_rssi` | -75 | WiFi signal strength | false |
| `ip_addr` | 192.168.178.25 | WiFi Station IP Address | true |

| status code | Remarks |
|---|---|
Expand All @@ -43,6 +44,7 @@ The AhoyDTU will publish on the following topics
|---|---|---|---|
| `available` | 2 | see table below | true |
| `last_success` | 1672155690 | UTC Timestamp | true |
| `ack_pwr_limit` | true | fast information if inverter has accepted power limit | false |

| status code | Remarks |
|---|---|
Expand Down
24 changes: 17 additions & 7 deletions scripts/getVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,52 @@ def readVersion(path, infile):
os.mkdir(path + "firmware/")
sha = os.getenv("SHA",default="sha")

versionout = version[:-1] + "_esp8266_" + sha + ".bin"
versionout = version[:-1] + "_" + sha + "_esp8266.bin"
src = path + ".pio/build/esp8266-release/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)

versionout = version[:-1] + "_esp8266_nokia5110_" + sha + ".bin"
versionout = version[:-1] + "_" + sha + "_esp8266_nokia5110.bin"
src = path + ".pio/build/esp8266-nokia5110/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)

versionout = version[:-1] + "_esp8266_ssd1306_" + sha + ".bin"
versionout = version[:-1] + "_" + sha + "_esp8266_ssd1306.bin"
src = path + ".pio/build/esp8266-ssd1306/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)

versionout = version[:-1] + "_" + sha + "_esp8266_sh1106.bin"
src = path + ".pio/build/esp8266-sh1106/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)

versionout = version[:-1] + "_esp8285_" + sha + ".bin"
versionout = version[:-1] + "_" + sha + "_esp8285.bin"
src = path + ".pio/build/esp8285-release/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)
gzip_bin(dst, dst + ".gz")

versionout = version[:-1] + "_esp32_" + sha + ".bin"
versionout = version[:-1] + "_" + sha + "_esp32.bin"
src = path + ".pio/build/esp32-wroom32-release/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)

versionout = version[:-1] + "_esp32_nokia5110_" + sha + ".bin"
versionout = version[:-1] + "_" + sha + "_esp32_nokia5110.bin"
src = path + ".pio/build/esp32-wroom32-nokia5110/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)

versionout = version[:-1] + "_esp32_ssd1306_" + sha + ".bin"
versionout = version[:-1] + "_" + sha + "_esp32_ssd1306.bin"
src = path + ".pio/build/esp32-wroom32-ssd1306/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)

versionout = version[:-1] + "_" + sha + "_esp32_sh1106.bin"
src = path + ".pio/build/esp32-wroom32-sh1106/firmware.bin"
dst = path + "firmware/" + versionout
os.rename(src, dst)

# other ESP32 bin files
src = path + ".pio/build/esp32-wroom32-release/"
dst = path + "firmware/"
Expand Down
57 changes: 24 additions & 33 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
# Changelog v0.5.66
# Changelog

**Note:** Version `0.5.42` to `0.5.65` were development versions. Last release version was `0.5.41`
Detailed change log (development changes): https://github.com/lumapu/ahoy/blob/945a671d27d10d0f7c175ebbf2fbb2806f9cd79a/src/CHANGES.md
(starting from release version `0.5.66`)

## 0.5.70
* corrected MQTT `comm_disabled` #529

* updated REST API and MQTT (both of them use the same functionality)
* improved stability
* Regular expressions for input fields which are used for MQTT to be compliant to MQTT
* WiFi optimization (AP Mode and STA in parallel, reconnect if local STA is unavailable)
* improved display of `/system`
* fix Update button protection (prevent double click #527)
* optimized scheduler #515
* fix of duplicates in API `/api/record/live` (#526)
* added update information to `index.html` (check for update with github.com)
* fix web logout (auto logout)
* switched MQTT library
* removed MQTT `available_text` (can be deducted from `available`)
* enhanced MQTT documentation in `User_Manual.md`
* changed MQTT topic `status` to nummeric value, check documentation in `User_Manual.md`
* added immediate (each minute) report of inverter status MQTT #522
* increased MQTT user, pwd and topic length to 64 characters + `\0`. (The string end `\0` reduces the available size by one) #516
* added disable night communication flag to MQTT #505
* added MQTT <TOPIC>/status to show status over all inverters
* added MQTT RX counter to index.html
* added protection mask to select which pages should be protected
* added monochrome display that show values also if nothing changed and in offline mode #498
* added icons to index.html, added WiFi-strength symbol on each page
* refactored communication offset (adjustable in minutes now)
* factory reset formats entire little fs
* renamed sunrise / sunset on index.html to start / stop communication
* fixed static IP save
* fix NTP with static IP
* all values are displayed on /live even if they are 0
* added NRF24 info to Systeminfo
* reordered enqueue commands after boot up to prevent same payload length for successive commands
## 0.5.69
* merged SH1106 1.3" Display, thx @dAjaY85
* added SH1106 to automatic build
* added IP address to MQTT (version, device and IP are retained and only transmitted once after boot) #556
* added `set_power_limit` acknowledge MQTT publish #553
* changed: version, device name are only published via MQTT once after boot
* added `Login` to menu if admin password is set #554
* added `development` to second changelog link in `index.html` #543
* added interval for MQTT (as option). With this settings MQTT live data is published in a fixed timing (only if inverter is available) #542, #523
* added MQTT `comm_disabled` #529
* changed name of binaries, moved GIT-Sha to the front #538

## 0.5.68
* repaired receive payload
* Powerlimit is transfered immediately to inverter

## 0.5.67
* changed calculation of start / stop communication to 1 min after last comm. stop #515
* moved payload send to `payload.h`, function `ivSend` #515
* payload: if last frame is missing, request all frames again
71 changes: 19 additions & 52 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void app::setup() {
#endif

mSys->addInverters(&mConfig->inst);
mPayload.setup(mSys);
mPayload.setup(this, mSys, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp);
mPayload.enableSerialDebug(mConfig->serial.debug);

if(!mSys->Radio.isChipConnected())
Expand All @@ -74,7 +74,7 @@ void app::setup() {
mApi.setup(this, mSys, mWeb.getWebSrvPtr(), mConfig);

// Plugins
#if defined(ENA_NOKIA) || defined(ENA_SSD1306)
#if defined(ENA_NOKIA) || defined(ENA_SSD1306) || defined(ENA_SH1106)
mMonoDisplay.setup(mSys, &mTimestamp);
everySec(std::bind(&MonoDisplayType::tickerSecond, &mMonoDisplay));
#endif
Expand All @@ -90,6 +90,7 @@ void app::loop(void) {

ah::Scheduler::loop();
mSys->Radio.loop();
mPayload.loop();

yield();

Expand All @@ -115,7 +116,7 @@ void app::loop(void) {
yield();

if (rxRdy)
mPayload.process(true, mConfig->nrf.maxRetransPerPyld, &mStat);
mPayload.process(true);
}

#if !defined(AP_ONLY)
Expand All @@ -138,14 +139,18 @@ void app::tickNtpUpdate(void) {

//-----------------------------------------------------------------------------
void app::tickCalcSunrise(void) {
ah::calculateSunriseSunset(mTimestamp, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset);
if (mSunrise == 0) // on boot/reboot calc sun values for current time
ah::calculateSunriseSunset(mTimestamp, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset);

if (mTimestamp > (mSunset + mConfig->sun.offsetSec)) // current time is past communication stop, calc sun values for next day
ah::calculateSunriseSunset(mTimestamp + 86400, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset);

tickIVCommunication();

uint32_t nxtTrig = mTimestamp - ((mTimestamp + mCalculatedTimezoneOffset - 10) % 86400) + 86400;; // next midnight, -10 for safety that it is certain next day, local timezone
uint32_t nxtTrig = mSunset + mConfig->sun.offsetSec + 60; // set next trigger to communication stop, +60 for safety that it is certain past communication stop
onceAt(std::bind(&app::tickCalcSunrise, this), nxtTrig);
if (mConfig->mqtt.broker[0] > 0) {
if (mConfig->mqtt.broker[0] > 0)
mMqtt.tickerSun(mSunrise, mSunset, mConfig->sun.offsetSec, mConfig->sun.disNightCom);
}
}

//-----------------------------------------------------------------------------
Expand All @@ -157,14 +162,17 @@ void app::tickIVCommunication(void) {
nxtTrig = mSunrise - mConfig->sun.offsetSec;
} else {
if (mTimestamp > (mSunset + mConfig->sun.offsetSec)) { // current time is past communication stop, nothing to do. Next update will be done at midnight by tickCalcSunrise
return;
nxtTrig = 0;
} else { // current time lies within communication start/stop time, set next trigger to communication stop
mIVCommunicationOn = true;
nxtTrig = mSunset + mConfig->sun.offsetSec;
}
}
onceAt(std::bind(&app::tickIVCommunication, this), nxtTrig);
if (nxtTrig != 0)
onceAt(std::bind(&app::tickIVCommunication, this), nxtTrig);
}
if (mConfig->mqtt.broker[0] > 0)
mMqtt.tickerComm(!mIVCommunicationOn);
}

//-----------------------------------------------------------------------------
Expand All @@ -187,49 +195,8 @@ void app::tickSend(void) {
} while ((NULL == iv) && ((maxLoop--) > 0));

if (NULL != iv) {
if(iv->config->enabled) {
if (!mPayload.isComplete(iv))
mPayload.process(false, mConfig->nrf.maxRetransPerPyld, &mStat);

if (!mPayload.isComplete(iv)) {
if (0 == mPayload.getMaxPacketId(iv))
mStat.rxFailNoAnser++;
else
mStat.rxFail++;

iv->setQueuedCmdFinished(); // command failed
if (mConfig->serial.debug)
DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout"));
if (mConfig->serial.debug) {
DPRINT(DBG_INFO, F("(#") + String(iv->id) + ") ");
DPRINTLN(DBG_INFO, F("no Payload received! (retransmits: ") + String(mPayload.getRetransmits(iv)) + ")");
}
}

mPayload.reset(iv, mTimestamp);
mPayload.request(iv);

yield();
if (mConfig->serial.debug) {
DPRINTLN(DBG_DEBUG, F("app:loop WiFi WiFi.status ") + String(WiFi.status()));
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Requesting Inv SN ") + String(iv->config->serial.u64, HEX));
}

if (iv->devControlRequest) {
if (mConfig->serial.debug)
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0]));
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit);
mPayload.setTxCmd(iv, iv->devControlCmd);
iv->clearCmdQueue();
iv->enqueCommand<InfoCommand>(SystemConfigPara); // read back power limit
} else {
uint8_t cmd = iv->getQueuedCmd();
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") sendTimePacket"));
mSys->Radio.sendTimePacket(iv->radioId.u64, cmd, mPayload.getTs(iv), iv->alarmMesIndex);
mPayload.setTxCmd(iv, cmd);
mRxTicker = 0;
}
}
if(iv->config->enabled)
mPayload.ivSend(iv);
}
} else {
if (mConfig->serial.debug)
Expand Down
14 changes: 11 additions & 3 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef PubMqtt<HmSystemType> PubMqttType;
typedef PubSerial<HmSystemType> PubSerialType;

// PLUGINS
#if defined(ENA_NOKIA) || defined(ENA_SSD1306)
#if defined(ENA_NOKIA) || defined(ENA_SSD1306) || defined(ENA_SH1106)
#include "plugins/MonochromeDisplay/MonochromeDisplay.h"
typedef MonochromeDisplay<HmSystemType> MonoDisplayType;
#endif
Expand Down Expand Up @@ -122,6 +122,14 @@ class app : public IApp, public ah::Scheduler {
once(std::bind(&PubMqttType::sendDiscoveryConfig, &mMqtt), 1);
}

void setMqttPowerLimitAck(Inverter<> *iv) {
mMqtt.setPowerLimitAck(iv);
}

void ivSendHighPrio(Inverter<> *iv) {
mPayload.ivSendHighPrio(iv);
}

bool getMqttIsConnected() {
return mMqtt.isConnected();
}
Expand Down Expand Up @@ -176,7 +184,7 @@ class app : public IApp, public ah::Scheduler {
#if !defined(AP_ONLY)
mMqtt.payloadEventListener(cmd);
#endif
#if defined(ENA_NOKIA) || defined(ENA_SSD1306)
#if defined(ENA_NOKIA) || defined(ENA_SSD1306) || defined(ENA_SH1106)
mMonoDisplay.payloadEventListener(cmd);
#endif
}
Expand Down Expand Up @@ -240,7 +248,7 @@ class app : public IApp, public ah::Scheduler {
uint32_t mSunrise, mSunset;

// plugins
#if defined(ENA_NOKIA) || defined(ENA_SSD1306)
#if defined(ENA_NOKIA) || defined(ENA_SSD1306) || defined(ENA_SH1106)
MonoDisplayType mMonoDisplay;
#endif
};
Expand Down
4 changes: 4 additions & 0 deletions src/appInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define __IAPP_H__

#include "defines.h"
#include "hm/hmSystem.h"

// abstract interface to App. Make members of App accessible from child class
// like web or API without forward declaration
Expand All @@ -33,6 +34,9 @@ class IApp {
virtual bool getRebootRequestState() = 0;
virtual bool getSettingsValid() = 0;
virtual void setMqttDiscoveryFlag() = 0;
virtual void setMqttPowerLimitAck(Inverter<> *iv) = 0;

virtual void ivSendHighPrio(Inverter<> *iv) = 0;

virtual bool getMqttIsConnected() = 0;
virtual uint32_t getMqttRxCnt() = 0;
Expand Down
6 changes: 5 additions & 1 deletion src/config/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ typedef struct {
char user[MQTT_USER_LEN];
char pwd[MQTT_PWD_LEN];
char topic[MQTT_TOPIC_LEN];
uint16_t interval;
} cfgMqtt_t;

typedef struct {
Expand Down Expand Up @@ -297,6 +298,7 @@ class settings {
snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", DEF_MQTT_USER);
snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", DEF_MQTT_PWD);
snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", DEF_MQTT_TOPIC);
mCfg.mqtt.interval = 0; // off

mCfg.led.led0 = DEF_LED0_PIN;
mCfg.led.led1 = DEF_LED1_PIN;
Expand Down Expand Up @@ -396,8 +398,10 @@ class settings {
obj[F("user")] = mCfg.mqtt.user;
obj[F("pwd")] = mCfg.mqtt.pwd;
obj[F("topic")] = mCfg.mqtt.topic;
obj[F("intvl")] = mCfg.mqtt.interval;
} else {
mCfg.mqtt.port = obj[F("port")];
mCfg.mqtt.port = obj[F("port")];
mCfg.mqtt.interval = obj[F("intvl")];
snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", obj[F("broker")].as<const char*>());
snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", obj[F("user")].as<const char*>());
snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", obj[F("pwd")].as<const char*>());
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 5
#define VERSION_PATCH 66
#define VERSION_PATCH 69

//-------------------------------------
typedef struct {
Expand Down
Loading

0 comments on commit 1d8100f

Please sign in to comment.