Skip to content

Commit

Permalink
0.8.5
Browse files Browse the repository at this point in the history
* fixed endless loop while switching CMT frequency
* removed obsolete "retries" field from settings #1224
* fixed crash while defining new invertes #1224
* fixed default frequency settings
* added default input power to `400` while adding new inverters
* fixed color of wifi RSSI icon #1224
  • Loading branch information
lumapu committed Nov 12, 2023
1 parent efdac96 commit 8ac895f
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 55 deletions.
8 changes: 8 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Development Changes

## 0.8.5 - 2023-11-12
* fixed endless loop while switching CMT frequency
* removed obsolete "retries" field from settings #1224
* fixed crash while defining new invertes #1224
* fixed default frequency settings
* added default input power to `400` while adding new inverters
* fixed color of wifi RSSI icon #1224

## 0.8.4 - 2023-11-10
* changed MqTT alarm topic, removed retained flag #1212
* reduce last_success MQTT messages (#1124)
Expand Down
10 changes: 1 addition & 9 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,7 @@ void app::setup() {
mCommunication.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2));
mSys.setup(&mTimestamp, &mConfig->inst);
for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
mSys.addInverter(i, [this](Inverter<> *iv) {
// will be only called for valid inverters
if((IV_MI == iv->ivGen) || (IV_HM == iv->ivGen))
iv->radio = &mNrfRadio;
#if defined(ESP32)
else if((IV_HMS == iv->ivGen) || (IV_HMT == iv->ivGen))
iv->radio = &mCmtRadio;
#endif
});
initInverter(i);
}

if(mConfig->nrf.enabled) {
Expand Down
11 changes: 11 additions & 0 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ class app : public IApp, public ah::Scheduler {
return true;
}

void initInverter(uint8_t id) {
mSys.addInverter(id, [this](Inverter<> *iv) {
if((IV_MI == iv->ivGen) || (IV_HM == iv->ivGen))
iv->radio = &mNrfRadio;
#if defined(ESP32)
else if((IV_HMS == iv->ivGen) || (IV_HMT == iv->ivGen))
iv->radio = &mCmtRadio;
#endif
});
}

bool readSettings(const char *path) {
return mSettings.readSettings(path);
}
Expand Down
1 change: 1 addition & 0 deletions src/appInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class IApp {
public:
virtual ~IApp() {}
virtual bool saveSettings(bool stopFs) = 0;
virtual void initInverter(uint8_t id) = 0;
virtual bool readSettings(const char *path) = 0;
virtual bool eraseSettings(bool eraseWifi) = 0;
virtual bool getSavePending() = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/config/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ class settings {
}

void loadAddedDefaults() {
if(0 == mCfg.configVersion) {
if(0 < mCfg.configVersion) {
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
mCfg.inst.iv[i].powerLevel = 0xff; // impossible high value
mCfg.inst.iv[i].frequency = 0x12; // 863MHz (minimum allowed frequency)
mCfg.inst.iv[i].frequency = 0x0; // 860MHz (backward compatibility)
}
}
}
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 8
#define VERSION_PATCH 4
#define VERSION_PATCH 5

//-------------------------------------
typedef struct {
Expand Down
10 changes: 10 additions & 0 deletions src/hm/Communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ class Communication : public CommQueue<> {
mHeu.printStatus(q->iv);
mHeu.getTxCh(q->iv);
mGotFragment = false;
if(NULL == q->iv->radio)
cmdDone(true); // can't communicate while radio is not defined!
mState = States::START;
break;

case States::START:
setTs(mTimestamp);
if((IV_HMS == q->iv->ivGen) || (IV_HMT == q->iv->ivGen)) {
// frequency was changed during runtime
if(q->iv->curCmtFreq != q->iv->config->frequency) {
if(q->iv->radio->switchFrequencyCh(q->iv, q->iv->curCmtFreq, q->iv->config->frequency))
q->iv->curCmtFreq = q->iv->config->frequency;
}
}

if(q->isDevControl) {
if(ActivePowerContr == q->cmd)
q->iv->powerLimitAck = false;
Expand Down
1 change: 1 addition & 0 deletions src/hm/hmInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class Inverter {
alarmCnt = 0;
alarmLastId = 0;
rssi = -127;
radio = NULL;
memset(&radioStatistics, 0, sizeof(statistics_t));
memset(txRfQuality, -6, 5);

Expand Down
13 changes: 3 additions & 10 deletions src/hm/hmSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ class HmSystem {
void setup(uint32_t *timestamp, cfgInst_t *config) {
mInverter[0].timestamp = timestamp;
mInverter[0].generalConfig = config;
mNumInv = 0;
}

void addInverter(uint8_t id, std::function<void(Inverter<> *iv)> cb) {
DPRINTLN(DBG_VERBOSE, F("hmSystem.h:addInverter"));
if(MAX_INVERTER <= mNumInv) {
DPRINT(DBG_WARN, F("max number of inverters reached!"));
return;
}
INVERTERTYPE *iv = &mInverter[mNumInv];
iv->id = mNumInv;
INVERTERTYPE *iv = &mInverter[id];
iv->id = id;
iv->config = &mInverter[0].generalConfig->iv[id];
DPRINT(DBG_VERBOSE, "SERIAL: " + String(iv->config->serial.b[5], HEX));
DPRINTLN(DBG_VERBOSE, " " + String(iv->config->serial.b[4], HEX));
Expand Down Expand Up @@ -73,7 +68,6 @@ class HmSystem {
iv->ivGen = IV_UNKNOWN;

iv->init();
mNumInv ++;
if(IV_UNKNOWN == iv->ivGen)
return; // serial is 0

Expand All @@ -99,7 +93,7 @@ class HmSystem {
INVERTERTYPE *findInverter(uint8_t buf[]) {
DPRINTLN(DBG_VERBOSE, F("hmSystem.h:findInverter"));
INVERTERTYPE *p;
for(uint8_t i = 0; i < mNumInv; i++) {
for(uint8_t i = 0; i < MAX_INVERTER; i++) {
p = &mInverter[i];
if((p->config->serial.b[3] == buf[0])
&& (p->config->serial.b[2] == buf[1])
Expand Down Expand Up @@ -134,7 +128,6 @@ class HmSystem {

private:
INVERTERTYPE mInverter[MAX_INVERTER];
uint8_t mNumInv;
};

#endif /*__HM_SYSTEM_H__*/
1 change: 1 addition & 0 deletions src/hm/radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Radio {
public:
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 switchFrequencyCh(Inverter<> *iv, uint8_t fromCh, uint8_t toCh) { return true; }
virtual void loop(void) {};

bool get() {
Expand Down
15 changes: 5 additions & 10 deletions src/hms/hmsRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class CmtRadio : public Radio {
return switchFrequencyCh(iv, fromCh, toCh);
}

private:
bool switchFrequencyCh(Inverter<> *iv, uint8_t fromCh, uint8_t toCh) {
if((0xff == fromCh) || (0xff == toCh))
return false;
Expand All @@ -80,16 +79,12 @@ class CmtRadio : public Radio {
return true;
}

private:

void sendPacket(Inverter<> *iv, uint8_t len, bool isRetransmit, bool appendCrc16=true) {
// frequency was changed during runtime
if(iv->curCmtFreq != iv->config->frequency) {
if(switchFrequencyCh(iv, iv->curCmtFreq, iv->config->frequency))
iv->curCmtFreq = iv->config->frequency;
} else {
// inverters have maybe different settings regarding frequency
if(mCmt.getCurrentChannel() != iv->config->frequency)
mCmt.switchChannel(iv->config->frequency);
}
// inverters have maybe different settings regarding frequency
if(mCmt.getCurrentChannel() != iv->config->frequency)
mCmt.switchChannel(iv->config->frequency);

updateCrcs(&len, appendCrc16);

Expand Down
15 changes: 1 addition & 14 deletions src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,20 +728,7 @@ class RestApi {
snprintf(iv->config->chName[i], MAX_NAME_LENGTH, "%s", jsonIn[F("ch")][i][F("name")].as<const char*>());
}

switch(iv->config->serial.b[4]) {
case 0x24:
case 0x22:
case 0x21: iv->type = INV_TYPE_1CH; iv->channels = 1; break;

case 0x44:
case 0x42:
case 0x41: iv->type = INV_TYPE_2CH; iv->channels = 2; break;

case 0x64:
case 0x62:
case 0x61: iv->type = INV_TYPE_4CH; iv->channels = 4; break;
default: break;
}
mApp->initInverter(jsonIn[F("id")]);
iv->config->frequency = jsonIn[F("freq")];
iv->config->powerLevel = jsonIn[F("pa")];
mApp->saveSettings(false); // without reboot
Expand Down
2 changes: 1 addition & 1 deletion src/web/html/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function parseRssi(obj) {
icon = iconWifi1;
else if(obj["wifi_rssi"] <= -70)
icon = iconWifi2;
document.getElementById("wifiicon").replaceChildren(svg(icon, 32, 32, "icon-fg", obj["wifi_rssi"]));
document.getElementById("wifiicon").replaceChildren(svg(icon, 32, 32, "icon-fg2", obj["wifi_rssi"]));
}

function toIsoDateStr(d) {
Expand Down
13 changes: 6 additions & 7 deletions src/web/html/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@
<div class="col-12 col-sm-3 my-2">Interval [s]</div>
<div class="col-12 col-sm-9"><input type="number" name="invInterval" title="Invalid input"/></div>
</div>
<div class="row mb-3">
<div class="col-12 col-sm-3 my-2">Max retries per Payload</div>
<div class="col-12 col-sm-9"><input type="number" name="invRetry"/></div>
</div>
<div class="row mb-3">
<div class="col-8 col-sm-3 mb-2">Reset values and YieldDay at midnight</div>
<div class="col-4 col-sm-9"><input type="checkbox" name="invRstMid"/></div>
Expand Down Expand Up @@ -578,7 +574,7 @@
}

function ivGlob(obj) {
for(var i of [["invInterval", "interval"], ["invRetry", "retries"], ["yldEff", "yldEff"]])
for(var i of [["invInterval", "interval"], ["yldEff", "yldEff"]])
document.getElementsByName(i[0])[0].value = obj[i[1]];
for(var i of ["Mid", "ComStop", "NotAvail", "MaxMid"])
document.getElementsByName("invRst"+i)[0].checked = obj["rst" + i];
Expand Down Expand Up @@ -644,14 +640,17 @@
add.id = obj.inverter.length;
add.name = "";
add.enabled = true;
add.ch_max_pwr = [];
add.ch_max_pwr = [400,400,400,400,400,400];
add.ch_name = [];
add.ch_yield_cor = [];
add.freq = 12;
add.pa = 30;

var e = document.getElementById("inverter");
e.innerHTML = ""; // remove all childs
e.append(ml("table", {class: "table"}, ml("tbody", {}, lines)));
e.append(ml("div", {class: "row my-3"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", value: "add Inverter", class: "btn", onclick: function() { ivModal(add); }}, null))));
if(obj.max_num_inverters > obj.inverter.length)
e.append(ml("div", {class: "row my-3"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", value: "add Inverter", class: "btn", onclick: function() { ivModal(add); }}, null))));

ivGlob(obj);
}
Expand Down
7 changes: 6 additions & 1 deletion src/web/html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ svg.icon {
fill: var(--fg);
}

.icon-fg2 {
fill: var(--fg2);
}

.title {
background-color: var(--primary);
color: #fff !important;
Expand Down Expand Up @@ -817,7 +821,8 @@ ul {
}

.nav-tabs .nav-link.active {
border-color: var(--fg) var(--fg) var(--bg);
border-color: var(--primary) var(--fg) var(--bg);
border-top-width: 4px;
}

.nav-link:hover, .nav-link:visited {
Expand Down

0 comments on commit 8ac895f

Please sign in to comment.