mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 23:46:37 +02:00
0.8.69
* fix brackets
This commit is contained in:
parent
ac58f2f078
commit
349184a113
7 changed files with 24 additions and 19 deletions
|
@ -87,7 +87,7 @@ class Communication : public CommQueue<> {
|
||||||
mIsRetransmit = false;
|
mIsRetransmit = false;
|
||||||
if(NULL == q->iv->radio)
|
if(NULL == q->iv->radio)
|
||||||
cmdDone(false); // can't communicate while radio is not defined!
|
cmdDone(false); // can't communicate while radio is not defined!
|
||||||
mFirstTry = INV_RADIO_TYPE_NRF == q->iv->ivRadioType && q->iv->isAvailable();
|
mFirstTry = (INV_RADIO_TYPE_NRF == q->iv->ivRadioType) && (q->iv->isAvailable());
|
||||||
q->iv->mCmd = q->cmd;
|
q->iv->mCmd = q->cmd;
|
||||||
q->iv->mIsSingleframeReq = false;
|
q->iv->mIsSingleframeReq = false;
|
||||||
mFramesExpected = getFramesExpected(q); // function to get expected frame count.
|
mFramesExpected = getFramesExpected(q); // function to get expected frame count.
|
||||||
|
@ -116,7 +116,7 @@ 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))
|
if(!mIsRetransmit && (q->cmd == AlarmData) || (q->cmd == GridOnProFilePara))
|
||||||
incrAttempt(q->cmd == AlarmData? MORE_ATTEMPS_ALARMDATA : MORE_ATTEMPS_GRIDONPROFILEPARA);
|
incrAttempt((q->cmd == AlarmData)? MORE_ATTEMPS_ALARMDATA : MORE_ATTEMPS_GRIDONPROFILEPARA);
|
||||||
|
|
||||||
mIsRetransmit = false;
|
mIsRetransmit = false;
|
||||||
setAttempt();
|
setAttempt();
|
||||||
|
@ -184,7 +184,7 @@ class Communication : public CommQueue<> {
|
||||||
if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command
|
if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command
|
||||||
if(parseFrame(p)) {
|
if(parseFrame(p)) {
|
||||||
q->iv->curFrmCnt++;
|
q->iv->curFrmCnt++;
|
||||||
if(!mIsRetransmit && (p->packet[9] == 0x02 || p->packet[9] == 0x82) && p->millis < LIMIT_FAST_IV)
|
if(!mIsRetransmit && ((p->packet[9] == 0x02) || (p->packet[9] == 0x82)) && (p->millis < LIMIT_FAST_IV))
|
||||||
mHeu.setIvRetriesGood(q->iv,p->millis < LIMIT_VERYFAST_IV);
|
mHeu.setIvRetriesGood(q->iv,p->millis < LIMIT_VERYFAST_IV);
|
||||||
}
|
}
|
||||||
} else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES)) { // response from dev control command
|
} else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES)) { // response from dev control command
|
||||||
|
@ -257,13 +257,13 @@ class Communication : public CommQueue<> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//count missing frames
|
//count missing frames
|
||||||
if(!q->iv->mIsSingleframeReq && q->iv->ivRadioType == INV_RADIO_TYPE_NRF) { // already checked?
|
if(!q->iv->mIsSingleframeReq && (q->iv->ivRadioType == INV_RADIO_TYPE_NRF)) { // already checked?
|
||||||
uint8_t missedFrames = 0;
|
uint8_t missedFrames = 0;
|
||||||
for(uint8_t i = 0; i < q->iv->radio->mFramesExpected; i++) {
|
for(uint8_t i = 0; i < q->iv->radio->mFramesExpected; i++) {
|
||||||
if(mLocalBuf[i].len == 0)
|
if(mLocalBuf[i].len == 0)
|
||||||
missedFrames++;
|
missedFrames++;
|
||||||
}
|
}
|
||||||
if(missedFrames > 3 || (q->cmd == RealTimeRunData_Debug && missedFrames > 1) || (missedFrames > 1 && missedFrames + 2 > q->attempts)) {
|
if(missedFrames > 3 || (q->cmd == RealTimeRunData_Debug && missedFrames > 1) || ((missedFrames > 1) && ((missedFrames + 2) > q->attempts))) {
|
||||||
if(*mSerialDebug) {
|
if(*mSerialDebug) {
|
||||||
DPRINT_IVID(DBG_INFO, q->iv->id);
|
DPRINT_IVID(DBG_INFO, q->iv->id);
|
||||||
DBGPRINT(String(missedFrames));
|
DBGPRINT(String(missedFrames));
|
||||||
|
@ -435,7 +435,7 @@ class Communication : public CommQueue<> {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool parseMiFrame(packet_t *p, const queue_s *q) {
|
inline bool parseMiFrame(packet_t *p, const queue_s *q) {
|
||||||
if(!mIsRetransmit && p->packet[9] == 0x00 && p->millis < LIMIT_FAST_IV_MI) //first frame is fast?
|
if((!mIsRetransmit && p->packet[9] == 0x00) && (p->millis < LIMIT_FAST_IV_MI)) //first frame is fast?
|
||||||
mHeu.setIvRetriesGood(q->iv,p->millis < LIMIT_VERYFAST_IV_MI);
|
mHeu.setIvRetriesGood(q->iv,p->millis < LIMIT_VERYFAST_IV_MI);
|
||||||
if ((p->packet[0] == MI_REQ_CH1 + ALL_FRAMES)
|
if ((p->packet[0] == MI_REQ_CH1 + ALL_FRAMES)
|
||||||
|| (p->packet[0] == MI_REQ_CH2 + ALL_FRAMES)
|
|| (p->packet[0] == MI_REQ_CH2 + ALL_FRAMES)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// 2023 Ahoy, https://github.com/lumpapu/ahoy
|
// 2024 Ahoy, https://github.com/lumpapu/ahoy
|
||||||
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed
|
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,11 @@ class HeuristicInv {
|
||||||
testChId = 0;
|
testChId = 0;
|
||||||
saveOldTestQuality = -6;
|
saveOldTestQuality = -6;
|
||||||
lastRxFragments = 0;
|
lastRxFragments = 0;
|
||||||
|
|
||||||
|
rxSpeeds[0] = false;
|
||||||
|
rxSpeeds[1] = false;
|
||||||
|
rxSpeedCnt[0] = 0;
|
||||||
|
rxSpeedCnt[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTxAtMax(void) const {
|
bool isTxAtMax(void) const {
|
||||||
|
@ -42,9 +47,8 @@ class HeuristicInv {
|
||||||
uint8_t testChId = 0;
|
uint8_t testChId = 0;
|
||||||
int8_t saveOldTestQuality = -6;
|
int8_t saveOldTestQuality = -6;
|
||||||
uint8_t lastRxFragments = 0;
|
uint8_t lastRxFragments = 0;
|
||||||
bool rxSpeeds[2] = {false,false}; // is inverter responding very fast respective fast?
|
bool rxSpeeds[2] = {false, false}; // is inverter responding very fast respective fast?
|
||||||
uint8_t rxSpeedCnt[2] = {0,0}; // count how many messages had been received very fast respective fast (10 max)
|
uint8_t rxSpeedCnt[2] = {0, 0}; // count how many messages had been received very fast respective fast (10 max)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__HEURISTIC_INV_H__*/
|
#endif /*__HEURISTIC_INV_H__*/
|
||||||
|
|
|
@ -84,7 +84,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] = {65,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
|
||||||
|
|
|
@ -464,7 +464,7 @@ class Inverter {
|
||||||
status = InverterStatus::OFF;
|
status = InverterStatus::OFF;
|
||||||
actPowerLimit = 0xffff; // power limit will be read once inverter becomes available
|
actPowerLimit = 0xffff; // power limit will be read once inverter becomes available
|
||||||
alarmMesIndex = 0;
|
alarmMesIndex = 0;
|
||||||
if(ivRadioType == INV_RADIO_TYPE_NRF) {
|
if(INV_RADIO_TYPE_NRF == ivRadioType) {
|
||||||
heuristics.clear();
|
heuristics.clear();
|
||||||
#ifdef DYNAMIC_OFFSET
|
#ifdef DYNAMIC_OFFSET
|
||||||
rxOffset = ivGen == IV_HM ? 13 : 12; // effective 3 (or 2), but can easily be recognized as default setting
|
rxOffset = ivGen == IV_HM ? 13 : 12; // effective 3 (or 2), but can easily be recognized as default setting
|
||||||
|
|
|
@ -328,12 +328,13 @@ class HmRadio : public Radio {
|
||||||
isLastPackage = (p.packet[9] > ALL_FRAMES); // > ALL_FRAMES indicates last packet received
|
isLastPackage = (p.packet[9] > ALL_FRAMES); // > ALL_FRAMES indicates last packet received
|
||||||
if(mLastIv->mIsSingleframeReq) // we only expect one frame here...
|
if(mLastIv->mIsSingleframeReq) // we only expect one frame here...
|
||||||
isRetransmitAnswer = true;
|
isRetransmitAnswer = true;
|
||||||
|
|
||||||
if(isLastPackage)
|
if(isLastPackage)
|
||||||
setExpectedFrames(p.packet[9] - ALL_FRAMES);
|
setExpectedFrames(p.packet[9] - ALL_FRAMES);
|
||||||
#ifdef DYNAMIC_OFFSET
|
#ifdef DYNAMIC_OFFSET
|
||||||
if(p.packet[9] == 1 && p.millis < DURATION_ONEFRAME)
|
if((p.packet[9] == 1) && (p.millis < DURATION_ONEFRAME))
|
||||||
mLastIv->rxOffset = (RF_CHANNELS + mTxChIdx - tempRxChIdx + 1) % RF_CHANNELS;
|
mLastIv->rxOffset = (RF_CHANNELS + mTxChIdx - tempRxChIdx + 1) % RF_CHANNELS;
|
||||||
else if(mNRFloopChannels && mLastIv->rxOffset > RF_CHANNELS) { // unsure setting?
|
else if(mNRFloopChannels && (mLastIv->rxOffset > RF_CHANNELS)) { // unsure setting?
|
||||||
mLastIv->rxOffset = (RF_CHANNELS + mTxChIdx - tempRxChIdx + (isLastPackage ? mFramesExpected : p.packet[9])); // make clear it's not sure, start with one more offset
|
mLastIv->rxOffset = (RF_CHANNELS + mTxChIdx - tempRxChIdx + (isLastPackage ? mFramesExpected : p.packet[9])); // make clear it's not sure, start with one more offset
|
||||||
mNRFloopChannels = false;
|
mNRFloopChannels = false;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +347,7 @@ class HmRadio : public Radio {
|
||||||
else if ((p.packet[0] != 0x88) && (p.packet[0] != 0x92)) // ignore MI status messages //#0 was p.packet[0] != 0x00 &&
|
else if ((p.packet[0] != 0x88) && (p.packet[0] != 0x92)) // ignore MI status messages //#0 was p.packet[0] != 0x00 &&
|
||||||
isLastPackage = true; // response from dev control command
|
isLastPackage = true; // response from dev control command
|
||||||
#ifdef DYNAMIC_OFFSET
|
#ifdef DYNAMIC_OFFSET
|
||||||
if(p.packet[9] == 0x00 && p.millis < DURATION_ONEFRAME)
|
if((p.packet[9] == 0x00) && (p.millis < DURATION_ONEFRAME))
|
||||||
mLastIv->rxOffset = (RF_CHANNELS + mTxChIdx - tempRxChIdx - 1) % RF_CHANNELS;
|
mLastIv->rxOffset = (RF_CHANNELS + mTxChIdx - tempRxChIdx - 1) % RF_CHANNELS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -408,7 +409,7 @@ class HmRadio : public Radio {
|
||||||
|
|
||||||
mNrf24->stopListening();
|
mNrf24->stopListening();
|
||||||
mNrf24->flush_rx();
|
mNrf24->flush_rx();
|
||||||
if(!isRetransmit && mTxRetries != mTxRetriesNext) {
|
if(!isRetransmit && (mTxRetries != mTxRetriesNext)) {
|
||||||
mNrf24->setRetries(3, mTxRetriesNext);
|
mNrf24->setRetries(3, mTxRetriesNext);
|
||||||
mTxRetries = mTxRetriesNext;
|
mTxRetries = mTxRetriesNext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,10 +96,10 @@ class HmSystem {
|
||||||
DPRINTLN(DBG_WARN, F("MI Inverter, has some restrictions!"));
|
DPRINTLN(DBG_WARN, F("MI Inverter, has some restrictions!"));
|
||||||
|
|
||||||
#ifdef DYNAMIC_OFFSET
|
#ifdef DYNAMIC_OFFSET
|
||||||
iv->rxOffset = iv->ivGen == IV_HM ? 13 : 12; // effective 3 (or 2), but can easily be recognized as default setting
|
iv->rxOffset = (iv->ivGen == IV_HM) ? 13 : 12; // effective 3 (or 2), but can easily be recognized as default setting
|
||||||
#else
|
#else
|
||||||
iv->rxOffset = (iv->ivGen == IV_HM && iv->type == INV_TYPE_4CH) ? 3 : 2;
|
iv->rxOffset = ((iv->ivGen == IV_HM) && (iv->type == INV_TYPE_4CH)) ? 3 : 2;
|
||||||
iv->rxOffset = iv->ivGen == IV_HM ? 3 : 2;
|
iv->rxOffset = (iv->ivGen == IV_HM) ? 3 : 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cb(iv);
|
cb(iv);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue