Browse Source

0.8.73

* fix nullpointer during communication #1401
* added `max_power` to MqTT total values #1375
pull/1402/head
lumapu 1 year ago
parent
commit
6b5435a246
  1. 4
      src/CHANGES.md
  2. 2
      src/defines.h
  3. 29
      src/hm/Communication.h
  4. 13
      src/publisher/pubMqttIvData.h

4
src/CHANGES.md

@ -1,5 +1,9 @@
# Development Changes
## 0.8.73 - 2024-02-03
* fix nullpointer during communication #1401
* added `max_power` to MqTT total values #1375
## 0.8.72 - 2024-02-03
* fixed translation #1403
* fixed sending commands to inverters which are soft turned off #1397

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 72
#define VERSION_PATCH 73
//-------------------------------------
typedef struct {

29
src/hm/Communication.h

@ -295,12 +295,14 @@ class Communication : public CommQueue<> {
return;
}
compilePayload(q);
if(compilePayload(q)) {
if((NULL != mCbPayload) && (GridOnProFilePara != q->cmd) && (GetLossRate != q->cmd))
(mCbPayload)(q->cmd, q->iv);
closeRequest(q, true);
} else
closeRequest(q, false);
break;
}
}
@ -498,7 +500,7 @@ class Communication : public CommQueue<> {
return accepted;
}
inline void compilePayload(const queue_s *q) {
inline bool compilePayload(const queue_s *q) {
uint16_t crc = 0xffff, crcRcv = 0x0000;
for(uint8_t i = 0; i < mMaxFrameId; i++) {
if(i == (mMaxFrameId - 1)) {
@ -514,13 +516,12 @@ class Communication : public CommQueue<> {
DBGPRINT(F("CRC Error "));
if(q->attempts == 0) {
DBGPRINTLN(F("-> Fail"));
closeRequest(q, false);
} else
DBGPRINTLN(F("-> complete retransmit"));
mCompleteRetry = true;
mState = States::RESET;
return;
return false;
}
memset(mPayload, 0, MAX_BUFFER);
@ -530,7 +531,7 @@ class Communication : public CommQueue<> {
for(uint8_t i = 0; i < mMaxFrameId; i++) {
if(mLocalBuf[i].len + len > MAX_BUFFER) {
DPRINTLN(DBG_ERROR, F("payload buffer to small!"));
return;
return true;
}
memcpy(&mPayload[len], mLocalBuf[i].buf, mLocalBuf[i].len);
len += mLocalBuf[i].len;
@ -552,19 +553,18 @@ class Communication : public CommQueue<> {
if(GridOnProFilePara == q->cmd) {
q->iv->addGridProfile(mPayload, len);
return;
return true;
}
record_t<> *rec = q->iv->getRecordStruct(q->cmd);
if(NULL == rec) {
if(GetLossRate == q->cmd) {
q->iv->parseGetLossRate(mPayload, len);
return;
} else {
return true;
} else
DPRINTLN(DBG_ERROR, F("record is NULL!"));
closeRequest(q, false);
}
return;
return false;
}
if((rec->pyldLen != len) && (0 != rec->pyldLen)) {
if(*mSerialDebug) {
@ -572,10 +572,8 @@ class Communication : public CommQueue<> {
DBGPRINT(String(rec->pyldLen));
DBGPRINTLN(F(" bytes"));
}
/*q->iv->radioStatistics.rxFail++;*/
closeRequest(q, false);
return;
return false;
}
rec->ts = q->ts;
@ -597,6 +595,7 @@ class Communication : public CommQueue<> {
yield();
}
}
return true;
}
void sendRetransmit(const queue_s *q, uint8_t i) {

13
src/publisher/pubMqttIvData.h

@ -78,7 +78,7 @@ class PubMqttIvData {
if((RealTimeRunData_Debug != mCmd) || !mRTRDataHasBeenSent) { // send RealTimeRunData only once
mSendTotals = (RealTimeRunData_Debug == mCmd);
memset(mTotal, 0, sizeof(float) * 4);
memset(mTotal, 0, sizeof(float) * 5);
mState = FIND_NXT_IV;
} else
mSendList->pop();
@ -164,6 +164,9 @@ class PubMqttIvData {
case FLD_PDC:
mTotal[3] += mIv->getValue(mPos, rec);
break;
case FLD_MP:
mTotal[4] += mIv->getValue(mPos, rec);
break;
}
} else
mAllTotalFound = false;
@ -204,7 +207,7 @@ class PubMqttIvData {
void stateSendTotals() {
uint8_t fieldId;
mRTRDataHasBeenSent = true;
if(mPos < 4) {
if(mPos < 5) {
bool retained = true;
switch (mPos) {
default:
@ -230,6 +233,10 @@ class PubMqttIvData {
fieldId = FLD_PDC;
retained = false;
break;
case 4:
fieldId = FLD_MP;
retained = false;
break;
}
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "total/%s", fields[fieldId]);
snprintf(mVal, 40, "%g", ah::round3(mTotal[mPos]));
@ -251,7 +258,7 @@ class PubMqttIvData {
uint8_t mCmd;
uint8_t mLastIvId;
bool mSendTotals, mTotalFound, mAllTotalFound, mSendTotalYd;
float mTotal[4], mYldTotalStore;
float mTotal[5], mYldTotalStore;
Inverter<> *mIv, *mIvSend;
uint8_t mPos;

Loading…
Cancel
Save