W433DataReciver robustness changes
This commit is contained in:
parent
d49db3df70
commit
53c42b050a
|
@ -64,8 +64,12 @@ bool W433DataReciver::reciveSync(const uint16_t elapsedTime)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(syncCount > 5) error(ERR_SYNC_FAIL);
|
if(syncCount > 4 && syncFailCount < 3) ++syncFailCount;
|
||||||
syncCount = 0;
|
else
|
||||||
|
{
|
||||||
|
syncCount = 0;
|
||||||
|
syncFailCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(syncCount > 10) return true;
|
if(syncCount > 10) return true;
|
||||||
else return false;
|
else return false;
|
||||||
|
@ -105,6 +109,8 @@ void W433DataReciver::setState(const uint8_t stateIn)
|
||||||
state = stateIn;
|
state = stateIn;
|
||||||
timesBufferIndex = 0;
|
timesBufferIndex = 0;
|
||||||
packetIndex = 0;
|
packetIndex = 0;
|
||||||
|
syncCount = 0;
|
||||||
|
syncFailCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void W433DataReciver::interrupt()
|
void W433DataReciver::interrupt()
|
||||||
|
@ -130,9 +136,9 @@ void W433DataReciver::interrupt()
|
||||||
}
|
}
|
||||||
else if(state == LOOKING_FOR_SYNC_END)
|
else if(state == LOOKING_FOR_SYNC_END)
|
||||||
{
|
{
|
||||||
if(elapsedTime > SYNC_TIME + 50)
|
if(elapsedTime > SYNC_TIME + SYNC_TIME_TOLERANCE)
|
||||||
{
|
{
|
||||||
if(elapsedTime < LARGE_TIME + 50)
|
if(elapsedTime < LARGE_TIME - LARGE_TIME_TOLERANCE)
|
||||||
{
|
{
|
||||||
setState(LOOKING_FOR_SYNC);
|
setState(LOOKING_FOR_SYNC);
|
||||||
error(ERR_NO_SYNC_END);
|
error(ERR_NO_SYNC_END);
|
||||||
|
|
|
@ -60,6 +60,7 @@ private:
|
||||||
void* const _userData;
|
void* const _userData;
|
||||||
|
|
||||||
volatile uint8_t syncCount = 0;
|
volatile uint8_t syncCount = 0;
|
||||||
|
volatile uint8_t syncFailCount = 0;
|
||||||
volatile uint8_t state = 0;
|
volatile uint8_t state = 0;
|
||||||
|
|
||||||
//private functions
|
//private functions
|
||||||
|
|
Loading…
Reference in a new issue