|
@ -94,10 +94,10 @@ class MiPayload { |
|
|
|
|
|
|
|
|
iv->setQueuedCmdFinished(); // command failed
|
|
|
iv->setQueuedCmdFinished(); // command failed
|
|
|
if (mSerialDebug) |
|
|
if (mSerialDebug) |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINTLN(F("enqueued cmd failed/timeout")); |
|
|
DBGPRINTLN(F("enqueued cmd failed/timeout")); |
|
|
if (mSerialDebug) { |
|
|
if (mSerialDebug) { |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINT(F("no Payload received! (retransmits: ")); |
|
|
DBGPRINT(F("no Payload received! (retransmits: ")); |
|
|
DBGPRINT(String(mPayload[iv->id].retransmits)); |
|
|
DBGPRINT(String(mPayload[iv->id].retransmits)); |
|
|
DBGPRINTLN(F(")")); |
|
|
DBGPRINTLN(F(")")); |
|
@ -111,14 +111,14 @@ class MiPayload { |
|
|
|
|
|
|
|
|
yield(); |
|
|
yield(); |
|
|
if (mSerialDebug){ |
|
|
if (mSerialDebug){ |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINT(F("Requesting Inv SN ")); |
|
|
DBGPRINT(F("Requesting Inv SN ")); |
|
|
DBGPRINTLN(String(iv->config->serial.u64, HEX)); |
|
|
DBGPRINTLN(String(iv->config->serial.u64, HEX)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (iv->getDevControlRequest()) { |
|
|
if (iv->getDevControlRequest()) { |
|
|
if (mSerialDebug) { |
|
|
if (mSerialDebug) { |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINT(F("Devcontrol request 0x")); |
|
|
DBGPRINT(F("Devcontrol request 0x")); |
|
|
DHEX(iv->devControlCmd); |
|
|
DHEX(iv->devControlCmd); |
|
|
DBGPRINT(F(" power limit ")); |
|
|
DBGPRINT(F(" power limit ")); |
|
@ -132,9 +132,9 @@ class MiPayload { |
|
|
iv->enqueCommand<InfoCommand>(SystemConfigPara); // try to read back power limit
|
|
|
iv->enqueCommand<InfoCommand>(SystemConfigPara); // try to read back power limit
|
|
|
} else { |
|
|
} else { |
|
|
uint8_t cmd = iv->getQueuedCmd(); |
|
|
uint8_t cmd = iv->getQueuedCmd(); |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINT(F("prepareDevInformCmd 0x")); |
|
|
DBGPRINT(F("prepareDevInformCmd 0x")); |
|
|
DHEXLN(cmd); |
|
|
DBGHEXLN(cmd); |
|
|
uint8_t cmd2 = cmd; |
|
|
uint8_t cmd2 = cmd; |
|
|
if ( cmd == SystemConfigPara ) { //0x05 for HM-types
|
|
|
if ( cmd == SystemConfigPara ) { //0x05 for HM-types
|
|
|
if (!mPayload[iv->id].limitrequested) { // only do once at startup
|
|
|
if (!mPayload[iv->id].limitrequested) { // only do once at startup
|
|
@ -180,7 +180,8 @@ class MiPayload { |
|
|
|
|
|
|
|
|
else if ( p->packet[0] == 0x09 + ALL_FRAMES || |
|
|
else if ( p->packet[0] == 0x09 + ALL_FRAMES || |
|
|
p->packet[0] == 0x11 + ALL_FRAMES || |
|
|
p->packet[0] == 0x11 + ALL_FRAMES || |
|
|
( p->packet[0] >= (0x36 + ALL_FRAMES) && p->packet[0] < (0x39 + SINGLE_FRAME) ) ) { // small MI or MI 1500 data responses to 0x09, 0x11, 0x36, 0x37, 0x38 and 0x39
|
|
|
( p->packet[0] >= (0x36 + ALL_FRAMES) && p->packet[0] < (0x39 + SINGLE_FRAME) |
|
|
|
|
|
&& mPayload[iv->id].txCmd != 0x0f) ) { // small MI or MI 1500 data responses to 0x09, 0x11, 0x36, 0x37, 0x38 and 0x39
|
|
|
mPayload[iv->id].txId = p->packet[0]; |
|
|
mPayload[iv->id].txId = p->packet[0]; |
|
|
miDataDecode(iv,p); |
|
|
miDataDecode(iv,p); |
|
|
} |
|
|
} |
|
@ -231,13 +232,15 @@ const byteAssign_t InfoAssignment[] = { |
|
|
iv->setValue(i, rec, (float) ((p->packet[(12+2*i)] << 8) + p->packet[(13+2*i)])/1); |
|
|
iv->setValue(i, rec, (float) ((p->packet[(12+2*i)] << 8) + p->packet[(13+2*i)])/1); |
|
|
} |
|
|
} |
|
|
iv->isConnected = true; |
|
|
iv->isConnected = true; |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
if(mSerialDebug) { |
|
|
|
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DPRINT(DBG_INFO,F("HW_VER is ")); |
|
|
DPRINT(DBG_INFO,F("HW_VER is ")); |
|
|
DBGPRINTLN(String((p->packet[24] << 8) + p->packet[25])); |
|
|
DBGPRINTLN(String((p->packet[24] << 8) + p->packet[25])); |
|
|
|
|
|
} |
|
|
/*iv->setQueuedCmdFinished();
|
|
|
/*iv->setQueuedCmdFinished();
|
|
|
mSys->Radio.sendCmdPacket(iv->radioId.u64, 0x0f, 0x01, false);*/ |
|
|
mSys->Radio.sendCmdPacket(iv->radioId.u64, 0x0f, 0x01, false);*/ |
|
|
} else if ( p->packet[9] == 0x01 || p->packet[9] == 0x10 ) {//second frame for MI, 3rd gen. answers in 0x10
|
|
|
} else if ( p->packet[9] == 0x01 || p->packet[9] == 0x10 ) {//second frame for MI, 3rd gen. answers in 0x10
|
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
if ( p->packet[9] == 0x01 ) { |
|
|
if ( p->packet[9] == 0x01 ) { |
|
|
DBGPRINTLN(F("got 2nd frame (hw info)")); |
|
|
DBGPRINTLN(F("got 2nd frame (hw info)")); |
|
|
} else { |
|
|
} else { |
|
@ -248,9 +251,11 @@ const byteAssign_t InfoAssignment[] = { |
|
|
DBGPRINTLN(String((uint32_t) (((p->packet[10] << 8) | p->packet[11]) << 8 | p->packet[12]) << 8 | p->packet[13])); |
|
|
DBGPRINTLN(String((uint32_t) (((p->packet[10] << 8) | p->packet[11]) << 8 | p->packet[12]) << 8 | p->packet[13])); |
|
|
//DBGPRINTLN(String((p->packet[12] << 8) + p->packet[13]));
|
|
|
//DBGPRINTLN(String((p->packet[12] << 8) + p->packet[13]));
|
|
|
if ( p->packet[9] == 0x01 ) { |
|
|
if ( p->packet[9] == 0x01 ) { |
|
|
|
|
|
iv->setValue(iv->getPosByChFld(0, FLD_YT, rec), rec, (float) ((p->packet[20] << 8) + p->packet[21])/1); |
|
|
|
|
|
if(mSerialDebug) { |
|
|
DPRINT(DBG_INFO,F("HW_ECapValue ")); |
|
|
DPRINT(DBG_INFO,F("HW_ECapValue ")); |
|
|
DBGPRINTLN(String((p->packet[20] << 8) + p->packet[21])); |
|
|
DBGPRINTLN(String((p->packet[20] << 8) + p->packet[21])); |
|
|
iv->setValue(iv->getPosByChFld(0, FLD_YT, rec), rec, (float) ((p->packet[20] << 8) + p->packet[21])/1); |
|
|
|
|
|
DPRINT(DBG_INFO,F("HW_FB_TLmValue ")); |
|
|
DPRINT(DBG_INFO,F("HW_FB_TLmValue ")); |
|
|
DBGPRINTLN(String((p->packet[14] << 8) + p->packet[15])); |
|
|
DBGPRINTLN(String((p->packet[14] << 8) + p->packet[15])); |
|
|
DPRINT(DBG_INFO,F("HW_FB_ReSPRT ")); |
|
|
DPRINT(DBG_INFO,F("HW_FB_ReSPRT ")); |
|
@ -258,8 +263,9 @@ const byteAssign_t InfoAssignment[] = { |
|
|
DPRINT(DBG_INFO,F("HW_GridSamp_ResValule ")); |
|
|
DPRINT(DBG_INFO,F("HW_GridSamp_ResValule ")); |
|
|
DBGPRINTLN(String((p->packet[18] << 8) + p->packet[19])); |
|
|
DBGPRINTLN(String((p->packet[18] << 8) + p->packet[19])); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
} else if ( p->packet[9] == 0x12 ) {//3rd frame
|
|
|
} else if ( p->packet[9] == 0x12 ) {//3rd frame
|
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINTLN(F("got 3rd frame (hw info)")); |
|
|
DBGPRINTLN(F("got 3rd frame (hw info)")); |
|
|
iv->setQueuedCmdFinished(); |
|
|
iv->setQueuedCmdFinished(); |
|
|
mStat->rxSuccess++; |
|
|
mStat->rxSuccess++; |
|
@ -276,9 +282,8 @@ const byteAssign_t InfoAssignment[] = { |
|
|
DPRINT(DBG_DEBUG, F("fragment number zero received")); |
|
|
DPRINT(DBG_DEBUG, F("fragment number zero received")); |
|
|
iv->setQueuedCmdFinished(); |
|
|
iv->setQueuedCmdFinished(); |
|
|
} else if (p->packet[9] == 0x81) { // might need some additional check, as this is only ment for short answers!
|
|
|
} else if (p->packet[9] == 0x81) { // might need some additional check, as this is only ment for short answers!
|
|
|
DPRINT(DBG_WARN, F("(#")); |
|
|
DPRINT_IVID(DBG_WARN, iv->id); |
|
|
DBGPRINT(String(iv->id)); |
|
|
DBGPRINTLN(F("seems to use 3rd gen. protocol - switching ivGen!")); |
|
|
DBGPRINTLN(F(") seems to use 3rd gen. protocol - switching ivGen!")); |
|
|
|
|
|
iv->ivGen = IV_HM; |
|
|
iv->ivGen = IV_HM; |
|
|
iv->setQueuedCmdFinished(); |
|
|
iv->setQueuedCmdFinished(); |
|
|
iv->clearCmdQueue(); |
|
|
iv->clearCmdQueue(); |
|
@ -301,7 +306,7 @@ const byteAssign_t InfoAssignment[] = { |
|
|
//}
|
|
|
//}
|
|
|
} else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES ) // response from dev control command
|
|
|
} else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES ) // response from dev control command
|
|
|
|| p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES -1)) { // response from DRED instruction
|
|
|
|| p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES -1)) { // response from DRED instruction
|
|
|
DPRINTHEAD(DBG_DEBUG, iv->id); |
|
|
DPRINT_IVID(DBG_DEBUG, iv->id); |
|
|
DBGPRINTLN(F("Response from devcontrol request received")); |
|
|
DBGPRINTLN(F("Response from devcontrol request received")); |
|
|
|
|
|
|
|
|
mPayload[iv->id].txId = p->packet[0]; |
|
|
mPayload[iv->id].txId = p->packet[0]; |
|
@ -309,7 +314,7 @@ const byteAssign_t InfoAssignment[] = { |
|
|
|
|
|
|
|
|
if ((p->packet[9] == 0x5a) && (p->packet[10] == 0x5a)) { |
|
|
if ((p->packet[9] == 0x5a) && (p->packet[10] == 0x5a)) { |
|
|
mApp->setMqttPowerLimitAck(iv); |
|
|
mApp->setMqttPowerLimitAck(iv); |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINT(F("has accepted power limit set point ")); |
|
|
DBGPRINT(F("has accepted power limit set point ")); |
|
|
DBGPRINT(String(iv->powerLimit[0])); |
|
|
DBGPRINT(String(iv->powerLimit[0])); |
|
|
DBGPRINT(F(" with PowerLimitControl ")); |
|
|
DBGPRINT(F(" with PowerLimitControl ")); |
|
@ -321,9 +326,9 @@ const byteAssign_t InfoAssignment[] = { |
|
|
iv->devControlCmd = Init; |
|
|
iv->devControlCmd = Init; |
|
|
} else { // some other response; copied from hmPayload:process; might not be correct to do that here!!!
|
|
|
} else { // some other response; copied from hmPayload:process; might not be correct to do that here!!!
|
|
|
DPRINT(DBG_INFO, F("procPyld: cmd: 0x")); |
|
|
DPRINT(DBG_INFO, F("procPyld: cmd: 0x")); |
|
|
DHEXLN(mPayload[iv->id].txCmd); |
|
|
DBGHEXLN(mPayload[iv->id].txCmd); |
|
|
DPRINT(DBG_INFO, F("procPyld: txid: 0x")); |
|
|
DPRINT(DBG_INFO, F("procPyld: txid: 0x")); |
|
|
DHEXLN(mPayload[iv->id].txId); |
|
|
DBGHEXLN(mPayload[iv->id].txId); |
|
|
//DPRINT(DBG_DEBUG, F("procPyld: max: "));
|
|
|
//DPRINT(DBG_DEBUG, F("procPyld: max: "));
|
|
|
//DBGPRINTLN(String(mPayload[iv->id].maxPackId));
|
|
|
//DBGPRINTLN(String(mPayload[iv->id].maxPackId));
|
|
|
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
|
|
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
|
@ -420,11 +425,11 @@ const byteAssign_t InfoAssignment[] = { |
|
|
if ((mPayload[iv->id].requested) && (retransmit)) { |
|
|
if ((mPayload[iv->id].requested) && (retransmit)) { |
|
|
if (iv->devControlCmd == Restart || iv->devControlCmd == CleanState_LockAndAlarm) { |
|
|
if (iv->devControlCmd == Restart || iv->devControlCmd == CleanState_LockAndAlarm) { |
|
|
// This is required to prevent retransmissions without answer.
|
|
|
// This is required to prevent retransmissions without answer.
|
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINTLN(F("Prevent retransmit on Restart / CleanState_LockAndAlarm...")); |
|
|
DBGPRINTLN(F("Prevent retransmit on Restart / CleanState_LockAndAlarm...")); |
|
|
mPayload[iv->id].retransmits = mMaxRetrans; |
|
|
mPayload[iv->id].retransmits = mMaxRetrans; |
|
|
} else if(iv->devControlCmd == ActivePowerContr) { |
|
|
} else if(iv->devControlCmd == ActivePowerContr) { |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINTLN(F("retransmit power limit")); |
|
|
DBGPRINTLN(F("retransmit power limit")); |
|
|
mRadio->sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true, false); |
|
|
mRadio->sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true, false); |
|
|
} else { |
|
|
} else { |
|
@ -432,7 +437,7 @@ const byteAssign_t InfoAssignment[] = { |
|
|
if (mPayload[iv->id].retransmits < mMaxRetrans) { |
|
|
if (mPayload[iv->id].retransmits < mMaxRetrans) { |
|
|
mPayload[iv->id].retransmits++; |
|
|
mPayload[iv->id].retransmits++; |
|
|
if( !mPayload[iv->id].gotFragment ) { |
|
|
if( !mPayload[iv->id].gotFragment ) { |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINTLN(F("nothing received")); |
|
|
DBGPRINTLN(F("nothing received")); |
|
|
mPayload[iv->id].retransmits = mMaxRetrans; |
|
|
mPayload[iv->id].retransmits = mMaxRetrans; |
|
|
} else if ( cmd == 0x0f ) { |
|
|
} else if ( cmd == 0x0f ) { |
|
@ -463,7 +468,7 @@ const byteAssign_t InfoAssignment[] = { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
if (change) { |
|
|
if (change) { |
|
|
DBGPRINT(F("next request is")); |
|
|
DBGPRINT(F("next request is")); |
|
|
//mPayload[iv->id].skipfirstrepeat = 0;
|
|
|
//mPayload[iv->id].skipfirstrepeat = 0;
|
|
@ -472,7 +477,7 @@ const byteAssign_t InfoAssignment[] = { |
|
|
DBGPRINT(F(" missing: Request Retransmit")); |
|
|
DBGPRINT(F(" missing: Request Retransmit")); |
|
|
} |
|
|
} |
|
|
DBGPRINT(F(" 0x")); |
|
|
DBGPRINT(F(" 0x")); |
|
|
DHEXLN(cmd); |
|
|
DBGHEXLN(cmd); |
|
|
//mSys->Radio.sendCmdPacket(iv->radioId.u64, cmd, cmd, true);
|
|
|
//mSys->Radio.sendCmdPacket(iv->radioId.u64, cmd, cmd, true);
|
|
|
mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, true, cmd); |
|
|
mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, true, cmd); |
|
|
mPayload[iv->id].txCmd = cmd; |
|
|
mPayload[iv->id].txCmd = cmd; |
|
@ -484,13 +489,13 @@ const byteAssign_t InfoAssignment[] = { |
|
|
} else if(!crcPass && pyldComplete) { // crc error on complete Payload
|
|
|
} else if(!crcPass && pyldComplete) { // crc error on complete Payload
|
|
|
if (mPayload[iv->id].retransmits < mMaxRetrans) { |
|
|
if (mPayload[iv->id].retransmits < mMaxRetrans) { |
|
|
mPayload[iv->id].retransmits++; |
|
|
mPayload[iv->id].retransmits++; |
|
|
DPRINTHEAD(DBG_WARN, iv->id); |
|
|
DPRINT_IVID(DBG_WARN, iv->id); |
|
|
DBGPRINTLN(F("CRC Error: Request Complete Retransmit")); |
|
|
DBGPRINTLN(F("CRC Error: Request Complete Retransmit")); |
|
|
mPayload[iv->id].txCmd = iv->getQueuedCmd(); |
|
|
mPayload[iv->id].txCmd = iv->getQueuedCmd(); |
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
|
|
|
|
|
|
DBGPRINT(F("prepareDevInformCmd 0x")); |
|
|
DBGPRINT(F("prepareDevInformCmd 0x")); |
|
|
DHEXLN(mPayload[iv->id].txCmd); |
|
|
DBGHEXLN(mPayload[iv->id].txCmd); |
|
|
mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); |
|
|
mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -574,8 +579,8 @@ const byteAssign_t InfoAssignment[] = { |
|
|
void miStsConsolidate(Inverter<> *iv, uint8_t stschan, record_t<> *rec, uint8_t uState, uint8_t uEnum, uint8_t lState = 0, uint8_t lEnum = 0) { |
|
|
void miStsConsolidate(Inverter<> *iv, uint8_t stschan, record_t<> *rec, uint8_t uState, uint8_t uEnum, uint8_t lState = 0, uint8_t lEnum = 0) { |
|
|
//uint8_t status = (p->packet[11] << 8) + p->packet[12];
|
|
|
//uint8_t status = (p->packet[11] << 8) + p->packet[12];
|
|
|
uint16_t status = 3; // regular status for MI, change to 1 later?
|
|
|
uint16_t status = 3; // regular status for MI, change to 1 later?
|
|
|
if ( uState < 3 ) { |
|
|
if ( uState == 2 ) { |
|
|
status = uState*100 + stschan; //first approach, needs review!
|
|
|
status = 5050 + stschan; //first approach, needs review!
|
|
|
if (lState) |
|
|
if (lState) |
|
|
status += lState*10; |
|
|
status += lState*10; |
|
|
} else if ( uState > 3 ) { |
|
|
} else if ( uState > 3 ) { |
|
@ -587,13 +592,16 @@ const byteAssign_t InfoAssignment[] = { |
|
|
if (uEnum < 6) { |
|
|
if (uEnum < 6) { |
|
|
status += stschan; |
|
|
status += stschan; |
|
|
} |
|
|
} |
|
|
|
|
|
if (status == 8000) |
|
|
|
|
|
status = 8310; //trick?
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint16_t prntsts = status == 3 ? 1 : status; |
|
|
uint16_t prntsts = status == 3 ? 1 : status; |
|
|
if ( status != mPayload[iv->id].sts[stschan] ) { //sth.'s changed?
|
|
|
if ( status != mPayload[iv->id].sts[stschan] ) { //sth.'s changed?
|
|
|
mPayload[iv->id].sts[stschan] = status; |
|
|
mPayload[iv->id].sts[stschan] = status; |
|
|
DPRINT(DBG_WARN, F("Status change for CH")); |
|
|
DPRINT(DBG_WARN, F("Status change for CH")); |
|
|
DBGPRINT(String(stschan)); DBGPRINT(F(": ")); |
|
|
DBGPRINT(String(stschan)); DBGPRINT(F(" (")); |
|
|
|
|
|
DBGPRINT(String(prntsts)); DBGPRINT(F("): ")); |
|
|
DBGPRINTLN(iv->getAlarmStr(prntsts)); |
|
|
DBGPRINTLN(iv->getAlarmStr(prntsts)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -605,7 +613,7 @@ const byteAssign_t InfoAssignment[] = { |
|
|
if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ |
|
|
if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ |
|
|
iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; // seems there's no status per channel in 3rd gen. models?!?
|
|
|
iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; // seems there's no status per channel in 3rd gen. models?!?
|
|
|
|
|
|
|
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINT(F("alarm ID incremented to ")); |
|
|
DBGPRINT(F("alarm ID incremented to ")); |
|
|
DBGPRINTLN(String(iv->alarmMesIndex)); |
|
|
DBGPRINTLN(String(iv->alarmMesIndex)); |
|
|
} |
|
|
} |
|
@ -692,7 +700,7 @@ const byteAssign_t InfoAssignment[] = { |
|
|
/*if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){
|
|
|
/*if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){
|
|
|
iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; |
|
|
iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; |
|
|
|
|
|
|
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINT_TXT(TXT_INCRALM); |
|
|
DBGPRINT_TXT(TXT_INCRALM); |
|
|
DBGPRINTLN(String(iv->alarmMesIndex)); |
|
|
DBGPRINTLN(String(iv->alarmMesIndex)); |
|
|
}*/ |
|
|
}*/ |
|
@ -728,7 +736,7 @@ const byteAssign_t InfoAssignment[] = { |
|
|
if (mPayload[iv->id].complete) |
|
|
if (mPayload[iv->id].complete) |
|
|
return; //if we got second message as well in repreated attempt
|
|
|
return; //if we got second message as well in repreated attempt
|
|
|
mPayload[iv->id].complete = true; // For 2 CH devices, this might be too short...
|
|
|
mPayload[iv->id].complete = true; // For 2 CH devices, this might be too short...
|
|
|
DPRINTHEAD(DBG_INFO, iv->id); |
|
|
DPRINT_IVID(DBG_INFO, iv->id); |
|
|
DBGPRINTLN(F("got all msgs")); |
|
|
DBGPRINTLN(F("got all msgs")); |
|
|
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); |
|
|
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); |
|
|
iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); |
|
|
iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); |
|
@ -753,38 +761,23 @@ const byteAssign_t InfoAssignment[] = { |
|
|
|
|
|
|
|
|
bool build(uint8_t id, bool *complete) { |
|
|
bool build(uint8_t id, bool *complete) { |
|
|
DPRINTLN(DBG_VERBOSE, F("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) |
|
|
|
|
|
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; |
|
|
|
|
|
*/ |
|
|
|
|
|
// check if all messages are there
|
|
|
// check if all messages are there
|
|
|
|
|
|
|
|
|
*complete = mPayload[id].complete; |
|
|
*complete = mPayload[id].complete; |
|
|
uint8_t txCmd = mPayload[id].txCmd; |
|
|
uint8_t txCmd = mPayload[id].txCmd; |
|
|
//uint8_t cmd = getQueuedCmd();
|
|
|
|
|
|
if(!*complete) { |
|
|
if(!*complete) { |
|
|
DPRINTLN(DBG_VERBOSE, F("incomlete, txCmd is 0x") + String(txCmd, HEX)); // + F("cmd is 0x") + String(cmd, HEX));
|
|
|
DPRINTLN(DBG_VERBOSE, F("incomlete, txCmd is 0x") + String(txCmd, HEX)); |
|
|
|
|
|
//DBGHEXLN(txCmd);
|
|
|
if (txCmd == 0x09 || txCmd == 0x11 || (txCmd >= 0x36 && txCmd <= 0x39)) |
|
|
if (txCmd == 0x09 || txCmd == 0x11 || (txCmd >= 0x36 && txCmd <= 0x39)) |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) {
|
|
|
|
|
|
if (mPayload[id].len[i] > 0) { |
|
|
|
|
|
if (i == (mPayload[id].maxPackId - 1)) { |
|
|
|
|
|
crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i] - 2, crc); |
|
|
|
|
|
crcRcv = (mPayload[id].data[i][mPayload[id].len[i] - 2] << 8) | (mPayload[id].data[i][mPayload[id].len[i] - 1]); |
|
|
|
|
|
} else |
|
|
|
|
|
crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i], crc); |
|
|
|
|
|
} |
|
|
|
|
|
yield(); |
|
|
|
|
|
} |
|
|
|
|
|
return (crc == crcRcv) ? true : false;*/ |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void reset(uint8_t id, bool clrSts = false) { |
|
|
void reset(uint8_t id, bool clrSts = false) { |
|
|
DPRINTHEAD(DBG_INFO, id); |
|
|
DPRINT_IVID(DBG_INFO, id); |
|
|
DBGPRINTLN(F("resetPayload")); |
|
|
DBGPRINTLN(F("resetPayload")); |
|
|
memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES); |
|
|
memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES); |
|
|
mPayload[id].gotFragment = false; |
|
|
mPayload[id].gotFragment = false; |
|
|