Skip to content

Commit

Permalink
0.8.39
Browse files Browse the repository at this point in the history
* add `getLossRate` to radio statistics and to MqTT #1199
  • Loading branch information
lumapu committed Jan 2, 2024
1 parent 27ad75b commit 40097ab
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* merge Prometheus metrics fix #1310
* merge MI grid profile request #1306
* merge update documentation / readme #1305
* add `getLossRate` to radio statistics and to MqTT #1199

## 0.8.38 - 2023-12-31
* fix Grid-Profile JSON #1304
Expand Down
4 changes: 4 additions & 0 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ typedef struct {
uint32_t frmCnt;
uint32_t txCnt;
uint32_t retransmits;
uint16_t ivRxCnt; // last iv rx frames (from GetLossRate)
uint16_t ivTxCnt; // last iv tx frames (from GetLossRate)
uint16_t dtuRxCnt; // current DTU rx frames (since last GetLossRate)
uint16_t dtuTxCnt; // current DTU tx frames (since last GetLossRate)
} statistics_t;

#endif /*__DEFINES_H__*/
2 changes: 1 addition & 1 deletion src/hm/Communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Communication : public CommQueue<> {

if(validateIvSerial(&p->packet[1], q->iv)) {
q->iv->radioStatistics.frmCnt++;
q->iv->mDtuRxCnt++;
q->iv->radioStatistics.dtuRxCnt++;

if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command
if(parseFrame(p))
Expand Down
35 changes: 15 additions & 20 deletions src/hm/hmInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ class Inverter {
uint8_t curCmtFreq; // current used CMT frequency, used to check if freq. was changed during runtime
bool commEnabled; // 'pause night communication' sets this field to false

uint16_t mIvRxCnt; // last iv rx frames (from GetLossRate)
uint16_t mIvTxCnt; // last iv tx frames (from GetLossRate)
uint16_t mDtuRxCnt; // cur dtu rx frames (since last GetLossRate)
uint16_t mDtuTxCnt; // cur dtu tx frames (since last getLoassRate)
uint8_t mGetLossInterval; // request iv every AHOY_GET_LOSS_INTERVAL RealTimeRunData_Debu

static uint32_t *timestamp; // system timestamp
static cfgInst_t *generalConfig; // general inverter configuration from setup

Expand All @@ -171,10 +165,6 @@ class Inverter {
mIsSingleframeReq = false;
radio = NULL;
commEnabled = true;
mIvRxCnt = 0;
mIvTxCnt = 0;
mDtuRxCnt = 0;
mDtuTxCnt = 0;

memset(&radioStatistics, 0, sizeof(statistics_t));
memset(heuristics.txRfQuality, -6, 5);
Expand Down Expand Up @@ -605,21 +595,25 @@ class Inverter {
uint16_t rxCnt = (pyld[0] << 8) + pyld[1];
uint16_t txCnt = (pyld[2] << 8) + pyld[3];

if (mIvRxCnt || mIvTxCnt) { // there was successful GetLossRate in the past
if (radioStatistics.ivRxCnt || radioStatistics.ivTxCnt) { // there was successful GetLossRate in the past
DPRINT_IVID(DBG_INFO, id);
DBGPRINTLN("Inv loss: " +
String (mDtuTxCnt - (rxCnt - mIvRxCnt)) + " of " +
String (mDtuTxCnt) + ", DTU loss: " +
String (txCnt - mIvTxCnt - mDtuRxCnt) + " of " +
String (txCnt - mIvTxCnt));
DBGPRINT(F("Inv loss: "));
DBGPRINT(String (radioStatistics.dtuTxCnt - (rxCnt - radioStatistics.ivRxCnt)));
DBGPRINT(F(" of "));
DBGPRINT(String (radioStatistics.dtuTxCnt));
DBGPRINT(F(", DTU loss: "));
DBGPRINT(String (txCnt - radioStatistics.ivTxCnt - radioStatistics.dtuRxCnt));
DBGPRINT(F(" of "));
DBGPRINTLN(String (txCnt - radioStatistics.ivTxCnt));
}

mIvRxCnt = rxCnt;
mIvTxCnt = txCnt;
mDtuRxCnt = 0; // start new interval
mDtuTxCnt = 0; // start new interval
radioStatistics.ivRxCnt = rxCnt;
radioStatistics.ivTxCnt = txCnt;
radioStatistics.dtuRxCnt = 0; // start new interval
radioStatistics.dtuTxCnt = 0; // start new interval
return true;
}

return false;
}

Expand Down Expand Up @@ -811,6 +805,7 @@ class Inverter {
bool mDevControlRequest; // true if change needed
uint8_t mGridLen = 0;
uint8_t mGridProfile[MAX_GRID_LENGTH];
uint8_t mGetLossInterval; // request iv every AHOY_GET_LOSS_INTERVAL RealTimeRunData_Debug
};

template <class REC_TYP>
Expand Down
2 changes: 1 addition & 1 deletion src/hm/hmRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class HmRadio : public Radio {
mMillis = millis();

mLastIv = iv;
iv->mDtuTxCnt++;
iv->radioStatistics.dtuTxCnt++;
}

uint64_t getIvId(Inverter<> *iv) {
Expand Down
2 changes: 1 addition & 1 deletion src/hms/hmsRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CmtRadio : public Radio {
if(CMT_ERR_RX_IN_FIFO == status)
mIrqRcvd = true;
}
iv->mDtuTxCnt++;
iv->radioStatistics.dtuTxCnt++;
}

uint64_t getIvId(Inverter<> *iv) {
Expand Down
10 changes: 7 additions & 3 deletions src/publisher/pubMqttIvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,16 @@ class PubMqttIvData {

inline void sendRadioStat(uint8_t start) {
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/radio_stat", mIv->config->name);
snprintf(mVal, 100, "{\"tx\":%d,\"success\":%d,\"fail\":%d,\"no_answer\":%d,\"retransmits\":%d}",
snprintf(mVal, 140, "{\"tx\":%d,\"success\":%d,\"fail\":%d,\"no_answer\":%d,\"retransmits\":%d,\"lossIvRx\":%d,\"lossIvTx\":%d,\"lossDtuRx\":%d,\"lossDtuTx\":%d}",
mIv->radioStatistics.txCnt,
mIv->radioStatistics.rxSuccess,
mIv->radioStatistics.rxFail,
mIv->radioStatistics.rxFailNoAnser,
mIv->radioStatistics.retransmits);
mIv->radioStatistics.retransmits,
mIv->radioStatistics.ivRxCnt,
mIv->radioStatistics.ivTxCnt,
mIv->radioStatistics.dtuRxCnt,
mIv->radioStatistics.dtuTxCnt);
mPublish(mSubTopic, mVal, false, QOS_0);
}

Expand Down Expand Up @@ -263,7 +267,7 @@ class PubMqttIvData {
bool mRTRDataHasBeenSent;

char mSubTopic[32 + MAX_NAME_LENGTH + 1];
char mVal[100];
char mVal[140];
bool mZeroValues; // makes sure that yield day is sent even if no inverter is online

std::queue<sendListCmdIv> *mSendList;
Expand Down

0 comments on commit 40097ab

Please sign in to comment.