Browse Source

added receive no answer counter #332

corrected resetPayload in app loop
pull/341/head
lumapu 2 years ago
parent
commit
7cd075fbad
  1. 27
      tools/esp8266/app.cpp
  2. 1
      tools/esp8266/defines.h
  3. 1
      tools/esp8266/html/index.html
  4. 9
      tools/esp8266/webApi.cpp

27
tools/esp8266/app.cpp

@ -226,25 +226,29 @@ void app::loop(void) {
mSendLastIvId = ((MAX_NUM_INVERTERS-1) == mSendLastIvId) ? 0 : mSendLastIvId + 1;
iv = mSys->getInverterByPos(mSendLastIvId);
} while((NULL == iv) && ((maxLoop--) > 0));
resetPayload(iv);
mPayload[iv->id].requested = true;
if(NULL != iv) {
if(!mPayload[iv->id].complete)
processPayload(false);
if(!mPayload[iv->id].complete) {
mStat.rxFail++;
if(0 == mPayload[iv->id].maxPackId)
mStat.rxFailNoAnser++;
else
mStat.rxFail++;
iv->setQueuedCmdFinished(); // command failed
if(mConfig.serialDebug) {
if(mConfig.serialDebug)
DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout"));
}
if(mConfig.serialDebug) {
DPRINT(DBG_INFO, F("Inverter #") + String(iv->id) + " ");
DPRINTLN(DBG_INFO, F("no Payload received! (retransmits: ") + String(mPayload[iv->id].retransmits) + ")");
}
}
resetPayload(iv);
mPayload[iv->id].requested = true;
yield();
if(mConfig.serialDebug) {
DPRINTLN(DBG_DEBUG, F("app:loop WiFi WiFi.status ") + String(WiFi.status()));
@ -257,7 +261,8 @@ void app::loop(void) {
mPayload[iv->id].txCmd = iv->devControlCmd;
iv->clearCmdQueue();
iv->enqueCommand<InfoCommand>(SystemConfigPara);
} else {
}
else {
uint8_t cmd = iv->getQueuedCmd();
mSys->Radio.sendTimePacket(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex);
mPayload[iv->id].txCmd = cmd;
@ -316,11 +321,12 @@ void app::processPayload(bool retransmit) {
for(uint8_t id = 0; id < mSys->getNumInverters(); id++) {
Inverter<> *iv = mSys->getInverterByPos(id);
if(NULL != iv) {
if(mPayload[iv->id].txId != (TX_REQ_INFO + 0x80)) {
if((mPayload[iv->id].txId != (TX_REQ_INFO + 0x80)) && (0 != mPayload[iv->id].txId)) {
// no processing needed if txId is not 0x95
DPRINTLN(DBG_DEBUG, F("processPayload - set complete"));
//DPRINTLN(DBG_INFO, F("processPayload - set complete, txId: ") + String(mPayload[iv->id].txId, HEX));
mPayload[iv->id].complete = true;
}
if(!mPayload[iv->id].complete ) {
if(!buildPayload(iv->id)) { // payload not complete
if(mPayload[iv->id].requested) {
@ -365,7 +371,8 @@ void app::processPayload(bool retransmit) {
DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId));
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
mPayload[iv->id].complete = true;
mStat.rxSuccess++;
if(mPayload[iv->id].txId == (TX_REQ_INFO + 0x80))
mStat.rxSuccess++;
uint8_t payload[128];
uint8_t offs = 0;
@ -466,8 +473,6 @@ void app::processPayload(bool retransmit) {
iv->setQueuedCmdFinished();
//resetPayload(iv);
#ifdef __MQTT_AFTER_RX__
doMQTT = true;
#endif

1
tools/esp8266/defines.h

@ -142,6 +142,7 @@ typedef struct {
typedef struct {
uint32_t rxFail;
uint32_t rxFailNoAnser;
uint32_t rxSuccess;
uint32_t frmCnt;
} statistics_t;

1
tools/esp8266/html/index.html

@ -67,6 +67,7 @@
function parseStat(obj) {
document.getElementById("stat").innerHTML = "RX success: " + obj["rx_success"]
+ "\nRX fail: " + obj["rx_fail"]
+ "\nRX no anwser: " + obj["rx_fail_answer"]
+ "\nFrames received: " + obj["frame_cnt"]
+ "\nTX Cnt: " + obj["tx_cnt"];
}

9
tools/esp8266/webApi.cpp

@ -129,10 +129,11 @@ void webApi::getSystem(JsonObject obj) {
//-----------------------------------------------------------------------------
void webApi::getStatistics(JsonObject obj) {
obj[F("rx_success")] = mStat->rxSuccess;
obj[F("rx_fail")] = mStat->rxFail;
obj[F("frame_cnt")] = mStat->frmCnt;
obj[F("tx_cnt")] = mApp->mSys->Radio.mSendCnt;
obj[F("rx_success")] = mStat->rxSuccess;
obj[F("rx_fail")] = mStat->rxFail;
obj[F("rx_fail_answer")] = mStat->rxFailNoAnser;
obj[F("frame_cnt")] = mStat->frmCnt;
obj[F("tx_cnt")] = mApp->mSys->Radio.mSendCnt;
}

Loading…
Cancel
Save