mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 23:46:37 +02:00
retransmit review
- look at how many frames are missing first - more "second try" if inverter is available (dependent on attempts)
This commit is contained in:
parent
d8af398208
commit
1118407019
5 changed files with 47 additions and 27 deletions
|
@ -12,8 +12,8 @@
|
|||
#include "../utils/dbg.h"
|
||||
|
||||
#define DEFAULT_ATTEMPS 5
|
||||
#define MORE_ATTEMPS_ALARMDATA 8
|
||||
#define MORE_ATTEMPS_GRIDONPROFILEPARA 5
|
||||
#define MORE_ATTEMPS_ALARMDATA 0 // 8
|
||||
#define MORE_ATTEMPS_GRIDONPROFILEPARA 0 // 5
|
||||
|
||||
template <uint8_t N=100>
|
||||
class CommQueue {
|
||||
|
|
|
@ -114,11 +114,11 @@ class Communication : public CommQueue<> {
|
|||
|
||||
q->iv->radioStatistics.txCnt++;
|
||||
q->iv->radio->mRadioWaitTime.startTimeMonitor(mTimeout);
|
||||
if(!mIsRetransmit && (q->cmd == AlarmData) || (q->cmd == GridOnProFilePara))
|
||||
incrAttempt(q->cmd == AlarmData? MORE_ATTEMPS_ALARMDATA : MORE_ATTEMPS_GRIDONPROFILEPARA);
|
||||
|
||||
mIsRetransmit = false;
|
||||
setAttempt();
|
||||
if((q->cmd == AlarmData) || (q->cmd == GridOnProFilePara))
|
||||
incrAttempt(q->cmd == AlarmData? MORE_ATTEMPS_ALARMDATA : MORE_ATTEMPS_GRIDONPROFILEPARA);
|
||||
mState = States::WAIT;
|
||||
break;
|
||||
|
||||
|
@ -155,6 +155,7 @@ class Communication : public CommQueue<> {
|
|||
q->iv->mIvTxCnt++;
|
||||
|
||||
if(mFirstTry) {
|
||||
if(q->attempts < 3 || !q->iv->isProducing())
|
||||
mFirstTry = false;
|
||||
//setAttempt();
|
||||
mHeu.evalTxChQuality(q->iv, false, 0, 0);
|
||||
|
@ -209,7 +210,7 @@ class Communication : public CommQueue<> {
|
|||
if(q->iv->ivGen != IV_MI) {
|
||||
mState = States::CHECK_PACKAGE;
|
||||
} else {
|
||||
bool fastNext = true;
|
||||
//bool fastNext = true;
|
||||
if(q->iv->miMultiParts < 6) {
|
||||
mState = States::WAIT;
|
||||
if((q->iv->radio->mRadioWaitTime.isTimeout() && mIsRetransmit) || !mIsRetransmit) {
|
||||
|
@ -222,11 +223,11 @@ class Communication : public CommQueue<> {
|
|||
|| ((q->cmd == MI_REQ_CH2) && (q->iv->type == INV_TYPE_2CH))
|
||||
|| ((q->cmd == MI_REQ_CH1) && (q->iv->type == INV_TYPE_1CH))) {
|
||||
miComplete(q->iv);
|
||||
fastNext = false;
|
||||
//fastNext = false;
|
||||
}
|
||||
if(fastNext)
|
||||
/*if(fastNext)
|
||||
miNextRequest(q->iv->type == INV_TYPE_4CH ? MI_REQ_4CH : MI_REQ_CH1, q);
|
||||
else
|
||||
else*/
|
||||
closeRequest(q, true);
|
||||
}
|
||||
}
|
||||
|
@ -263,6 +264,25 @@ class Communication : public CommQueue<> {
|
|||
closeRequest(q, false);
|
||||
return;
|
||||
}
|
||||
//count missing frames
|
||||
if(!q->iv->mIsSingleframeReq && q->iv->ivRadioType == INV_RADIO_TYPE_NRF) { // already checked?
|
||||
uint8_t missedFrames = 0;
|
||||
for(uint8_t i = 0; i < q->iv->radio->mFramesExpected; i++) {
|
||||
if(mLocalBuf[i].len == 0)
|
||||
missedFrames++;
|
||||
}
|
||||
if(missedFrames > 3 || (q->cmd == RealTimeRunData_Debug && missedFrames > 1) || (missedFrames > 1 && missedFrames + 2 > q->attempts)) {
|
||||
if(*mSerialDebug) {
|
||||
DPRINT_IVID(DBG_INFO, q->iv->id);
|
||||
DBGPRINT(String(missedFrames));
|
||||
DBGPRINT(F(" frames missing "));
|
||||
DBGPRINTLN(F("-> complete retransmit"));
|
||||
}
|
||||
mState = States::RESET;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setAttempt();
|
||||
|
||||
if(*mSerialDebug) {
|
||||
|
@ -411,8 +431,8 @@ class Communication : public CommQueue<> {
|
|||
|
||||
if((*frameId & ALL_FRAMES) == ALL_FRAMES) {
|
||||
mMaxFrameId = (*frameId & 0x7f);
|
||||
if(mMaxFrameId > 8) // large payloads, e.g. AlarmData
|
||||
incrAttempt(mMaxFrameId - 6);
|
||||
/*if(mMaxFrameId > 8) // large payloads, e.g. AlarmData
|
||||
incrAttempt(mMaxFrameId - 6);*/
|
||||
}
|
||||
|
||||
frame_t *f = &mLocalBuf[(*frameId & 0x7f) - 1];
|
||||
|
|
|
@ -92,7 +92,7 @@ enum {INV_RADIO_TYPE_NRF = 0, INV_RADIO_TYPE_CMT};
|
|||
#define DURATION_TXFRAME 85 // timeout parameter for first transmission and first expected frame (time to first channel switch from tx start!) (ms)
|
||||
#define DURATION_LISTEN_MIN 5 // time to stay at least on a listening channel (ms)
|
||||
#define DURATION_PAUSE_LASTFR 45 // how long to pause after last frame (ms)
|
||||
const uint8_t duration_reserve[2] = {115,115};
|
||||
const uint8_t duration_reserve[2] = {65,115};
|
||||
|
||||
#define LIMIT_FAST_IV 85 // time limit to qualify an inverter as very fast answering inverter
|
||||
#define LIMIT_VERYFAST_IV 70 // time limit to qualify an inverter as very fast answering inverter
|
||||
|
|
|
@ -220,6 +220,11 @@ class Inverter {
|
|||
cb(RealTimeRunData_Debug, false); // get live data
|
||||
}
|
||||
} else { // MI
|
||||
cb(((type == INV_TYPE_4CH) ? MI_REQ_4CH : MI_REQ_CH1), false);
|
||||
mGetLossInterval++;
|
||||
if (type != INV_TYPE_4CH)
|
||||
mIvRxCnt++; // statistics workaround...
|
||||
if(isAvailable()) {
|
||||
if(0 == getFwVersion()) {
|
||||
mIvRxCnt +=2;
|
||||
cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number
|
||||
|
@ -230,11 +235,6 @@ class Inverter {
|
|||
mIvRxCnt +=2;
|
||||
} else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && generalConfig->readGrid) // read grid profile
|
||||
cb(0x10, false); // legacy GPF command
|
||||
else {
|
||||
cb(((type == INV_TYPE_4CH) ? MI_REQ_4CH : MI_REQ_CH1), false);
|
||||
mGetLossInterval++;
|
||||
if (type != INV_TYPE_4CH)
|
||||
mIvRxCnt++; // statistics workaround...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ class Radio {
|
|||
uint8_t mIrqOk = IRQ_UNKNOWN;
|
||||
TimeMonitor mRadioWaitTime = TimeMonitor(0, true); // start as expired (due to code in RESET state)
|
||||
uint8_t mTxRetriesNext = 15; // let heuristics tell us the next reties count (for nRF type radios only)
|
||||
uint8_t mFramesExpected = 0x0c;
|
||||
|
||||
protected:
|
||||
virtual void sendPacket(Inverter<> *iv, uint8_t len, bool isRetransmit, bool appendCrc16=true) = 0;
|
||||
|
@ -130,7 +131,6 @@ class Radio {
|
|||
volatile bool mIrqRcvd;
|
||||
bool *mSerialDebug, *mPrivacyMode, *mPrintWholeTrace;
|
||||
uint8_t mTxBuf[MAX_RF_PAYLOAD_SIZE];
|
||||
uint8_t mFramesExpected = 0x0c;
|
||||
};
|
||||
|
||||
#endif /*__RADIO_H__*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue