Merge pull request #44 from mmrein/dev-sx126x-bitsync
[SX126x] Add setSyncBits method
This commit is contained in:
commit
1af88dd1cc
4 changed files with 48 additions and 0 deletions
|
@ -73,6 +73,13 @@ void setup() {
|
|||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// FSK modem on SX126x can handle the sync word setting in bits, not just
|
||||
// whole bytes. The value used is left-justified.
|
||||
// This makes same result as fsk.setSyncWord(syncWord, 8):
|
||||
state = fsk.setSyncBits(syncWord, 64);
|
||||
// This will use 0x012 as sync word (12 bits only):
|
||||
state = fsk.setSyncBits(syncWord, 12);
|
||||
|
||||
// FSK modem allows advanced CRC configuration
|
||||
// Default is CCIT CRC16 (2 bytes, initial 0x1D0F, polynomial 0x1021, inverted)
|
||||
|
|
|
@ -106,6 +106,7 @@ setDio2Action KEYWORD2
|
|||
setTCXO KEYWORD2
|
||||
setDio2AsRfSwitch KEYWORD2
|
||||
getTimeOnAir KEYWORD2
|
||||
setSyncBits KEYWORD2
|
||||
|
||||
# ESP8266
|
||||
join KEYWORD2
|
||||
|
|
|
@ -721,6 +721,35 @@ int16_t SX126x::setSyncWord(uint8_t* syncWord, uint8_t len) {
|
|||
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) {
|
||||
// check active modem
|
||||
if(getPacketType() != SX126X_PACKET_TYPE_GFSK) {
|
||||
|
|
|
@ -604,6 +604,17 @@ class SX126x: public PhysicalLayer {
|
|||
*/
|
||||
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. If less than 64 bits the LSB's of syncWord will be ignored.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setSyncBits(uint8_t *syncWord, uint8_t bitsLen);
|
||||
|
||||
/*!
|
||||
\brief Sets node address. Calling this method will also enable address filtering for node address only.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue