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. 12
      src/publisher/pubMqtt.h
  7. 13
      src/publisher/pubMqttIvData.h
  8. 10
      src/web/html/index.html

4
src/CHANGES.md

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

5
src/config/config.h

@ -16,9 +16,8 @@
//------------------------------------- //-------------------------------------
// Fallback WiFi Info // Fallback WiFi Info
#define FB_WIFI_SSID "YOUR_WIFI_SSID" #define FB_WIFI_SSID ""
#define FB_WIFI_PWD "YOUR_WIFI_PWD" #define FB_WIFI_PWD ""
// Access Point Info // Access Point Info
// In case there is no WiFi Network or Ahoy can not connect to it, it will act as an Access Point // 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__ #ifndef __CONFIG_OVERRIDE_H__
#define __CONFIG_OVERRIDE_H__ #define __CONFIG_OVERRIDE_H__
// override fallback WiFi info
#define FB_WIFI_OVERRIDDEN
// each override must be preceded with an #undef statement // each override must be preceded with an #undef statement
#undef FB_WIFI_SSID #undef FB_WIFI_SSID
#define FB_WIFI_SSID "MY_SSID" #define FB_WIFI_SSID "MY_SSID"

2
src/defines.h

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

2
src/network/AhoyWifiEsp32.h

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

12
src/publisher/pubMqtt.h

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

13
src/publisher/pubMqttIvData.h

@ -197,13 +197,20 @@ class PubMqttIvData {
if (!mCfg->json) { 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(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))); 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; uint8_t qos = (FLD_ACT_ACTIVE_PWR_LIMIT == rec->assign[mPos].fieldId) ? QOS_2 : QOS_0;
if((FLD_EVT != rec->assign[mPos].fieldId) if((FLD_EVT != rec->assign[mPos].fieldId) && (FLD_LAST_ALARM_CODE != rec->assign[mPos].fieldId))
&& (FLD_LAST_ALARM_CODE != rec->assign[mPos].fieldId))
mPublish(mSubTopic.data(), mVal.data(), retained, qos); mPublish(mSubTopic.data(), mVal.data(), retained, qos);
} }
} }

10
src/web/html/index.html

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

Loading…
Cancel
Save