From 3361d5b9bf52881aaa2b23304f8138afffb9b562 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sat, 6 Aug 2022 17:20:52 +0200 Subject: [PATCH 01/29] change default for power limit persistens --- tools/esp8266/hmRadio.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index da4c78ee..65b4c26f 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -161,8 +161,7 @@ class HmRadio { void sendControlPacket(uint64_t invId, uint8_t cmd, uint16_t data) { DPRINTLN(DBG_VERBOSE, F("hmRadio.h:sendControlPacket")); - // sendCmdPacket(invId, 0x51, 0x80, false); // 0x80 implementation as original DTU code - sendCmdPacket(invId, 0x51, 0x81, false); + sendCmdPacket(invId, 0x51, 0x80, false); // 0x80 implementation as original DTU code int cnt = 0; mTxBuf[10] = cmd; // cmd --> 0x0b => Type_ActivePowerContr, 0 on, 1 off, 2 restart, 12 reactive power, 13 power factor mTxBuf[10 + (++cnt)] = 0x00; @@ -177,8 +176,8 @@ class HmRadio { } mTxBuf[10 + (++cnt)] = (data >> 8) & 0xff; // 0x01 mTxBuf[10 + (++cnt)] = (data ) & 0xff; // 0x2c - // mTxBuf[10 + (++cnt)] = 0x00; // not persistent - mTxBuf[10 + (++cnt)] = 0x01; // persistent + mTxBuf[10 + (++cnt)] = 0x00; // not persistent + //mTxBuf[10 + (++cnt)] = 0x01; // persistent mTxBuf[10 + (++cnt)] = 0x00; } // crc control data From c915e445576b68e19efbe00136bbadcc03d70570 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sat, 6 Aug 2022 18:23:49 +0200 Subject: [PATCH 02/29] Removed set power limit to zero in intial case --- tools/esp8266/app.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index d19e43c4..a6c9c806 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -83,9 +83,11 @@ void app::setup(uint32_t timeout) { iv = mSys->addInverter(name, invSerial, modPwr); if(NULL != iv) { mEep->read(ADDR_INV_PWR_LIM + (i * 2),&iv->powerLimit); - iv->devControlCmd = 11; // set active power limit - iv->devControlRequest = true; // set to true to update the active power limit from setup html page - DPRINTLN(DBG_INFO, F("add inverter: ") + String(name) + ", SN: " + String(invSerial, HEX) + ", Power Limit: " + String(iv->powerLimit)); + if (iv->powerLimit != 0xffff) { // only set it, if it is changed by user. Default value in the html setup page is -1 = 0xffff + iv->devControlCmd = 11; // set active power limit + iv->devControlRequest = true; // set to true to update the active power limit from setup html page + DPRINTLN(DBG_INFO, F("add inverter: ") + String(name) + ", SN: " + String(invSerial, HEX) + ", Power Limit: " + String(iv->powerLimit)); + } for(uint8_t j = 0; j < 4; j++) { mEep->read(ADDR_INV_CH_NAME + (i * 4 * MAX_NAME_LENGTH) + j * MAX_NAME_LENGTH, iv->chName[j], MAX_NAME_LENGTH); } @@ -550,7 +552,12 @@ void app::showSetup(void) { inv += F(""); inv += F(""; @@ -928,7 +935,9 @@ void app::saveValues(bool webSend = true) { // active power limit activepowerlimit = mWeb->arg("inv" + String(i) + "ActivePowerLimit").toInt(); - mEep->write(ADDR_INV_PWR_LIM + i * 2,activepowerlimit); + if (activepowerlimit != 0xffff && activepowerlimit > 0) { + mEep->write(ADDR_INV_PWR_LIM + i * 2,activepowerlimit); + } // name mWeb->arg("inv" + String(i) + "Name").toCharArray(buf, 20); From 028aedb788f0b987225792b608ee8f056e2e20a1 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 7 Aug 2022 17:27:50 +0200 Subject: [PATCH 03/29] prototype webapi to get info, improved pwr limit --- tools/esp8266/app.cpp | 200 ++++++++++++++++++++++--------------- tools/esp8266/app.h | 2 +- tools/esp8266/defines.h | 37 +++++++ tools/esp8266/hmInverter.h | 5 +- tools/esp8266/hmRadio.h | 40 +++++--- tools/esp8266/hmSystem.h | 3 + 6 files changed, 188 insertions(+), 99 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index a6c9c806..217eeec9 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -9,6 +9,8 @@ #include "html/h/index_html.h" #include "html/h/setup_html.h" #include "html/h/hoymiles_html.h" +#include + //----------------------------------------------------------------------------- @@ -53,17 +55,17 @@ void app::setup(uint32_t timeout) { DPRINTLN(DBG_VERBOSE, F("app::setup")); Main::setup(timeout); - mWeb->on("/", std::bind(&app::showIndex, this)); - mWeb->on("/favicon.ico", std::bind(&app::showFavicon, this)); - mWeb->on("/setup", std::bind(&app::showSetup, this)); - mWeb->on("/save", std::bind(&app::showSave, this)); - mWeb->on("/erase", std::bind(&app::showErase, this)); - mWeb->on("/cmdstat", std::bind(&app::showStatistics, this)); - mWeb->on("/hoymiles", std::bind(&app::showHoymiles, this)); - mWeb->on("/livedata", std::bind(&app::showLiveData, this)); - mWeb->on("/json", std::bind(&app::showJSON, this)); - mWeb->on("/devcontrol", std::bind(&app::devControl, this)); - + mWeb->on("/", std::bind(&app::showIndex, this)); + mWeb->on("/favicon.ico", std::bind(&app::showFavicon, this)); + mWeb->on("/setup", std::bind(&app::showSetup, this)); + mWeb->on("/save", std::bind(&app::showSave, this)); + mWeb->on("/erase", std::bind(&app::showErase, this)); + mWeb->on("/cmdstat", std::bind(&app::showStatistics, this)); + mWeb->on("/hoymiles", std::bind(&app::showHoymiles, this)); + mWeb->on("/livedata", std::bind(&app::showLiveData, this)); + mWeb->on("/json", std::bind(&app::showJSON, this)); + mWeb->on("/api",HTTP_POST, std::bind(&app::webapi, this)); + if(mSettingsValid) { mEep->read(ADDR_INV_INTERVAL, &mSendInterval); if(mSendInterval < MIN_SEND_INTERVAL) @@ -82,11 +84,12 @@ void app::setup(uint32_t timeout) { if(0ULL != invSerial) { iv = mSys->addInverter(name, invSerial, modPwr); if(NULL != iv) { - mEep->read(ADDR_INV_PWR_LIM + (i * 2),&iv->powerLimit); - if (iv->powerLimit != 0xffff) { // only set it, if it is changed by user. Default value in the html setup page is -1 = 0xffff + mEep->read(ADDR_INV_PWR_LIM + (i * 2),&iv->powerLimit[0]); + if (iv->powerLimit[0] != 0xffff) { // only set it, if it is changed by user. Default value in the html setup page is -1 = 0xffff + iv->powerLimit[1] = 0x0100; // set the limit as persistent iv->devControlCmd = 11; // set active power limit iv->devControlRequest = true; // set to true to update the active power limit from setup html page - DPRINTLN(DBG_INFO, F("add inverter: ") + String(name) + ", SN: " + String(invSerial, HEX) + ", Power Limit: " + String(iv->powerLimit)); + DPRINTLN(DBG_INFO, F("add inverter: ") + String(name) + ", SN: " + String(invSerial, HEX) + ", Power Limit: " + String(iv->powerLimit[0])); } for(uint8_t j = 0; j < 4; j++) { mEep->read(ADDR_INV_CH_NAME + (i * 4 * MAX_NAME_LENGTH) + j * MAX_NAME_LENGTH, iv->chName[j], MAX_NAME_LENGTH); @@ -232,52 +235,84 @@ void app::loop(void) { // process buffer only on first occurrence if(mSerialDebug) { DPRINT(DBG_INFO, "RX " + String(len) + "B Ch" + String(p->rxCh) + " | "); - mSys->Radio.dumpBuf(NULL, p->packet, len); } mFrameCnt++; if(0 != len) { Inverter<> *iv = mSys->findInverter(&p->packet[1]); - if(NULL != iv && p->packet[0] == (0x15 + 0x80)) { // response from get all information command - uint8_t *pid = &p->packet[9]; - if (*pid == 0x00) { - DPRINT(DBG_DEBUG, "fragment number zero received and ignored"); - } else { - if((*pid & 0x7F) < 5) { - memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], len-11); - mPayload[iv->id].len[(*pid & 0x7F) - 1] = len-11; + if(NULL != iv && p->packet[0] == (TX_REQ_INFO + 0x80)) { // response from get information command + DPRINTLN(DBG_DEBUG, F("Response from info request received")); + switch (mSys->InfoCmd){ + case InverterDevInform_Simple: + { + DPRINT(DBG_INFO, "Response from inform simple\n"); + mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default + break; } + case InverterDevInform_All: + { + DPRINT(DBG_INFO, "Response from inform all\n"); + mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default + break; + } + case GetLossRate: + { + DPRINT(DBG_INFO, "Response from get loss rate\n"); + mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default + break; + } + case RealTimeRunData_Debug: + { + uint8_t *pid = &p->packet[9]; + if (*pid == 0x00) { + DPRINT(DBG_DEBUG, "fragment number zero received and ignored"); + } else { + if((*pid & 0x7F) < 5) { + memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], len-11); + mPayload[iv->id].len[(*pid & 0x7F) - 1] = len-11; + } - if((*pid & 0x80) == 0x80) { - if((*pid & 0x7f) > mPayload[iv->id].maxPackId) { - mPayload[iv->id].maxPackId = (*pid & 0x7f); - if(*pid > 0x81) - mLastPacketId = *pid; + if((*pid & 0x80) == 0x80) { // Last packet + if((*pid & 0x7f) > mPayload[iv->id].maxPackId) { + mPayload[iv->id].maxPackId = (*pid & 0x7f); + if(*pid > 0x81) + mLastPacketId = *pid; + } + } } + break; } } } - if(NULL != iv && p->packet[0] == (0x51 + 0x80)) { // response from dev control command - DPRINTLN(DBG_INFO, F("Response from devcontrol received")); + if(NULL != iv && p->packet[0] == (TX_REQ_DEVCONTROL + 0x80)) { // response from dev control command + DPRINTLN(DBG_DEBUG, F("Response from devcontrol request received")); iv->devControlRequest = false; - if (p->packet[12] != 11 && iv->devControlCmd == 11){ - // set back to last accpted limit - mEep->read(ADDR_INV_PWR_LIM + iv->id * 2, &iv->powerLimit); + switch (p->packet[12]){ + case ActivePowerContr: + if (iv->devControlCmd == ActivePowerContr){ // ok inverter accepted the set point copy it to dtu eeprom + if (iv->powerLimit[1]>0){ // User want to have it persistent + mEep->write(ADDR_INV_PWR_LIM + iv->id * 2,iv->powerLimit[0]); + updateCrc(); + mEep->commit(); + DPRINTLN(DBG_INFO, F("Inverter has accepted power limit set point, written to dtu eeprom")); + } + DPRINTLN(DBG_INFO, F("Inverter has accepted power limit set point")); + iv->devControlCmd = Init; + } + break; + default: + if (iv->devControlCmd == ActivePowerContr){ + //case inverter did not accept the sent limit; set back to last stored limit + mEep->read(ADDR_INV_PWR_LIM + iv->id * 2, &iv->powerLimit[0]); DPRINTLN(DBG_INFO, F("Inverter has not accepted power limit set point")); - } - if (p->packet[12] == 11 && iv->devControlCmd == 11){ // ok inverter accepted the set point copy it to dtu eeprom - // on every reboot the dtu sets the power limit acc to the value in eeprom - mEep->write(ADDR_INV_PWR_LIM + iv->id * 2,iv->powerLimit); - updateCrc(); - mEep->commit(); - DPRINTLN(DBG_INFO, F("Inverter has accepted power limit set point, written to dtu eeprom")); - iv->devControlCmd = 0xff; // set to none known command. + } + iv->devControlCmd = Init; + break; } } } } - mSys->BufCtrl.popBack(); } yield(); @@ -384,10 +419,10 @@ void app::loop(void) { DPRINTLN(DBG_INFO, F("Requesting Inverter SN ") + String(iv->serial.u64, HEX)); if(iv->devControlRequest){ if(mSerialDebug) - DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit)); - mSys->Radio.sendControlPacket(iv->radioId.u64,iv->devControlCmd ,uint16_t(iv->powerLimit)); + DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0])); + mSys->Radio.sendControlPacket(iv->radioId.u64,iv->devControlCmd ,iv->powerLimit); } else { - mSys->Radio.sendTimePacket(iv->radioId.u64, mPayload[iv->id].ts); + mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts); mRxTicker = 0; } } @@ -449,7 +484,7 @@ void app::processPayload(bool retransmit) { if(mPayload[iv->id].len[i] == 0) { if(mSerialDebug) DPRINTLN(DBG_ERROR, F("while retrieving data: Frame ") + String(i+1) + F(" missing: Request Retransmit")); - mSys->Radio.sendCmdPacket(iv->radioId.u64, 0x15, (0x81+i), true); + mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME+i), true); break; // only retransmit one frame per loop } yield(); @@ -459,9 +494,9 @@ void app::processPayload(bool retransmit) { if(mSerialDebug) DPRINTLN(DBG_ERROR, F("while retrieving data: last frame missing: Request Retransmit")); if(0x00 != mLastPacketId) - mSys->Radio.sendCmdPacket(iv->radioId.u64, 0x15, mLastPacketId, true); + mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, mLastPacketId, true); else - mSys->Radio.sendTimePacket(iv->radioId.u64, mPayload[iv->id].ts); + mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts); } mSys->Radio.switchRxCh(100); } @@ -669,43 +704,44 @@ void app::cbMqtt(char* topic, byte* payload, unsigned int length) { if(NULL != iv) { if (!iv->devControlRequest) { // still pending token = strtok(NULL, "/"); - uint8_t subcmd = std::stoi(token); - switch ( subcmd ){ - case 11: // Active Power Control + switch ( std::stoi(token) ){ + case ActivePowerContr: // Active Power Control if (true){ // if (std::stoi((char*)payload) > 0) error handling powerlimit needed? - iv->devControlCmd = 11; - iv->powerLimit = std::stoi((char*)payload); - DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit) + F("W") ); + iv->devControlCmd = ActivePowerContr; + iv->powerLimit[0] = std::stoi((char*)payload); + iv->powerLimit[1] = 0x0000; // if power limit is set via external interface --> set it temporay + DPRINTLN(DBG_DEBUG, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("W") ); } iv->devControlRequest = true; break; - case 0: // Turn On - iv->devControlCmd = 0; + case TurnOn: // Turn On + iv->devControlCmd = TurnOn; DPRINTLN(DBG_INFO, F("Turn on inverter ") + String(iv->id) ); iv->devControlRequest = true; break; - case 1: // Turn Off - iv->devControlCmd = 1; + case TurnOff: // Turn Off + iv->devControlCmd = TurnOff; DPRINTLN(DBG_INFO, F("Turn off inverter ") + String(iv->id) ); iv->devControlRequest = true; break; - case 2: // Restart - iv->devControlCmd = 2; + case Restart: // Restart + iv->devControlCmd = Restart; DPRINTLN(DBG_INFO, F("Restart inverter ") + String(iv->id) ); iv->devControlRequest = true; break; - case 12: // Reactive Power Control - // iv->devControlCmd = 12; - // uint16_t reactive_power = std::stoi(strtok(NULL, "/")); - // .../devcontrol/// - // ^^^ - DPRINTLN(DBG_INFO, F("Reactive Power Control not implemented for inverter ") + String(iv->id) ); + case ReactivePowerContr: // Reactive Power Control + iv->devControlCmd = ReactivePowerContr; + if (true){ // if (std::stoi((char*)payload) > 0) error handling powerlimit needed? + iv->devControlCmd = ReactivePowerContr; + iv->powerLimit[0] = std::stoi((char*)payload); + iv->powerLimit[1] = 0x0000; // if reactivepower limit is set via external interface --> set it temporay + DPRINTLN(DBG_DEBUG, F("Reactivepower limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("W") ); + iv->devControlRequest = true; + } break; - case 13: // Set Power Factor - // iv->devControlCmd = 13; + case PFSet: // Set Power Factor + // iv->devControlCmd = PFSet; // uint16_t power_factor = std::stoi(strtok(NULL, "/")); - // .../devcontrol/// - // ^^^ DPRINTLN(DBG_INFO, F("Set Power Factor not implemented for inverter ") + String(iv->id) ); break; default: @@ -775,16 +811,20 @@ void app::showStatistics(void) { } //----------------------------------------------------------------------------- -void app::devControl(void) { // ToDo - DPRINTLN(DBG_VERBOSE, F("app::devControl")); - if(mWeb->args() > 0) { - //mWeb->arg("ivid").toChar... - // get iv - // set devControl on/off/power limt --> integrate buttons in app::showLiveData - // ... - mWeb->send(200, F("text/html"), F("Command sent" - "

sent

")); +void app::webapi(void) { // ToDo + DPRINTLN(DBG_VERBOSE, F("app::api")); + DPRINTLN(DBG_DEBUG, mWeb->arg("plain")); + const size_t capacity = 200; // Use arduinojson.org/assistant to compute the capacity. + DynamicJsonDocument payload(capacity); + + // Parse JSON object + deserializeJson(payload, mWeb->arg("plain")); + // ToDo: error handling for payload + if (payload["tx_request"] == TX_REQ_INFO){ + mSys->InfoCmd = payload["cmd"]; + DPRINTLN(DBG_INFO, F("Will make tx-request 0x15 with subcmd ") + String(mSys->InfoCmd)); } + mWeb->send ( 200, "text/json", "{success:true}" ); } @@ -826,7 +866,7 @@ void app::showLiveData(void) { } modHtml += F("
" - "
") + String(iv->name) + F(" Limit ") + String(iv->powerLimit) + F(" W"); + "
") + String(iv->name) + F(" Limit ") + String(iv->powerLimit[0]) + F(" W"); uint8_t list[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PCT, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF}; for(uint8_t fld = 0; fld < 10; fld++) { diff --git a/tools/esp8266/app.h b/tools/esp8266/app.h index a9309e00..ca9bac1f 100644 --- a/tools/esp8266/app.h +++ b/tools/esp8266/app.h @@ -71,7 +71,7 @@ class app : public Main { void showHoymiles(void); void showLiveData(void); void showJSON(void); - void devControl(void); + void webapi(void); void saveValues(bool webSend); diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 76035dcb..77a0f111 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -30,6 +30,43 @@ typedef struct { uint8_t packet[MAX_RF_PAYLOAD_SIZE]; } packet_t; +typedef enum +{ + InverterDevInform_Simple = 0, // 0x00 + InverterDevInform_All = 1, // 0x01 + //GridOnProFilePara = 2, // 0x02 + //HardWareConfig = 3, // 0x03 + //SimpleCalibrationPara = 4, // 0x04 + //SystemConfigPara = 5, // 0x05 + RealTimeRunData_Debug = 11, // 0x0b + //RealTimeRunData_Reality = 12, // 0x0c + //RealTimeRunData_A_Phase = 13, // 0x0d + //RealTimeRunData_B_Phase = 14, // 0x0e + //RealTimeRunData_C_Phase = 15, // 0x0f + //AlarmData = 17, // 0x11 //Alarm data - all unsent alarms + //AlarmUpdate = 18, // 0x12 //Alarm data - all pending alarms + //RecordData = 19, // 0x13 + //InternalData = 20, // 0x14 + GetLossRate = 21, // 0x15 + //GetSelfCheckState = 30, // 0x1e + //InitDataState = 0xff +} InfoCmdType; + +typedef enum +{ + TurnOn = 0, // 0x00 + TurnOff = 1, // 0x01 + Restart = 2, // 0x02 + Lock = 3, // 0x03 + Unlock = 4, // 0x04 + ActivePowerContr = 11, // 0x0b + ReactivePowerContr = 12, // 0x0c + PFSet = 13, // 0x0d + CleanState_LockAndAlarm = 20, // 0x14 + SelfInspection = 40, // 0x28 // self-inspection of grid-connected protection files + Init = 0xff +} DevControlCmdType; + // minimum serial interval #define MIN_SERIAL_INTERVAL 5 diff --git a/tools/esp8266/hmInverter.h b/tools/esp8266/hmInverter.h index b074284e..db22ddd4 100644 --- a/tools/esp8266/hmInverter.h +++ b/tools/esp8266/hmInverter.h @@ -69,7 +69,7 @@ class Inverter { uint8_t type; // integer which refers to inverter type byteAssign_t* assign; // type of inverter uint8_t listLen; // length of assignments - uint16_t powerLimit; // limit power output + uint16_t powerLimit[2]; // limit power output uint8_t devControlCmd; // carries the requested cmd bool devControlRequest; // true if change needed serial_u serial; // serial number as on barcode @@ -82,7 +82,8 @@ class Inverter { Inverter() { ts = 0; - powerLimit = -1; // 65535 W Limit -> unlimited + powerLimit[0] = -1; // 65535 W Limit -> unlimited + powerLimit[1] = 0x0100; // 0x0000 --> set temporary , 0x0100 --> set persistent devControlRequest = false; devControlCmd = 0xff; } diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index 65b4c26f..55d6fed8 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -22,6 +22,10 @@ #define RF_CHANNELS 5 #define RF_LOOP_CNT 300 +#define TX_REQ_INFO 0X15 +#define TX_REQ_DEVCONTROL 0x51 +#define ALL_FRAMES 0x80 +#define SINGLE_FRAME 0x81 const char* const rf24AmpPower[] = {"MIN", "LOW", "HIGH", "MAX"}; @@ -159,26 +163,25 @@ class HmRadio { return mRfChLst[mTxChIdx]; } - void sendControlPacket(uint64_t invId, uint8_t cmd, uint16_t data) { + void sendControlPacket(uint64_t invId, uint8_t cmd, uint16_t *data) { DPRINTLN(DBG_VERBOSE, F("hmRadio.h:sendControlPacket")); - sendCmdPacket(invId, 0x51, 0x80, false); // 0x80 implementation as original DTU code + sendCmdPacket(invId, TX_REQ_DEVCONTROL, ALL_FRAMES, false); // 0x80 implementation as original DTU code int cnt = 0; mTxBuf[10] = cmd; // cmd --> 0x0b => Type_ActivePowerContr, 0 on, 1 off, 2 restart, 12 reactive power, 13 power factor mTxBuf[10 + (++cnt)] = 0x00; - if (cmd == 11){ + if (cmd == ActivePowerContr){ // 4 bytes control data // Power Limit fix point 10 eg. 30 W --> 0d300 = 0x012c // -1 = 0xffff --> no limit - if (data == 0xffff){ - data &= 0xffff; // ToDo: unlimit value is needed and is inverter specific! --> get it via RF from inverter or via user interface + if (data[0] == 0xffff){ + data[0] &= 0xffff; // ToDo: unlimit value is needed and is inverter specific! --> get it via RF from inverter or via user interface } else { - data*= 10; + data[0] *= 10; } - mTxBuf[10 + (++cnt)] = (data >> 8) & 0xff; // 0x01 - mTxBuf[10 + (++cnt)] = (data ) & 0xff; // 0x2c - mTxBuf[10 + (++cnt)] = 0x00; // not persistent - //mTxBuf[10 + (++cnt)] = 0x01; // persistent - mTxBuf[10 + (++cnt)] = 0x00; + mTxBuf[10 + (++cnt)] = (data[0] >> 8) & 0xff; // power limit + mTxBuf[10 + (++cnt)] = (data[0] ) & 0xff; // power limit + mTxBuf[10 + (++cnt)] = (data[1] >> 8) & 0xff; // setting for persistens handling + mTxBuf[10 + (++cnt)] = (data[1] ) & 0xff; // setting for persistens handling } // crc control data uint16_t crc = crc16(&mTxBuf[10], cnt+1); @@ -191,14 +194,17 @@ class HmRadio { sendPacket(invId, mTxBuf, 10 + (++cnt), true); } - void sendTimePacket(uint64_t invId, uint32_t ts) { + void sendTimePacket(uint64_t invId, uint8_t cmd, uint32_t ts) { //DPRINTLN(DBG_VERBOSE, F("hmRadio.h:sendTimePacket")); - sendCmdPacket(invId, 0x15, 0x80, false); - mTxBuf[10] = 0x0b; // cid + sendCmdPacket(invId, TX_REQ_INFO, ALL_FRAMES, false); + mTxBuf[10] = cmd; // cid mTxBuf[11] = 0x00; CP_U32_LittleEndian(&mTxBuf[12], ts); - mTxBuf[19] = 0x05; - + if (cmd == RealTimeRunData_Debug){ + mTxBuf[19] = 0x05; // ToDo: Shall be the last received Alarm Index Number + } else { + mTxBuf[19] = 0x00; + } uint16_t crc = crc16(&mTxBuf[10], 14); mTxBuf[24] = (crc >> 8) & 0xff; mTxBuf[25] = (crc ) & 0xff; @@ -341,6 +347,8 @@ class HmRadio { BUFFER *mBufCtrl; uint8_t mTxBuf[MAX_RF_PAYLOAD_SIZE]; + DevControlCmdType DevControlCmd; + volatile bool mIrqRcvd; }; diff --git a/tools/esp8266/hmSystem.h b/tools/esp8266/hmSystem.h index a2ddbcf4..3d7f7f2b 100644 --- a/tools/esp8266/hmSystem.h +++ b/tools/esp8266/hmSystem.h @@ -19,9 +19,12 @@ class HmSystem { RadioType Radio; typedef BUFFER BufferType; BufferType BufCtrl; + InfoCmdType InfoCmd; + //DevControlCmdType DevControlCmd; HmSystem() { mNumInv = 0; + InfoCmd = RealTimeRunData_Debug; // default case } ~HmSystem() { // TODO: cleanup From 03bb7fbb889e15a3bdb4b655d1e977d5ab83de30 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 7 Aug 2022 18:42:21 +0200 Subject: [PATCH 04/29] bugfix pointer for pwr limit data --- tools/esp8266/app.cpp | 8 ++++---- tools/esp8266/hmRadio.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 217eeec9..519e070e 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -84,10 +84,10 @@ void app::setup(uint32_t timeout) { if(0ULL != invSerial) { iv = mSys->addInverter(name, invSerial, modPwr); if(NULL != iv) { - mEep->read(ADDR_INV_PWR_LIM + (i * 2),&iv->powerLimit[0]); + mEep->read(ADDR_INV_PWR_LIM + (i * 2),(uint16_t *)&(iv->powerLimit[0])); if (iv->powerLimit[0] != 0xffff) { // only set it, if it is changed by user. Default value in the html setup page is -1 = 0xffff iv->powerLimit[1] = 0x0100; // set the limit as persistent - iv->devControlCmd = 11; // set active power limit + iv->devControlCmd = ActivePowerContr; // set active power limit iv->devControlRequest = true; // set to true to update the active power limit from setup html page DPRINTLN(DBG_INFO, F("add inverter: ") + String(name) + ", SN: " + String(invSerial, HEX) + ", Power Limit: " + String(iv->powerLimit[0])); } @@ -304,7 +304,7 @@ void app::loop(void) { default: if (iv->devControlCmd == ActivePowerContr){ //case inverter did not accept the sent limit; set back to last stored limit - mEep->read(ADDR_INV_PWR_LIM + iv->id * 2, &iv->powerLimit[0]); + mEep->read(ADDR_INV_PWR_LIM + iv->id * 2, (uint16_t *)&(iv->powerLimit[0])); DPRINTLN(DBG_INFO, F("Inverter has not accepted power limit set point")); } iv->devControlCmd = Init; @@ -571,7 +571,7 @@ void app::showSetup(void) { mEep->read(ADDR_INV_ADDR + (i * 8), &invSerial); mEep->read(ADDR_INV_NAME + (i * MAX_NAME_LENGTH), name, MAX_NAME_LENGTH); mEep->read(ADDR_INV_CH_PWR + (i * 2 * 4), modPwr, 4); - mEep->read(ADDR_INV_PWR_LIM + (i * 2),&invActivePowerLimit); + mEep->read(ADDR_INV_PWR_LIM + (i * 2),(uint16_t *) &invActivePowerLimit); inv += F("

Inverter ") + String(i) + "

"; inv += F(""); diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index 55d6fed8..b64591ad 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -176,12 +176,13 @@ class HmRadio { if (data[0] == 0xffff){ data[0] &= 0xffff; // ToDo: unlimit value is needed and is inverter specific! --> get it via RF from inverter or via user interface } else { - data[0] *= 10; + data[0] *= 10; // will overwrite the data bc it is a pointer } mTxBuf[10 + (++cnt)] = (data[0] >> 8) & 0xff; // power limit mTxBuf[10 + (++cnt)] = (data[0] ) & 0xff; // power limit mTxBuf[10 + (++cnt)] = (data[1] >> 8) & 0xff; // setting for persistens handling mTxBuf[10 + (++cnt)] = (data[1] ) & 0xff; // setting for persistens handling + data[0] /= 10; // UGLY! } // crc control data uint16_t crc = crc16(&mTxBuf[10], cnt+1); From 3b86d4d3b351ad41a9da19d02bf7ac873135e475 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 7 Aug 2022 19:39:31 +0200 Subject: [PATCH 05/29] added reactive power in overview page --- tools/esp8266/app.cpp | 4 ++-- tools/esp8266/hmDefines.h | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index efa3c222..3b81dd65 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -880,9 +880,9 @@ void app::showLiveData(void) { modHtml += F("
" "
") + String(iv->name) + F(" Limit ") + String(iv->powerLimit[0]) + F(" W"); - uint8_t list[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PCT, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF}; + uint8_t list[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PCT, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_PRA}; - for(uint8_t fld = 0; fld < 10; fld++) { + for(uint8_t fld = 0; fld < 11; fld++) { pos = (iv->getPosByChFld(CH0, list[fld])); if(0xff != pos) { modHtml += F("
"); diff --git a/tools/esp8266/hmDefines.h b/tools/esp8266/hmDefines.h index 6499b44b..c62fb717 100644 --- a/tools/esp8266/hmDefines.h +++ b/tools/esp8266/hmDefines.h @@ -17,15 +17,15 @@ union serial_u { // units -enum {UNIT_V = 0, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_HZ, UNIT_C, UNIT_PCT}; -const char* const units[] = {"V", "A", "W", "Wh", "kWh", "Hz", "°C", "%"}; +enum {UNIT_V = 0, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_HZ, UNIT_C, UNIT_PCT, UNIT_VA}; +const char* const units[] = {"V", "A", "W", "Wh", "kWh", "Hz", "°C", "%","VA"}; // field types enum {FLD_UDC = 0, FLD_IDC, FLD_PDC, FLD_YD, FLD_YW, FLD_YT, - FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_T, FLD_PCT, FLD_EFF, FLD_IRR}; + FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_T, FLD_PCT, FLD_EFF, FLD_IRR, FLD_PRA}; const char* const fields[] = {"U_DC", "I_DC", "P_DC", "YieldDay", "YieldWeek", "YieldTotal", - "U_AC", "I_AC", "P_AC", "Freq", "Temp", "Pct", "Efficiency", "Irradiation"}; + "U_AC", "I_AC", "P_AC", "Freq", "Temp", "Pct", "Efficiency", "Irradiation","P_ACr"}; // mqtt discovery device classes enum {DEVICE_CLS_NONE = 0, DEVICE_CLS_CURRENT, DEVICE_CLS_ENERGY, DEVICE_CLS_PWR, DEVICE_CLS_VOLTAGE, DEVICE_CLS_FREQ, DEVICE_CLS_TEMP}; @@ -95,6 +95,7 @@ const byteAssign_t hm1chAssignment[] = { { FLD_UAC, UNIT_V, CH0, 14, 2, 10 }, { FLD_IAC, UNIT_A, CH0, 22, 2, 100 }, { FLD_PAC, UNIT_W, CH0, 18, 2, 10 }, + { FLD_PRA, UNIT_VA, CH0, 20, 2, 10 }, { FLD_F, UNIT_HZ, CH0, 16, 2, 100 }, { FLD_T, UNIT_C, CH0, 26, 2, 10 }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, @@ -124,6 +125,7 @@ const byteAssign_t hm2chAssignment[] = { { FLD_UAC, UNIT_V, CH0, 26, 2, 10 }, { FLD_IAC, UNIT_A, CH0, 34, 2, 100 }, { FLD_PAC, UNIT_W, CH0, 30, 2, 10 }, + { FLD_PRA, UNIT_VA, CH0, 32, 2, 10 }, { FLD_F, UNIT_HZ, CH0, 28, 2, 100 }, { FLD_T, UNIT_C, CH0, 38, 2, 10 }, { FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC }, @@ -170,6 +172,7 @@ const byteAssign_t hm4chAssignment[] = { { FLD_UAC, UNIT_V, CH0, 46, 2, 10 }, { FLD_IAC, UNIT_A, CH0, 54, 2, 100 }, { FLD_PAC, UNIT_W, CH0, 50, 2, 10 }, + { FLD_PRA, UNIT_VA, CH0, 52, 2, 10 }, { FLD_F, UNIT_HZ, CH0, 48, 2, 100 }, { FLD_PCT, UNIT_PCT, CH0, 56, 2, 10 }, { FLD_T, UNIT_C, CH0, 58, 2, 10 }, From ade747a367e8b6a0be3fa2f3559931cb60dfc5a4 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 7 Aug 2022 19:52:50 +0200 Subject: [PATCH 06/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 701015a5..c4b10d55 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -7,7 +7,7 @@ on: - '**.md' # Do no build on *.md changes jobs: build: - runs-on: ubuntu-latest + runs-on: self-hosted steps: - uses: actions/checkout@v3 From 883c1df61ff7ed460b1e3cfc115ec1768ed70f39 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 7 Aug 2022 19:53:59 +0200 Subject: [PATCH 07/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 701015a5..c4b10d55 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -7,7 +7,7 @@ on: - '**.md' # Do no build on *.md changes jobs: build: - runs-on: ubuntu-latest + runs-on: self-hosted steps: - uses: actions/checkout@v3 From 7f1c593b42b0d243fb81bb41b5e2e3f21fa0e097 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 7 Aug 2022 19:56:59 +0200 Subject: [PATCH 08/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index c4b10d55..f3be4cf4 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -2,7 +2,7 @@ name: ESP8266 on: push: - branches: main + branches: !master paths-ignore: - '**.md' # Do no build on *.md changes jobs: From 7ac83fbfea1dda69913697cbefb9100f3641491d Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 7 Aug 2022 19:58:22 +0200 Subject: [PATCH 09/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index f3be4cf4..0375daf0 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -2,7 +2,11 @@ name: ESP8266 on: push: - branches: !master + branches: + - '*' # matches every branch that doesn't contain a '/' + - '*/*' # matches every branch containing a single '/' + - '**' # matches every branch + - '!main' # excludes master paths-ignore: - '**.md' # Do no build on *.md changes jobs: From 72732ebd2aa1868eaa523bd1dbaddc20cc4e0094 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 7 Aug 2022 20:02:49 +0200 Subject: [PATCH 10/29] updat version patch --- tools/esp8266/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 8105593c..6c782ed6 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -21,7 +21,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 2 +#define VERSION_PATCH 3 //------------------------------------- From 94f18295bb31deabdde5fefe27a44451280d0768 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 7 Aug 2022 20:58:30 +0200 Subject: [PATCH 11/29] * version increase to 0.5.3 --- tools/esp8266/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 3de84795..2bb5294c 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -21,7 +21,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 2 +#define VERSION_PATCH 3 //------------------------------------- From 7131ea5c7d9831918709a0e48230186188292b70 Mon Sep 17 00:00:00 2001 From: stefan123t Date: Mon, 8 Aug 2022 00:54:36 +0200 Subject: [PATCH 12/29] fix line end comments fix line end comments in tools/rpi/hoymiles/decoders/__init__.py --- tools/rpi/hoymiles/decoders/__init__.py | 140 ++++++++++++------------ 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/tools/rpi/hoymiles/decoders/__init__.py b/tools/rpi/hoymiles/decoders/__init__.py index e2b7c7ff..809dd796 100644 --- a/tools/rpi/hoymiles/decoders/__init__.py +++ b/tools/rpi/hoymiles/decoders/__init__.py @@ -217,76 +217,76 @@ class EventsResponse(UnknownResponse): """ Hoymiles micro-inverter event log decode helper """ alarm_codes = { - // HM Error Codes - 1: 'Inverter start', // 0x01 - 2: 'DTU command failed', // 0x02 - 121: 'Over temperature protection', // 0x79 - 125: 'Grid configuration parameter error', // 0x7D - 126: 'Software error code 126', // 0x7E - 127: 'Firmware error', // 0x7F - 128: 'Software error code 128', // 0x80 - 129: 'Software error code 129', // 0x81 - 130: 'Offline', // 0x82 - 141: 'Grid overvoltage', // 0x8D - 142: 'Average grid overvoltage', // 0x8E - 143: 'Grid undervoltage', // 0x8F - 144: 'Grid overfrequency', // 0x90 - 145: 'Grid underfrequency', // 0x91 - 146: 'Rapid grid frequency change', // 0x92 - 147: 'Power grid outage', // 0x93 - 148: 'Grid disconnection', // 0x94 - 149: 'Island detected', // 0x95 - 205: 'Input port 1 & 2 overvoltage', // 0xCD - 206: 'Input port 3 & 4 overvoltage', // 0xCE - 207: 'Input port 1 & 2 undervoltage', // 0xCF - 208: 'Input port 3 & 4 undervoltage', // 0xD0 - 209: 'Port 1 no input', // 0xD1 - 210: 'Port 2 no input', // 0xD2 - 211: 'Port 3 no input', // 0xD3 - 212: 'Port 4 no input', // 0xD4 - 213: 'PV-1 & PV-2 abnormal wiring', // 0xD5 - 214: 'PV-3 & PV-4 abnormal wiring', // 0xD6 - 215: 'PV-1 Input overvoltage', // 0xD7 - 216: 'PV-1 Input undervoltage', // 0xD8 - 217: 'PV-2 Input overvoltage', // 0xD9 - 218: 'PV-2 Input undervoltage', // 0xDA - 219: 'PV-3 Input overvoltage', // 0xDB - 220: 'PV-3 Input undervoltage', // 0xDC - 221: 'PV-4 Input overvoltage', // 0xDD - 222: 'PV-4 Input undervoltage', // 0xDE - 301: 'Hardware error code 301', // 0x012D - 302: 'Hardware error code 302', // 0x012E - 303: 'Hardware error code 303', // 0x012F - 304: 'Hardware error code 304', // 0x0130 - 305: 'Hardware error code 305', // 0x0131 - 306: 'Hardware error code 306', // 0x0132 - 307: 'Hardware error code 307', // 0x0133 - 308: 'Hardware error code 308', // 0x0134 - 309: 'Hardware error code 309', // 0x0135 - 310: 'Hardware error code 310', // 0x0136 - 311: 'Hardware error code 311', // 0x0137 - 312: 'Hardware error code 312', // 0x0138 - 313: 'Hardware error code 313', // 0x0139 - 314: 'Hardware error code 314', // 0x013A - // MI Error Codes - 5041: 'Error code-04 Port 1', // 0x13B1 - 5042: 'Error code-04 Port 2', // 0x13B2 - 5043: 'Error code-04 Port 3', // 0x13B3 - 5044: 'Error code-04 Port 4', // 0x13B4 - 5051: 'PV Input 1 Overvoltage/Undervoltage', // 0x13BB - 5052: 'PV Input 2 Overvoltage/Undervoltage', // 0x13BC - 5053: 'PV Input 3 Overvoltage/Undervoltage', // 0x13BD - 5054: 'PV Input 4 Overvoltage/Undervoltage', // 0x13BE - 5060: 'Abnormal bias', // 0x13C4 - 5070: 'Over temperature protection', // 0x13CE - 5080: 'Grid Overvoltage/Undervoltage', // 0x13D8 - 5090: 'Grid Overfrequency/Underfrequency', // 0x13E2 - 5100: 'Island detected', // 0x13EC - 5120: 'EEPROM reading and writing error', // 0x1400 - 5150: '10 min value grid overvoltage', // 0x141E - 5200: 'Firmware error', // 0x1450 - 8310: 'Shut down', // 0x2076 - 9000: 'Microinverter is suspected of being stolen' // 0x2328 + # HM Error Codes + 1: 'Inverter start', # 0x01 + 2: 'DTU command failed', # 0x02 + 121: 'Over temperature protection', # 0x79 + 125: 'Grid configuration parameter error', # 0x7D + 126: 'Software error code 126', # 0x7E + 127: 'Firmware error', # 0x7F + 128: 'Software error code 128', # 0x80 + 129: 'Software error code 129', # 0x81 + 130: 'Offline', # 0x82 + 141: 'Grid overvoltage', # 0x8D + 142: 'Average grid overvoltage', # 0x8E + 143: 'Grid undervoltage', # 0x8F + 144: 'Grid overfrequency', # 0x90 + 145: 'Grid underfrequency', # 0x91 + 146: 'Rapid grid frequency change', # 0x92 + 147: 'Power grid outage', # 0x93 + 148: 'Grid disconnection', # 0x94 + 149: 'Island detected', # 0x95 + 205: 'Input port 1 & 2 overvoltage', # 0xCD + 206: 'Input port 3 & 4 overvoltage', # 0xCE + 207: 'Input port 1 & 2 undervoltage', # 0xCF + 208: 'Input port 3 & 4 undervoltage', # 0xD0 + 209: 'Port 1 no input', # 0xD1 + 210: 'Port 2 no input', # 0xD2 + 211: 'Port 3 no input', # 0xD3 + 212: 'Port 4 no input', # 0xD4 + 213: 'PV-1 & PV-2 abnormal wiring', # 0xD5 + 214: 'PV-3 & PV-4 abnormal wiring', # 0xD6 + 215: 'PV-1 Input overvoltage', # 0xD7 + 216: 'PV-1 Input undervoltage', # 0xD8 + 217: 'PV-2 Input overvoltage', # 0xD9 + 218: 'PV-2 Input undervoltage', # 0xDA + 219: 'PV-3 Input overvoltage', # 0xDB + 220: 'PV-3 Input undervoltage', # 0xDC + 221: 'PV-4 Input overvoltage', # 0xDD + 222: 'PV-4 Input undervoltage', # 0xDE + 301: 'Hardware error code 301', # 0x012D + 302: 'Hardware error code 302', # 0x012E + 303: 'Hardware error code 303', # 0x012F + 304: 'Hardware error code 304', # 0x0130 + 305: 'Hardware error code 305', # 0x0131 + 306: 'Hardware error code 306', # 0x0132 + 307: 'Hardware error code 307', # 0x0133 + 308: 'Hardware error code 308', # 0x0134 + 309: 'Hardware error code 309', # 0x0135 + 310: 'Hardware error code 310', # 0x0136 + 311: 'Hardware error code 311', # 0x0137 + 312: 'Hardware error code 312', # 0x0138 + 313: 'Hardware error code 313', # 0x0139 + 314: 'Hardware error code 314', # 0x013A + # MI Error Codes + 5041: 'Error code-04 Port 1', # 0x13B1 + 5042: 'Error code-04 Port 2', # 0x13B2 + 5043: 'Error code-04 Port 3', # 0x13B3 + 5044: 'Error code-04 Port 4', # 0x13B4 + 5051: 'PV Input 1 Overvoltage/Undervoltage', # 0x13BB + 5052: 'PV Input 2 Overvoltage/Undervoltage', # 0x13BC + 5053: 'PV Input 3 Overvoltage/Undervoltage', # 0x13BD + 5054: 'PV Input 4 Overvoltage/Undervoltage', # 0x13BE + 5060: 'Abnormal bias', # 0x13C4 + 5070: 'Over temperature protection', # 0x13CE + 5080: 'Grid Overvoltage/Undervoltage', # 0x13D8 + 5090: 'Grid Overfrequency/Underfrequency', # 0x13E2 + 5100: 'Island detected', # 0x13EC + 5120: 'EEPROM reading and writing error', # 0x1400 + 5150: '10 min value grid overvoltage', # 0x141E + 5200: 'Firmware error', # 0x1450 + 8310: 'Shut down', # 0x2076 + 9000: 'Microinverter is suspected of being stolen' # 0x2328 } def __init__(self, *args, **params): From 406e7fdb8f2746525ff587ba671c6bb84483a88b Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 10:38:12 +0200 Subject: [PATCH 13/29] handling of reactive power limit --- tools/esp8266/app.cpp | 5 +++-- tools/esp8266/hmRadio.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 3b81dd65..e804553d 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -295,14 +295,15 @@ void app::loop(void) { iv->devControlRequest = false; switch (p->packet[12]){ case ActivePowerContr: - if (iv->devControlCmd == ActivePowerContr){ // ok inverter accepted the set point copy it to dtu eeprom + if (iv->devControlCmd >= ActivePowerContr && iv->devControlCmd <= PFSet){ // ok inverter accepted the set point copy it to dtu eeprom if (iv->powerLimit[1]>0){ // User want to have it persistent mEep->write(ADDR_INV_PWR_LIM + iv->id * 2,iv->powerLimit[0]); updateCrc(); mEep->commit(); DPRINTLN(DBG_INFO, F("Inverter has accepted power limit set point, written to dtu eeprom")); + } else { + DPRINTLN(DBG_INFO, F("Inverter has accepted power limit set point")); } - DPRINTLN(DBG_INFO, F("Inverter has accepted power limit set point")); iv->devControlCmd = Init; } break; diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index b64591ad..a08b662d 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -169,7 +169,7 @@ class HmRadio { int cnt = 0; mTxBuf[10] = cmd; // cmd --> 0x0b => Type_ActivePowerContr, 0 on, 1 off, 2 restart, 12 reactive power, 13 power factor mTxBuf[10 + (++cnt)] = 0x00; - if (cmd == ActivePowerContr){ + if (cmd >= ActivePowerContr && cmd <= PFSet){ // 4 bytes control data // Power Limit fix point 10 eg. 30 W --> 0d300 = 0x012c // -1 = 0xffff --> no limit From 3ba4a569fc0e2d67d28e4bef39cef6f943002855 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 10:47:12 +0200 Subject: [PATCH 14/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 0375daf0..701015a5 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -2,16 +2,12 @@ name: ESP8266 on: push: - branches: - - '*' # matches every branch that doesn't contain a '/' - - '*/*' # matches every branch containing a single '/' - - '**' # matches every branch - - '!main' # excludes master + branches: main paths-ignore: - '**.md' # Do no build on *.md changes jobs: build: - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 68777bd804d49d82e39a8e94ccd2e5d91ca000c2 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:08:38 +0200 Subject: [PATCH 15/29] Update getVersion.py --- tools/esp8266/helpers/getVersion.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/esp8266/helpers/getVersion.py b/tools/esp8266/helpers/getVersion.py index 3b4a9145..71b429ac 100644 --- a/tools/esp8266/helpers/getVersion.py +++ b/tools/esp8266/helpers/getVersion.py @@ -16,7 +16,13 @@ def readVersion(path, infile): if(p != -1): version += line[p+13:].rstrip() + "." - version = version[:-1] + "_esp8266.bin" + version = version[:-1] + "_esp8266_node_mcu_v2.bin" + src = path + ".pio/build/node_mcu_v2/firmware.bin" + dst = path + ".pio/build/node_mcu_v2/out/" + version + os.mkdir(path + ".pio/build/node_mcu_v2/out/") + os.rename(src, dst) + + version = version[:-1] + "_esp8266_d1_mini.bin" src = path + ".pio/build/d1_mini/firmware.bin" dst = path + ".pio/build/d1_mini/out/" + version os.mkdir(path + ".pio/build/d1_mini/out/") From 75b97cbb82018f0fa18f61695ad0a1104a819554 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:08:44 +0200 Subject: [PATCH 16/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 701015a5..71abda61 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -35,11 +35,13 @@ jobs: working-directory: tools/esp8266/html run: python convert.py - name: Run PlatformIO - run: pio run -d tools/esp8266 + run: | + pio run -d tools/esp8266 --environment node_mcu_v2 + pio run -d tools/esp8266 --environment d1_mini - name: rename working-directory: tools/esp8266/helpers run: python getVersion.py - uses: actions/upload-artifact@v3 with: name: esp8266 - path: tools/esp8266/.pio/build/d1_mini/out + path: tools/esp8266/.pio/build/d1_mini/out/*.bin From 50883bf36d6e807a2563b7f28f5ca92b9ac6a068 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:20:52 +0200 Subject: [PATCH 17/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 71abda61..8af7f1f5 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -35,9 +35,9 @@ jobs: working-directory: tools/esp8266/html run: python convert.py - name: Run PlatformIO - run: | - pio run -d tools/esp8266 --environment node_mcu_v2 - pio run -d tools/esp8266 --environment d1_mini + run: pio run -d tools/esp8266 --environment node_mcu_v2 + - name: Run PlatformIO + run: pio run -d tools/esp8266 --environment d1_mini - name: rename working-directory: tools/esp8266/helpers run: python getVersion.py From 1261c5a160a7a570004d4e429e506b61d21a42db Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:26:37 +0200 Subject: [PATCH 18/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 8af7f1f5..5eb70e41 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -35,9 +35,7 @@ jobs: working-directory: tools/esp8266/html run: python convert.py - name: Run PlatformIO - run: pio run -d tools/esp8266 --environment node_mcu_v2 - - name: Run PlatformIO - run: pio run -d tools/esp8266 --environment d1_mini + run: pio run -d tools/esp8266 - name: rename working-directory: tools/esp8266/helpers run: python getVersion.py From 723781e98ce6ccdb5f29989fbb432b1d7f422bb5 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:36:49 +0200 Subject: [PATCH 19/29] update build workflow --- tools/esp8266/helpers/getVersion.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/esp8266/helpers/getVersion.py b/tools/esp8266/helpers/getVersion.py index 71b429ac..98f75b9e 100644 --- a/tools/esp8266/helpers/getVersion.py +++ b/tools/esp8266/helpers/getVersion.py @@ -15,17 +15,17 @@ def readVersion(path, infile): p = line.find(s) if(p != -1): version += line[p+13:].rstrip() + "." - - version = version[:-1] + "_esp8266_node_mcu_v2.bin" + + os.mkdir(path + ".pio/build/out/") + + versionout = version[:-1] + "_esp8266_node_mcu_v2.bin" src = path + ".pio/build/node_mcu_v2/firmware.bin" - dst = path + ".pio/build/node_mcu_v2/out/" + version - os.mkdir(path + ".pio/build/node_mcu_v2/out/") + dst = path + ".pio/build/out/" + versionout os.rename(src, dst) - version = version[:-1] + "_esp8266_d1_mini.bin" + versionout = version[:-1] + "_esp8266_d1_mini.bin" src = path + ".pio/build/d1_mini/firmware.bin" - dst = path + ".pio/build/d1_mini/out/" + version - os.mkdir(path + ".pio/build/d1_mini/out/") + dst = path + ".pio/build/out/" + versionout os.rename(src, dst) readVersion("../", "defines.h") From 8b54bd936eaa1a2d43dac8d3f849a4f0c3c76346 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:39:17 +0200 Subject: [PATCH 20/29] update build workflow --- .github/workflows/compile_esp8266.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 5eb70e41..7815e5b6 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -42,4 +42,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: esp8266 - path: tools/esp8266/.pio/build/d1_mini/out/*.bin + path: tools/esp8266/.pio/build/out/*.bin From b5f8b722038d631385f7ebb9d14ee6ed9508260b Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:43:41 +0200 Subject: [PATCH 21/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 7815e5b6..68bcad89 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -41,5 +41,5 @@ jobs: run: python getVersion.py - uses: actions/upload-artifact@v3 with: - name: esp8266 + name: esp8266_$GITHUB_REPOSITORY_OWNER_$GITHUB_SHA path: tools/esp8266/.pio/build/out/*.bin From 7025c22a6a6b708b392408d2806723d3391bd46f Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:51:37 +0200 Subject: [PATCH 22/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 68bcad89..b379044d 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -41,5 +41,5 @@ jobs: run: python getVersion.py - uses: actions/upload-artifact@v3 with: - name: esp8266_$GITHUB_REPOSITORY_OWNER_$GITHUB_SHA + name: esp8266_$${{env.GITHUB_REPOSITORY_OWNER}}_$${{env.GITHUB_SHA}} path: tools/esp8266/.pio/build/out/*.bin From 32cf94e2aa23ebc051e313d4dea178c4d53160a7 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:55:03 +0200 Subject: [PATCH 23/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index b379044d..496f55fe 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -41,5 +41,5 @@ jobs: run: python getVersion.py - uses: actions/upload-artifact@v3 with: - name: esp8266_$${{env.GITHUB_REPOSITORY_OWNER}}_$${{env.GITHUB_SHA}} + name: esp8266_${GITHUB_REPOSITORY_OWNER}_${env.GITHUB_SHA} path: tools/esp8266/.pio/build/out/*.bin From de3a6434afb57e989a8913d468d75ef1cce193dd Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 8 Aug 2022 11:58:04 +0200 Subject: [PATCH 24/29] Update compile_esp8266.yml --- .github/workflows/compile_esp8266.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 496f55fe..1271b36e 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -41,5 +41,5 @@ jobs: run: python getVersion.py - uses: actions/upload-artifact@v3 with: - name: esp8266_${GITHUB_REPOSITORY_OWNER}_${env.GITHUB_SHA} + name: esp8266_ahoy path: tools/esp8266/.pio/build/out/*.bin From 155f9e3f41025fe7d0542a95014cc5f6762e8299 Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 8 Aug 2022 22:06:33 +0200 Subject: [PATCH 25/29] * new NRF24 lib (1.4.2 -> 1.4.5) * add build info on index.html (like OpenDTU) * add Discord Link to index.html --- .github/workflows/compile_esp8266.yml | 2 +- tools/esp8266/app.cpp | 3 ++- tools/esp8266/defines.h | 2 +- tools/esp8266/html/h/index_html.h | 2 +- tools/esp8266/html/index.html | 5 +++- tools/esp8266/platformio.ini | 12 ++++++--- .../esp8266/scripts/auto_firmware_version.py | 26 +++++++++++++++++++ .../{helpers => scripts}/getVersion.py | 0 8 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 tools/esp8266/scripts/auto_firmware_version.py rename tools/esp8266/{helpers => scripts}/getVersion.py (100%) diff --git a/.github/workflows/compile_esp8266.yml b/.github/workflows/compile_esp8266.yml index 701015a5..18021623 100644 --- a/.github/workflows/compile_esp8266.yml +++ b/.github/workflows/compile_esp8266.yml @@ -37,7 +37,7 @@ jobs: - name: Run PlatformIO run: pio run -d tools/esp8266 - name: rename - working-directory: tools/esp8266/helpers + working-directory: tools/esp8266/scripts run: python getVersion.py - uses: actions/upload-artifact@v3 with: diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 31750269..913b8a1c 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -510,6 +510,7 @@ void app::showIndex(void) { html.replace(F("{VERSION}"), mVersion); html.replace(F("{TS}"), String(mSendInterval) + " "); html.replace(F("{JS_TS}"), String(mSendInterval * 1000)); + html.replace(F("{BUILD}"), String(AUTO_GIT_HASH)); mWeb->send(200, "text/html", html); } @@ -1113,4 +1114,4 @@ const char* app::getFieldStateClass(uint8_t fieldId) { break; } return (pos >= DEVICE_CLS_ASSIGN_LIST_LEN) ? NULL : stateClasses[deviceFieldAssignment[pos].stateClsId]; -} \ No newline at end of file +} diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 2bb5294c..33d76132 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -21,7 +21,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 3 +#define VERSION_PATCH 4 //------------------------------------- diff --git a/tools/esp8266/html/h/index_html.h b/tools/esp8266/html/h/index_html.h index 542d39dd..6c4255bf 100644 --- a/tools/esp8266/html/h/index_html.h +++ b/tools/esp8266/html/h/index_html.h @@ -1,4 +1,4 @@ #ifndef __INDEX_HTML_H__ #define __INDEX_HTML_H__ -const char index_html[] PROGMEM = "Index - {DEVICE}

AHOY - {DEVICE}

Visualization

Setup

Uptime:

Time:

Statistics:

Every {TS}seconds the values are updated

This project was started from this discussion. (Mikrocontroller.net)
New updates can be found on Github: https://github.com/grindylow/ahoy

Please report issues using the feature provided by Github.

Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/
Check the licenses which are published on https://github.com/grindylow/ahoyas well

© 2022

Update Firmware

AHOY :: {VERSION}

Reboot

"; +const char index_html[] PROGMEM = "Index - {DEVICE}

AHOY - {DEVICE}

Visualization

Setup

Uptime:

Time:

Statistics:

Every {TS}seconds the values are updated

This project was started from this discussion. (Mikrocontroller.net)
New updates can be found on Github: https://github.com/grindylow/ahoy

Please report issues using the feature provided by Github

Discuss with us on Discord

Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/
Check the licenses which are published on https://github.com/grindylow/ahoyas well

© 2022

Update Firmware

AHOY :: {VERSION}

Reboot

Git SHA: {BUILD}

"; #endif /*__INDEX_HTML_H__*/ diff --git a/tools/esp8266/html/index.html b/tools/esp8266/html/index.html index 07638851..f0d2ffa8 100644 --- a/tools/esp8266/html/index.html +++ b/tools/esp8266/html/index.html @@ -46,7 +46,9 @@ This project was started from this discussion. (Mikrocontroller.net)
New updates can be found on Github: https://github.com/grindylow/ahoy

- Please report issues using the feature provided by Github.
+ Please report issues using the feature provided by Github
+
+ Discuss with us on Discord

Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/
Check the licenses which are published on https://github.com/grindylow/ahoy as well

@@ -57,6 +59,7 @@

Update Firmware

AHOY :: {VERSION}

Reboot

+

Git SHA: {BUILD}

diff --git a/tools/esp8266/platformio.ini b/tools/esp8266/platformio.ini index b9def408..ecfe4748 100644 --- a/tools/esp8266/platformio.ini +++ b/tools/esp8266/platformio.ini @@ -32,8 +32,11 @@ monitor_filters = time ; Add timestamp with milliseconds for each new line ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory +extra_scripts = + pre:scripts/auto_firmware_version.py + lib_deps = - nrf24/RF24@1.4.2 + nrf24/RF24@1.4.5 paulstoffregen/Time@^1.6.1 knolleary/PubSubClient@^2.8 bblanchon/ArduinoJson@^6.19.4 @@ -67,8 +70,11 @@ monitor_filters = ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory upload_port = /dev/ttyUSB0 +extra_scripts = + pre:scripts/auto_firmware_version.py + lib_deps = - nrf24/RF24@1.4.2 + nrf24/RF24@1.4.5 paulstoffregen/Time@^1.6.1 knolleary/PubSubClient@^2.8 bblanchon/ArduinoJson@^6.19.4 @@ -78,4 +84,4 @@ lib_deps = ;esp8266/ESP8266WebServer@^1.0 ;esp8266/ESP8266WiFi@^1.0 ;esp8266/SPI@1.0 - ;esp8266/Ticker@^1.0 + ;esp8266/Ticker@^1.0 \ No newline at end of file diff --git a/tools/esp8266/scripts/auto_firmware_version.py b/tools/esp8266/scripts/auto_firmware_version.py new file mode 100644 index 00000000..7992f9df --- /dev/null +++ b/tools/esp8266/scripts/auto_firmware_version.py @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2022 Thomas Basler and others +# +import pkg_resources + +Import("env") + +required_pkgs = {'dulwich'} +installed_pkgs = {pkg.key for pkg in pkg_resources.working_set} +missing_pkgs = required_pkgs - installed_pkgs + +if missing_pkgs: + env.Execute('"$PYTHONEXE" -m pip install dulwich --global-option="--pure"') + +from dulwich import porcelain + +def get_firmware_specifier_build_flag(): + build_version = porcelain.describe('../../') # refers to the repository root dir + build_flag = "-D AUTO_GIT_HASH=\\\"" + build_version + "\\\"" + print ("Firmware Revision: " + build_version) + return (build_flag) + +env.Append( + BUILD_FLAGS=[get_firmware_specifier_build_flag()] +) diff --git a/tools/esp8266/helpers/getVersion.py b/tools/esp8266/scripts/getVersion.py similarity index 100% rename from tools/esp8266/helpers/getVersion.py rename to tools/esp8266/scripts/getVersion.py From 4237a33b9cb8198eb0a1c4fadfe223078eeb5358 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Wed, 10 Aug 2022 09:34:14 +0200 Subject: [PATCH 26/29] prevent to switch off by sending zero as pwr limit --- tools/esp8266/app.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 18c722af..12c5b6a1 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -424,7 +424,7 @@ void app::loop(void) { if(mSerialDebug) DPRINTLN(DBG_DEBUG, F("app:loop WiFi WiFi.status ") + String(WiFi.status()) ); DPRINTLN(DBG_INFO, F("Requesting Inverter SN ") + String(iv->serial.u64, HEX)); - if(iv->devControlRequest){ + if(iv->devControlRequest && iv->powerLimit[0] > 0){ // prevent to "switch off" if(mSerialDebug) DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0])); mSys->Radio.sendControlPacket(iv->radioId.u64,iv->devControlCmd ,iv->powerLimit); From 14b6e08532ca51d6ecab17323fa29fd8fa15ae09 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Wed, 10 Aug 2022 10:41:38 +0200 Subject: [PATCH 27/29] alarm handling --- tools/esp8266/app.cpp | 20 ++++++++++++++++---- tools/esp8266/defines.h | 4 ++-- tools/esp8266/hmDefines.h | 11 +++++++---- tools/esp8266/hmInverter.h | 6 +++++- tools/esp8266/hmRadio.h | 9 ++++++--- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 12c5b6a1..4b3a8b56 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -267,6 +267,18 @@ void app::loop(void) { mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default break; } + case AlarmData: + { + DPRINT(DBG_INFO, "Response from AlarmData\n"); + mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default + break; + } + case AlarmUpdate: + { + DPRINT(DBG_INFO, "Response from AlarmUpdate\n"); + mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default + break; + } case RealTimeRunData_Debug: { uint8_t *pid = &p->packet[9]; @@ -429,7 +441,7 @@ void app::loop(void) { DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0])); mSys->Radio.sendControlPacket(iv->radioId.u64,iv->devControlCmd ,iv->powerLimit); } else { - mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts); + mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts,iv->alarmMesIndex); mRxTicker = 0; } } @@ -503,7 +515,7 @@ void app::processPayload(bool retransmit) { if(0x00 != mLastPacketId) mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, mLastPacketId, true); else - mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts); + mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts,iv->alarmMesIndex); } mSys->Radio.switchRxCh(100); } @@ -882,9 +894,9 @@ void app::showLiveData(void) { modHtml += F("
" "
") + String(iv->name) + F(" Limit ") + String(iv->powerLimit[0]) + F(" W"); - uint8_t list[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PCT, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_PRA}; + uint8_t list[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PCT, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_PRA, FLD_ALARM_MES_ID}; - for(uint8_t fld = 0; fld < 11; fld++) { + for(uint8_t fld = 0; fld < 12; fld++) { pos = (iv->getPosByChFld(CH0, list[fld])); if(0xff != pos) { modHtml += F("
"); diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 3d00af3f..0300f70b 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -43,8 +43,8 @@ typedef enum //RealTimeRunData_A_Phase = 13, // 0x0d //RealTimeRunData_B_Phase = 14, // 0x0e //RealTimeRunData_C_Phase = 15, // 0x0f - //AlarmData = 17, // 0x11 //Alarm data - all unsent alarms - //AlarmUpdate = 18, // 0x12 //Alarm data - all pending alarms + AlarmData = 17, // 0x11 //Alarm data - all unsent alarms + AlarmUpdate = 18, // 0x12 //Alarm data - all pending alarms //RecordData = 19, // 0x13 //InternalData = 20, // 0x14 GetLossRate = 21, // 0x15 diff --git a/tools/esp8266/hmDefines.h b/tools/esp8266/hmDefines.h index c62fb717..1450379b 100644 --- a/tools/esp8266/hmDefines.h +++ b/tools/esp8266/hmDefines.h @@ -17,15 +17,15 @@ union serial_u { // units -enum {UNIT_V = 0, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_HZ, UNIT_C, UNIT_PCT, UNIT_VA}; -const char* const units[] = {"V", "A", "W", "Wh", "kWh", "Hz", "°C", "%","VA"}; +enum {UNIT_V = 0, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_HZ, UNIT_C, UNIT_PCT, UNIT_VA, UNIT_ALARM_MES_ID}; +const char* const units[] = {"V", "A", "W", "Wh", "kWh", "Hz", "°C", "%","VAr",""}; // field types enum {FLD_UDC = 0, FLD_IDC, FLD_PDC, FLD_YD, FLD_YW, FLD_YT, - FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_T, FLD_PCT, FLD_EFF, FLD_IRR, FLD_PRA}; + FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_T, FLD_PCT, FLD_EFF, FLD_IRR, FLD_PRA,FLD_ALARM_MES_ID}; const char* const fields[] = {"U_DC", "I_DC", "P_DC", "YieldDay", "YieldWeek", "YieldTotal", - "U_AC", "I_AC", "P_AC", "Freq", "Temp", "Pct", "Efficiency", "Irradiation","P_ACr"}; + "U_AC", "I_AC", "P_AC", "Freq", "Temp", "Pct", "Efficiency", "Irradiation","P_ACr","ALARM_MES_ID"}; // mqtt discovery device classes enum {DEVICE_CLS_NONE = 0, DEVICE_CLS_CURRENT, DEVICE_CLS_ENERGY, DEVICE_CLS_PWR, DEVICE_CLS_VOLTAGE, DEVICE_CLS_FREQ, DEVICE_CLS_TEMP}; @@ -98,6 +98,7 @@ const byteAssign_t hm1chAssignment[] = { { FLD_PRA, UNIT_VA, CH0, 20, 2, 10 }, { FLD_F, UNIT_HZ, CH0, 16, 2, 100 }, { FLD_T, UNIT_C, CH0, 26, 2, 10 }, + { FLD_ALARM_MES_ID, UNIT_ALARM_MES_ID, CH0, 28, 2, 1 }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, { FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC } }; @@ -128,6 +129,7 @@ const byteAssign_t hm2chAssignment[] = { { FLD_PRA, UNIT_VA, CH0, 32, 2, 10 }, { FLD_F, UNIT_HZ, CH0, 28, 2, 100 }, { FLD_T, UNIT_C, CH0, 38, 2, 10 }, + { FLD_ALARM_MES_ID, UNIT_ALARM_MES_ID, CH0, 40, 2, 1 }, { FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC }, { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, @@ -176,6 +178,7 @@ const byteAssign_t hm4chAssignment[] = { { FLD_F, UNIT_HZ, CH0, 48, 2, 100 }, { FLD_PCT, UNIT_PCT, CH0, 56, 2, 10 }, { FLD_T, UNIT_C, CH0, 58, 2, 10 }, + { FLD_ALARM_MES_ID, UNIT_ALARM_MES_ID, CH0, 60, 2, 1 }, { FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC }, { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, diff --git a/tools/esp8266/hmInverter.h b/tools/esp8266/hmInverter.h index db22ddd4..531e1e60 100644 --- a/tools/esp8266/hmInverter.h +++ b/tools/esp8266/hmInverter.h @@ -69,6 +69,7 @@ class Inverter { uint8_t type; // integer which refers to inverter type byteAssign_t* assign; // type of inverter uint8_t listLen; // length of assignments + uint16_t alarmMesIndex; // Last recorded Alarm Message Index uint16_t powerLimit[2]; // limit power output uint8_t devControlCmd; // carries the requested cmd bool devControlRequest; // true if change needed @@ -132,7 +133,6 @@ class Inverter { uint8_t ptr = assign[pos].start; uint8_t end = ptr + assign[pos].num; uint16_t div = assign[pos].div; - if(CMD_CALC != div) { uint32_t val = 0; do { @@ -142,6 +142,10 @@ class Inverter { record[pos] = (RECORDTYPE)(val) / (RECORDTYPE)(div); } + // get last alarm message index and save it in the inverter instance + if (getPosByChFld(0, FLD_ALARM_MES_ID) == pos){ + alarmMesIndex = record[pos]; + } } RECORDTYPE getValue(uint8_t pos) { diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index a08b662d..4c4866b5 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -195,15 +195,18 @@ class HmRadio { sendPacket(invId, mTxBuf, 10 + (++cnt), true); } - void sendTimePacket(uint64_t invId, uint8_t cmd, uint32_t ts) { + void sendTimePacket(uint64_t invId, uint8_t cmd, uint32_t ts, uint16_t alarmMesId) { //DPRINTLN(DBG_VERBOSE, F("hmRadio.h:sendTimePacket")); sendCmdPacket(invId, TX_REQ_INFO, ALL_FRAMES, false); mTxBuf[10] = cmd; // cid mTxBuf[11] = 0x00; CP_U32_LittleEndian(&mTxBuf[12], ts); - if (cmd == RealTimeRunData_Debug){ - mTxBuf[19] = 0x05; // ToDo: Shall be the last received Alarm Index Number + if (cmd == RealTimeRunData_Debug || cmd == AlarmData || cmd == AlarmUpdate ){ + mTxBuf[18] = (alarmMesId >> 8) & 0xff; + mTxBuf[19] = (alarmMesId ) & 0xff; + //mTxBuf[19] = 0x05; // ToDo: Shall be the last received Alarm Index Number } else { + mTxBuf[18] = 0x00; mTxBuf[19] = 0x00; } uint16_t crc = crc16(&mTxBuf[10], 14); From 31a09dbaf9a512b219389424edd3420fdeead73e Mon Sep 17 00:00:00 2001 From: lumapu Date: Wed, 10 Aug 2022 12:00:45 +0200 Subject: [PATCH 28/29] * flush rx every time --- tools/esp8266/hmRadio.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index da4c78ee..721d00b0 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -135,13 +135,12 @@ class HmRadio { mNrf24.read(p->packet, len); mBufCtrl->pushFront(p); + yield(); } - else { - mNrf24.flush_rx(); // drop the packet + else break; - } - yield(); } + mNrf24.flush_rx(); // drop the packet } else RESTORE_IRQ; From 6276957b22f4268e1daf38e8c4d5271d1dc5f819 Mon Sep 17 00:00:00 2001 From: lumapu Date: Wed, 10 Aug 2022 12:03:58 +0200 Subject: [PATCH 29/29] version increase 0.5.5 reformat defines.h (beautified) --- tools/esp8266/defines.h | 188 ++++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 95 deletions(-) diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 0300f70b..eade9a22 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -21,7 +21,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 4 +#define VERSION_PATCH 5 //------------------------------------- @@ -30,40 +30,38 @@ typedef struct { uint8_t packet[MAX_RF_PAYLOAD_SIZE]; } packet_t; -typedef enum -{ - InverterDevInform_Simple = 0, // 0x00 - InverterDevInform_All = 1, // 0x01 - //GridOnProFilePara = 2, // 0x02 - //HardWareConfig = 3, // 0x03 - //SimpleCalibrationPara = 4, // 0x04 - //SystemConfigPara = 5, // 0x05 - RealTimeRunData_Debug = 11, // 0x0b +typedef enum { + InverterDevInform_Simple = 0, // 0x00 + InverterDevInform_All = 1, // 0x01 + //GridOnProFilePara = 2, // 0x02 + //HardWareConfig = 3, // 0x03 + //SimpleCalibrationPara = 4, // 0x04 + //SystemConfigPara = 5, // 0x05 + RealTimeRunData_Debug = 11, // 0x0b //RealTimeRunData_Reality = 12, // 0x0c //RealTimeRunData_A_Phase = 13, // 0x0d //RealTimeRunData_B_Phase = 14, // 0x0e //RealTimeRunData_C_Phase = 15, // 0x0f - AlarmData = 17, // 0x11 //Alarm data - all unsent alarms - AlarmUpdate = 18, // 0x12 //Alarm data - all pending alarms - //RecordData = 19, // 0x13 - //InternalData = 20, // 0x14 - GetLossRate = 21, // 0x15 - //GetSelfCheckState = 30, // 0x1e + AlarmData = 17, // 0x11, Alarm data - all unsent alarms + AlarmUpdate = 18, // 0x12, Alarm data - all pending alarms + //RecordData = 19, // 0x13 + //InternalData = 20, // 0x14 + GetLossRate = 21, // 0x15 + //GetSelfCheckState = 30, // 0x1e //InitDataState = 0xff } InfoCmdType; -typedef enum -{ - TurnOn = 0, // 0x00 - TurnOff = 1, // 0x01 - Restart = 2, // 0x02 - Lock = 3, // 0x03 - Unlock = 4, // 0x04 - ActivePowerContr = 11, // 0x0b - ReactivePowerContr = 12, // 0x0c - PFSet = 13, // 0x0d +typedef enum { + TurnOn = 0, // 0x00 + TurnOff = 1, // 0x01 + Restart = 2, // 0x02 + Lock = 3, // 0x03 + Unlock = 4, // 0x04 + ActivePowerContr = 11, // 0x0b + ReactivePowerContr = 12, // 0x0c + PFSet = 13, // 0x0d CleanState_LockAndAlarm = 20, // 0x14 - SelfInspection = 40, // 0x28 // self-inspection of grid-connected protection files + SelfInspection = 40, // 0x28, self-inspection of grid-connected protection files Init = 0xff } DevControlCmdType; @@ -79,76 +77,76 @@ typedef enum //------------------------------------- // EEPROM //------------------------------------- -#define SSID_LEN 32 -#define PWD_LEN 64 -#define DEVNAME_LEN 16 -#define CRC_LEN 2 // uint16_t - -#define INV_ADDR_LEN MAX_NUM_INVERTERS * 8 // uint64_t -#define INV_NAME_LEN MAX_NUM_INVERTERS * MAX_NAME_LENGTH // char[] -#define INV_CH_CH_PWR_LEN MAX_NUM_INVERTERS * 2 * 4 // uint16_t (4 channels) -#define INV_CH_CH_NAME_LEN MAX_NUM_INVERTERS * MAX_NAME_LENGTH * 4 // (4 channels) -#define INV_INTERVAL_LEN 2 // uint16_t -#define INV_MAX_RTRY_LEN 1 // uint8_t -#define INV_PWR_LIM_LEN MAX_NUM_INVERTERS * 2 // uint16_t - -#define PINOUT_LEN 3 // 3 pins: CS, CE, IRQ - -#define RF24_AMP_PWR_LEN 1 - -#define NTP_ADDR_LEN 32 // DNS Name -#define NTP_PORT_LEN 2 // uint16_t - -#define MQTT_ADDR_LEN 32 // DNS Name -#define MQTT_USER_LEN 16 -#define MQTT_PWD_LEN 32 -#define MQTT_TOPIC_LEN 32 -#define MQTT_INTERVAL_LEN 2 // uint16_t -#define MQTT_PORT_LEN 2 // uint16_t -#define MQTT_DISCOVERY_PREFIX "homeassistant" -#define MQTT_MAX_PACKET_SIZE 384 - -#define SER_ENABLE_LEN 1 // uint8_t -#define SER_DEBUG_LEN 1 // uint8_t -#define SER_INTERVAL_LEN 2 // uint16_t - - -#define ADDR_START 0 -#define ADDR_SSID ADDR_START -#define ADDR_PWD ADDR_SSID + SSID_LEN -#define ADDR_DEVNAME ADDR_PWD + PWD_LEN -#define ADDR_WIFI_CRC ADDR_DEVNAME + DEVNAME_LEN -#define ADDR_START_SETTINGS ADDR_WIFI_CRC + CRC_LEN - -#define ADDR_PINOUT ADDR_START_SETTINGS - -#define ADDR_RF24_AMP_PWR ADDR_PINOUT + PINOUT_LEN - -#define ADDR_INV_ADDR ADDR_RF24_AMP_PWR + RF24_AMP_PWR_LEN -#define ADDR_INV_NAME ADDR_INV_ADDR + INV_ADDR_LEN -#define ADDR_INV_CH_PWR ADDR_INV_NAME + INV_NAME_LEN -#define ADDR_INV_CH_NAME ADDR_INV_CH_PWR + INV_CH_CH_PWR_LEN -#define ADDR_INV_INTERVAL ADDR_INV_CH_NAME + INV_CH_CH_NAME_LEN -#define ADDR_INV_MAX_RTRY ADDR_INV_INTERVAL + INV_INTERVAL_LEN -#define ADDR_INV_PWR_LIM ADDR_INV_MAX_RTRY + INV_MAX_RTRY_LEN - -#define ADDR_NTP_ADDR ADDR_INV_PWR_LIM + INV_PWR_LIM_LEN //Bugfix #125 -#define ADDR_NTP_PORT ADDR_NTP_ADDR + NTP_ADDR_LEN - -#define ADDR_MQTT_ADDR ADDR_NTP_PORT + NTP_PORT_LEN -#define ADDR_MQTT_USER ADDR_MQTT_ADDR + MQTT_ADDR_LEN -#define ADDR_MQTT_PWD ADDR_MQTT_USER + MQTT_USER_LEN -#define ADDR_MQTT_TOPIC ADDR_MQTT_PWD + MQTT_PWD_LEN -#define ADDR_MQTT_INTERVAL ADDR_MQTT_TOPIC + MQTT_TOPIC_LEN -#define ADDR_MQTT_PORT ADDR_MQTT_INTERVAL + MQTT_INTERVAL_LEN - -#define ADDR_SER_ENABLE ADDR_MQTT_PORT + MQTT_PORT_LEN -#define ADDR_SER_DEBUG ADDR_SER_ENABLE + SER_ENABLE_LEN -#define ADDR_SER_INTERVAL ADDR_SER_DEBUG + SER_DEBUG_LEN -#define ADDR_NEXT ADDR_SER_INTERVAL + SER_INTERVAL_LEN +#define SSID_LEN 32 +#define PWD_LEN 64 +#define DEVNAME_LEN 16 +#define CRC_LEN 2 // uint16_t + +#define INV_ADDR_LEN MAX_NUM_INVERTERS * 8 // uint64_t +#define INV_NAME_LEN MAX_NUM_INVERTERS * MAX_NAME_LENGTH // char[] +#define INV_CH_CH_PWR_LEN MAX_NUM_INVERTERS * 2 * 4 // uint16_t (4 channels) +#define INV_CH_CH_NAME_LEN MAX_NUM_INVERTERS * MAX_NAME_LENGTH * 4 // (4 channels) +#define INV_INTERVAL_LEN 2 // uint16_t +#define INV_MAX_RTRY_LEN 1 // uint8_t +#define INV_PWR_LIM_LEN MAX_NUM_INVERTERS * 2 // uint16_t + +#define PINOUT_LEN 3 // 3 pins: CS, CE, IRQ + +#define RF24_AMP_PWR_LEN 1 + +#define NTP_ADDR_LEN 32 // DNS Name +#define NTP_PORT_LEN 2 // uint16_t + +#define MQTT_ADDR_LEN 32 // DNS Name +#define MQTT_USER_LEN 16 +#define MQTT_PWD_LEN 32 +#define MQTT_TOPIC_LEN 32 +#define MQTT_INTERVAL_LEN 2 // uint16_t +#define MQTT_PORT_LEN 2 // uint16_t +#define MQTT_DISCOVERY_PREFIX "homeassistant" +#define MQTT_MAX_PACKET_SIZE 384 + +#define SER_ENABLE_LEN 1 // uint8_t +#define SER_DEBUG_LEN 1 // uint8_t +#define SER_INTERVAL_LEN 2 // uint16_t + + +#define ADDR_START 0 +#define ADDR_SSID ADDR_START +#define ADDR_PWD ADDR_SSID + SSID_LEN +#define ADDR_DEVNAME ADDR_PWD + PWD_LEN +#define ADDR_WIFI_CRC ADDR_DEVNAME + DEVNAME_LEN +#define ADDR_START_SETTINGS ADDR_WIFI_CRC + CRC_LEN + +#define ADDR_PINOUT ADDR_START_SETTINGS + +#define ADDR_RF24_AMP_PWR ADDR_PINOUT + PINOUT_LEN + +#define ADDR_INV_ADDR ADDR_RF24_AMP_PWR + RF24_AMP_PWR_LEN +#define ADDR_INV_NAME ADDR_INV_ADDR + INV_ADDR_LEN +#define ADDR_INV_CH_PWR ADDR_INV_NAME + INV_NAME_LEN +#define ADDR_INV_CH_NAME ADDR_INV_CH_PWR + INV_CH_CH_PWR_LEN +#define ADDR_INV_INTERVAL ADDR_INV_CH_NAME + INV_CH_CH_NAME_LEN +#define ADDR_INV_MAX_RTRY ADDR_INV_INTERVAL + INV_INTERVAL_LEN +#define ADDR_INV_PWR_LIM ADDR_INV_MAX_RTRY + INV_MAX_RTRY_LEN + +#define ADDR_NTP_ADDR ADDR_INV_PWR_LIM + INV_PWR_LIM_LEN //Bugfix #125 +#define ADDR_NTP_PORT ADDR_NTP_ADDR + NTP_ADDR_LEN + +#define ADDR_MQTT_ADDR ADDR_NTP_PORT + NTP_PORT_LEN +#define ADDR_MQTT_USER ADDR_MQTT_ADDR + MQTT_ADDR_LEN +#define ADDR_MQTT_PWD ADDR_MQTT_USER + MQTT_USER_LEN +#define ADDR_MQTT_TOPIC ADDR_MQTT_PWD + MQTT_PWD_LEN +#define ADDR_MQTT_INTERVAL ADDR_MQTT_TOPIC + MQTT_TOPIC_LEN +#define ADDR_MQTT_PORT ADDR_MQTT_INTERVAL + MQTT_INTERVAL_LEN + +#define ADDR_SER_ENABLE ADDR_MQTT_PORT + MQTT_PORT_LEN +#define ADDR_SER_DEBUG ADDR_SER_ENABLE + SER_ENABLE_LEN +#define ADDR_SER_INTERVAL ADDR_SER_DEBUG + SER_DEBUG_LEN +#define ADDR_NEXT ADDR_SER_INTERVAL + SER_INTERVAL_LEN // #define ADDR_SETTINGS_CRC 950 -#define ADDR_SETTINGS_CRC ADDR_NEXT + 2 +#define ADDR_SETTINGS_CRC ADDR_NEXT + 2 #if(ADDR_SETTINGS_CRC <= ADDR_NEXT) #pragma error "address overlap! (ADDR_SETTINGS_CRC="+ ADDR_SETTINGS_CRC +", ADDR_NEXT="+ ADDR_NEXT +")"