diff --git a/src/modules/LR11x0/LR11x0.cpp b/src/modules/LR11x0/LR11x0.cpp index 3001563c..fa68071b 100644 --- a/src/modules/LR11x0/LR11x0.cpp +++ b/src/modules/LR11x0/LR11x0.cpp @@ -1310,6 +1310,14 @@ RadioLibTime_t LR11x0::getTimeOnAir(size_t len) { return(0); } +int16_t LR11x0::implicitHeader(size_t len) { + return(this->setHeaderType(RADIOLIB_LR11X0_LORA_HEADER_IMPLICIT, len)); +} + +int16_t LR11x0::explicitHeader() { + return(this->setHeaderType(RADIOLIB_LR11X0_LORA_HEADER_EXPLICIT)); +} + float LR11x0::getDataRate() const { return(this->dataRateMeasured); } @@ -1694,6 +1702,26 @@ int16_t LR11x0::startCad(uint8_t symbolNum, uint8_t detPeak, uint8_t detMin) { return(setCad()); } +int16_t LR11x0::setHeaderType(uint8_t hdrType, size_t len) { + // check active modem + uint8_t type = RADIOLIB_LR11X0_PACKET_TYPE_NONE; + int16_t state = getPacketType(&type); + RADIOLIB_ASSERT(state); + if(type != RADIOLIB_LR11X0_PACKET_TYPE_LORA) { + return(RADIOLIB_ERR_WRONG_MODEM); + } + + // set requested packet mode + state = setPacketParamsLoRa(this->preambleLengthLoRa, hdrType, len, this->crcTypeLoRa, this->invertIQEnabled); + RADIOLIB_ASSERT(state); + + // update cached value + this->headerType = hdrType; + this->implicitLen = len; + + return(state); +} + Module* LR11x0::getMod() { return(this->mod); } diff --git a/src/modules/LR11x0/LR11x0.h b/src/modules/LR11x0/LR11x0.h index 53edd721..42ed4e56 100644 --- a/src/modules/LR11x0/LR11x0.h +++ b/src/modules/LR11x0/LR11x0.h @@ -1141,6 +1141,19 @@ class LR11x0: public PhysicalLayer { */ RadioLibTime_t getTimeOnAir(size_t len) override; + /*! + \brief Set implicit header mode for future reception/transmission. + \param len Payload length in bytes. + \returns \ref status_codes + */ + int16_t implicitHeader(size_t len); + + /*! + \brief Set explicit header mode for future reception/transmission. + \returns \ref status_codes + */ + int16_t explicitHeader(); + /*! \brief Gets effective data rate for the last transmitted packet. The value is calculated only for payload bytes. \returns Effective data rate in bps. @@ -1404,6 +1417,7 @@ class LR11x0: public PhysicalLayer { int16_t config(uint8_t modem); int16_t setPacketMode(uint8_t mode, uint8_t len); int16_t startCad(uint8_t symbolNum, uint8_t detPeak, uint8_t detMin); + int16_t setHeaderType(uint8_t hdrType, size_t len = 0xFF); // common methods to avoid some copy-paste int16_t bleBeaconCommon(uint16_t cmd, uint8_t chan, uint8_t* payload, size_t len);