mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-11 16:06:38 +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"
|
#include "../utils/dbg.h"
|
||||||
|
|
||||||
#define DEFAULT_ATTEMPS 5
|
#define DEFAULT_ATTEMPS 5
|
||||||
#define MORE_ATTEMPS_ALARMDATA 8
|
#define MORE_ATTEMPS_ALARMDATA 0 // 8
|
||||||
#define MORE_ATTEMPS_GRIDONPROFILEPARA 5
|
#define MORE_ATTEMPS_GRIDONPROFILEPARA 0 // 5
|
||||||
|
|
||||||
template <uint8_t N=100>
|
template <uint8_t N=100>
|
||||||
class CommQueue {
|
class CommQueue {
|
||||||
|
|
|
@ -114,11 +114,11 @@ class Communication : public CommQueue<> {
|
||||||
|
|
||||||
q->iv->radioStatistics.txCnt++;
|
q->iv->radioStatistics.txCnt++;
|
||||||
q->iv->radio->mRadioWaitTime.startTimeMonitor(mTimeout);
|
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;
|
mIsRetransmit = false;
|
||||||
setAttempt();
|
setAttempt();
|
||||||
if((q->cmd == AlarmData) || (q->cmd == GridOnProFilePara))
|
|
||||||
incrAttempt(q->cmd == AlarmData? MORE_ATTEMPS_ALARMDATA : MORE_ATTEMPS_GRIDONPROFILEPARA);
|
|
||||||
mState = States::WAIT;
|
mState = States::WAIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -155,7 +155,8 @@ class Communication : public CommQueue<> {
|
||||||
q->iv->mIvTxCnt++;
|
q->iv->mIvTxCnt++;
|
||||||
|
|
||||||
if(mFirstTry) {
|
if(mFirstTry) {
|
||||||
mFirstTry = false;
|
if(q->attempts < 3 || !q->iv->isProducing())
|
||||||
|
mFirstTry = false;
|
||||||
//setAttempt();
|
//setAttempt();
|
||||||
mHeu.evalTxChQuality(q->iv, false, 0, 0);
|
mHeu.evalTxChQuality(q->iv, false, 0, 0);
|
||||||
//q->iv->radioStatistics.rxFailNoAnser++; // should only be one of fail or retransmit.
|
//q->iv->radioStatistics.rxFailNoAnser++; // should only be one of fail or retransmit.
|
||||||
|
@ -209,7 +210,7 @@ class Communication : public CommQueue<> {
|
||||||
if(q->iv->ivGen != IV_MI) {
|
if(q->iv->ivGen != IV_MI) {
|
||||||
mState = States::CHECK_PACKAGE;
|
mState = States::CHECK_PACKAGE;
|
||||||
} else {
|
} else {
|
||||||
bool fastNext = true;
|
//bool fastNext = true;
|
||||||
if(q->iv->miMultiParts < 6) {
|
if(q->iv->miMultiParts < 6) {
|
||||||
mState = States::WAIT;
|
mState = States::WAIT;
|
||||||
if((q->iv->radio->mRadioWaitTime.isTimeout() && mIsRetransmit) || !mIsRetransmit) {
|
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_CH2) && (q->iv->type == INV_TYPE_2CH))
|
||||||
|| ((q->cmd == MI_REQ_CH1) && (q->iv->type == INV_TYPE_1CH))) {
|
|| ((q->cmd == MI_REQ_CH1) && (q->iv->type == INV_TYPE_1CH))) {
|
||||||
miComplete(q->iv);
|
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);
|
miNextRequest(q->iv->type == INV_TYPE_4CH ? MI_REQ_4CH : MI_REQ_CH1, q);
|
||||||
else
|
else*/
|
||||||
closeRequest(q, true);
|
closeRequest(q, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,6 +264,25 @@ class Communication : public CommQueue<> {
|
||||||
closeRequest(q, false);
|
closeRequest(q, false);
|
||||||
return;
|
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();
|
setAttempt();
|
||||||
|
|
||||||
if(*mSerialDebug) {
|
if(*mSerialDebug) {
|
||||||
|
@ -411,8 +431,8 @@ class Communication : public CommQueue<> {
|
||||||
|
|
||||||
if((*frameId & ALL_FRAMES) == ALL_FRAMES) {
|
if((*frameId & ALL_FRAMES) == ALL_FRAMES) {
|
||||||
mMaxFrameId = (*frameId & 0x7f);
|
mMaxFrameId = (*frameId & 0x7f);
|
||||||
if(mMaxFrameId > 8) // large payloads, e.g. AlarmData
|
/*if(mMaxFrameId > 8) // large payloads, e.g. AlarmData
|
||||||
incrAttempt(mMaxFrameId - 6);
|
incrAttempt(mMaxFrameId - 6);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_t *f = &mLocalBuf[(*frameId & 0x7f) - 1];
|
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_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_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)
|
#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_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
|
#define LIMIT_VERYFAST_IV 70 // time limit to qualify an inverter as very fast answering inverter
|
||||||
|
|
|
@ -220,21 +220,21 @@ class Inverter {
|
||||||
cb(RealTimeRunData_Debug, false); // get live data
|
cb(RealTimeRunData_Debug, false); // get live data
|
||||||
}
|
}
|
||||||
} else { // MI
|
} else { // MI
|
||||||
if(0 == getFwVersion()) {
|
cb(((type == INV_TYPE_4CH) ? MI_REQ_4CH : MI_REQ_CH1), false);
|
||||||
mIvRxCnt +=2;
|
mGetLossInterval++;
|
||||||
cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number
|
if (type != INV_TYPE_4CH)
|
||||||
} else {
|
mIvRxCnt++; // statistics workaround...
|
||||||
record_t<> *rec = getRecordStruct(InverterDevInform_Simple);
|
if(isAvailable()) {
|
||||||
if (getChannelFieldValue(CH0, FLD_PART_NUM, rec) == 0) {
|
if(0 == getFwVersion()) {
|
||||||
cb(0x0f, false); // hard- and firmware version for missing HW part nr, delivered by frame 1
|
|
||||||
mIvRxCnt +=2;
|
mIvRxCnt +=2;
|
||||||
} else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && generalConfig->readGrid) // read grid profile
|
cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number
|
||||||
cb(0x10, false); // legacy GPF command
|
} else {
|
||||||
else {
|
record_t<> *rec = getRecordStruct(InverterDevInform_Simple);
|
||||||
cb(((type == INV_TYPE_4CH) ? MI_REQ_4CH : MI_REQ_CH1), false);
|
if (getChannelFieldValue(CH0, FLD_PART_NUM, rec) == 0) {
|
||||||
mGetLossInterval++;
|
cb(0x0f, false); // hard- and firmware version for missing HW part nr, delivered by frame 1
|
||||||
if (type != INV_TYPE_4CH)
|
mIvRxCnt +=2;
|
||||||
mIvRxCnt++; // statistics workaround...
|
} else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && generalConfig->readGrid) // read grid profile
|
||||||
|
cb(0x10, false); // legacy GPF command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,7 @@ class Radio {
|
||||||
uint8_t mIrqOk = IRQ_UNKNOWN;
|
uint8_t mIrqOk = IRQ_UNKNOWN;
|
||||||
TimeMonitor mRadioWaitTime = TimeMonitor(0, true); // start as expired (due to code in RESET state)
|
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 mTxRetriesNext = 15; // let heuristics tell us the next reties count (for nRF type radios only)
|
||||||
|
uint8_t mFramesExpected = 0x0c;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void sendPacket(Inverter<> *iv, uint8_t len, bool isRetransmit, bool appendCrc16=true) = 0;
|
virtual void sendPacket(Inverter<> *iv, uint8_t len, bool isRetransmit, bool appendCrc16=true) = 0;
|
||||||
|
@ -130,7 +131,6 @@ class Radio {
|
||||||
volatile bool mIrqRcvd;
|
volatile bool mIrqRcvd;
|
||||||
bool *mSerialDebug, *mPrivacyMode, *mPrintWholeTrace;
|
bool *mSerialDebug, *mPrivacyMode, *mPrintWholeTrace;
|
||||||
uint8_t mTxBuf[MAX_RF_PAYLOAD_SIZE];
|
uint8_t mTxBuf[MAX_RF_PAYLOAD_SIZE];
|
||||||
uint8_t mFramesExpected = 0x0c;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__RADIO_H__*/
|
#endif /*__RADIO_H__*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue