mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-23 22:06:11 +02:00
clean up pull request
This commit is contained in:
parent
b498ea619f
commit
3ed76324d5
4 changed files with 76 additions and 189 deletions
|
@ -143,10 +143,10 @@ class Inverter {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void enqueCommand(uint8_t cmd) {
|
void enqueCommand(uint8_t cmd) {
|
||||||
_commandQueue.push(std::make_shared<T>(cmd));
|
_commandQueue.push(std::make_shared<T>(cmd));
|
||||||
DPRINTHEAD(DBG_INFO, id);
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
//DBGPRINTLN(F("enqueuedCmd: 0x") + String(cmd, HEX));
|
DBGPRINT(String(id));
|
||||||
DBGPRINT_TXT(TXT_ENQUCMD);
|
DBGPRINT(F(") enqueCommand: 0x"));
|
||||||
DBGHEXLN(cmd);
|
DHEX(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setQueuedCmdFinished() {
|
void setQueuedCmdFinished() {
|
||||||
|
@ -157,8 +157,7 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearCmdQueue() {
|
void clearCmdQueue() {
|
||||||
DPRINTHEAD(DBG_INFO, id);
|
DPRINTLN(DBG_INFO, F("clearCmdQueue"));
|
||||||
DBGPRINTLN_TXT(TXT_CLRQUE);
|
|
||||||
while (!_commandQueue.empty()) {
|
while (!_commandQueue.empty()) {
|
||||||
// Will destroy CommandAbstract Class Object (?)
|
// Will destroy CommandAbstract Class Object (?)
|
||||||
_commandQueue.pop();
|
_commandQueue.pop();
|
||||||
|
|
|
@ -117,13 +117,11 @@ class HmPayload {
|
||||||
|
|
||||||
iv->setQueuedCmdFinished(); // command failed
|
iv->setQueuedCmdFinished(); // command failed
|
||||||
if (mSerialDebug)
|
if (mSerialDebug)
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout"));
|
||||||
DBGPRINTLN_TXT(TXT_TIMEOUT);
|
|
||||||
//DBGPRINTLN(F("enqueued cmd failed/timeout"));
|
|
||||||
if (mSerialDebug) {
|
if (mSerialDebug) {
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
//DBGPRINT(F("no Payload received! (retransmits: "));
|
DBGPRINT(String(iv->id));
|
||||||
DBGPRINT_TXT(TXT_NOPYLD);
|
DBGPRINT(F(") no Payload received! (retransmits: "));
|
||||||
DBGPRINT(String(mPayload[iv->id].retransmits));
|
DBGPRINT(String(mPayload[iv->id].retransmits));
|
||||||
DBGPRINTLN(F(")"));
|
DBGPRINTLN(F(")"));
|
||||||
}
|
}
|
||||||
|
@ -136,17 +134,17 @@ class HmPayload {
|
||||||
|
|
||||||
yield();
|
yield();
|
||||||
if (mSerialDebug) {
|
if (mSerialDebug) {
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
//DBGPRINT(F("Requesting Inv SN "));
|
DBGPRINT(String(iv->id));
|
||||||
DBGPRINT_TXT(TXT_INVSERNO);
|
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(DBG_INFO, F("(#"));
|
||||||
//DBGPRINT(F("Devcontrol request 0x"));
|
DBGPRINT(String(iv->id));
|
||||||
DBGPRINT_TXT(TXT_DEVCTRL);
|
DBGPRINT(F(") Devcontrol request 0x"));
|
||||||
DBGPRINT(String(iv->devControlCmd, HEX));
|
DBGPRINT(String(iv->devControlCmd, HEX));
|
||||||
DBGPRINT(F(" power limit "));
|
DBGPRINT(F(" power limit "));
|
||||||
DBGPRINTLN(String(iv->powerLimit[0]));
|
DBGPRINTLN(String(iv->powerLimit[0]));
|
||||||
|
@ -157,9 +155,9 @@ class HmPayload {
|
||||||
//iv->enqueCommand<InfoCommand>(SystemConfigPara); // read back power limit
|
//iv->enqueCommand<InfoCommand>(SystemConfigPara); // read back power limit
|
||||||
} else {
|
} else {
|
||||||
uint8_t cmd = iv->getQueuedCmd();
|
uint8_t cmd = iv->getQueuedCmd();
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
//DBGPRINT(F("prepareDevInformCmd 0x"));
|
DBGPRINT(String(iv->id));
|
||||||
DBGPRINT_TXT(TXT_GDEVINF);
|
DBGPRINT(F(") prepareDevInformCmd 0x"));
|
||||||
DBGPRINTLN(String(cmd, HEX));
|
DBGPRINTLN(String(cmd, HEX));
|
||||||
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false);
|
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false);
|
||||||
mPayload[iv->id].txCmd = cmd;
|
mPayload[iv->id].txCmd = cmd;
|
||||||
|
@ -202,8 +200,9 @@ class HmPayload {
|
||||||
mApp->setMqttPowerLimitAck(iv);
|
mApp->setMqttPowerLimitAck(iv);
|
||||||
else
|
else
|
||||||
ok = false;
|
ok = false;
|
||||||
DPRINTHEAD(DBG_INFO,iv->id);
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
DBGPRINT(F("has "));
|
DBGPRINT(String(iv->id));
|
||||||
|
DBGPRINT(F(" has "));
|
||||||
if(!ok) DBGPRINT(F("not "));
|
if(!ok) DBGPRINT(F("not "));
|
||||||
DBGPRINT(F("accepted power limit set point "));
|
DBGPRINT(F("accepted power limit set point "));
|
||||||
DBGPRINT(String(iv->powerLimit[0]));
|
DBGPRINT(String(iv->powerLimit[0]));
|
||||||
|
@ -241,14 +240,12 @@ class HmPayload {
|
||||||
mPayload[iv->id].retransmits++;
|
mPayload[iv->id].retransmits++;
|
||||||
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.
|
||||||
//DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm..."));
|
DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm..."));
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
|
||||||
DBGPRINTLN_TXT(TXT_PREVSND);
|
|
||||||
mPayload[iv->id].retransmits = mMaxRetrans;
|
mPayload[iv->id].retransmits = mMaxRetrans;
|
||||||
} else if(iv->devControlCmd == ActivePowerContr) {
|
} else if(iv->devControlCmd == ActivePowerContr) {
|
||||||
//DPRINTLN(DBG_INFO, F("retransmit power limit"));
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DBGPRINT(String(iv->id));
|
||||||
DBGPRINTLN_TXT(TXT_RESPLIM);
|
DPRINTLN(DBG_INFO, F(") retransmit power limit"));
|
||||||
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true);
|
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true);
|
||||||
} else {
|
} else {
|
||||||
if(false == mPayload[iv->id].gotFragment) {
|
if(false == mPayload[iv->id].gotFragment) {
|
||||||
|
@ -258,18 +255,18 @@ class HmPayload {
|
||||||
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX));
|
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX));
|
||||||
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
||||||
*/
|
*/
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
DBGPRINTLN_TXT(TXT_NOPYLD2);
|
DBGPRINT(String(iv->id));
|
||||||
|
DBGPRINTLN(F(") nothing received"));
|
||||||
mPayload[iv->id].retransmits = mMaxRetrans;
|
mPayload[iv->id].retransmits = mMaxRetrans;
|
||||||
} else {
|
} else {
|
||||||
for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) {
|
for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) {
|
||||||
if (mPayload[iv->id].len[i] == 0) {
|
if (mPayload[iv->id].len[i] == 0) {
|
||||||
DPRINTHEAD(DBG_WARN,iv->id);
|
DPRINT(DBG_WARN, F("(#"));
|
||||||
DBGPRINT(F("Frame "));
|
DBGPRINT(String(iv->id));
|
||||||
|
DBGPRINT(F(") Frame "));
|
||||||
DBGPRINT(String(i + 1));
|
DBGPRINT(String(i + 1));
|
||||||
//DBGPRINTLN(F(" missing: Request Retransmit"));
|
DBGPRINTLN(F(" missing: Request Retransmit"));
|
||||||
DBGPRINT_TXT(TXT_REQRETR);
|
|
||||||
DBGPRINT(F("\r\n"));
|
|
||||||
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME + i), true);
|
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME + i), true);
|
||||||
break; // only request retransmit one frame per loop
|
break; // only request retransmit one frame per loop
|
||||||
}
|
}
|
||||||
|
@ -282,29 +279,21 @@ class HmPayload {
|
||||||
} 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);
|
DPRINTLN(DBG_WARN, F("CRC Error: Request Complete Retransmit"));
|
||||||
DBGPRINTLN_TXT(TXT_CRCERR);
|
|
||||||
mPayload[iv->id].txCmd = iv->getQueuedCmd();
|
mPayload[iv->id].txCmd = iv->getQueuedCmd();
|
||||||
DPRINTHEAD(DBG_INFO,iv->id);
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
DBGPRINT_TXT(TXT_GDEVINF);
|
DBGPRINT(String(iv->id));
|
||||||
//DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX));
|
DBGPRINT(F(") prepareDevInformCmd 0x"));
|
||||||
DBGHEXLN(mPayload[iv->id].txCmd);
|
DHEXLN(mPayload[iv->id].txCmd);
|
||||||
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
||||||
}
|
}
|
||||||
} else { // payload complete
|
} else { // payload complete
|
||||||
DPRINT(DBG_INFO, F("procPyld: cmd: 0x"));
|
DPRINT(DBG_INFO, F("procPyld: cmd: 0x"));
|
||||||
//DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX));
|
DHEXLN(mPayload[iv->id].txCmd);
|
||||||
//DPRINT_INIT(DBG_INFO,TXT_PPYDCMD);
|
|
||||||
DBGHEXLN(mPayload[iv->id].txCmd);
|
|
||||||
DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
|
DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
|
||||||
//DPRINT_INIT(DBG_INFO,TXT_PPYDTXI);
|
DHEXLN(mPayload[iv->id].txId);
|
||||||
//DBGPRINTLN(String(mPayload[iv->id].txId, HEX));
|
DPRINTLN(DBG_DEBUG, F("procPyld: max: "));
|
||||||
DBGHEXLN(mPayload[iv->id].txId);
|
DBGPRINT(String(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
|
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
||||||
mPayload[iv->id].complete = true;
|
mPayload[iv->id].complete = true;
|
||||||
|
|
||||||
|
@ -328,7 +317,7 @@ class HmPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == rec) {
|
if (NULL == rec) {
|
||||||
DPRINTLN_TXT(DBG_ERROR, TXT_NULLREC);
|
DPRINTLN(DBG_ERROR, F("record is NULL!"));
|
||||||
} else if ((rec->pyldLen == payloadLen) || (0 == rec->pyldLen)) {
|
} else if ((rec->pyldLen == payloadLen) || (0 == rec->pyldLen)) {
|
||||||
if (mPayload[iv->id].txId == (TX_REQ_INFO + ALL_FRAMES))
|
if (mPayload[iv->id].txId == (TX_REQ_INFO + ALL_FRAMES))
|
||||||
mStat->rxSuccess++;
|
mStat->rxSuccess++;
|
||||||
|
@ -381,8 +370,6 @@ class HmPayload {
|
||||||
|
|
||||||
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;
|
uint16_t crc = 0xffff, crcRcv = 0x0000;
|
||||||
if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
|
if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
|
||||||
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
||||||
|
@ -411,8 +398,8 @@ class HmPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(uint8_t id) {
|
void reset(uint8_t id) {
|
||||||
DPRINTHEAD(DBG_INFO,id);
|
DPRINT(DBG_INFO, "resetPayload: id: ");
|
||||||
DBGPRINTLN_TXT(TXT_RSTPYLD);
|
DBGPRINTLN(String(id));
|
||||||
memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES);
|
memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES);
|
||||||
mPayload[id].txCmd = 0;
|
mPayload[id].txCmd = 0;
|
||||||
mPayload[id].gotFragment = false;
|
mPayload[id].gotFragment = false;
|
||||||
|
|
|
@ -95,12 +95,10 @@ class MiPayload {
|
||||||
iv->setQueuedCmdFinished(); // command failed
|
iv->setQueuedCmdFinished(); // command failed
|
||||||
if (mSerialDebug)
|
if (mSerialDebug)
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
//DBGPRINTLN(F("enqueued cmd failed/timeout"));
|
DBGPRINTLN(F("enqueued cmd failed/timeout"));
|
||||||
DBGPRINTLN_TXT(TXT_TIMEOUT);
|
|
||||||
if (mSerialDebug) {
|
if (mSerialDebug) {
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
//DBGPRINT(F("no Payload received! (retransmits: "));
|
DBGPRINT(F("no Payload received! (retransmits: "));
|
||||||
DBGPRINT_TXT(TXT_NOPYLD);
|
|
||||||
DBGPRINT(String(mPayload[iv->id].retransmits));
|
DBGPRINT(String(mPayload[iv->id].retransmits));
|
||||||
DBGPRINTLN(F(")"));
|
DBGPRINTLN(F(")"));
|
||||||
}
|
}
|
||||||
|
@ -114,16 +112,14 @@ class MiPayload {
|
||||||
yield();
|
yield();
|
||||||
if (mSerialDebug){
|
if (mSerialDebug){
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
//DBGPRINT(F("Requesting Inv SN "));
|
DBGPRINT(F("Requesting Inv SN "));
|
||||||
DBGPRINT_TXT(TXT_INVSERNO);
|
|
||||||
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);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
//DBGPRINT(F("Devcontrol request 0x"));
|
DBGPRINT(F("Devcontrol request 0x"));
|
||||||
DBGPRINT_TXT(TXT_DEVCTRL);
|
|
||||||
DHEX(iv->devControlCmd);
|
DHEX(iv->devControlCmd);
|
||||||
DBGPRINT(F(" power limit "));
|
DBGPRINT(F(" power limit "));
|
||||||
DBGPRINTLN(String(iv->powerLimit[0]));
|
DBGPRINTLN(String(iv->powerLimit[0]));
|
||||||
|
@ -137,8 +133,8 @@ class MiPayload {
|
||||||
} else {
|
} else {
|
||||||
uint8_t cmd = iv->getQueuedCmd();
|
uint8_t cmd = iv->getQueuedCmd();
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
DBGPRINT_TXT(TXT_GDEVINF);
|
DBGPRINT(F("prepareDevInformCmd 0x"));
|
||||||
DBGHEXLN(cmd);
|
DHEXLN(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
|
||||||
|
@ -149,7 +145,7 @@ class MiPayload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd == 0x1 || cmd == SystemConfigPara ) { //0x1 and 0x05 for HM-types
|
if (cmd == 0x01 || cmd == SystemConfigPara ) { //0x1 and 0x05 for HM-types
|
||||||
cmd = 0x0f; // for MI, these seem to make part of the Polling the device software and hardware version number command
|
cmd = 0x0f; // for MI, these seem to make part of the Polling the device software and hardware version number command
|
||||||
cmd2 = cmd == SystemConfigPara ? 0x01 : 0x00; //perhaps we can only try to get second frame?
|
cmd2 = cmd == SystemConfigPara ? 0x01 : 0x00; //perhaps we can only try to get second frame?
|
||||||
mSys->Radio.sendCmdPacket(iv->radioId.u64, cmd, cmd2, false);
|
mSys->Radio.sendCmdPacket(iv->radioId.u64, cmd, cmd2, false);
|
||||||
|
@ -270,20 +266,19 @@ const byteAssign_t InfoAssignment[] = {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ( p->packet[0] == (TX_REQ_INFO + ALL_FRAMES) // response from get information command
|
} else if ( p->packet[0] == (TX_REQ_INFO + ALL_FRAMES) // response from get information command
|
||||||
|| p->packet[0] == 0xB6 && mPayload[iv->id].txCmd != 0x36) { // strange short response from MI-1500 3rd gen; might be missleading!
|
|| (p->packet[0] == 0xB6 && mPayload[iv->id].txCmd != 0x36)) { // strange short response from MI-1500 3rd gen; might be missleading!
|
||||||
// atm, we just do nothing else than print out what we got...
|
// atm, we just do nothing else than print out what we got...
|
||||||
// for decoding see xls- Data collection instructions - #147ff
|
// for decoding see xls- Data collection instructions - #147ff
|
||||||
//mPayload[iv->id].txId = p->packet[0];
|
//mPayload[iv->id].txId = p->packet[0];
|
||||||
//DPRINTLN(DBG_DEBUG, F("Response from info request received"));
|
DPRINTLN(DBG_DEBUG, F("Response from info request received"));
|
||||||
DBGPRINTLN_TXT(TXT_RXDIREQ);
|
|
||||||
uint8_t *pid = &p->packet[9];
|
uint8_t *pid = &p->packet[9];
|
||||||
if (*pid == 0x00) {
|
if (*pid == 0x00) {
|
||||||
//DPRINT(DBG_DEBUG, F("fragment number zero received"));
|
DPRINT(DBG_DEBUG, F("fragment number zero received"));
|
||||||
DBGPRINTLN_TXT(TXT_FRAGM0);
|
|
||||||
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!
|
||||||
DPRINTHEAD(DBG_WARN, iv->id);
|
DPRINT(DBG_WARN, F("(#"));
|
||||||
DBGPRINTLN_TXT(TXT_NO2NDG);
|
DBGPRINT(String(iv->id));
|
||||||
|
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();
|
||||||
|
@ -307,8 +302,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);
|
DPRINTHEAD(DBG_DEBUG, iv->id);
|
||||||
DBGPRINTLN_TXT(TXT_RXCTRREQ);
|
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];
|
||||||
iv->clearDevControlRequest();
|
iv->clearDevControlRequest();
|
||||||
|
@ -326,14 +320,12 @@ 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!!!
|
||||||
//DPRINTLN(DBG_INFO, F("procPyld: cmd: 0x") + String(mPayload[iv->id].txCmd, HEX));
|
DPRINT(DBG_INFO, F("procPyld: cmd: 0x"));
|
||||||
//DPRINTLN(DBG_INFO, F("procPyld: txid: 0x") + String(mPayload[iv->id].txId, HEX));
|
DHEXLN(mPayload[iv->id].txCmd);
|
||||||
//DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId));
|
DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DHEXLN(mPayload[iv->id].txId);
|
||||||
DBGPRINT_TXT(TXT_PPYDCMD);
|
//DPRINT(DBG_DEBUG, F("procPyld: max: "));
|
||||||
DBGHEXLN(mPayload[iv->id].txCmd);
|
//DBGPRINTLN(String(mPayload[iv->id].maxPackId));
|
||||||
DBGPRINT_TXT(TXT_PPYDTXI);
|
|
||||||
DBGHEXLN(mPayload[iv->id].txId);
|
|
||||||
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
||||||
mPayload[iv->id].complete = true;
|
mPayload[iv->id].complete = true;
|
||||||
|
|
||||||
|
@ -355,7 +347,7 @@ const byteAssign_t InfoAssignment[] = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == rec) {
|
if (NULL == rec) {
|
||||||
DPRINTLN_TXT(DBG_ERROR, TXT_NULLREC);
|
DPRINTLN(DBG_ERROR, F("record is NULL!"));
|
||||||
} else if ((rec->pyldLen == payloadLen) || (0 == rec->pyldLen)) {
|
} else if ((rec->pyldLen == payloadLen) || (0 == rec->pyldLen)) {
|
||||||
if (mPayload[iv->id].txId == (TX_REQ_INFO + ALL_FRAMES))
|
if (mPayload[iv->id].txId == (TX_REQ_INFO + ALL_FRAMES))
|
||||||
mStat->rxSuccess++;
|
mStat->rxSuccess++;
|
||||||
|
@ -429,11 +421,11 @@ const byteAssign_t InfoAssignment[] = {
|
||||||
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);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
DBGPRINTLN_TXT(TXT_PREVSND);
|
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);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
DBGPRINTLN_TXT(TXT_RESPLIM);
|
DBGPRINTLN(F("retransmit power limit"));
|
||||||
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true, false);
|
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true, false);
|
||||||
} else {
|
} else {
|
||||||
uint8_t cmd = mPayload[iv->id].txCmd;
|
uint8_t cmd = mPayload[iv->id].txCmd;
|
||||||
|
@ -441,7 +433,7 @@ const byteAssign_t InfoAssignment[] = {
|
||||||
mPayload[iv->id].retransmits++;
|
mPayload[iv->id].retransmits++;
|
||||||
if( !mPayload[iv->id].gotFragment ) {
|
if( !mPayload[iv->id].gotFragment ) {
|
||||||
DPRINTHEAD(DBG_INFO, iv->id);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
DBGPRINTLN_TXT(TXT_NOPYLD2);
|
DBGPRINTLN(F("nothing received"));
|
||||||
mPayload[iv->id].retransmits = mMaxRetrans;
|
mPayload[iv->id].retransmits = mMaxRetrans;
|
||||||
} else if ( cmd == 0x0f ) {
|
} else if ( cmd == 0x0f ) {
|
||||||
//hard/firmware request
|
//hard/firmware request
|
||||||
|
@ -477,11 +469,10 @@ const byteAssign_t InfoAssignment[] = {
|
||||||
//mPayload[iv->id].skipfirstrepeat = 0;
|
//mPayload[iv->id].skipfirstrepeat = 0;
|
||||||
} else {
|
} else {
|
||||||
DBGPRINT(F("sth."));
|
DBGPRINT(F("sth."));
|
||||||
DBGPRINT_TXT(TXT_REQRETR);
|
DBGPRINT(F(" missing: Request Retransmit"));
|
||||||
}
|
}
|
||||||
//DBGPRINTLN(String(cmd, HEX));
|
|
||||||
DBGPRINT(F(" 0x"));
|
DBGPRINT(F(" 0x"));
|
||||||
DBGHEXLN(cmd);
|
DHEXLN(cmd);
|
||||||
//mSys->Radio.sendCmdPacket(iv->radioId.u64, cmd, cmd, true);
|
//mSys->Radio.sendCmdPacket(iv->radioId.u64, cmd, cmd, true);
|
||||||
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, true, cmd);
|
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, true, cmd);
|
||||||
mPayload[iv->id].txCmd = cmd;
|
mPayload[iv->id].txCmd = cmd;
|
||||||
|
@ -494,14 +485,12 @@ const byteAssign_t InfoAssignment[] = {
|
||||||
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);
|
DPRINTHEAD(DBG_WARN, iv->id);
|
||||||
DBGPRINTLN_TXT(TXT_CRCERR);
|
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);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
|
|
||||||
DBGPRINT_TXT(TXT_GDEVINF);
|
DBGPRINT(F("prepareDevInformCmd 0x"));
|
||||||
//DBGPRINTLN(F("prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX));
|
DHEXLN(mPayload[iv->id].txCmd);
|
||||||
DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX));
|
|
||||||
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -617,7 +606,7 @@ const byteAssign_t InfoAssignment[] = {
|
||||||
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);
|
DPRINTHEAD(DBG_INFO, iv->id);
|
||||||
DBGPRINT_TXT(TXT_INCRALM);
|
DBGPRINT(F("alarm ID incremented to "));
|
||||||
DBGPRINTLN(String(iv->alarmMesIndex));
|
DBGPRINTLN(String(iv->alarmMesIndex));
|
||||||
}
|
}
|
||||||
/*if(AlarmData == mPayload[iv->id].txCmd) {
|
/*if(AlarmData == mPayload[iv->id].txCmd) {
|
||||||
|
@ -796,7 +785,7 @@ const byteAssign_t InfoAssignment[] = {
|
||||||
|
|
||||||
void reset(uint8_t id, bool clrSts = false) {
|
void reset(uint8_t id, bool clrSts = false) {
|
||||||
DPRINTHEAD(DBG_INFO, id);
|
DPRINTHEAD(DBG_INFO, id);
|
||||||
DBGPRINTLN_TXT(TXT_RSTPYLD);
|
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;
|
||||||
/*mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
/*mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DBGHEXLN(uint8_t b) {
|
inline void DHEXLN(uint8_t b) {
|
||||||
DHEX(b);
|
DHEX(b);
|
||||||
DBGPRINT(F("\r\n"));
|
DBGPRINT(F("\r\n"));
|
||||||
}
|
}
|
||||||
|
@ -151,16 +151,6 @@
|
||||||
}\
|
}\
|
||||||
})
|
})
|
||||||
|
|
||||||
#define DPRINT_INIT(level,text) ({\
|
|
||||||
DPRINT(level,F(""));\
|
|
||||||
DBGPRINT_TXT(text);\
|
|
||||||
})
|
|
||||||
|
|
||||||
#define DPRINTLN_TXT(level,text) ({\
|
|
||||||
DPRINT(level,F(""));\
|
|
||||||
DBGPRINTLN_TXT(text);\
|
|
||||||
})
|
|
||||||
|
|
||||||
#define DPRINTHEAD(level, id) ({\
|
#define DPRINTHEAD(level, id) ({\
|
||||||
DPRINT(level, F("(#")); DBGPRINT(String(id)); DBGPRINT(F(") "));\
|
DPRINT(level, F("(#")); DBGPRINT(String(id)); DBGPRINT(F(") "));\
|
||||||
})
|
})
|
||||||
|
@ -176,84 +166,6 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// available text variables
|
|
||||||
#define TXT_ENQUCMD 6
|
|
||||||
#define TXT_INVSERNO 2
|
|
||||||
#define TXT_REQRETR 7
|
|
||||||
#define TXT_PPYDMAX 10
|
|
||||||
#define TXT_NOPYLD 1
|
|
||||||
#define TXT_GDEVINF 3
|
|
||||||
#define TXT_DEVCTRL 4
|
|
||||||
#define TXT_INCRALM 5
|
|
||||||
#define TXT_PPYDCMD 8
|
|
||||||
#define TXT_PPYDTXI 9
|
|
||||||
|
|
||||||
|
|
||||||
/* DBGPRINT(F(" power limit "));
|
|
||||||
DPRINTLN(DBG_DEBUG, F("Response from info request received"));
|
|
||||||
|
|
||||||
DBGPRINTLN(F("Response from devcontrol request received"));
|
|
||||||
DBGPRINT(F("has accepted power limit set point "));
|
|
||||||
DBGPRINT(F(" with PowerLimitControl "));
|
|
||||||
DPRINT(DBG_INFO, F("Payload (") + String(payloadLen) + "): ");
|
|
||||||
DPRINTLN(DBG_ERROR, F("plausibility check failed, expected ") + String(rec->pyldLen) + F(" bytes"));
|
|
||||||
|
|
||||||
DPRINTLN(DBG_VERBOSE, F("incomlete, txCmd is 0x") + String(txCmd, HEX)); // + F("cmd is 0x") + String(cmd, HEX));
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DBGPRINT_TXT(text) ({\
|
|
||||||
switch(text) {\
|
|
||||||
case TXT_NOPYLD: DBGPRINT(F("no Payload received! (retransmits: ")); break; \
|
|
||||||
case TXT_INVSERNO: DBGPRINT(F("Requesting Inv SN ")); break; \
|
|
||||||
case TXT_GDEVINF: DBGPRINT(F("prepareDevInformCmd 0x")); break; \
|
|
||||||
case TXT_DEVCTRL: DBGPRINT(F("Devcontrol request 0x")); break; \
|
|
||||||
case TXT_INCRALM: DBGPRINT(F("alarm ID incremented to ")); break; \
|
|
||||||
case TXT_ENQUCMD: DBGPRINT(F("enqueuedCmd: 0x")); break; \
|
|
||||||
case TXT_REQRETR: DBGPRINT(F(" missing: Request Retransmit")); break; \
|
|
||||||
case TXT_PPYDCMD: DBGPRINT(F("procPyld: cmd: 0x")); break; \
|
|
||||||
case TXT_PPYDTXI: DBGPRINT(F("procPyld: txid: 0x")); break; \
|
|
||||||
case TXT_PPYDMAX: DBGPRINT(F("procPyld: max: ")); break; \
|
|
||||||
default: ; break; \
|
|
||||||
}\
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// available text variables w. lf
|
|
||||||
#define TXT_BUILD 1
|
|
||||||
#define TXT_TIMEOUT 2
|
|
||||||
#define TXT_NOPYLD2 3
|
|
||||||
#define TXT_CRCERR 4
|
|
||||||
#define TXT_RSTPYLD 5
|
|
||||||
#define TXT_RXDIREQ 6
|
|
||||||
#define TXT_CLRQUE 7
|
|
||||||
#define TXT_RXCTRREQ 8
|
|
||||||
#define TXT_NULLREC 9
|
|
||||||
#define TXT_PREVSND 10
|
|
||||||
#define TXT_RESPLIM 11
|
|
||||||
#define TXT_FRAGM0 20
|
|
||||||
#define TXT_NO2NDG 100
|
|
||||||
|
|
||||||
#define DBGPRINTLN_TXT(text) ({\
|
|
||||||
switch(text) {\
|
|
||||||
case TXT_TIMEOUT: DBGPRINTLN(F("enqueued cmd failed/timeout")); break; \
|
|
||||||
case TXT_BUILD: DBGPRINTLN(F("build")); break; \
|
|
||||||
case TXT_NOPYLD2: DBGPRINTLN(F("nothing received")); break; \
|
|
||||||
case TXT_CRCERR: DBGPRINTLN(F("CRC Error: Request Complete Retransmit")); break; \
|
|
||||||
case TXT_RSTPYLD: DBGPRINTLN(F("resetPayload"));break; \
|
|
||||||
case TXT_RXDIREQ: DBGPRINTLN(F("Response from info request received")); break; \
|
|
||||||
case TXT_CLRQUE: DBGPRINTLN(F("clearCmdQueue")); break; \
|
|
||||||
case TXT_RXCTRREQ: DBGPRINTLN(F("Response from devcontrol request received")); break; \
|
|
||||||
case TXT_NULLREC: DBGPRINTLN(F("record is NULL!")); break; \
|
|
||||||
case TXT_PREVSND: DBGPRINTLN(F("Prevent retransmit on Restart / CleanState_LockAndAlarm...")); break; \
|
|
||||||
case TXT_RESPLIM: DBGPRINTLN(F("retransmit power limit")); break; \
|
|
||||||
case TXT_FRAGM0: DBGPRINTLN(F("fragment number zero received")); break; \
|
|
||||||
case TXT_NO2NDG: DBGPRINTLN(F("seems to use 3rd gen. protocol - switching ivGen!")); break; \
|
|
||||||
default: ; break; \
|
|
||||||
}\
|
|
||||||
})
|
|
||||||
|
|
||||||
/*class ahoyLog {
|
/*class ahoyLog {
|
||||||
public:
|
public:
|
||||||
ahoyLog() {}
|
ahoyLog() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue