Add setSyncBits for SX126x

Add setSyncBits for possibility to set the sync word length in bits
This commit is contained in:
mmrein 2019-09-12 10:16:36 +02:00
parent a04a376afc
commit 1046db24e4
2 changed files with 38 additions and 0 deletions

View file

@ -721,6 +721,33 @@ int16_t SX126x::setSyncWord(uint8_t* syncWord, uint8_t len) {
return(state); return(state);
} }
int16_t SX126x::setSyncBits(uint8_t *syncWord, uint8_t bitsLen) {
// check active modem
if(getPacketType() != SX126X_PACKET_TYPE_GFSK) {
return(ERR_WRONG_MODEM);
}
// check sync word Length
if(bitsLen > 0x40) {
return(ERR_INVALID_SYNC_WORD);
}
uint8_t bytesLen = bitsLen / 8;
if ((bitsLen % 8) != 0) bytesLen++;
// write sync word
int16_t state = writeRegister(SX126X_REG_SYNC_WORD_0, syncWord, bytesLen);
if(state != ERR_NONE) {
return(state);
}
// update packet parameters
_syncWordLength = bitsLen;
state = setPacketParamsFSK(_preambleLengthFSK, _crcTypeFSK, _syncWordLength, _addrComp);
return(state);
}
int16_t SX126x::setNodeAddress(uint8_t nodeAddr) { int16_t SX126x::setNodeAddress(uint8_t nodeAddr) {
// check active modem // check active modem
if(getPacketType() != SX126X_PACKET_TYPE_GFSK) { if(getPacketType() != SX126X_PACKET_TYPE_GFSK) {

View file

@ -604,6 +604,17 @@ class SX126x: public PhysicalLayer {
*/ */
int16_t setSyncWord(uint8_t* syncWord, uint8_t len); int16_t setSyncWord(uint8_t* syncWord, uint8_t len);
/*!
\brief Sets FSK sync word in the form of array of up to 8 bytes.
\param syncWord FSK sync word to be set.
\param len FSK sync word length in bits.
\returns \ref status_codes
*/
int16_t setSyncBits(uint8_t *sync, uint8_t bitsLen);
/*! /*!
\brief Sets node address. Calling this method will also enable address filtering for node address only. \brief Sets node address. Calling this method will also enable address filtering for node address only.