reciver changes
This commit is contained in:
@ -30,8 +30,8 @@ int8_t W433DataReciver::reciveBit(uint8_t index)
|
||||
if(
|
||||
timesBuffer[index] < 0 &&
|
||||
isTime(timesBuffer[index+1], SMALL_TIME, true, SMALL_TIME_TOLERANCE) &&
|
||||
isTime(timesBuffer[index+2], LARGE_TIME, false, LARGE_TIME_TOLERANCE) &&
|
||||
isTime(timesBuffer[index+3], SMALL_TIME, true, SMALL_TIME_TOLERANCE)
|
||||
isTime(timesBuffer[index+2], LARGE_TIME, false, LARGE_TIME_TOLERANCE) //&&
|
||||
//isTime(timesBuffer[index+3], SMALL_TIME, true, SMALL_TIME_TOLERANCE)
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
@ -39,8 +39,8 @@ int8_t W433DataReciver::reciveBit(uint8_t index)
|
||||
else if(
|
||||
timesBuffer[index] < 0 &&
|
||||
isTime(timesBuffer[index+1], LARGE_TIME, true, LARGE_TIME_TOLERANCE) &&
|
||||
isTime(timesBuffer[index+2], SMALL_TIME, false, SMALL_TIME_TOLERANCE) &&
|
||||
isTime(timesBuffer[index+3], SMALL_TIME, true, SMALL_TIME_TOLERANCE)
|
||||
isTime(timesBuffer[index+2], SMALL_TIME, false, SMALL_TIME_TOLERANCE) //&&
|
||||
//isTime(timesBuffer[index+3], SMALL_TIME, true, SMALL_TIME_TOLERANCE)
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
@ -67,8 +67,8 @@ bool W433DataReciver::reciveSync(const uint16_t elapsedTime)
|
||||
if(syncCount > 4 && syncFailCount < 3) ++syncFailCount;
|
||||
else
|
||||
{
|
||||
syncCount = 0;
|
||||
syncFailCount = 0;
|
||||
//if(syncCount > 7) error(ERR_SYNC_FAIL);
|
||||
setState(LOOKING_FOR_SYNC);
|
||||
}
|
||||
}
|
||||
if(syncCount > 10) return true;
|
||||
@ -79,6 +79,7 @@ bool W433DataReciver::recivedByte(const uint16_t elapsedTime)
|
||||
{
|
||||
timesBuffer[timesBufferIndex] = readPin(_port, _pin) ? 0-elapsedTime : elapsedTime;
|
||||
++timesBufferIndex;
|
||||
if(timesBufferIndex == 32) writePin(&PORTC, PC0, true);
|
||||
return timesBufferIndex == 32;
|
||||
}
|
||||
|
||||
@ -119,14 +120,14 @@ void W433DataReciver::interrupt()
|
||||
|
||||
if(elapsedTime < DISCARD_TIME)
|
||||
{
|
||||
if(timesBufferIndex > 0 && elapsedTime + timesBuffer[timesBufferIndex-1] < LARGE_TIME+LARGE_TIME_TOLERANCE)
|
||||
if(timesBufferIndex > 0 && elapsedTime + abs(timesBuffer[timesBufferIndex-1]) < LARGE_TIME+LARGE_TIME_TOLERANCE)
|
||||
{
|
||||
writePin(&PORTC, PC2, true);
|
||||
previousTime = *_timerRegister - elapsedTime - abs(timesBuffer[timesBufferIndex-1]);
|
||||
--timesBufferIndex;
|
||||
timesBufferIndex-=1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
previousTime = *_timerRegister;
|
||||
*_timerOverflowRegister = *_timerOverflowRegister | 0x01;
|
||||
|
||||
@ -136,7 +137,7 @@ void W433DataReciver::interrupt()
|
||||
}
|
||||
else if(state == LOOKING_FOR_SYNC_END)
|
||||
{
|
||||
if(elapsedTime > SYNC_TIME + SYNC_TIME_TOLERANCE)
|
||||
if(elapsedTime > SYNC_TIME + SYNC_END_TIME_TOLERANCE)
|
||||
{
|
||||
if(elapsedTime < LARGE_TIME - LARGE_TIME_TOLERANCE)
|
||||
{
|
||||
@ -194,7 +195,9 @@ void W433DataReciver::interrupt()
|
||||
|
||||
if(computedChecksum == recivedChecksum)
|
||||
{
|
||||
#ifdef USE_RINGBUFFER
|
||||
_ringBuffer.write(const_cast<uint8_t*>(buffer), sizeof(packet));
|
||||
#endif
|
||||
if(_packetCallback != nullptr)(*_packetCallback)(packet, _userData);
|
||||
}
|
||||
else error(ERR_CHECKSUM);
|
||||
@ -204,7 +207,9 @@ void W433DataReciver::interrupt()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_RINGBUFFER
|
||||
RingBuffer<W433DataReciver::RINGBUFFER_LENGTH, uint8_t>* W433DataReciver::getRingBuffer()
|
||||
{
|
||||
return &_ringBuffer;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user