mirror of
https://github.com/lumapu/ahoy.git
synced 2025-07-14 23:17:15 +02:00
0.8.33
* improved communication thx @rejoe2
This commit is contained in:
parent
a8b10eec6c
commit
b043f4c2ac
2 changed files with 25 additions and 5 deletions
|
@ -1,5 +1,8 @@
|
|||
# Development Changes
|
||||
|
||||
## 0.8.33 - 2023-12-29
|
||||
* improved communication thx @rejoe2
|
||||
|
||||
## 0.8.32 - 2023-12-29
|
||||
* fix `start` / `stop` / `restart` commands #1287
|
||||
* added message, if profile was not read until now #1300
|
||||
|
|
|
@ -113,34 +113,51 @@ class HmRadio : public Radio {
|
|||
mNrf24->flush_tx(); // empty TX FIFO
|
||||
|
||||
// start listening
|
||||
uint8_t chOffset = 2;
|
||||
mRxChIdx = (mTxChIdx + chOffset) % RF_CHANNELS;
|
||||
mNrf24->setChannel(mRfChLst[mRxChIdx]);
|
||||
mNrf24->startListening();
|
||||
|
||||
if(NULL == mLastIv) // prevent reading on NULL object!
|
||||
return;
|
||||
|
||||
uint32_t startMicros = micros();
|
||||
uint32_t innerLoopTimeout = 55000;
|
||||
uint32_t loopMillis = millis();
|
||||
uint32_t outerLoopTimeout = (mLastIv->mIsSingleframeReq) ? 100 : ((mLastIv->mCmd != AlarmData) && (mLastIv->mCmd != GridOnProFilePara)) ? 400 : 600;
|
||||
bool isRxInit = true;
|
||||
|
||||
|
||||
while ((millis() - loopMillis) < outerLoopTimeout) {
|
||||
startMicros = micros();
|
||||
while ((micros() - startMicros) < 5110) { // listen (4088us or?) 5110us to each channel
|
||||
uint32_t startMicros = micros();
|
||||
while ((micros() - startMicros) < innerLoopTimeout) { // listen (4088us or?) 5110us to each channel
|
||||
if (mIrqRcvd) {
|
||||
mIrqRcvd = false;
|
||||
|
||||
if (getReceived()) { // everything received
|
||||
return;
|
||||
}
|
||||
|
||||
innerLoopTimeout = 4088*5;
|
||||
if (isRxInit) {
|
||||
isRxInit = false;
|
||||
if (micros() - startMicros < 42000) {
|
||||
innerLoopTimeout = 4088*12;
|
||||
mRxChIdx = (mRxChIdx + 4) % RF_CHANNELS;
|
||||
mNrf24->setChannel(mRfChLst[mRxChIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
startMicros = micros();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
// switch to next RX channel
|
||||
mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS;
|
||||
mRxChIdx = (mRxChIdx + 4) % RF_CHANNELS;
|
||||
mNrf24->setChannel(mRfChLst[mRxChIdx]);
|
||||
innerLoopTimeout = 4088;
|
||||
isRxInit = false;
|
||||
}
|
||||
// not finished but time is over
|
||||
mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS;
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue