Browse Source

combine CMD module status to antenna-symbol

... and for this harmonize hmRadio and hmsRadio is_Chip_Connected()
pull/1248/head
Wusaweki 1 year ago
parent
commit
99add5c8b2
  1. 6
      src/app.cpp
  2. 2
      src/app.h
  3. 5
      src/appInterface.h
  4. 2
      src/hm/radio.h
  5. 2
      src/hms/hmsRadio.h
  6. 21
      src/plugins/Display/Display.h
  7. 2
      src/web/RestApi.h

6
src/app.cpp

@ -86,7 +86,11 @@ void app::setup() {
// Plugins // Plugins
#if defined(PLUGIN_DISPLAY) #if defined(PLUGIN_DISPLAY)
if (mConfig->plugin.display.type != 0) if (mConfig->plugin.display.type != 0)
mDisplay.setup(this, &mConfig->plugin.display, &mSys, &mNrfRadio, &mTimestamp); #if defined(ESP32)
mDisplay.setup(this, &mConfig->plugin.display, &mSys, &mNrfRadio, &mCmtRadio, &mTimestamp);
#else
mDisplay.setup(this, &mConfig->plugin.display, &mSys, &mNrfRadio, NULL, &mTimestamp);
#endif
#endif #endif
mPubSerial.setup(mConfig, &mSys, &mTimestamp); mPubSerial.setup(mConfig, &mSys, &mTimestamp);

2
src/app.h

@ -51,7 +51,7 @@ typedef PubSerial<HmSystemType> PubSerialType;
#if defined(PLUGIN_DISPLAY) #if defined(PLUGIN_DISPLAY)
#include "plugins/Display/Display.h" #include "plugins/Display/Display.h"
#include "plugins/Display/Display_data.h" #include "plugins/Display/Display_data.h"
typedef Display<HmSystemType, HmRadio<>> DisplayType; typedef Display<HmSystemType, Radio> DisplayType;
#endif #endif
class app : public IApp, public ah::Scheduler { class app : public IApp, public ah::Scheduler {

5
src/appInterface.h

@ -53,8 +53,11 @@ class IApp {
virtual bool getSettingsValid() = 0; virtual bool getSettingsValid() = 0;
virtual void setMqttDiscoveryFlag() = 0; virtual void setMqttDiscoveryFlag() = 0;
virtual void setMqttPowerLimitAck(Inverter<> *iv) = 0; virtual void setMqttPowerLimitAck(Inverter<> *iv) = 0;
virtual bool getMqttIsConnected() = 0; virtual bool getMqttIsConnected() = 0;
virtual bool getNrfEnabled() = 0;
virtual bool getCmtEnabled() = 0;
virtual uint32_t getMqttRxCnt() = 0; virtual uint32_t getMqttRxCnt() = 0;
virtual uint32_t getMqttTxCnt() = 0; virtual uint32_t getMqttTxCnt() = 0;

2
src/hm/radio.h

@ -24,6 +24,8 @@ class Radio {
virtual void sendControlPacket(Inverter<> *iv, uint8_t cmd, uint16_t *data, bool isRetransmit) = 0; virtual void sendControlPacket(Inverter<> *iv, uint8_t cmd, uint16_t *data, bool isRetransmit) = 0;
virtual bool switchFrequency(Inverter<> *iv, uint32_t fromkHz, uint32_t tokHz) { return true; } virtual bool switchFrequency(Inverter<> *iv, uint32_t fromkHz, uint32_t tokHz) { return true; }
virtual bool switchFrequencyCh(Inverter<> *iv, uint8_t fromCh, uint8_t toCh) { return true; } virtual bool switchFrequencyCh(Inverter<> *iv, uint8_t fromCh, uint8_t toCh) { return true; }
virtual bool isChipConnected(void) { return false; }
virtual void loop(void) {}; virtual void loop(void) {};
bool get() { bool get() {

2
src/hms/hmsRadio.h

@ -45,7 +45,7 @@ class CmtRadio : public Radio {
} }
} }
bool isConnected() { bool isChipConnected(void) {
return mCmtAvail; return mCmtAvail;
} }

21
src/plugins/Display/Display.h

@ -15,16 +15,17 @@
#include "Display_ePaper.h" #include "Display_ePaper.h"
#include "Display_data.h" #include "Display_data.h"
template <class HMSYSTEM, class HMRADIO> template <class HMSYSTEM, class RADIO>
class Display { class Display {
public: public:
Display() { Display() {
mMono = NULL; mMono = NULL;
} }
void setup(IApp *app, display_t *cfg, HMSYSTEM *sys, HMRADIO *radio, uint32_t *utcTs) { void setup(IApp *app, display_t *cfg, HMSYSTEM *sys, RADIO *hmradio, RADIO *hmsradio, uint32_t *utcTs) {
mApp = app; mApp = app;
mHmRadio = radio; mHmRadio = hmradio;
mHmsRadio = hmsradio;
mCfg = cfg; mCfg = cfg;
mSys = sys; mSys = sys;
mUtcTs = utcTs; mUtcTs = utcTs;
@ -141,7 +142,16 @@ class Display {
mDisplayData.totalPower = (allOff) ? 0.0 : totalPower; // if all inverters are off, total power can't be greater than 0 mDisplayData.totalPower = (allOff) ? 0.0 : totalPower; // if all inverters are off, total power can't be greater than 0
mDisplayData.totalYieldDay = totalYieldDay; mDisplayData.totalYieldDay = totalYieldDay;
mDisplayData.totalYieldTotal = totalYieldTotal; mDisplayData.totalYieldTotal = totalYieldTotal;
mDisplayData.RadioSymbol = mHmRadio->isChipConnected(); bool nrf_en = mApp->getNrfEnabled();
bool nrf_ok = nrf_en && mHmRadio->isChipConnected();
#if defined(ESP32)
bool cmt_en = mApp->getCmtEnabled();
bool cmt_ok = cmt_en && mHmsRadio->isChipConnected();
#else
bool cmt_en = false;
bool cmt_ok = false;
#endif
mDisplayData.RadioSymbol = (nrf_ok && !cmt_en) || (cmt_ok && !nrf_en) || (nrf_ok && cmt_ok);
mDisplayData.WifiSymbol = (WiFi.status() == WL_CONNECTED); mDisplayData.WifiSymbol = (WiFi.status() == WL_CONNECTED);
mDisplayData.MQTTSymbol = mApp->getMqttIsConnected(); mDisplayData.MQTTSymbol = mApp->getMqttIsConnected();
mDisplayData.RadioRSSI = (0 < mDisplayData.nrProducing) ? ivQuality2RadioRSSI(minQAllInv) : SCHAR_MIN; // Workaround as NRF24 has no RSSI. Approximation by quality levels from heuristic function mDisplayData.RadioRSSI = (0 < mDisplayData.nrProducing) ? ivQuality2RadioRSSI(minQAllInv) : SCHAR_MIN; // Workaround as NRF24 has no RSSI. Approximation by quality levels from heuristic function
@ -212,7 +222,8 @@ class Display {
uint32_t *mUtcTs; uint32_t *mUtcTs;
display_t *mCfg; display_t *mCfg;
HMSYSTEM *mSys; HMSYSTEM *mSys;
HMRADIO *mHmRadio; RADIO *mHmRadio;
RADIO *mHmsRadio;
uint16_t mRefreshCycle; uint16_t mRefreshCycle;
#if defined(ESP32) #if defined(ESP32)

2
src/web/RestApi.h

@ -547,7 +547,7 @@ class RestApi {
void getRadioCmtInfo(JsonObject obj) { void getRadioCmtInfo(JsonObject obj) {
obj[F("en")] = (bool) mConfig->cmt.enabled; obj[F("en")] = (bool) mConfig->cmt.enabled;
obj[F("isconnected")] = mRadioCmt->isConnected(); obj[F("isconnected")] = mRadioCmt->isChipConnected();
obj[F("sn")] = String(mRadioCmt->getDTUSn(), HEX); obj[F("sn")] = String(mRadioCmt->getDTUSn(), HEX);
} }
#endif #endif

Loading…
Cancel
Save