Browse Source

no retransmit on Restart / CleanState_LockAndAlarm

pull/328/head
stefan123t 2 years ago
parent
commit
f5c784f44c
  1. 44
      tools/esp8266/app.cpp
  2. 8
      tools/esp8266/hmRadio.h

44
tools/esp8266/app.cpp

@ -325,30 +325,36 @@ void app::processPayload(bool retransmit) {
if(!buildPayload(iv->id)) { // payload not complete
if(mPayload[iv->id].requested) {
if(retransmit) {
if(mPayload[iv->id].retransmits < mConfig.maxRetransPerPyld) {
mPayload[iv->id].retransmits++;
if(mPayload[iv->id].maxPackId != 0) {
for(uint8_t i = 0; i < (mPayload[iv->id].maxPackId-1); i++) {
if(mPayload[iv->id].len[i] == 0) {
if(mConfig.serialDebug)
DPRINTLN(DBG_WARN, F("while retrieving data: Frame ") + String(i+1) + F(" missing: Request Retransmit"));
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME+i), true);
break; // only retransmit one frame per loop
if(iv->devControlCmd == Restart || CleanState_LockAndAlarm || iv->devControlCmd) {
// This is required to prevent retransmissions without answer.
DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm..."));
mPayload[iv->id].retransmits = mConfig.maxRetransPerPyld;
} else {
if(mPayload[iv->id].retransmits < mConfig.maxRetransPerPyld) {
mPayload[iv->id].retransmits++;
if(mPayload[iv->id].maxPackId != 0) {
for(uint8_t i = 0; i < (mPayload[iv->id].maxPackId-1); i++) {
if(mPayload[iv->id].len[i] == 0) {
if(mConfig.serialDebug)
DPRINTLN(DBG_WARN, F("while retrieving data: Frame ") + String(i+1) + F(" missing: Request Retransmit"));
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME+i), true);
break; // only retransmit one frame per loop
}
yield();
}
yield();
}
}
else {
if(mConfig.serialDebug)
DPRINTLN(DBG_WARN, F("while retrieving data: last frame missing: Request Retransmit"));
if(0x00 != mLastPacketId)
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, mLastPacketId, true);
else {
mPayload[iv->id].txCmd = iv->getQueuedCmd();
mSys->Radio.sendTimePacket(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex);
if(mConfig.serialDebug)
DPRINTLN(DBG_WARN, F("while retrieving data: last frame missing: Request Retransmit"));
if(0x00 != mLastPacketId)
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, mLastPacketId, true);
else {
mPayload[iv->id].txCmd = iv->getQueuedCmd();
mSys->Radio.sendTimePacket(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex);
}
}
mSys->Radio.switchRxCh(100);
}
mSys->Radio.switchRxCh(100);
}
}
}

8
tools/esp8266/hmRadio.h

@ -190,14 +190,6 @@ class HmRadio {
mTxBuf[10 + cnt] = Ahoy::crc8(mTxBuf, 10 + cnt);
sendPacket(invId, mTxBuf, 10 + (++cnt), true);
// Is required to prevent retransmissions without answer.
if (cmd == CleanState_LockAndAlarm || cmd == Restart)
{
DPRINTLN(DBG_INFO, F("TODO: Prevent retransmit after Reboot / CleanState_LockAndAlarm..."));
// if(mPayload[iv->id].retransmits < mConfig.maxRetransPerPyld)
//mPayload[iv->id].retransmits = mConfig.maxRetransPerPyld;
}
}
void sendTimePacket(uint64_t invId, uint8_t cmd, uint32_t ts, uint16_t alarmMesId) {

Loading…
Cancel
Save