W433DataReciver robustness changes

This commit is contained in:
2019-01-10 19:43:25 +01:00
parent d49db3df70
commit 53c42b050a
2 changed files with 11 additions and 4 deletions

View File

@ -64,8 +64,12 @@ bool W433DataReciver::reciveSync(const uint16_t elapsedTime)
}
else
{
if(syncCount > 5) error(ERR_SYNC_FAIL);
syncCount = 0;
if(syncCount > 4 && syncFailCount < 3) ++syncFailCount;
else
{
syncCount = 0;
syncFailCount = 0;
}
}
if(syncCount > 10) return true;
else return false;
@ -105,6 +109,8 @@ void W433DataReciver::setState(const uint8_t stateIn)
state = stateIn;
timesBufferIndex = 0;
packetIndex = 0;
syncCount = 0;
syncFailCount = 0;
}
void W433DataReciver::interrupt()
@ -130,9 +136,9 @@ void W433DataReciver::interrupt()
}
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);
error(ERR_NO_SYNC_END);