[SX128x] Add LoRa Rx header infos method

pull/1588/head
GUVWAF 2025-08-31 19:35:47 +02:00
rodzic 72873b4a97
commit ab8043ac4e
2 zmienionych plików z 23 dodań i 0 usunięć

Wyświetl plik

@ -1286,6 +1286,20 @@ size_t SX128x::getPacketLength(bool update, uint8_t* offset) {
return((size_t)rxBufStatus[0]);
}
int16_t SX128x::getLoRaRxHeaderInfo(uint8_t* cr, bool* hasCRC) {
int16_t state = RADIOLIB_ERR_NONE;
// check if in explicit header mode
if(this->headerType == RADIOLIB_SX128X_LORA_HEADER_IMPLICIT) {
return(RADIOLIB_ERR_WRONG_MODEM);
}
if(cr) { *cr = this->mod->SPIgetRegValue(RADIOLIB_SX128X_REG_LORA_RX_CODING_RATE, 6, 4) >> 4; }
if(hasCRC) { *hasCRC = (this->mod->SPIgetRegValue(RADIOLIB_SX128X_REG_FEI_MSB, 4, 4) != 0); }
return(state);
}
int16_t SX128x::fixedPacketLengthMode(uint8_t len) {
return(setPacketMode(RADIOLIB_SX128X_GFSK_FLRC_PACKET_FIXED, len));
}

Wyświetl plik

@ -84,6 +84,7 @@
#define RADIOLIB_SX128X_REG_FREQ_ERROR_CORRECTION 0x093C
#define RADIOLIB_SX128X_REG_LORA_SYNC_WORD_MSB 0x0944
#define RADIOLIB_SX128X_REG_LORA_SYNC_WORD_LSB 0x0945
#define RADIOLIB_SX128X_REG_LORA_RX_CODING_RATE 0x0950
#define RADIOLIB_SX128X_REG_RANGING_FILTER_RSSI_OFFSET 0x0953
#define RADIOLIB_SX128X_REG_FEI_MSB 0x0954
#define RADIOLIB_SX128X_REG_FEI_MID 0x0955
@ -795,6 +796,14 @@ class SX128x: public PhysicalLayer {
*/
size_t getPacketLength(bool update, uint8_t* offset);
/*!
\brief Get LoRa header information from last received packet. Only valid in explicit header mode.
\param cr Pointer to variable to store the coding rate.
\param hasCRC Pointer to variable to store the CRC status.
\returns \ref status_codes
*/
int16_t getLoRaRxHeaderInfo(uint8_t* cr, bool* hasCRC);
/*!
\brief Set modem in fixed packet length mode. Available in GFSK mode only.
\param len Packet length.