check modem type when header type set
This commit is contained in:
parent
3ac63e8c95
commit
e441e101ff
2 changed files with 21 additions and 4 deletions
|
@ -1179,13 +1179,11 @@ uint32_t SX126x::getTimeOnAir(size_t len) {
|
|||
}
|
||||
|
||||
void SX126x::implicitHeader(size_t len) {
|
||||
_headerType = SX126X_LORA_HEADER_IMPLICIT;
|
||||
_implicitLen = len;
|
||||
return setHeaderType(SX126X_LORA_HEADER_IMPLICIT, len);
|
||||
}
|
||||
|
||||
void SX126x::explicitHeader() {
|
||||
_headerType = SX126X_LORA_HEADER_EXPLICIT;
|
||||
_implicitLen = 0xFF;
|
||||
return setHeaderType(SX126X_LORA_HEADER_EXPLICIT);
|
||||
}
|
||||
|
||||
int16_t SX126x::setTCXO(float voltage, uint32_t delay) {
|
||||
|
@ -1364,6 +1362,24 @@ int16_t SX126x::setPacketMode(uint8_t mode, uint8_t len) {
|
|||
return(state);
|
||||
}
|
||||
|
||||
int16_t SX126x::setHeaderType(uint8_t headerType, size_t len) {
|
||||
// check active modem
|
||||
if(getPacketType() != SX126X_PACKET_TYPE_LORA) {
|
||||
return(ERR_WRONG_MODEM);
|
||||
}
|
||||
// set requested packet mode
|
||||
int16_t state = setPacketParams(_preambleLength, _crcType, len, headerType);
|
||||
|
||||
if(state != ERR_NONE) {
|
||||
return(state);
|
||||
}
|
||||
|
||||
// update cached value
|
||||
_headerType = headerType;
|
||||
_implicitLen = len;
|
||||
return(state);
|
||||
}
|
||||
|
||||
int16_t SX126x::setModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro) {
|
||||
// calculate symbol length and enable low data rate optimization, if needed
|
||||
if(ldro == 0xFF) {
|
||||
|
|
|
@ -838,6 +838,7 @@ class SX126x: public PhysicalLayer {
|
|||
int16_t setFrequencyRaw(float freq);
|
||||
int16_t setOptimalHiPowerPaConfig(int8_t* inOutPower);
|
||||
int16_t setPacketMode(uint8_t mode, uint8_t len);
|
||||
int16_t setHeaderType(uint8_t headerType, size_t len = 0xFF);
|
||||
|
||||
// fixes to errata
|
||||
int16_t fixSensitivity();
|
||||
|
|
Loading…
Add table
Reference in a new issue