Browse Source

Merge branch 'development03' of https://github.com/rejoe2/ahoy into rejoe2-development03

pull/1298/head
lumapu 9 months ago
parent
commit
dd7635280d
  1. 28
      src/hm/Communication.h
  2. 4
      src/hm/hmRadio.h

28
src/hm/Communication.h

@ -59,7 +59,7 @@ class Communication : public CommQueue<> {
mLastEmptyQueueMillis = millis();
mPrintSequenceDuration = true;
uint16_t timeout = (q->iv->ivGen == IV_MI) ? MI_TIMEOUT : (((q->iv->mGotFragment && q->iv->mGotLastMsg) || mIsRetransmit) ? SINGLEFR_TIMEOUT : ((q->cmd != AlarmData) ? DEFAULT_TIMEOUT : (1.5 * DEFAULT_TIMEOUT)));
uint16_t timeout = (q->iv->ivGen == IV_MI) ? MI_TIMEOUT : (((q->iv->mGotFragment && q->iv->mGotLastMsg) || mIsRetransmit) ? SINGLEFR_TIMEOUT : ((q->cmd != AlarmData) && q->cmd != GridOnProFilePara ? DEFAULT_TIMEOUT : (1.5 * DEFAULT_TIMEOUT)));
uint16_t timeout_min = (q->iv->ivGen == IV_MI) ? MI_TIMEOUT : ((q->iv->mGotFragment || mIsRetransmit)) ? SINGLEFR_TIMEOUT : FRSTMSG_TIMEOUT;
/*if(mDebugState != mState) {
@ -113,10 +113,35 @@ class Communication : public CommQueue<> {
mIsRetransmit = false;
mlastTO_min = timeout_min;
setAttempt();
if(q->cmd == AlarmData || q->cmd == GridOnProFilePara)
incrAttempt(q->cmd == AlarmData? 5 : 3);
mState = States::WAIT;
break;
case States::WAIT:
/*if(millis() > mWaitTimeout_min) {
if(mIsRetransmit) { // we already have been through...
mWaitTimeout = mWaitTimeout_min;
} else if(q->iv->mGotFragment) { // nothing received yet?
if(q->iv->mGotLastMsg) {
//mState = States::CHECK_FRAMES;
mWaitTimeout = mWaitTimeout_min;
}
} else if(mFirstTry) {
if(*mSerialDebug) {
DPRINT_IVID(DBG_INFO, q->iv->id);
DBGPRINT(String(millis() - mWaitTimeout_min + mlastTO_min));
DBGPRINTLN(F("ms - second try"));
}
mFirstTry = false;
mlastTO_min = timeout_min;
q->iv->radioStatistics.retransmits++; // got nothing
mState = States::START;
break;
}
}*/
if(millis() < mWaitTimeout)
return;
mState = States::CHECK_FRAMES;
@ -446,7 +471,6 @@ class Communication : public CommQueue<> {
if(NULL == rec) {
if(GetLossRate == q->cmd) {
q->iv->parseGetLossRate(mPayload, len);
//closeRequest(q, true); //@lumapu: Activating would crash most esp's!
return;
} else {
DPRINTLN(DBG_ERROR, F("record is NULL!"));

4
src/hm/hmRadio.h

@ -121,9 +121,10 @@ class HmRadio : public Radio {
uint32_t startMicros = micros();
uint32_t loopMillis = millis();
uint32_t outerLoopTimeout = (mLastIv->mIsSingleframeReq) ? 100 : ((mLastIv->mCmd != AlarmData) ? 400 : 600);
uint32_t outerLoopTimeout = (mLastIv->mIsSingleframeReq) ? 100 : ((mLastIv->mCmd != AlarmData) && (mLastIv->mCmd != GridOnProFilePara)) ? 400 : 600;
while ((millis() - loopMillis) < outerLoopTimeout) {
uint32_t startMicros = micros();
while ((micros() - startMicros) < 5110) { // listen (4088us or?) 5110us to each channel
if (mIrqRcvd) {
mIrqRcvd = false;
@ -137,7 +138,6 @@ class HmRadio : public Radio {
// switch to next RX channel
mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS;
mNrf24->setChannel(mRfChLst[mRxChIdx]);
startMicros = micros();
}
// not finished but time is over
mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS;

Loading…
Cancel
Save