[PHY] Added option to disable sync word matching (#337)

This commit is contained in:
jgromes 2021-09-26 17:45:35 +02:00
parent 127f05d876
commit 2125dfe276
2 changed files with 14 additions and 4 deletions

View file

@ -193,18 +193,27 @@ int16_t PhysicalLayer::available() {
}
uint8_t PhysicalLayer::read() {
_gotSync = false;
_syncBuffer = 0;
if(_directSyncWordLen > 0) {
_gotSync = false;
_syncBuffer = 0;
}
_bufferWritePos--;
return(_buffer[_bufferReadPos++]);
}
int16_t PhysicalLayer::setDirectSyncWord(uint32_t syncWord, uint8_t len) {
if((len > 32) || (len == 0)) {
if(len > 32) {
return(ERR_INVALID_SYNC_WORD);
}
_directSyncWordMask = 0xFFFFFFFF >> (32 - len);
_directSyncWordLen = len;
_directSyncWord = syncWord;
// override sync word matching when length is set to 0
if(_directSyncWordLen == 0) {
_gotSync = true;
}
return(ERR_NONE);
}

View file

@ -264,7 +264,7 @@ class PhysicalLayer {
\param syncWord Sync word bits.
\param len Sync word length in bits.
\param len Sync word length in bits. Set to zero to disable sync word matching.
\returns \ref status_codes
*/
@ -313,6 +313,7 @@ class PhysicalLayer {
uint8_t _buffer[RADIOLIB_STATIC_ARRAY_SIZE];
uint32_t _syncBuffer;
uint32_t _directSyncWord;
uint8_t _directSyncWordLen;
uint32_t _directSyncWordMask;
bool _gotSync;
};