Browse Source

Merge branch 'lumapu:development03' into development03

pull/1670/head
DanielR92 10 months ago
committed by GitHub
parent
commit
47a2ac27b5
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      src/CHANGES.md
  2. 5
      src/config/config.h
  3. 3
      src/config/config_override_example.h
  4. 2
      src/defines.h
  5. 2
      src/network/AhoyWifiEsp32.h
  6. 16
      src/publisher/pubMqtt.h
  7. 13
      src/publisher/pubMqttIvData.h
  8. 18
      src/web/html/index.html

4
src/CHANGES.md

@ -1,5 +1,9 @@
# Development Changes
## 0.8.125 - 2024-06-09
* fix ESP8266 compilation
* merge PR: active_PowerLimit #1663
## 0.8.124 - 2024-06-06
* improved MqTT `OnMessage` (threadsafe)
* support of HERF inverters, serial number is converted in Javascript #1425

5
src/config/config.h

@ -16,9 +16,8 @@
//-------------------------------------
// Fallback WiFi Info
#define FB_WIFI_SSID "YOUR_WIFI_SSID"
#define FB_WIFI_PWD "YOUR_WIFI_PWD"
#define FB_WIFI_SSID ""
#define FB_WIFI_PWD ""
// Access Point Info
// In case there is no WiFi Network or Ahoy can not connect to it, it will act as an Access Point

3
src/config/config_override_example.h

@ -6,9 +6,6 @@
#ifndef __CONFIG_OVERRIDE_H__
#define __CONFIG_OVERRIDE_H__
// override fallback WiFi info
#define FB_WIFI_OVERRIDDEN
// each override must be preceded with an #undef statement
#undef FB_WIFI_SSID
#define FB_WIFI_SSID "MY_SSID"

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 124
#define VERSION_PATCH 125
//-------------------------------------
typedef struct {
uint8_t ch;

2
src/network/AhoyWifiEsp32.h

@ -17,7 +17,7 @@ class AhoyWifi : public AhoyNetwork {
void begin() override {
mAp.enable();
if(String(FB_WIFI_SSID) == mConfig->sys.stationSsid)
if(strlen(mConfig->sys.stationSsid) == 0)
return; // no station wifi defined
WiFi.disconnect(); // clean up

16
src/publisher/pubMqtt.h

@ -11,6 +11,8 @@
#if defined(ENABLE_MQTT)
#ifdef ESP8266
#include <ESP8266WiFi.h>
#define xSemaphoreTake(a, b) { while(a) { yield(); } a = true; }
#define xSemaphoreGive(a) { a = false; }
#elif defined(ESP32)
#include <WiFi.h>
#endif
@ -39,8 +41,12 @@ template<class HMSYSTEM>
class PubMqtt {
public:
PubMqtt() : SendIvData() {
mutex = xSemaphoreCreateBinaryStatic(&mutexBuffer);
xSemaphoreGive(mutex);
#if defined(ESP32)
mutex = xSemaphoreCreateBinaryStatic(&mutexBuffer);
xSemaphoreGive(mutex);
#else
mutex = false;
#endif
mLastIvState.fill(InverterStatus::OFF);
mIvLastRTRpub.fill(0);
@ -54,7 +60,9 @@ class PubMqtt {
}
~PubMqtt() {
#if defined(ESP32)
vSemaphoreDelete(mutex);
#endif
}
void setup(IApp *app, cfgMqtt_t *cfg_mqtt, const char *devName, const char *version, HMSYSTEM *sys, uint32_t *utcTs, uint32_t *uptime) {
@ -667,9 +675,11 @@ class PubMqtt {
IApp *mApp;
#if defined(ESP8266)
WiFiEventHandler mHWifiCon, mHWifiDiscon;
#endif
volatile bool mutex;
#else
SemaphoreHandle_t mutex;
StaticSemaphore_t mutexBuffer;
#endif
HMSYSTEM *mSys = nullptr;
PubMqttIvData<HMSYSTEM> SendIvData;

13
src/publisher/pubMqttIvData.h

@ -197,13 +197,20 @@ class PubMqttIvData {
if (!mCfg->json) {
snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch%d/%s", mIv->config->name, rec->assign[mPos].ch, fields[rec->assign[mPos].fieldId]);
snprintf(mVal.data(), mVal.size(), "%g", ah::round3(mIv->getValue(mPos, rec)));
} else {
if (FLD_ACT_ACTIVE_PWR_LIMIT == rec->assign[mPos].fieldId) {
uint8_t qos = (FLD_ACT_ACTIVE_PWR_LIMIT == rec->assign[mPos].fieldId) ? QOS_2 : QOS_0;
snprintf(mSubTopic.data(), mSubTopic.size(), "%s/%s", mIv->config->name, fields[rec->assign[mPos].fieldId]);
snprintf(mVal.data(), mVal.size(), "%g", ah::round3(mIv->getValue(mPos, rec)));
mPublish(mSubTopic.data(), mVal.data(), retained, qos);
}
}
}
if ((InverterDevInform_All == mCmd) || (InverterDevInform_Simple == mCmd) || !mCfg->json) {
if ((InverterDevInform_All == mCmd) || (InverterDevInform_Simple == mCmd) || !mCfg->json)
{
uint8_t qos = (FLD_ACT_ACTIVE_PWR_LIMIT == rec->assign[mPos].fieldId) ? QOS_2 : QOS_0;
if((FLD_EVT != rec->assign[mPos].fieldId)
&& (FLD_LAST_ALARM_CODE != rec->assign[mPos].fieldId))
if((FLD_EVT != rec->assign[mPos].fieldId) && (FLD_LAST_ALARM_CODE != rec->assign[mPos].fieldId))
mPublish(mSubTopic.data(), mVal.data(), retained, qos);
}
}

18
src/web/html/index.html

@ -116,6 +116,8 @@
var p = div(["none"]);
var total = 0;
var count = 0;
var mobile = window.screen.width < 470;
for(var i of obj) {
var icon = iconSuccess;
var cl = "icon-success";
@ -131,7 +133,8 @@
} else if(0 == i["ts_last_success"]) {
avail = "{#AVAIL_NO_DATA}";
} else {
avail = "{#AVAIL} ";
if (!mobile)
avail = "{#AVAIL} ";
if(false == i["is_producing"])
avail += "{#NOT_PRODUCING}";
else {
@ -142,11 +145,16 @@
}
}
var text;
if (mobile)
text = "#";
else
text = "{#INVERTER} #";
p.append(
svg(icon, 30, 30, "icon " + cl),
span("{#INVERTER} #" + i["id"] + ": " + i["name"] + " {#IS} " + avail),
br()
);
svg(icon, 30, 30, "icon " + cl),
span(text + i["id"] + ": " + i["name"] + " {#IS} " + avail),
br()
);
if(false == i["is_avail"]) {
if(i["ts_last_success"] > 0) {

Loading…
Cancel
Save