Skip to content

Commit

Permalink
MI - debug output for error calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
rejoe2 authored Mar 23, 2023
1 parent 0535117 commit 250d3f9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
20 changes: 10 additions & 10 deletions src/hm/hmPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,18 @@ class HmPayload {
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
}
} else { // payload complete
//DPRINT(DBG_INFO, F("procPyld: cmd: 0x"));
DPRINT(DBG_INFO, F("procPyld: cmd: 0x"));
//DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX));
DPRINT_INIT(DBG_INFO,TXT_PPYDCMD);
//DPRINT_INIT(DBG_INFO,TXT_PPYDCMD);
DBGHEXLN(mPayload[iv->id].txCmd);
//DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
DPRINT_INIT(DBG_INFO,TXT_PPYDTXI);
DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
//DPRINT_INIT(DBG_INFO,TXT_PPYDTXI);
//DBGPRINTLN(String(mPayload[iv->id].txId, HEX));
DBGHEXLN(mPayload[iv->id].txId);
DPRINT_INIT(DBG_DEBUG,TXT_PPYDMAX);
DBGPRINTLN(String(mPayload[iv->id].maxPackId));
//DPRINT(DBG_DEBUG, F("procPyld: max: ");// + String(mPayload[iv->id].maxPackId));
//DBGHEXLN(mPayload[iv->id].maxPackId);
//DPRINT_INIT(DBG_DEBUG,TXT_PPYDMAX);
//DBGPRINTLN(String(mPayload[iv->id].maxPackId));
DPRINT(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;
Expand Down Expand Up @@ -380,8 +380,8 @@ class HmPayload {
}

bool build(uint8_t id, bool *complete) {
//DPRINTLN(DBG_VERBOSE, F("build"));
DPRINTLN_TXT(DBG_VERBOSE, TXT_BUILD);
DPRINTLN(DBG_VERBOSE, F("build"));
//DPRINTLN_TXT(DBG_VERBOSE, TXT_BUILD);

uint16_t crc = 0xffff, crcRcv = 0x0000;
if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
Expand Down
30 changes: 21 additions & 9 deletions src/hm/miPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct {
bool complete;
bool dataAB[3];
bool stsAB[3];
uint8_t sts[5];
uint16_t sts[5];
uint8_t txId;
uint8_t invId;
uint8_t retransmits;
Expand Down Expand Up @@ -260,9 +260,10 @@ const byteAssign_t InfoAssignment[] = {
mStat->rxSuccess++;
}

} else if ( p->packet[0] == (TX_REQ_INFO + ALL_FRAMES) || p->packet[0] == 0xB6 ) { // response from get information command
// atm, we just do nothing else than print out what we got...
// for decoding see xls- Data collection instructions - #147ff
} else if ( p->packet[0] == (TX_REQ_INFO + ALL_FRAMES) // response from get information command
|| p->packet[0] == 0xB6 ) { // strange short response from MI-1500 3rd gen; might be missleading!
// atm, we just do nothing else than print out what we got...
// for decoding see xls- Data collection instructions - #147ff
//mPayload[iv->id].txId = p->packet[0];
//DPRINTLN(DBG_DEBUG, F("Response from info request received"));
DBGPRINTLN_TXT(TXT_RXDIREQ);
Expand All @@ -271,7 +272,7 @@ const byteAssign_t InfoAssignment[] = {
//DPRINT(DBG_DEBUG, F("fragment number zero received"));
DBGPRINTLN_TXT(TXT_FRAGM0);
iv->setQueuedCmdFinished();
} else if (p->packet[9] == 0x81) {
} else if (p->packet[9] == 0x81) { // might need some additional check, as this is only ment for short answers!
DPRINTHEAD(DBG_WARN, iv->id);
DBGPRINTLN_TXT(TXT_NO2NDG);
iv->ivGen = IV_HM;
Expand Down Expand Up @@ -574,13 +575,24 @@ const byteAssign_t InfoAssignment[] = {
mPayload[iv->id].txId = p->packet[0];

//uint8_t status = (p->packet[11] << 8) + p->packet[12];
uint8_t status = (p->packet[9] << 8) + p->packet[10];
//uint8_t stschan = p->packet[0] == 0x88 ? CH1 : CH2;
uint16_t status = 3; // regular status for MI, change to 1 later?
if ( p->packet[10] < 3 ) {
status = p->packet[10]*100 + p->packet[9]*10 + stschan; //first approach, needs review!
} else if ( p->packet[10] > 3 ) {
status = p->packet[10]*1000 + p->packet[9]*100 + p->packet[12]*10 + p->packet[11];
if (p->packet[12] < 6) {
status += stschan;
}
}
if ( status != 3 ) {
DPRINTLN(DBG_WARN, F("Error code ") + String(status));
}

mPayload[iv->id].sts[stschan] = status;
mPayload[iv->id].stsAB[stschan] = true;
if (mPayload[iv->id].stsAB[CH1] && mPayload[iv->id].stsAB[CH2])
mPayload[iv->id].stsAB[CH0] = true;
if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) {
if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0] ) {
mPayload[iv->id].sts[0] = status;
iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, status);
}
Expand Down Expand Up @@ -641,7 +653,7 @@ const byteAssign_t InfoAssignment[] = {
FCODE = (uint8_t)(p->packet[27]);
}*/

uint8_t status = (uint8_t)(p->packet[23]);
uint16_t status = (uint8_t)(p->packet[23]);
mPayload[iv->id].sts[datachan] = status;
if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) {
mPayload[iv->id].sts[0] = status;
Expand Down

0 comments on commit 250d3f9

Please sign in to comment.