From 76c654c0c10b74eb97193e39ae7844776d077499 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 23 Apr 2023 22:05:18 +0200 Subject: [PATCH] [SX128x] General reformatting --- src/modules/SX128x/SX1280.cpp | 18 +- src/modules/SX128x/SX1280.h | 11 - src/modules/SX128x/SX1281.h | 2 - src/modules/SX128x/SX1282.h | 2 - src/modules/SX128x/SX128x.cpp | 498 ++++++++++----------- src/modules/SX128x/SX128x.h | 793 +++++++++++++++------------------- 6 files changed, 601 insertions(+), 723 deletions(-) diff --git a/src/modules/SX128x/SX1280.cpp b/src/modules/SX128x/SX1280.cpp index 224d4f8e..b53c1a62 100644 --- a/src/modules/SX128x/SX1280.cpp +++ b/src/modules/SX128x/SX1280.cpp @@ -12,10 +12,10 @@ int16_t SX1280::range(bool master, uint32_t addr, uint16_t calTable[3][6]) { RADIOLIB_ASSERT(state); // wait until ranging is finished - uint32_t start = _mod->hal->millis(); - while(!_mod->hal->digitalRead(_mod->getIrq())) { - _mod->hal->yield(); - if(_mod->hal->millis() - start > 10000) { + uint32_t start = this->mod->hal->millis(); + while(!this->mod->hal->digitalRead(this->mod->getIrq())) { + this->mod->hal->yield(); + if(this->mod->hal->millis() - start > 10000) { clearIrqStatus(); standby(); return(RADIOLIB_ERR_RANGING_TIMEOUT); @@ -50,11 +50,11 @@ int16_t SX1280::startRanging(bool master, uint32_t addr, uint16_t calTable[3][6] } // set modulation parameters - state = setModulationParams(_sf, _bw, _cr); + state = setModulationParams(this->spreadingFactor, this->bandwidth, this->codingRateLoRa); RADIOLIB_ASSERT(state); // set packet parameters - state = setPacketParamsLoRa(_preambleLengthLoRa, _headerType, _payloadLen, _crcLoRa); + state = setPacketParamsLoRa(this->preambleLengthLoRa, this->headerType, this->payloadLen, this->crcLoRa); RADIOLIB_ASSERT(state); // check all address bits @@ -100,9 +100,9 @@ int16_t SX1280::startRanging(bool master, uint32_t addr, uint16_t calTable[3][6] } // set calibration values - uint8_t index = (_sf >> 4) - 5; + uint8_t index = (this->spreadingFactor >> 4) - 5; uint16_t val = 0; - switch(_bw) { + switch(this->bandwidth) { case(RADIOLIB_SX128X_LORA_BW_406_25): val = calTbl[0][index]; break; @@ -176,7 +176,7 @@ float SX1280::getRangingResult() { // calculate the real result uint32_t raw = ((uint32_t)data[0] << 16) | ((uint32_t)data[1] << 8) | data[2]; - return((float)raw * 150.0 / (4.096 * _bwKhz)); + return((float)raw * 150.0 / (4.096 * this->bandwidthKhz)); } #endif diff --git a/src/modules/SX128x/SX1280.h b/src/modules/SX128x/SX1280.h index 10f48ab1..51bb7c0b 100644 --- a/src/modules/SX128x/SX1280.h +++ b/src/modules/SX128x/SX1280.h @@ -11,47 +11,36 @@ /*! \class SX1280 - \brief Derived class for %SX1280 modules. */ class SX1280: public SX1281 { public: /*! \brief Default constructor. - \param mod Instance of Module that will be used to communicate with the radio. */ SX1280(Module* mod); /*! \brief Blocking ranging method. - \param master Whether to execute ranging in master mode (true) or slave mode (false). - \param addr Ranging address to be used. - \param calTable Ranging calibration table - set to NULL to use the default. - \returns \ref status_codes */ int16_t range(bool master, uint32_t addr, uint16_t calTable[3][6] = NULL); /*! \brief Interrupt-driven ranging method. - \param master Whether to execute ranging in master mode (true) or slave mode (false). - \param addr Ranging address to be used. - \param calTable Ranging calibration table - set to NULL to use the default. - \returns \ref status_codes */ int16_t startRanging(bool master, uint32_t addr, uint16_t calTable[3][6] = NULL); /*! \brief Gets ranging result of the last ranging exchange. - \returns Ranging result in meters. */ float getRangingResult(); diff --git a/src/modules/SX128x/SX1281.h b/src/modules/SX128x/SX1281.h index 4482e3c5..04a9eb19 100644 --- a/src/modules/SX128x/SX1281.h +++ b/src/modules/SX128x/SX1281.h @@ -10,14 +10,12 @@ /*! \class SX1281 - \brief Derived class for %SX1281 modules. */ class SX1281: public SX128x { public: /*! \brief Default constructor. - \param mod Instance of Module that will be used to communicate with the radio. */ SX1281(Module* mod); diff --git a/src/modules/SX128x/SX1282.h b/src/modules/SX128x/SX1282.h index 71feb29a..864e463d 100644 --- a/src/modules/SX128x/SX1282.h +++ b/src/modules/SX128x/SX1282.h @@ -11,14 +11,12 @@ /*! \class SX1282 - \brief Derived class for %SX1282 modules. */ class SX1282: public SX1280 { public: /*! \brief Default constructor. - \param mod Instance of Module that will be used to communicate with the radio. */ SX1282(Module* mod); diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index a1637492..ffad917f 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -3,36 +3,36 @@ #if !defined(RADIOLIB_EXCLUDE_SX128X) SX128x::SX128x(Module* mod) : PhysicalLayer(RADIOLIB_SX128X_FREQUENCY_STEP_SIZE, RADIOLIB_SX128X_MAX_PACKET_LENGTH) { - _mod = mod; + this->mod = mod; } Module* SX128x::getMod() { - return(_mod); + return(this->mod); } -int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength) { +int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t pwr, uint16_t preambleLength) { // set module properties - _mod->init(); - _mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput); - _mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput); - _mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER; - _mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER; - _mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP; - _mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS; - _mod->SPIstreamType = true; - _mod->SPIparseStatusCb = SPIparseStatus; + this->mod->init(); + this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput); + this->mod->hal->pinMode(this->mod->getGpio(), this->mod->hal->GpioModeInput); + this->mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER; + this->mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER; + this->mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP; + this->mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS; + this->mod->SPIstreamType = true; + this->mod->SPIparseStatusCb = SPIparseStatus; RADIOLIB_DEBUG_PRINTLN("M\tSX128x"); // initialize LoRa modulation variables - _bwKhz = bw; - _sf = RADIOLIB_SX128X_LORA_SF_9; - _cr = RADIOLIB_SX128X_LORA_CR_4_7; + this->bandwidthKhz = bw; + this->spreadingFactor = RADIOLIB_SX128X_LORA_SF_9; + this->codingRateLoRa = RADIOLIB_SX128X_LORA_CR_4_7; // initialize LoRa packet variables - _preambleLengthLoRa = preambleLength; - _headerType = RADIOLIB_SX128X_LORA_HEADER_EXPLICIT; - _payloadLen = 0xFF; - _crcLoRa = RADIOLIB_SX128X_LORA_CRC_ON; + this->preambleLengthLoRa = preambleLength; + this->headerType = RADIOLIB_SX128X_LORA_HEADER_EXPLICIT; + this->payloadLen = 0xFF; + this->crcLoRa = RADIOLIB_SX128X_LORA_CRC_ON; // reset the module and verify startup int16_t state = reset(); @@ -65,38 +65,38 @@ int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync state = setPreambleLength(preambleLength); RADIOLIB_ASSERT(state); - state = setOutputPower(power); + state = setOutputPower(pwr); RADIOLIB_ASSERT(state); return(state); } -int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, uint16_t preambleLength) { +int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t pwr, uint16_t preambleLength) { // set module properties - _mod->init(); - _mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput); - _mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput); - _mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER; - _mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER; - _mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP; - _mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS; - _mod->SPIstreamType = true; - _mod->SPIparseStatusCb = SPIparseStatus; + this->mod->init(); + this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput); + this->mod->hal->pinMode(this->mod->getGpio(), this->mod->hal->GpioModeInput); + this->mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER; + this->mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER; + this->mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP; + this->mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS; + this->mod->SPIstreamType = true; + this->mod->SPIparseStatusCb = SPIparseStatus; RADIOLIB_DEBUG_PRINTLN("M\tSX128x"); // initialize GFSK modulation variables - _brKbps = br; - _br = RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4; - _modIndexReal = 1.0; - _modIndex = RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_00; - _shaping = RADIOLIB_SX128X_BLE_GFSK_BT_0_5; + this->bitRateKbps = br; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4; + this->modIndexReal = 1.0; + this->modIndex = RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_00; + this->shaping = RADIOLIB_SX128X_BLE_GFSK_BT_0_5; // initialize GFSK packet variables - _preambleLengthGFSK = preambleLength; - _syncWordLen = 2; - _syncWordMatch = RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1; - _crcGFSK = RADIOLIB_SX128X_GFSK_FLRC_CRC_2_BYTE; - _whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON; + this->preambleLengthGFSK = preambleLength; + this->syncWordLen = 2; + this->syncWordMatch = RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1; + this->crcGFSK = RADIOLIB_SX128X_GFSK_FLRC_CRC_2_BYTE; + this->whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON; // reset the module and verify startup int16_t state = reset(); @@ -120,7 +120,7 @@ int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, state = setFrequencyDeviation(freqDev); RADIOLIB_ASSERT(state); - state = setOutputPower(power); + state = setOutputPower(pwr); RADIOLIB_ASSERT(state); state = setPreambleLength(preambleLength); @@ -140,29 +140,29 @@ int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, return(state); } -int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, uint8_t dataShaping) { +int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t pwr, uint8_t dataShaping) { // set module properties - _mod->init(); - _mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput); - _mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput); - _mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER; - _mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER; - _mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP; - _mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS; - _mod->SPIstreamType = true; - _mod->SPIparseStatusCb = SPIparseStatus; + this->mod->init(); + this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput); + this->mod->hal->pinMode(this->mod->getGpio(), this->mod->hal->GpioModeInput); + this->mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER; + this->mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER; + this->mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP; + this->mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS; + this->mod->SPIstreamType = true; + this->mod->SPIparseStatusCb = SPIparseStatus; RADIOLIB_DEBUG_PRINTLN("M\tSX128x"); // initialize BLE modulation variables - _brKbps = br; - _br = RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4; - _modIndexReal = 1.0; - _modIndex = RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_00; - _shaping = RADIOLIB_SX128X_BLE_GFSK_BT_0_5; + this->bitRateKbps = br; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4; + this->modIndexReal = 1.0; + this->modIndex = RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_00; + this->shaping = RADIOLIB_SX128X_BLE_GFSK_BT_0_5; // initialize BLE packet variables - _crcGFSK = RADIOLIB_SX128X_BLE_CRC_3_BYTE; - _whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON; + this->crcGFSK = RADIOLIB_SX128X_BLE_CRC_3_BYTE; + this->whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON; // reset the module and verify startup int16_t state = reset(); @@ -186,7 +186,7 @@ int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, u state = setFrequencyDeviation(freqDev); RADIOLIB_ASSERT(state); - state = setOutputPower(power); + state = setOutputPower(pwr); RADIOLIB_ASSERT(state); state = setDataShaping(dataShaping); @@ -195,31 +195,31 @@ int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, u return(state); } -int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uint16_t preambleLength, uint8_t dataShaping) { +int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t pwr, uint16_t preambleLength, uint8_t dataShaping) { // set module properties - _mod->init(); - _mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput); - _mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput); - _mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER; - _mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER; - _mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP; - _mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS; - _mod->SPIstreamType = true; - _mod->SPIparseStatusCb = SPIparseStatus; + this->mod->init(); + this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput); + this->mod->hal->pinMode(this->mod->getGpio(), this->mod->hal->GpioModeInput); + this->mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER; + this->mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER; + this->mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP; + this->mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS; + this->mod->SPIstreamType = true; + this->mod->SPIparseStatusCb = SPIparseStatus; RADIOLIB_DEBUG_PRINTLN("M\tSX128x"); // initialize FLRC modulation variables - _brKbps = br; - _br = RADIOLIB_SX128X_FLRC_BR_0_650_BW_0_6; - _crFLRC = RADIOLIB_SX128X_FLRC_CR_3_4; - _shaping = RADIOLIB_SX128X_FLRC_BT_0_5; + this->bitRateKbps = br; + this->bitRate = RADIOLIB_SX128X_FLRC_BR_0_650_BW_0_6; + this->codingRateFLRC = RADIOLIB_SX128X_FLRC_CR_3_4; + this->shaping = RADIOLIB_SX128X_FLRC_BT_0_5; // initialize FLRC packet variables - _preambleLengthGFSK = preambleLength; - _syncWordLen = 2; - _syncWordMatch = RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1; - _crcGFSK = RADIOLIB_SX128X_GFSK_FLRC_CRC_2_BYTE; - _whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_OFF; + this->preambleLengthGFSK = preambleLength; + this->syncWordLen = 2; + this->syncWordMatch = RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1; + this->crcGFSK = RADIOLIB_SX128X_GFSK_FLRC_CRC_2_BYTE; + this->whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_OFF; // reset the module and verify startup int16_t state = reset(); @@ -243,7 +243,7 @@ int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uin state = setCodingRate(cr); RADIOLIB_ASSERT(state); - state = setOutputPower(power); + state = setOutputPower(pwr); RADIOLIB_ASSERT(state); state = setPreambleLength(preambleLength); @@ -262,10 +262,10 @@ int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uin int16_t SX128x::reset(bool verify) { // run the reset sequence - same as SX126x, as SX128x docs don't seem to mention this - _mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput); - _mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow); - _mod->hal->delay(1); - _mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh); + this->mod->hal->pinMode(this->mod->getRst(), this->mod->hal->GpioModeOutput); + this->mod->hal->digitalWrite(this->mod->getRst(), this->mod->hal->GpioLevelLow); + this->mod->hal->delay(1); + this->mod->hal->digitalWrite(this->mod->getRst(), this->mod->hal->GpioLevelHigh); // return immediately when verification is disabled if(!verify) { @@ -273,7 +273,7 @@ int16_t SX128x::reset(bool verify) { } // set mode to standby - uint32_t start = _mod->hal->millis(); + uint32_t start = this->mod->hal->millis(); while(true) { // try to set mode to standby int16_t state = standby(); @@ -283,13 +283,13 @@ int16_t SX128x::reset(bool verify) { } // standby command failed, check timeout and try again - if(_mod->hal->millis() - start >= 3000) { + if(this->mod->hal->millis() - start >= 3000) { // timed out, possibly incorrect wiring return(state); } // wait a bit to not spam the module - _mod->hal->delay(10); + this->mod->hal->delay(10); } } @@ -319,10 +319,10 @@ int16_t SX128x::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for packet transmission or timeout - uint32_t start = _mod->hal->micros(); - while(!_mod->hal->digitalRead(_mod->getIrq())) { - _mod->hal->yield(); - if(_mod->hal->micros() - start > timeout) { + uint32_t start = this->mod->hal->micros(); + while(!this->mod->hal->digitalRead(this->mod->getIrq())) { + this->mod->hal->yield(); + if(this->mod->hal->micros() - start > timeout) { finishTransmit(); return(RADIOLIB_ERR_TX_TIMEOUT); } @@ -353,10 +353,10 @@ int16_t SX128x::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for packet reception or timeout - uint32_t start = _mod->hal->micros(); - while(!_mod->hal->digitalRead(_mod->getIrq())) { - _mod->hal->yield(); - if(_mod->hal->micros() - start > timeout) { + uint32_t start = this->mod->hal->micros(); + while(!this->mod->hal->digitalRead(this->mod->getIrq())) { + this->mod->hal->yield(); + if(this->mod->hal->micros() - start > timeout) { clearIrqStatus(); standby(); return(RADIOLIB_ERR_RX_TIMEOUT); @@ -369,7 +369,7 @@ int16_t SX128x::receive(uint8_t* data, size_t len) { int16_t SX128x::transmitDirect(uint32_t frf) { // set RF switch (if present) - _mod->setRfSwitchState(Module::MODE_TX); + this->mod->setRfSwitchState(Module::MODE_TX); // user requested to start transmitting immediately (required for RTTY) int16_t state = RADIOLIB_ERR_NONE; @@ -379,12 +379,12 @@ int16_t SX128x::transmitDirect(uint32_t frf) { RADIOLIB_ASSERT(state); // start transmitting - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_TX_CONTINUOUS_WAVE, NULL, 0)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_TX_CONTINUOUS_WAVE, NULL, 0)); } int16_t SX128x::receiveDirect() { // set RF switch (if present) - _mod->setRfSwitchState(Module::MODE_RX); + this->mod->setRfSwitchState(Module::MODE_RX); // SX128x is unable to output received data directly return(RADIOLIB_ERR_UNKNOWN); @@ -409,15 +409,15 @@ int16_t SX128x::scanChannel() { RADIOLIB_ASSERT(state); // set RF switch (if present) - _mod->setRfSwitchState(Module::MODE_RX); + this->mod->setRfSwitchState(Module::MODE_RX); // set mode to CAD state = setCad(); RADIOLIB_ASSERT(state); // wait for channel activity detected or timeout - while(!_mod->hal->digitalRead(_mod->getIrq())) { - _mod->hal->yield(); + while(!this->mod->hal->digitalRead(this->mod->getIrq())) { + this->mod->hal->yield(); } // check CAD result @@ -437,16 +437,16 @@ int16_t SX128x::scanChannel() { int16_t SX128x::sleep(bool retainConfig) { // set RF switch (if present) - _mod->setRfSwitchState(Module::MODE_IDLE); + this->mod->setRfSwitchState(Module::MODE_IDLE); uint8_t sleepConfig = RADIOLIB_SX128X_SLEEP_DATA_BUFFER_RETAIN | RADIOLIB_SX128X_SLEEP_DATA_RAM_RETAIN; if(!retainConfig) { sleepConfig = RADIOLIB_SX128X_SLEEP_DATA_BUFFER_FLUSH | RADIOLIB_SX128X_SLEEP_DATA_RAM_FLUSH; } - int16_t state = _mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_SLEEP, &sleepConfig, 1, false, false); + int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_SLEEP, &sleepConfig, 1, false, false); // wait for SX128x to safely enter sleep mode - _mod->hal->delay(1); + this->mod->hal->delay(1); return(state); } @@ -457,18 +457,18 @@ int16_t SX128x::standby() { int16_t SX128x::standby(uint8_t mode) { // set RF switch (if present) - _mod->setRfSwitchState(Module::MODE_IDLE); + this->mod->setRfSwitchState(Module::MODE_IDLE); uint8_t data[] = { mode }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_STANDBY, data, 1)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_STANDBY, data, 1)); } void SX128x::setDio1Action(void (*func)(void)) { - _mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, _mod->hal->GpioInterruptRising); + this->mod->hal->attachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()), func, this->mod->hal->GpioInterruptRising); } void SX128x::clearDio1Action() { - _mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq())); + this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq())); } int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { @@ -484,18 +484,18 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { int16_t state = RADIOLIB_ERR_NONE; uint8_t modem = getPacketType(); if(modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) { - state = setPacketParamsLoRa(_preambleLengthLoRa, _headerType, len, _crcLoRa, _invertIQ); + state = setPacketParamsLoRa(this->preambleLengthLoRa, this->headerType, len, this->crcLoRa, this->invertIQEnabled); } else if((modem == RADIOLIB_SX128X_PACKET_TYPE_GFSK) || (modem == RADIOLIB_SX128X_PACKET_TYPE_FLRC)) { - state = setPacketParamsGFSK(_preambleLengthGFSK, _syncWordLen, _syncWordMatch, _crcGFSK, _whitening, len); + state = setPacketParamsGFSK(this->preambleLengthGFSK, this->syncWordLen, this->syncWordMatch, this->crcGFSK, this->whitening, len); } else if(modem == RADIOLIB_SX128X_PACKET_TYPE_BLE) { - state = setPacketParamsBLE(_connectionState, _crcBLE, _bleTestPayload, _whitening); + state = setPacketParamsBLE(this->connectionState, this->crcBLE, this->bleTestPayload, this->whitening); } else { return(RADIOLIB_ERR_WRONG_MODEM); } RADIOLIB_ASSERT(state); // update output power - state = setTxParams(_pwr); + state = setTxParams(this->power); RADIOLIB_ASSERT(state); // set buffer pointers @@ -521,15 +521,15 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // set RF switch (if present) - _mod->setRfSwitchState(Module::MODE_TX); + this->mod->setRfSwitchState(Module::MODE_TX); // start transmission state = setTx(RADIOLIB_SX128X_TX_TIMEOUT_NONE); RADIOLIB_ASSERT(state); // wait for BUSY to go low (= PA ramp up done) - while(_mod->hal->digitalRead(_mod->getGpio())) { - _mod->hal->yield(); + while(this->mod->hal->digitalRead(this->mod->getGpio())) { + this->mod->hal->yield(); } return(state); @@ -568,13 +568,13 @@ int16_t SX128x::startReceive(uint16_t timeout, uint16_t irqFlags, uint16_t irqMa RADIOLIB_ASSERT(state); // set implicit mode and expected len if applicable - if((_headerType == RADIOLIB_SX128X_LORA_HEADER_IMPLICIT) && (getPacketType() == RADIOLIB_SX128X_PACKET_TYPE_LORA)) { - state = setPacketParamsLoRa(_preambleLengthLoRa, _headerType, _payloadLen, _crcLoRa, _invertIQ); + if((this->headerType == RADIOLIB_SX128X_LORA_HEADER_IMPLICIT) && (getPacketType() == RADIOLIB_SX128X_PACKET_TYPE_LORA)) { + state = setPacketParamsLoRa(this->preambleLengthLoRa, this->headerType, this->payloadLen, this->crcLoRa, this->invertIQEnabled); RADIOLIB_ASSERT(state); } // set RF switch (if present) - _mod->setRfSwitchState(Module::MODE_RX); + this->mod->setRfSwitchState(Module::MODE_RX); // set mode to receive state = setRx(timeout); @@ -641,20 +641,20 @@ int16_t SX128x::setBandwidth(float bw) { } if(fabs(bw - 203.125) <= 0.001) { - _bw = RADIOLIB_SX128X_LORA_BW_203_125; + this->bandwidth = RADIOLIB_SX128X_LORA_BW_203_125; } else if(fabs(bw - 406.25) <= 0.001) { - _bw = RADIOLIB_SX128X_LORA_BW_406_25; + this->bandwidth = RADIOLIB_SX128X_LORA_BW_406_25; } else if(fabs(bw - 812.5) <= 0.001) { - _bw = RADIOLIB_SX128X_LORA_BW_812_50; + this->bandwidth = RADIOLIB_SX128X_LORA_BW_812_50; } else if(fabs(bw - 1625.0) <= 0.001) { - _bw = RADIOLIB_SX128X_LORA_BW_1625_00; + this->bandwidth = RADIOLIB_SX128X_LORA_BW_1625_00; } else { return(RADIOLIB_ERR_INVALID_BANDWIDTH); } // update modulation parameters - _bwKhz = bw; - return(setModulationParams(_sf, _bw, _cr)); + this->bandwidthKhz = bw; + return(setModulationParams(this->spreadingFactor, this->bandwidth, this->codingRateLoRa)); } int16_t SX128x::setSpreadingFactor(uint8_t sf) { @@ -671,16 +671,16 @@ int16_t SX128x::setSpreadingFactor(uint8_t sf) { } // update modulation parameters - _sf = sf << 4; - int16_t state = setModulationParams(_sf, _bw, _cr); + this->spreadingFactor = sf << 4; + int16_t state = setModulationParams(this->spreadingFactor, this->bandwidth, this->codingRateLoRa); RADIOLIB_ASSERT(state); // update mystery register in LoRa mode - SX1280 datasheet v3.0 section 13.4.1 if(modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) { uint8_t data = 0; - if((_sf == RADIOLIB_SX128X_LORA_SF_5) || (_sf == RADIOLIB_SX128X_LORA_SF_6)) { + if((this->spreadingFactor == RADIOLIB_SX128X_LORA_SF_5) || (this->spreadingFactor == RADIOLIB_SX128X_LORA_SF_6)) { data = 0x1E; - } else if((_sf == RADIOLIB_SX128X_LORA_SF_7) || (_sf == RADIOLIB_SX128X_LORA_SF_8)) { + } else if((this->spreadingFactor == RADIOLIB_SX128X_LORA_SF_7) || (this->spreadingFactor == RADIOLIB_SX128X_LORA_SF_8)) { data = 0x37; } else { data = 0x32; @@ -701,28 +701,28 @@ int16_t SX128x::setCodingRate(uint8_t cr, bool longInterleaving) { // update modulation parameters if(longInterleaving && (modem == RADIOLIB_SX128X_PACKET_TYPE_LORA)) { - _cr = cr; + this->codingRateLoRa = cr; } else { - _cr = cr - 4; + this->codingRateLoRa = cr - 4; } - return(setModulationParams(_sf, _bw, _cr)); + return(setModulationParams(this->spreadingFactor, this->bandwidth, this->codingRateLoRa)); // FLRC } else if(modem == RADIOLIB_SX128X_PACKET_TYPE_FLRC) { RADIOLIB_CHECK_RANGE(cr, 2, 4, RADIOLIB_ERR_INVALID_CODING_RATE); // update modulation parameters - _crFLRC = (cr - 2) * 2; - return(setModulationParams(_br, _crFLRC, _shaping)); + this->codingRateFLRC = (cr - 2) * 2; + return(setModulationParams(this->bitRate, this->codingRateFLRC, this->shaping)); } return(RADIOLIB_ERR_WRONG_MODEM); } -int16_t SX128x::setOutputPower(int8_t power) { - RADIOLIB_CHECK_RANGE(power, -18, 13, RADIOLIB_ERR_INVALID_OUTPUT_POWER); - _pwr = power + 18; - return(setTxParams(_pwr)); +int16_t SX128x::setOutputPower(int8_t pwr) { + RADIOLIB_CHECK_RANGE(pwr, -18, 13, RADIOLIB_ERR_INVALID_OUTPUT_POWER); + this->power = pwr + 18; + return(setTxParams(this->power)); } int16_t SX128x::setPreambleLength(uint32_t preambleLength) { @@ -753,8 +753,8 @@ int16_t SX128x::setPreambleLength(uint32_t preambleLength) { } // update packet parameters - _preambleLengthLoRa = (e << 4) | m; - return(setPacketParamsLoRa(_preambleLengthLoRa, _headerType, _payloadLen, _crcLoRa, _invertIQ)); + this->preambleLengthLoRa = (e << 4) | m; + return(setPacketParamsLoRa(this->preambleLengthLoRa, this->headerType, this->payloadLen, this->crcLoRa, this->invertIQEnabled)); } else if((modem == RADIOLIB_SX128X_PACKET_TYPE_GFSK) || (modem == RADIOLIB_SX128X_PACKET_TYPE_FLRC)) { // GFSK or FLRC @@ -766,8 +766,8 @@ int16_t SX128x::setPreambleLength(uint32_t preambleLength) { } // update packet parameters - _preambleLengthGFSK = ((preambleLength / 4) - 1) << 4; - return(setPacketParamsGFSK(_preambleLengthGFSK, _syncWordLen, _syncWordMatch, _crcGFSK, _whitening)); + this->preambleLengthGFSK = ((preambleLength / 4) - 1) << 4; + return(setPacketParamsGFSK(this->preambleLengthGFSK, this->syncWordLen, this->syncWordMatch, this->crcGFSK, this->whitening)); } return(RADIOLIB_ERR_WRONG_MODEM); @@ -780,50 +780,50 @@ int16_t SX128x::setBitRate(float br) { // GFSK/BLE if((modem == RADIOLIB_SX128X_PACKET_TYPE_GFSK) || (modem == RADIOLIB_SX128X_PACKET_TYPE_BLE)) { if((uint16_t)br == 125) { - _br = RADIOLIB_SX128X_BLE_GFSK_BR_0_125_BW_0_3; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_0_125_BW_0_3; } else if((uint16_t)br == 250) { - _br = RADIOLIB_SX128X_BLE_GFSK_BR_0_250_BW_0_6; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_0_250_BW_0_6; } else if((uint16_t)br == 400) { - _br = RADIOLIB_SX128X_BLE_GFSK_BR_0_400_BW_1_2; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_0_400_BW_1_2; } else if((uint16_t)br == 500) { - _br = RADIOLIB_SX128X_BLE_GFSK_BR_0_500_BW_1_2; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_0_500_BW_1_2; } else if((uint16_t)br == 800) { - _br = RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4; } else if((uint16_t)br == 1000) { - _br = RADIOLIB_SX128X_BLE_GFSK_BR_1_000_BW_2_4; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_1_000_BW_2_4; } else if((uint16_t)br == 1600) { - _br = RADIOLIB_SX128X_BLE_GFSK_BR_1_600_BW_2_4; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_1_600_BW_2_4; } else if((uint16_t)br == 2000) { - _br = RADIOLIB_SX128X_BLE_GFSK_BR_2_000_BW_2_4; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_2_000_BW_2_4; } else { return(RADIOLIB_ERR_INVALID_BIT_RATE); } // update modulation parameters - _brKbps = (uint16_t)br; - return(setModulationParams(_br, _modIndex, _shaping)); + this->bitRateKbps = (uint16_t)br; + return(setModulationParams(this->bitRate, this->modIndex, this->shaping)); // FLRC } else if(modem == RADIOLIB_SX128X_PACKET_TYPE_FLRC) { if((uint16_t)br == 260) { - _br = RADIOLIB_SX128X_FLRC_BR_0_260_BW_0_3; + this->bitRate = RADIOLIB_SX128X_FLRC_BR_0_260_BW_0_3; } else if((uint16_t)br == 325) { - _br = RADIOLIB_SX128X_FLRC_BR_0_325_BW_0_3; + this->bitRate = RADIOLIB_SX128X_FLRC_BR_0_325_BW_0_3; } else if((uint16_t)br == 520) { - _br = RADIOLIB_SX128X_FLRC_BR_0_520_BW_0_6; + this->bitRate = RADIOLIB_SX128X_FLRC_BR_0_520_BW_0_6; } else if((uint16_t)br == 650) { - _br = RADIOLIB_SX128X_FLRC_BR_0_650_BW_0_6; + this->bitRate = RADIOLIB_SX128X_FLRC_BR_0_650_BW_0_6; } else if((uint16_t)br == 1000) { - _br = RADIOLIB_SX128X_FLRC_BR_1_000_BW_1_2; + this->bitRate = RADIOLIB_SX128X_FLRC_BR_1_000_BW_1_2; } else if((uint16_t)br == 1300) { - _br = RADIOLIB_SX128X_FLRC_BR_1_300_BW_1_2; + this->bitRate = RADIOLIB_SX128X_FLRC_BR_1_300_BW_1_2; } else { return(RADIOLIB_ERR_INVALID_BIT_RATE); } // update modulation parameters - _brKbps = (uint16_t)br; - return(setModulationParams(_br, _crFLRC, _shaping)); + this->bitRateKbps = (uint16_t)br; + return(setModulationParams(this->bitRate, this->codingRateFLRC, this->shaping)); } @@ -847,20 +847,20 @@ int16_t SX128x::setFrequencyDeviation(float freqDev) { // override for the lowest possible frequency deviation - required for some PhysicalLayer protocols if(newFreqDev == 0.0) { - _modIndex = RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_35; - _br = RADIOLIB_SX128X_BLE_GFSK_BR_0_125_BW_0_3; - return(setModulationParams(_br, _modIndex, _shaping)); + this->modIndex = RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_35; + this->bitRate = RADIOLIB_SX128X_BLE_GFSK_BR_0_125_BW_0_3; + return(setModulationParams(this->bitRate, this->modIndex, this->shaping)); } // update modulation parameters - uint8_t modIndex = (uint8_t)((8.0 * (newFreqDev / (float)_brKbps)) - 1.0); + uint8_t modIndex = (uint8_t)((8.0 * (newFreqDev / (float)this->bitRateKbps)) - 1.0); if(modIndex > RADIOLIB_SX128X_BLE_GFSK_MOD_IND_4_00) { return(RADIOLIB_ERR_INVALID_MODULATION_PARAMETERS); } // update modulation parameters - _modIndex = modIndex; - return(setModulationParams(_br, _modIndex, _shaping)); + this->modIndex = modIndex; + return(setModulationParams(this->bitRate, this->modIndex, this->shaping)); } int16_t SX128x::setDataShaping(uint8_t sh) { @@ -870,16 +870,16 @@ int16_t SX128x::setDataShaping(uint8_t sh) { return(RADIOLIB_ERR_WRONG_MODEM); } - // set data shaping + // set data this->shaping switch(sh) { case RADIOLIB_SHAPING_NONE: - _shaping = RADIOLIB_SX128X_BLE_GFSK_BT_OFF; + this->shaping = RADIOLIB_SX128X_BLE_GFSK_BT_OFF; break; case RADIOLIB_SHAPING_0_5: - _shaping = RADIOLIB_SX128X_BLE_GFSK_BT_0_5; + this->shaping = RADIOLIB_SX128X_BLE_GFSK_BT_0_5; break; case RADIOLIB_SHAPING_1_0: - _shaping = RADIOLIB_SX128X_BLE_GFSK_BT_1_0; + this->shaping = RADIOLIB_SX128X_BLE_GFSK_BT_1_0; break; default: return(RADIOLIB_ERR_INVALID_DATA_SHAPING); @@ -887,9 +887,9 @@ int16_t SX128x::setDataShaping(uint8_t sh) { // update modulation parameters if((modem == RADIOLIB_SX128X_PACKET_TYPE_GFSK) || (modem == RADIOLIB_SX128X_PACKET_TYPE_BLE)) { - return(setModulationParams(_br, _modIndex, _shaping)); + return(setModulationParams(this->bitRate, this->modIndex, this->shaping)); } else { - return(setModulationParams(_br, _crFLRC, _shaping)); + return(setModulationParams(this->bitRate, this->codingRateFLRC, this->shaping)); } } @@ -908,7 +908,7 @@ int16_t SX128x::setSyncWord(uint8_t* syncWord, uint8_t len) { // calculate sync word length parameter value if(len > 0) { - _syncWordLen = (len - 1)*2; + this->syncWordLen = (len - 1)*2; } } else { @@ -918,7 +918,7 @@ int16_t SX128x::setSyncWord(uint8_t* syncWord, uint8_t len) { } // save sync word length parameter value - _syncWordLen = len; + this->syncWordLen = len; } // reverse sync word byte order @@ -932,13 +932,13 @@ int16_t SX128x::setSyncWord(uint8_t* syncWord, uint8_t len) { RADIOLIB_ASSERT(state); // update packet parameters - if(_syncWordLen == 0) { - _syncWordMatch = RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_OFF; + if(this->syncWordLen == 0) { + this->syncWordMatch = RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_OFF; } else { /// \todo add support for multiple sync words - _syncWordMatch = RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1; + this->syncWordMatch = RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1; } - return(setPacketParamsGFSK(_preambleLengthGFSK, _syncWordLen, _syncWordMatch, _crcGFSK, _whitening)); + return(setPacketParamsGFSK(this->preambleLengthGFSK, this->syncWordLen, this->syncWordMatch, this->crcGFSK, this->whitening)); } int16_t SX128x::setSyncWord(uint8_t syncWord, uint8_t controlBits) { @@ -968,8 +968,8 @@ int16_t SX128x::setCRC(uint8_t len, uint32_t initial, uint16_t polynomial) { return(RADIOLIB_ERR_INVALID_CRC_CONFIGURATION); } } - _crcGFSK = len << 4; - state = setPacketParamsGFSK(_preambleLengthGFSK, _syncWordLen, _syncWordMatch, _crcGFSK, _whitening); + this->crcGFSK = len << 4; + state = setPacketParamsGFSK(this->preambleLengthGFSK, this->syncWordLen, this->syncWordMatch, this->crcGFSK, this->whitening); RADIOLIB_ASSERT(state); // set initial CRC value @@ -986,13 +986,13 @@ int16_t SX128x::setCRC(uint8_t len, uint32_t initial, uint16_t polynomial) { } else if(modem == RADIOLIB_SX128X_PACKET_TYPE_BLE) { // update packet parameters if(len == 0) { - _crcBLE = RADIOLIB_SX128X_BLE_CRC_OFF; + this->crcBLE = RADIOLIB_SX128X_BLE_CRC_OFF; } else if(len == 3) { - _crcBLE = RADIOLIB_SX128X_BLE_CRC_3_BYTE; + this->crcBLE = RADIOLIB_SX128X_BLE_CRC_3_BYTE; } else { return(RADIOLIB_ERR_INVALID_CRC_CONFIGURATION); } - state = setPacketParamsBLE(_connectionState, _crcBLE, _bleTestPayload, _whitening); + state = setPacketParamsBLE(this->connectionState, this->crcBLE, this->bleTestPayload, this->whitening); RADIOLIB_ASSERT(state); // set initial CRC value @@ -1003,13 +1003,13 @@ int16_t SX128x::setCRC(uint8_t len, uint32_t initial, uint16_t polynomial) { } else if((modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) || (modem == RADIOLIB_SX128X_PACKET_TYPE_RANGING)) { // update packet parameters if(len == 0) { - _crcLoRa = RADIOLIB_SX128X_LORA_CRC_OFF; + this->crcLoRa = RADIOLIB_SX128X_LORA_CRC_OFF; } else if(len == 2) { - _crcLoRa = RADIOLIB_SX128X_LORA_CRC_ON; + this->crcLoRa = RADIOLIB_SX128X_LORA_CRC_ON; } else { return(RADIOLIB_ERR_INVALID_CRC_CONFIGURATION); } - state = setPacketParamsLoRa(_preambleLengthLoRa, _headerType, _payloadLen, _crcLoRa, _invertIQ); + state = setPacketParamsLoRa(this->preambleLengthLoRa, this->headerType, this->payloadLen, this->crcLoRa, this->invertIQEnabled); return(state); } @@ -1025,15 +1025,15 @@ int16_t SX128x::setWhitening(bool enabled) { // update packet parameters if(enabled) { - _whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON; + this->whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON; } else { - _whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_OFF; + this->whitening = RADIOLIB_SX128X_GFSK_BLE_WHITENING_OFF; } if(modem == RADIOLIB_SX128X_PACKET_TYPE_GFSK) { - return(setPacketParamsGFSK(_preambleLengthGFSK, _syncWordLen, _syncWordMatch, _crcGFSK, _whitening)); + return(setPacketParamsGFSK(this->preambleLengthGFSK, this->syncWordLen, this->syncWordMatch, this->crcGFSK, this->whitening)); } - return(setPacketParamsBLE(_connectionState, _crcBLE, _bleTestPayload, _whitening)); + return(setPacketParamsBLE(this->connectionState, this->crcBLE, this->bleTestPayload, this->whitening)); } int16_t SX128x::setAccessAddress(uint32_t addr) { @@ -1047,13 +1047,13 @@ int16_t SX128x::setAccessAddress(uint32_t addr) { return(SX128x::writeRegister(RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_3, addrBuff, 4)); } -int16_t SX128x::setHighSensitivityMode(bool hsm) { +int16_t SX128x::setHighSensitivityMode(bool enable) { // read the current registers uint8_t RxGain = 0; int16_t state = readRegister(RADIOLIB_SX128X_REG_GAIN_MODE, &RxGain, 1); RADIOLIB_ASSERT(state); - if(hsm) { + if(enable) { RxGain |= 0xC0; // Set bits 6 and 7 } else { RxGain &= ~0xC0; // Unset bits 6 and 7 @@ -1103,7 +1103,7 @@ int16_t SX128x::setGainControl(uint8_t gain) { float SX128x::getRSSI() { // get packet status uint8_t packetStatus[5]; - _mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_PACKET_STATUS, packetStatus, 5); + this->mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_PACKET_STATUS, packetStatus, 5); // check active modem uint8_t modem = getPacketType(); @@ -1133,7 +1133,7 @@ float SX128x::getSNR() { // get packet status uint8_t packetStatus[5]; - _mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_PACKET_STATUS, packetStatus, 5); + this->mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_PACKET_STATUS, packetStatus, 5); // calculate real SNR uint8_t snr = packetStatus[1]; @@ -1169,9 +1169,9 @@ float SX128x::getFrequencyError() { // frequency error is negative efe |= (uint32_t) 0xFFF00000; efe = ~efe + 1; - error = 1.55 * (float) efe / (1600.0 / (float) _bwKhz) * -1.0; + error = 1.55 * (float) efe / (1600.0 / (float) this->bandwidthKhz) * -1.0; } else { - error = 1.55 * (float) efe / (1600.0 / (float) _bwKhz); + error = 1.55 * (float) efe / (1600.0 / (float) this->bandwidthKhz); } return(error); @@ -1181,12 +1181,12 @@ size_t SX128x::getPacketLength(bool update) { (void)update; // in implicit mode, return the cached value - if((getPacketType() == RADIOLIB_SX128X_PACKET_TYPE_LORA) && (_headerType == RADIOLIB_SX128X_LORA_HEADER_IMPLICIT)) { - return(_payloadLen); + if((getPacketType() == RADIOLIB_SX128X_PACKET_TYPE_LORA) && (this->headerType == RADIOLIB_SX128X_LORA_HEADER_IMPLICIT)) { + return(this->payloadLen); } uint8_t rxBufStatus[2] = {0, 0}; - _mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_RX_BUFFER_STATUS, rxBufStatus, 2); + this->mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_RX_BUFFER_STATUS, rxBufStatus, 2); return((size_t)rxBufStatus[0]); } @@ -1196,8 +1196,8 @@ uint32_t SX128x::getTimeOnAir(size_t len) { if(modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) { // calculate number of symbols float N_symbol = 0; - uint8_t sf = _sf >> 4; - if(_cr <= RADIOLIB_SX128X_LORA_CR_4_8) { + uint8_t sf = this->spreadingFactor >> 4; + if(this->codingRateLoRa <= RADIOLIB_SX128X_LORA_CR_4_8) { // legacy coding rate - nice and simple // get SF coefficients @@ -1223,21 +1223,21 @@ uint32_t SX128x::getTimeOnAir(size_t len) { // get CRC length int16_t N_bitCRC = 16; - if(_crcLoRa == RADIOLIB_SX128X_LORA_CRC_OFF) { + if(this->crcLoRa == RADIOLIB_SX128X_LORA_CRC_OFF) { N_bitCRC = 0; } // get header length int16_t N_symbolHeader = 20; - if(_headerType == RADIOLIB_SX128X_LORA_HEADER_IMPLICIT) { + if(this->headerType == RADIOLIB_SX128X_LORA_HEADER_IMPLICIT) { N_symbolHeader = 0; } // calculate number of LoRa preamble symbols - uint32_t N_symbolPreamble = (_preambleLengthLoRa & 0x0F) * (uint32_t(1) << ((_preambleLengthLoRa & 0xF0) >> 4)); + uint32_t N_symbolPreamble = (this->preambleLengthLoRa & 0x0F) * (uint32_t(1) << ((this->preambleLengthLoRa & 0xF0) >> 4)); // calculate the number of symbols - N_symbol = (float)N_symbolPreamble + coeff1 + 8.0 + ceil(max((int16_t)(8 * len + N_bitCRC - coeff2 + N_symbolHeader), (int16_t)0) / (float)coeff3) * (float)(_cr + 4); + N_symbol = (float)N_symbolPreamble + coeff1 + 8.0 + ceil(max((int16_t)(8 * len + N_bitCRC - coeff2 + N_symbolHeader), (int16_t)0) / (float)coeff3) * (float)(this->codingRateLoRa + 4); } else { // long interleaving - abandon hope all ye who enter here @@ -1246,10 +1246,10 @@ uint32_t SX128x::getTimeOnAir(size_t len) { } // get time-on-air in us - return(((uint32_t(1) << sf) / _bwKhz) * N_symbol * 1000.0); + return(((uint32_t(1) << sf) / this->bandwidthKhz) * N_symbol * 1000.0); } else { - return(((uint32_t)len * 8 * 1000) / _brKbps); + return(((uint32_t)len * 8 * 1000) / this->bitRateKbps); } } @@ -1267,11 +1267,11 @@ int16_t SX128x::setEncoding(uint8_t encoding) { } void SX128x::setRfSwitchPins(uint32_t rxEn, uint32_t txEn) { - _mod->setRfSwitchPins(rxEn, txEn); + this->mod->setRfSwitchPins(rxEn, txEn); } void SX128x::setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) { - _mod->setRfSwitchTable(pins, table); + this->mod->setRfSwitchTable(pins, table); } uint8_t SX128x::randomByte() { @@ -1280,18 +1280,18 @@ uint8_t SX128x::randomByte() { return(0); } -int16_t SX128x::invertIQ(bool invertIQ) { +int16_t SX128x::invertIQ(bool enable) { if(getPacketType() != RADIOLIB_SX128X_PACKET_TYPE_LORA) { return(RADIOLIB_ERR_WRONG_MODEM); } - if(invertIQ) { - _invertIQ = RADIOLIB_SX128X_LORA_IQ_INVERTED; + if(enable) { + this->invertIQEnabled = RADIOLIB_SX128X_LORA_IQ_INVERTED; } else { - _invertIQ = RADIOLIB_SX128X_LORA_IQ_STANDARD; + this->invertIQEnabled = RADIOLIB_SX128X_LORA_IQ_STANDARD; } - return(setPacketParamsLoRa(_preambleLengthLoRa, _headerType, _payloadLen, _crcLoRa, _invertIQ)); + return(setPacketParamsLoRa(this->preambleLengthLoRa, this->headerType, this->payloadLen, this->crcLoRa, this->invertIQEnabled)); } #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) @@ -1310,87 +1310,87 @@ void SX128x::readBit(uint32_t pin) { uint8_t SX128x::getStatus() { uint8_t data = 0; - _mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_STATUS, &data, 1); + this->mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_STATUS, &data, 1); return(data); } int16_t SX128x::writeRegister(uint16_t addr, uint8_t* data, uint8_t numBytes) { - _mod->SPIwriteRegisterBurst(addr, data, numBytes); + this->mod->SPIwriteRegisterBurst(addr, data, numBytes); return(RADIOLIB_ERR_NONE); } int16_t SX128x::readRegister(uint16_t addr, uint8_t* data, uint8_t numBytes) { // send the command - _mod->SPIreadRegisterBurst(addr, numBytes, data); + this->mod->SPIreadRegisterBurst(addr, numBytes, data); // check the status - int16_t state = _mod->SPIcheckStream(); + int16_t state = this->mod->SPIcheckStream(); return(state); } int16_t SX128x::writeBuffer(uint8_t* data, uint8_t numBytes, uint8_t offset) { uint8_t cmd[] = { RADIOLIB_SX128X_CMD_WRITE_BUFFER, offset }; - return(_mod->SPIwriteStream(cmd, 2, data, numBytes)); + return(this->mod->SPIwriteStream(cmd, 2, data, numBytes)); } int16_t SX128x::readBuffer(uint8_t* data, uint8_t numBytes) { uint8_t cmd[] = { RADIOLIB_SX128X_CMD_READ_BUFFER, RADIOLIB_SX128X_CMD_NOP }; - return(_mod->SPIreadStream(cmd, 2, data, numBytes)); + return(this->mod->SPIreadStream(cmd, 2, data, numBytes)); } int16_t SX128x::setTx(uint16_t periodBaseCount, uint8_t periodBase) { uint8_t data[] = { periodBase, (uint8_t)((periodBaseCount >> 8) & 0xFF), (uint8_t)(periodBaseCount & 0xFF) }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_TX, data, 3)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_TX, data, 3)); } int16_t SX128x::setRx(uint16_t periodBaseCount, uint8_t periodBase) { uint8_t data[] = { periodBase, (uint8_t)((periodBaseCount >> 8) & 0xFF), (uint8_t)(periodBaseCount & 0xFF) }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_RX, data, 3)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_RX, data, 3)); } int16_t SX128x::setCad() { - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_CAD, NULL, 0)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_CAD, NULL, 0)); } uint8_t SX128x::getPacketType() { uint8_t data = 0xFF; - _mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_PACKET_TYPE, &data, 1); + this->mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_PACKET_TYPE, &data, 1); return(data); } int16_t SX128x::setRfFrequency(uint32_t frf) { uint8_t data[] = { (uint8_t)((frf >> 16) & 0xFF), (uint8_t)((frf >> 8) & 0xFF), (uint8_t)(frf & 0xFF) }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_RF_FREQUENCY, data, 3)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_RF_FREQUENCY, data, 3)); } -int16_t SX128x::setTxParams(uint8_t power, uint8_t rampTime) { - uint8_t data[] = { power, rampTime }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_TX_PARAMS, data, 2)); +int16_t SX128x::setTxParams(uint8_t pwr, uint8_t rampTime) { + uint8_t data[] = { pwr, rampTime }; + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_TX_PARAMS, data, 2)); } int16_t SX128x::setBufferBaseAddress(uint8_t txBaseAddress, uint8_t rxBaseAddress) { uint8_t data[] = { txBaseAddress, rxBaseAddress }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_BUFFER_BASE_ADDRESS, data, 2)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_BUFFER_BASE_ADDRESS, data, 2)); } int16_t SX128x::setModulationParams(uint8_t modParam1, uint8_t modParam2, uint8_t modParam3) { uint8_t data[] = { modParam1, modParam2, modParam3 }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_MODULATION_PARAMS, data, 3)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_MODULATION_PARAMS, data, 3)); } -int16_t SX128x::setPacketParamsGFSK(uint8_t preambleLen, uint8_t syncWordLen, uint8_t syncWordMatch, uint8_t crcLen, uint8_t whitening, uint8_t payloadLen, uint8_t headerType) { - uint8_t data[] = { preambleLen, syncWordLen, syncWordMatch, headerType, payloadLen, crcLen, whitening }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS, data, 7)); +int16_t SX128x::setPacketParamsGFSK(uint8_t preambleLen, uint8_t syncLen, uint8_t syncMatch, uint8_t crcLen, uint8_t whiten, uint8_t payLen, uint8_t hdrType) { + uint8_t data[] = { preambleLen, syncLen, syncMatch, hdrType, this->payloadLen, crcLen, whiten }; + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS, data, 7)); } -int16_t SX128x::setPacketParamsBLE(uint8_t connState, uint8_t crcLen, uint8_t bleTestPayload, uint8_t whitening) { - uint8_t data[] = { connState, crcLen, bleTestPayload, whitening, 0x00, 0x00, 0x00 }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS, data, 7)); +int16_t SX128x::setPacketParamsBLE(uint8_t connState, uint8_t crcLen, uint8_t bleTest, uint8_t whiten) { + uint8_t data[] = { connState, crcLen, bleTest, whiten, 0x00, 0x00, 0x00 }; + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS, data, 7)); } -int16_t SX128x::setPacketParamsLoRa(uint8_t preambleLen, uint8_t headerType, uint8_t payloadLen, uint8_t crc, uint8_t invertIQ) { - uint8_t data[] = { preambleLen, headerType, payloadLen, crc, invertIQ, 0x00, 0x00 }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS, data, 7)); +int16_t SX128x::setPacketParamsLoRa(uint8_t preambleLen, uint8_t hdrType, uint8_t payLen, uint8_t crc, uint8_t invIQ) { + uint8_t data[] = { preambleLen, hdrType, this->payloadLen, crc, invIQ, 0x00, 0x00 }; + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS, data, 7)); } int16_t SX128x::setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask, uint16_t dio3Mask) { @@ -1398,31 +1398,31 @@ int16_t SX128x::setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t di (uint8_t)((dio1Mask >> 8) & 0xFF), (uint8_t)(dio1Mask & 0xFF), (uint8_t)((dio2Mask >> 8) & 0xFF), (uint8_t)(dio2Mask & 0xFF), (uint8_t)((dio3Mask >> 8) & 0xFF), (uint8_t)(dio3Mask & 0xFF) }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_DIO_IRQ_PARAMS, data, 8)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_DIO_IRQ_PARAMS, data, 8)); } uint16_t SX128x::getIrqStatus() { uint8_t data[] = { 0x00, 0x00 }; - _mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_IRQ_STATUS, data, 2); + this->mod->SPIreadStream(RADIOLIB_SX128X_CMD_GET_IRQ_STATUS, data, 2); return(((uint16_t)(data[0]) << 8) | data[1]); } int16_t SX128x::clearIrqStatus(uint16_t clearIrqParams) { uint8_t data[] = { (uint8_t)((clearIrqParams >> 8) & 0xFF), (uint8_t)(clearIrqParams & 0xFF) }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_CLEAR_IRQ_STATUS, data, 2)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_CLEAR_IRQ_STATUS, data, 2)); } int16_t SX128x::setRangingRole(uint8_t role) { uint8_t data[] = { role }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_RANGING_ROLE, data, 1)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_RANGING_ROLE, data, 1)); } int16_t SX128x::setPacketType(uint8_t type) { uint8_t data[] = { type }; - return(_mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_TYPE, data, 1)); + return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_TYPE, data, 1)); } -int16_t SX128x::setHeaderType(uint8_t headerType, size_t len) { +int16_t SX128x::setHeaderType(uint8_t hdrType, size_t len) { // check active modem uint8_t modem = getPacketType(); if(!((modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) || (modem == RADIOLIB_SX128X_PACKET_TYPE_RANGING))) { @@ -1430,9 +1430,9 @@ int16_t SX128x::setHeaderType(uint8_t headerType, size_t len) { } // update packet parameters - _headerType = headerType; - _payloadLen = len; - return(setPacketParamsLoRa(_preambleLengthLoRa, _headerType, _payloadLen, _crcLoRa, _invertIQ)); + this->headerType = hdrType; + this->payloadLen = len; + return(setPacketParamsLoRa(this->preambleLengthLoRa, this->headerType, this->payloadLen, this->crcLoRa, this->invertIQEnabled)); } int16_t SX128x::config(uint8_t modem) { @@ -1443,17 +1443,17 @@ int16_t SX128x::config(uint8_t modem) { // set modem uint8_t data[1]; data[0] = modem; - state = _mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_TYPE, data, 1); + state = this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_PACKET_TYPE, data, 1); RADIOLIB_ASSERT(state); // set CAD parameters data[0] = RADIOLIB_SX128X_CAD_ON_8_SYMB; - state = _mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_CAD_PARAMS, data, 1); + state = this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_CAD_PARAMS, data, 1); RADIOLIB_ASSERT(state); // set regulator mode to DC-DC data[0] = RADIOLIB_SX128X_REGULATOR_DC_DC; - state = _mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_REGULATOR_MODE, data, 1); + state = this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_REGULATOR_MODE, data, 1); RADIOLIB_ASSERT(state); return(RADIOLIB_ERR_NONE); diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index 0dca7e49..804c4fa8 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -10,341 +10,340 @@ #include "../../protocols/PhysicalLayer/PhysicalLayer.h" // SX128X physical layer properties -#define RADIOLIB_SX128X_FREQUENCY_STEP_SIZE 198.3642578 -#define RADIOLIB_SX128X_MAX_PACKET_LENGTH 255 -#define RADIOLIB_SX128X_CRYSTAL_FREQ 52.0 -#define RADIOLIB_SX128X_DIV_EXPONENT 18 +#define RADIOLIB_SX128X_FREQUENCY_STEP_SIZE 198.3642578 +#define RADIOLIB_SX128X_MAX_PACKET_LENGTH 255 +#define RADIOLIB_SX128X_CRYSTAL_FREQ 52.0 +#define RADIOLIB_SX128X_DIV_EXPONENT 18 // SX128X SPI commands -#define RADIOLIB_SX128X_CMD_NOP 0x00 -#define RADIOLIB_SX128X_CMD_GET_STATUS 0xC0 -#define RADIOLIB_SX128X_CMD_WRITE_REGISTER 0x18 -#define RADIOLIB_SX128X_CMD_READ_REGISTER 0x19 -#define RADIOLIB_SX128X_CMD_WRITE_BUFFER 0x1A -#define RADIOLIB_SX128X_CMD_READ_BUFFER 0x1B -#define RADIOLIB_SX128X_CMD_SET_SLEEP 0x84 -#define RADIOLIB_SX128X_CMD_SET_STANDBY 0x80 -#define RADIOLIB_SX128X_CMD_SET_FS 0xC1 -#define RADIOLIB_SX128X_CMD_SET_TX 0x83 -#define RADIOLIB_SX128X_CMD_SET_RX 0x82 -#define RADIOLIB_SX128X_CMD_SET_RX_DUTY_CYCLE 0x94 -#define RADIOLIB_SX128X_CMD_SET_CAD 0xC5 -#define RADIOLIB_SX128X_CMD_SET_TX_CONTINUOUS_WAVE 0xD1 -#define RADIOLIB_SX128X_CMD_SET_TX_CONTINUOUS_PREAMBLE 0xD2 -#define RADIOLIB_SX128X_CMD_SET_PACKET_TYPE 0x8A -#define RADIOLIB_SX128X_CMD_GET_PACKET_TYPE 0x03 -#define RADIOLIB_SX128X_CMD_SET_RF_FREQUENCY 0x86 -#define RADIOLIB_SX128X_CMD_SET_TX_PARAMS 0x8E -#define RADIOLIB_SX128X_CMD_SET_CAD_PARAMS 0x88 -#define RADIOLIB_SX128X_CMD_SET_BUFFER_BASE_ADDRESS 0x8F -#define RADIOLIB_SX128X_CMD_SET_MODULATION_PARAMS 0x8B -#define RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS 0x8C -#define RADIOLIB_SX128X_CMD_GET_RX_BUFFER_STATUS 0x17 -#define RADIOLIB_SX128X_CMD_GET_PACKET_STATUS 0x1D -#define RADIOLIB_SX128X_CMD_GET_RSSI_INST 0x1F -#define RADIOLIB_SX128X_CMD_SET_DIO_IRQ_PARAMS 0x8D -#define RADIOLIB_SX128X_CMD_GET_IRQ_STATUS 0x15 -#define RADIOLIB_SX128X_CMD_CLEAR_IRQ_STATUS 0x97 -#define RADIOLIB_SX128X_CMD_SET_REGULATOR_MODE 0x96 -#define RADIOLIB_SX128X_CMD_SET_SAVE_CONTEXT 0xD5 -#define RADIOLIB_SX128X_CMD_SET_AUTO_TX 0x98 -#define RADIOLIB_SX128X_CMD_SET_AUTO_FS 0x9E -#define RADIOLIB_SX128X_CMD_SET_PERF_COUNTER_MODE 0x9C -#define RADIOLIB_SX128X_CMD_SET_LONG_PREAMBLE 0x9B -#define RADIOLIB_SX128X_CMD_SET_UART_SPEED 0x9D -#define RADIOLIB_SX128X_CMD_SET_RANGING_ROLE 0xA3 -#define RADIOLIB_SX128X_CMD_SET_ADVANCED_RANGING 0x9A +#define RADIOLIB_SX128X_CMD_NOP 0x00 +#define RADIOLIB_SX128X_CMD_GET_STATUS 0xC0 +#define RADIOLIB_SX128X_CMD_WRITE_REGISTER 0x18 +#define RADIOLIB_SX128X_CMD_READ_REGISTER 0x19 +#define RADIOLIB_SX128X_CMD_WRITE_BUFFER 0x1A +#define RADIOLIB_SX128X_CMD_READ_BUFFER 0x1B +#define RADIOLIB_SX128X_CMD_SET_SLEEP 0x84 +#define RADIOLIB_SX128X_CMD_SET_STANDBY 0x80 +#define RADIOLIB_SX128X_CMD_SET_FS 0xC1 +#define RADIOLIB_SX128X_CMD_SET_TX 0x83 +#define RADIOLIB_SX128X_CMD_SET_RX 0x82 +#define RADIOLIB_SX128X_CMD_SET_RX_DUTY_CYCLE 0x94 +#define RADIOLIB_SX128X_CMD_SET_CAD 0xC5 +#define RADIOLIB_SX128X_CMD_SET_TX_CONTINUOUS_WAVE 0xD1 +#define RADIOLIB_SX128X_CMD_SET_TX_CONTINUOUS_PREAMBLE 0xD2 +#define RADIOLIB_SX128X_CMD_SET_PACKET_TYPE 0x8A +#define RADIOLIB_SX128X_CMD_GET_PACKET_TYPE 0x03 +#define RADIOLIB_SX128X_CMD_SET_RF_FREQUENCY 0x86 +#define RADIOLIB_SX128X_CMD_SET_TX_PARAMS 0x8E +#define RADIOLIB_SX128X_CMD_SET_CAD_PARAMS 0x88 +#define RADIOLIB_SX128X_CMD_SET_BUFFER_BASE_ADDRESS 0x8F +#define RADIOLIB_SX128X_CMD_SET_MODULATION_PARAMS 0x8B +#define RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS 0x8C +#define RADIOLIB_SX128X_CMD_GET_RX_BUFFER_STATUS 0x17 +#define RADIOLIB_SX128X_CMD_GET_PACKET_STATUS 0x1D +#define RADIOLIB_SX128X_CMD_GET_RSSI_INST 0x1F +#define RADIOLIB_SX128X_CMD_SET_DIO_IRQ_PARAMS 0x8D +#define RADIOLIB_SX128X_CMD_GET_IRQ_STATUS 0x15 +#define RADIOLIB_SX128X_CMD_CLEAR_IRQ_STATUS 0x97 +#define RADIOLIB_SX128X_CMD_SET_REGULATOR_MODE 0x96 +#define RADIOLIB_SX128X_CMD_SET_SAVE_CONTEXT 0xD5 +#define RADIOLIB_SX128X_CMD_SET_AUTO_TX 0x98 +#define RADIOLIB_SX128X_CMD_SET_AUTO_FS 0x9E +#define RADIOLIB_SX128X_CMD_SET_PERF_COUNTER_MODE 0x9C +#define RADIOLIB_SX128X_CMD_SET_LONG_PREAMBLE 0x9B +#define RADIOLIB_SX128X_CMD_SET_UART_SPEED 0x9D +#define RADIOLIB_SX128X_CMD_SET_RANGING_ROLE 0xA3 +#define RADIOLIB_SX128X_CMD_SET_ADVANCED_RANGING 0x9A // SX128X register map -#define RADIOLIB_SX128X_REG_GAIN_MODE 0x0891 -#define RADIOLIB_SX128X_REG_MANUAL_GAIN_CONTROL_ENABLE_2 0x0895 -#define RADIOLIB_SX128X_REG_MANUAL_GAIN_SETTING 0x089E -#define RADIOLIB_SX128X_REG_MANUAL_GAIN_CONTROL_ENABLE_1 0x089F -#define RADIOLIB_SX128X_REG_SYNCH_PEAK_ATTENUATION 0x08C2 -#define RADIOLIB_SX128X_REG_LORA_FIXED_PAYLOAD_LENGTH 0x0901 -#define RADIOLIB_SX128X_REG_LORA_HEADER_MODE 0x0903 -#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_3 0x0912 -#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_2 0x0913 -#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_1 0x0914 -#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_0 0x0915 -#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_3 0x0916 -#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_2 0x0917 -#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_1 0x0918 -#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_0 0x0919 -#define RADIOLIB_SX128X_REG_RANGING_FILTER_WINDOW_SIZE 0x091E -#define RADIOLIB_SX128X_REG_RANGING_FILTER_RESET 0x0923 -#define RADIOLIB_SX128X_REG_RANGING_TYPE 0x0924 -#define RADIOLIB_SX128X_REG_LORA_SF_CONFIG 0x0925 -#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_SWITCH 0x0927 -#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_BYTE_2 0x092B -#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_MSB 0x092C -#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_LSB 0x092D -#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_WIDTH 0x0931 -#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_RANGING_FILTER_RSSI_OFFSET 0x0953 -#define RADIOLIB_SX128X_REG_FEI_MSB 0x0954 -#define RADIOLIB_SX128X_REG_FEI_MID 0x0955 -#define RADIOLIB_SX128X_REG_FEI_LSB 0x0956 -#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_MSB 0x095F -#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_LSB 0x0960 -#define RADIOLIB_SX128X_REG_RANGING_RESULT_MSB 0x0961 -#define RADIOLIB_SX128X_REG_RANGING_RESULT_MID 0x0962 -#define RADIOLIB_SX128X_REG_RANGING_RESULT_LSB 0x0963 -#define RADIOLIB_SX128X_REG_RANGING_RSSI 0x0964 -#define RADIOLIB_SX128X_REG_RANGING_LORA_CLOCK_ENABLE 0x097F -#define RADIOLIB_SX128X_REG_PACKET_PREAMBLE_SETTINGS 0x09C1 -#define RADIOLIB_SX128X_REG_WHITENING_INITIAL_VALUE 0x09C5 -#define RADIOLIB_SX128X_REG_CRC_POLYNOMIAL_MSB 0x09C6 -#define RADIOLIB_SX128X_REG_CRC_POLYNOMIAL_LSB 0x09C7 -#define RADIOLIB_SX128X_REG_CRC_INITIAL_MSB 0x09C8 -#define RADIOLIB_SX128X_REG_CRC_INITIAL_LSB 0x09C9 -#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_MSB 0x09C7 -#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_MID (RADIOLIB_SX128X_REG_CRC_INITIAL_MSB) -#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_LSB (RADIOLIB_SX128X_REG_CRC_INITIAL_LSB) -#define RADIOLIB_SX128X_REG_SYNCH_ADDRESS_CONTROL 0x09CD -#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_4 0x09CE -#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_3 0x09CF -#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_2 0x09D0 -#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_1 0x09D1 -#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_0 0x09D2 -#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_4 0x09D3 -#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_3 0x09D4 -#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_2 0x09D5 -#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_1 0x09D6 -#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_0 0x09D7 -#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_4 0x09D8 -#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_3 0x09D9 -#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_2 0x09DA -#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_1 0x09DB -#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_0 0x09DC -#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_3 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_3) -#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_2 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_2) -#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_1 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_1) -#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_0 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_0) +#define RADIOLIB_SX128X_REG_GAIN_MODE 0x0891 +#define RADIOLIB_SX128X_REG_MANUAL_GAIN_CONTROL_ENABLE_2 0x0895 +#define RADIOLIB_SX128X_REG_MANUAL_GAIN_SETTING 0x089E +#define RADIOLIB_SX128X_REG_MANUAL_GAIN_CONTROL_ENABLE_1 0x089F +#define RADIOLIB_SX128X_REG_SYNCH_PEAK_ATTENUATION 0x08C2 +#define RADIOLIB_SX128X_REG_LORA_FIXED_PAYLOAD_LENGTH 0x0901 +#define RADIOLIB_SX128X_REG_LORA_HEADER_MODE 0x0903 +#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_3 0x0912 +#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_2 0x0913 +#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_1 0x0914 +#define RADIOLIB_SX128X_REG_MASTER_RANGING_ADDRESS_BYTE_0 0x0915 +#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_3 0x0916 +#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_2 0x0917 +#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_1 0x0918 +#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_BYTE_0 0x0919 +#define RADIOLIB_SX128X_REG_RANGING_FILTER_WINDOW_SIZE 0x091E +#define RADIOLIB_SX128X_REG_RANGING_FILTER_RESET 0x0923 +#define RADIOLIB_SX128X_REG_RANGING_TYPE 0x0924 +#define RADIOLIB_SX128X_REG_LORA_SF_CONFIG 0x0925 +#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_SWITCH 0x0927 +#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_BYTE_2 0x092B +#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_MSB 0x092C +#define RADIOLIB_SX128X_REG_RANGING_CALIBRATION_LSB 0x092D +#define RADIOLIB_SX128X_REG_SLAVE_RANGING_ADDRESS_WIDTH 0x0931 +#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_RANGING_FILTER_RSSI_OFFSET 0x0953 +#define RADIOLIB_SX128X_REG_FEI_MSB 0x0954 +#define RADIOLIB_SX128X_REG_FEI_MID 0x0955 +#define RADIOLIB_SX128X_REG_FEI_LSB 0x0956 +#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_MSB 0x095F +#define RADIOLIB_SX128X_REG_RANGING_ADDRESS_LSB 0x0960 +#define RADIOLIB_SX128X_REG_RANGING_RESULT_MSB 0x0961 +#define RADIOLIB_SX128X_REG_RANGING_RESULT_MID 0x0962 +#define RADIOLIB_SX128X_REG_RANGING_RESULT_LSB 0x0963 +#define RADIOLIB_SX128X_REG_RANGING_RSSI 0x0964 +#define RADIOLIB_SX128X_REG_RANGING_LORA_CLOCK_ENABLE 0x097F +#define RADIOLIB_SX128X_REG_PACKET_PREAMBLE_SETTINGS 0x09C1 +#define RADIOLIB_SX128X_REG_WHITENING_INITIAL_VALUE 0x09C5 +#define RADIOLIB_SX128X_REG_CRC_POLYNOMIAL_MSB 0x09C6 +#define RADIOLIB_SX128X_REG_CRC_POLYNOMIAL_LSB 0x09C7 +#define RADIOLIB_SX128X_REG_CRC_INITIAL_MSB 0x09C8 +#define RADIOLIB_SX128X_REG_CRC_INITIAL_LSB 0x09C9 +#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_MSB 0x09C7 +#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_MID (RADIOLIB_SX128X_REG_CRC_INITIAL_MSB) +#define RADIOLIB_SX128X_REG_BLE_CRC_INITIAL_LSB (RADIOLIB_SX128X_REG_CRC_INITIAL_LSB) +#define RADIOLIB_SX128X_REG_SYNCH_ADDRESS_CONTROL 0x09CD +#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_4 0x09CE +#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_3 0x09CF +#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_2 0x09D0 +#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_1 0x09D1 +#define RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_0 0x09D2 +#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_4 0x09D3 +#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_3 0x09D4 +#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_2 0x09D5 +#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_1 0x09D6 +#define RADIOLIB_SX128X_REG_SYNC_WORD_2_BYTE_0 0x09D7 +#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_4 0x09D8 +#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_3 0x09D9 +#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_2 0x09DA +#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_1 0x09DB +#define RADIOLIB_SX128X_REG_SYNC_WORD_3_BYTE_0 0x09DC +#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_3 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_3) +#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_2 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_2) +#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_1 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_1) +#define RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_0 (RADIOLIB_SX128X_REG_SYNC_WORD_1_BYTE_0) // SX128X SPI command variables -//RADIOLIB_SX128X_CMD_GET_STATUS MSB LSB DESCRIPTION -#define RADIOLIB_SX128X_STATUS_MODE_STDBY_RC 0b01000000 // 7 5 current chip mode: STDBY_RC -#define RADIOLIB_SX128X_STATUS_MODE_STDBY_XOSC 0b01100000 // 7 5 STDBY_XOSC -#define RADIOLIB_SX128X_STATUS_MODE_FS 0b10000000 // 7 5 FS -#define RADIOLIB_SX128X_STATUS_MODE_RX 0b10100000 // 7 5 Rx -#define RADIOLIB_SX128X_STATUS_MODE_TX 0b11000000 // 7 5 Tx -#define RADIOLIB_SX128X_STATUS_CMD_PROCESSED 0b00000100 // 4 2 command status: processing OK -#define RADIOLIB_SX128X_STATUS_DATA_AVAILABLE 0b00001000 // 4 2 data available -#define RADIOLIB_SX128X_STATUS_CMD_TIMEOUT 0b00001100 // 4 2 timeout -#define RADIOLIB_SX128X_STATUS_CMD_ERROR 0b00010000 // 4 2 processing error -#define RADIOLIB_SX128X_STATUS_CMD_FAILED 0b00010100 // 4 2 failed to execute -#define RADIOLIB_SX128X_STATUS_TX_DONE 0b00011000 // 4 2 transmission finished -#define RADIOLIB_SX128X_STATUS_BUSY 0b00000001 // 0 0 chip busy -#define RADIOLIB_SX128X_STATUS_SPI_FAILED 0b11111111 // 7 0 SPI transaction failed +//RADIOLIB_SX128X_CMD_GET_STATUS MSB LSB DESCRIPTION +#define RADIOLIB_SX128X_STATUS_MODE_STDBY_RC 0b01000000 // 7 5 current chip mode: STDBY_RC +#define RADIOLIB_SX128X_STATUS_MODE_STDBY_XOSC 0b01100000 // 7 5 STDBY_XOSC +#define RADIOLIB_SX128X_STATUS_MODE_FS 0b10000000 // 7 5 FS +#define RADIOLIB_SX128X_STATUS_MODE_RX 0b10100000 // 7 5 Rx +#define RADIOLIB_SX128X_STATUS_MODE_TX 0b11000000 // 7 5 Tx +#define RADIOLIB_SX128X_STATUS_CMD_PROCESSED 0b00000100 // 4 2 command status: processing OK +#define RADIOLIB_SX128X_STATUS_DATA_AVAILABLE 0b00001000 // 4 2 data available +#define RADIOLIB_SX128X_STATUS_CMD_TIMEOUT 0b00001100 // 4 2 timeout +#define RADIOLIB_SX128X_STATUS_CMD_ERROR 0b00010000 // 4 2 processing error +#define RADIOLIB_SX128X_STATUS_CMD_FAILED 0b00010100 // 4 2 failed to execute +#define RADIOLIB_SX128X_STATUS_TX_DONE 0b00011000 // 4 2 transmission finished +#define RADIOLIB_SX128X_STATUS_BUSY 0b00000001 // 0 0 chip busy +#define RADIOLIB_SX128X_STATUS_SPI_FAILED 0b11111111 // 7 0 SPI transaction failed //RADIOLIB_SX128X_CMD_SET_SLEEP -#define RADIOLIB_SX128X_SLEEP_DATA_BUFFER_FLUSH 0b00000000 // 1 1 data buffer behavior in sleep mode: flush -#define RADIOLIB_SX128X_SLEEP_DATA_BUFFER_RETAIN 0b00000010 // 1 1 retain -#define RADIOLIB_SX128X_SLEEP_DATA_RAM_FLUSH 0b00000000 // 0 0 data RAM (configuration) behavior in sleep mode: flush -#define RADIOLIB_SX128X_SLEEP_DATA_RAM_RETAIN 0b00000001 // 0 0 retain +#define RADIOLIB_SX128X_SLEEP_DATA_BUFFER_FLUSH 0b00000000 // 1 1 data buffer behavior in sleep mode: flush +#define RADIOLIB_SX128X_SLEEP_DATA_BUFFER_RETAIN 0b00000010 // 1 1 retain +#define RADIOLIB_SX128X_SLEEP_DATA_RAM_FLUSH 0b00000000 // 0 0 data RAM (configuration) behavior in sleep mode: flush +#define RADIOLIB_SX128X_SLEEP_DATA_RAM_RETAIN 0b00000001 // 0 0 retain //RADIOLIB_SX128X_CMD_SET_STANDBY -#define RADIOLIB_SX128X_STANDBY_RC 0x00 // 7 0 standby mode: 13 MHz RC oscillator -#define RADIOLIB_SX128X_STANDBY_XOSC 0x01 // 7 0 52 MHz crystal oscillator +#define RADIOLIB_SX128X_STANDBY_RC 0x00 // 7 0 standby mode: 13 MHz RC oscillator +#define RADIOLIB_SX128X_STANDBY_XOSC 0x01 // 7 0 52 MHz crystal oscillator //RADIOLIB_SX128X_CMD_SET_TX + RADIOLIB_SX128X_CMD_SET_RX + RADIOLIB_SX128X_CMD_SET_RX_DUTY_CYCLE -#define RADIOLIB_SX128X_PERIOD_BASE_15_625_US 0x00 // 7 0 time period step: 15.625 us -#define RADIOLIB_SX128X_PERIOD_BASE_62_5_US 0x01 // 7 0 62.5 us -#define RADIOLIB_SX128X_PERIOD_BASE_1_MS 0x02 // 7 0 1 ms -#define RADIOLIB_SX128X_PERIOD_BASE_4_MS 0x03 // 7 0 4 ms +#define RADIOLIB_SX128X_PERIOD_BASE_15_625_US 0x00 // 7 0 time period step: 15.625 us +#define RADIOLIB_SX128X_PERIOD_BASE_62_5_US 0x01 // 7 0 62.5 us +#define RADIOLIB_SX128X_PERIOD_BASE_1_MS 0x02 // 7 0 1 ms +#define RADIOLIB_SX128X_PERIOD_BASE_4_MS 0x03 // 7 0 4 ms //RADIOLIB_SX128X_CMD_SET_TX -#define RADIOLIB_SX128X_TX_TIMEOUT_NONE 0x0000 // 15 0 Tx timeout duration: no timeout (Tx single mode) +#define RADIOLIB_SX128X_TX_TIMEOUT_NONE 0x0000 // 15 0 Tx timeout duration: no timeout (Tx single mode) //RADIOLIB_SX128X_CMD_SET_RX -#define RADIOLIB_SX128X_RX_TIMEOUT_NONE 0x0000 // 15 0 Rx timeout duration: no timeout (Rx single mode) -#define RADIOLIB_SX128X_RX_TIMEOUT_INF 0xFFFF // 15 0 infinite (Rx continuous mode) +#define RADIOLIB_SX128X_RX_TIMEOUT_NONE 0x0000 // 15 0 Rx timeout duration: no timeout (Rx single mode) +#define RADIOLIB_SX128X_RX_TIMEOUT_INF 0xFFFF // 15 0 infinite (Rx continuous mode) //RADIOLIB_SX128X_CMD_SET_PACKET_TYPE -#define RADIOLIB_SX128X_PACKET_TYPE_GFSK 0x00 // 7 0 packet type: (G)FSK -#define RADIOLIB_SX128X_PACKET_TYPE_LORA 0x01 // 7 0 LoRa -#define RADIOLIB_SX128X_PACKET_TYPE_RANGING 0x02 // 7 0 ranging engine -#define RADIOLIB_SX128X_PACKET_TYPE_FLRC 0x03 // 7 0 FLRC -#define RADIOLIB_SX128X_PACKET_TYPE_BLE 0x04 // 7 0 BLE +#define RADIOLIB_SX128X_PACKET_TYPE_GFSK 0x00 // 7 0 packet type: (G)FSK +#define RADIOLIB_SX128X_PACKET_TYPE_LORA 0x01 // 7 0 LoRa +#define RADIOLIB_SX128X_PACKET_TYPE_RANGING 0x02 // 7 0 ranging engine +#define RADIOLIB_SX128X_PACKET_TYPE_FLRC 0x03 // 7 0 FLRC +#define RADIOLIB_SX128X_PACKET_TYPE_BLE 0x04 // 7 0 BLE //RADIOLIB_SX128X_CMD_SET_TX_PARAMS -#define RADIOLIB_SX128X_PA_RAMP_02_US 0x00 // 7 0 PA ramp time: 2 us -#define RADIOLIB_SX128X_PA_RAMP_04_US 0x20 // 7 0 4 us -#define RADIOLIB_SX128X_PA_RAMP_06_US 0x40 // 7 0 6 us -#define RADIOLIB_SX128X_PA_RAMP_08_US 0x60 // 7 0 8 us -#define RADIOLIB_SX128X_PA_RAMP_10_US 0x80 // 7 0 10 us -#define RADIOLIB_SX128X_PA_RAMP_12_US 0xA0 // 7 0 12 us -#define RADIOLIB_SX128X_PA_RAMP_16_US 0xC0 // 7 0 16 us -#define RADIOLIB_SX128X_PA_RAMP_20_US 0xE0 // 7 0 20 us +#define RADIOLIB_SX128X_PA_RAMP_02_US 0x00 // 7 0 PA ramp time: 2 us +#define RADIOLIB_SX128X_PA_RAMP_04_US 0x20 // 7 0 4 us +#define RADIOLIB_SX128X_PA_RAMP_06_US 0x40 // 7 0 6 us +#define RADIOLIB_SX128X_PA_RAMP_08_US 0x60 // 7 0 8 us +#define RADIOLIB_SX128X_PA_RAMP_10_US 0x80 // 7 0 10 us +#define RADIOLIB_SX128X_PA_RAMP_12_US 0xA0 // 7 0 12 us +#define RADIOLIB_SX128X_PA_RAMP_16_US 0xC0 // 7 0 16 us +#define RADIOLIB_SX128X_PA_RAMP_20_US 0xE0 // 7 0 20 us //RADIOLIB_SX128X_CMD_SET_CAD_PARAMS -#define RADIOLIB_SX128X_CAD_ON_1_SYMB 0x00 // 7 0 number of symbols used for CAD: 1 -#define RADIOLIB_SX128X_CAD_ON_2_SYMB 0x20 // 7 0 2 -#define RADIOLIB_SX128X_CAD_ON_4_SYMB 0x40 // 7 0 4 -#define RADIOLIB_SX128X_CAD_ON_8_SYMB 0x60 // 7 0 8 -#define RADIOLIB_SX128X_CAD_ON_16_SYMB 0x80 // 7 0 16 +#define RADIOLIB_SX128X_CAD_ON_1_SYMB 0x00 // 7 0 number of symbols used for CAD: 1 +#define RADIOLIB_SX128X_CAD_ON_2_SYMB 0x20 // 7 0 2 +#define RADIOLIB_SX128X_CAD_ON_4_SYMB 0x40 // 7 0 4 +#define RADIOLIB_SX128X_CAD_ON_8_SYMB 0x60 // 7 0 8 +#define RADIOLIB_SX128X_CAD_ON_16_SYMB 0x80 // 7 0 16 //RADIOLIB_SX128X_CMD_SET_MODULATION_PARAMS -#define RADIOLIB_SX128X_BLE_GFSK_BR_2_000_BW_2_4 0x04 // 7 0 GFSK/BLE bit rate and bandwidth setting: 2.0 Mbps 2.4 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_1_600_BW_2_4 0x28 // 7 0 1.6 Mbps 2.4 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_1_000_BW_2_4 0x4C // 7 0 1.0 Mbps 2.4 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_1_000_BW_1_2 0x45 // 7 0 1.0 Mbps 1.2 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4 0x70 // 7 0 0.8 Mbps 2.4 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_1_2 0x69 // 7 0 0.8 Mbps 1.2 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_500_BW_1_2 0x8D // 7 0 0.5 Mbps 1.2 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_500_BW_0_6 0x86 // 7 0 0.5 Mbps 0.6 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_400_BW_1_2 0xB1 // 7 0 0.4 Mbps 1.2 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_400_BW_0_6 0xAA // 7 0 0.4 Mbps 0.6 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_250_BW_0_6 0xCE // 7 0 0.25 Mbps 0.6 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_250_BW_0_3 0xC7 // 7 0 0.25 Mbps 0.3 MHz -#define RADIOLIB_SX128X_BLE_GFSK_BR_0_125_BW_0_3 0xEF // 7 0 0.125 Mbps 0.3 MHz -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_35 0x00 // 7 0 GFSK/BLE modulation index: 0.35 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_50 0x01 // 7 0 0.50 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_75 0x02 // 7 0 0.75 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_00 0x03 // 7 0 1.00 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_25 0x04 // 7 0 1.25 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_50 0x05 // 7 0 1.50 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_75 0x06 // 7 0 1.75 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_00 0x07 // 7 0 2.00 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_25 0x08 // 7 0 2.25 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_50 0x09 // 7 0 2.50 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_75 0x0A // 7 0 2.75 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_00 0x0B // 7 0 3.00 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_25 0x0C // 7 0 3.25 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_50 0x0D // 7 0 3.50 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_75 0x0E // 7 0 3.75 -#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_4_00 0x0F // 7 0 4.00 -#define RADIOLIB_SX128X_BLE_GFSK_BT_OFF 0x00 // 7 0 GFSK Gaussian filter BT product: filter disabled -#define RADIOLIB_SX128X_BLE_GFSK_BT_1_0 0x10 // 7 0 1.0 -#define RADIOLIB_SX128X_BLE_GFSK_BT_0_5 0x20 // 7 0 0.5 -#define RADIOLIB_SX128X_FLRC_BR_1_300_BW_1_2 0x45 // 7 0 FLRC bit rate and bandwidth setting: 1.3 Mbps 1.2 MHz -#define RADIOLIB_SX128X_FLRC_BR_1_000_BW_1_2 0x69 // 7 0 1.04 Mbps 1.2 MHz -#define RADIOLIB_SX128X_FLRC_BR_0_650_BW_0_6 0x86 // 7 0 0.65 Mbps 0.6 MHz -#define RADIOLIB_SX128X_FLRC_BR_0_520_BW_0_6 0xAA // 7 0 0.52 Mbps 0.6 MHz -#define RADIOLIB_SX128X_FLRC_BR_0_325_BW_0_3 0xC7 // 7 0 0.325 Mbps 0.3 MHz -#define RADIOLIB_SX128X_FLRC_BR_0_260_BW_0_3 0xEB // 7 0 0.260 Mbps 0.3 MHz -#define RADIOLIB_SX128X_FLRC_CR_1_2 0x00 // 7 0 FLRC coding rate: 1/2 -#define RADIOLIB_SX128X_FLRC_CR_3_4 0x02 // 7 0 3/4 -#define RADIOLIB_SX128X_FLRC_CR_1_0 0x04 // 7 0 1/1 -#define RADIOLIB_SX128X_FLRC_BT_OFF 0x00 // 7 0 FLRC Gaussian filter BT product: filter disabled -#define RADIOLIB_SX128X_FLRC_BT_1_0 0x10 // 7 0 1.0 -#define RADIOLIB_SX128X_FLRC_BT_0_5 0x20 // 7 0 0.5 -#define RADIOLIB_SX128X_LORA_SF_5 0x50 // 7 0 LoRa spreading factor: 5 -#define RADIOLIB_SX128X_LORA_SF_6 0x60 // 7 0 6 -#define RADIOLIB_SX128X_LORA_SF_7 0x70 // 7 0 7 -#define RADIOLIB_SX128X_LORA_SF_8 0x80 // 7 0 8 -#define RADIOLIB_SX128X_LORA_SF_9 0x90 // 7 0 9 -#define RADIOLIB_SX128X_LORA_SF_10 0xA0 // 7 0 10 -#define RADIOLIB_SX128X_LORA_SF_11 0xB0 // 7 0 11 -#define RADIOLIB_SX128X_LORA_SF_12 0xC0 // 7 0 12 -#define RADIOLIB_SX128X_LORA_BW_1625_00 0x0A // 7 0 LoRa bandwidth: 1625.0 kHz -#define RADIOLIB_SX128X_LORA_BW_812_50 0x18 // 7 0 812.5 kHz -#define RADIOLIB_SX128X_LORA_BW_406_25 0x26 // 7 0 406.25 kHz -#define RADIOLIB_SX128X_LORA_BW_203_125 0x34 // 7 0 203.125 kHz -#define RADIOLIB_SX128X_LORA_CR_4_5 0x01 // 7 0 LoRa coding rate: 4/5 -#define RADIOLIB_SX128X_LORA_CR_4_6 0x02 // 7 0 4/6 -#define RADIOLIB_SX128X_LORA_CR_4_7 0x03 // 7 0 4/7 -#define RADIOLIB_SX128X_LORA_CR_4_8 0x04 // 7 0 4/8 -#define RADIOLIB_SX128X_LORA_CR_4_5_LI 0x05 // 7 0 4/5, long interleaving -#define RADIOLIB_SX128X_LORA_CR_4_6_LI 0x06 // 7 0 4/6, long interleaving -#define RADIOLIB_SX128X_LORA_CR_4_7_LI 0x07 // 7 0 4/7, long interleaving +#define RADIOLIB_SX128X_BLE_GFSK_BR_2_000_BW_2_4 0x04 // 7 0 GFSK/BLE bit rate and bandwidth setting: 2.0 Mbps 2.4 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_1_600_BW_2_4 0x28 // 7 0 1.6 Mbps 2.4 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_1_000_BW_2_4 0x4C // 7 0 1.0 Mbps 2.4 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_1_000_BW_1_2 0x45 // 7 0 1.0 Mbps 1.2 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_2_4 0x70 // 7 0 0.8 Mbps 2.4 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_800_BW_1_2 0x69 // 7 0 0.8 Mbps 1.2 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_500_BW_1_2 0x8D // 7 0 0.5 Mbps 1.2 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_500_BW_0_6 0x86 // 7 0 0.5 Mbps 0.6 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_400_BW_1_2 0xB1 // 7 0 0.4 Mbps 1.2 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_400_BW_0_6 0xAA // 7 0 0.4 Mbps 0.6 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_250_BW_0_6 0xCE // 7 0 0.25 Mbps 0.6 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_250_BW_0_3 0xC7 // 7 0 0.25 Mbps 0.3 MHz +#define RADIOLIB_SX128X_BLE_GFSK_BR_0_125_BW_0_3 0xEF // 7 0 0.125 Mbps 0.3 MHz +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_35 0x00 // 7 0 GFSK/BLE modulation index: 0.35 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_50 0x01 // 7 0 0.50 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_0_75 0x02 // 7 0 0.75 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_00 0x03 // 7 0 1.00 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_25 0x04 // 7 0 1.25 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_50 0x05 // 7 0 1.50 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_1_75 0x06 // 7 0 1.75 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_00 0x07 // 7 0 2.00 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_25 0x08 // 7 0 2.25 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_50 0x09 // 7 0 2.50 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_2_75 0x0A // 7 0 2.75 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_00 0x0B // 7 0 3.00 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_25 0x0C // 7 0 3.25 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_50 0x0D // 7 0 3.50 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_3_75 0x0E // 7 0 3.75 +#define RADIOLIB_SX128X_BLE_GFSK_MOD_IND_4_00 0x0F // 7 0 4.00 +#define RADIOLIB_SX128X_BLE_GFSK_BT_OFF 0x00 // 7 0 GFSK Gaussian filter BT product: filter disabled +#define RADIOLIB_SX128X_BLE_GFSK_BT_1_0 0x10 // 7 0 1.0 +#define RADIOLIB_SX128X_BLE_GFSK_BT_0_5 0x20 // 7 0 0.5 +#define RADIOLIB_SX128X_FLRC_BR_1_300_BW_1_2 0x45 // 7 0 FLRC bit rate and bandwidth setting: 1.3 Mbps 1.2 MHz +#define RADIOLIB_SX128X_FLRC_BR_1_000_BW_1_2 0x69 // 7 0 1.04 Mbps 1.2 MHz +#define RADIOLIB_SX128X_FLRC_BR_0_650_BW_0_6 0x86 // 7 0 0.65 Mbps 0.6 MHz +#define RADIOLIB_SX128X_FLRC_BR_0_520_BW_0_6 0xAA // 7 0 0.52 Mbps 0.6 MHz +#define RADIOLIB_SX128X_FLRC_BR_0_325_BW_0_3 0xC7 // 7 0 0.325 Mbps 0.3 MHz +#define RADIOLIB_SX128X_FLRC_BR_0_260_BW_0_3 0xEB // 7 0 0.260 Mbps 0.3 MHz +#define RADIOLIB_SX128X_FLRC_CR_1_2 0x00 // 7 0 FLRC coding rate: 1/2 +#define RADIOLIB_SX128X_FLRC_CR_3_4 0x02 // 7 0 3/4 +#define RADIOLIB_SX128X_FLRC_CR_1_0 0x04 // 7 0 1/1 +#define RADIOLIB_SX128X_FLRC_BT_OFF 0x00 // 7 0 FLRC Gaussian filter BT product: filter disabled +#define RADIOLIB_SX128X_FLRC_BT_1_0 0x10 // 7 0 1.0 +#define RADIOLIB_SX128X_FLRC_BT_0_5 0x20 // 7 0 0.5 +#define RADIOLIB_SX128X_LORA_SF_5 0x50 // 7 0 LoRa spreading factor: 5 +#define RADIOLIB_SX128X_LORA_SF_6 0x60 // 7 0 6 +#define RADIOLIB_SX128X_LORA_SF_7 0x70 // 7 0 7 +#define RADIOLIB_SX128X_LORA_SF_8 0x80 // 7 0 8 +#define RADIOLIB_SX128X_LORA_SF_9 0x90 // 7 0 9 +#define RADIOLIB_SX128X_LORA_SF_10 0xA0 // 7 0 10 +#define RADIOLIB_SX128X_LORA_SF_11 0xB0 // 7 0 11 +#define RADIOLIB_SX128X_LORA_SF_12 0xC0 // 7 0 12 +#define RADIOLIB_SX128X_LORA_BW_1625_00 0x0A // 7 0 LoRa bandwidth: 1625.0 kHz +#define RADIOLIB_SX128X_LORA_BW_812_50 0x18 // 7 0 812.5 kHz +#define RADIOLIB_SX128X_LORA_BW_406_25 0x26 // 7 0 406.25 kHz +#define RADIOLIB_SX128X_LORA_BW_203_125 0x34 // 7 0 203.125 kHz +#define RADIOLIB_SX128X_LORA_CR_4_5 0x01 // 7 0 LoRa coding rate: 4/5 +#define RADIOLIB_SX128X_LORA_CR_4_6 0x02 // 7 0 4/6 +#define RADIOLIB_SX128X_LORA_CR_4_7 0x03 // 7 0 4/7 +#define RADIOLIB_SX128X_LORA_CR_4_8 0x04 // 7 0 4/8 +#define RADIOLIB_SX128X_LORA_CR_4_5_LI 0x05 // 7 0 4/5, long interleaving +#define RADIOLIB_SX128X_LORA_CR_4_6_LI 0x06 // 7 0 4/6, long interleaving +#define RADIOLIB_SX128X_LORA_CR_4_7_LI 0x07 // 7 0 4/7, long interleaving //RADIOLIB_SX128X_CMD_SET_PACKET_PARAMS -#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_OFF 0x00 // 7 0 GFSK/FLRC sync word used: none -#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1 0x10 // 7 0 sync word 1 -#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_2 0x20 // 7 0 sync word 2 -#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_2 0x30 // 7 0 sync words 1 and 2 -#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_3 0x40 // 7 0 sync word 3 -#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_3 0x50 // 7 0 sync words 1 and 3 -#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_2_3 0x60 // 7 0 sync words 2 and 3 -#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_2_3 0x70 // 7 0 sync words 1, 2 and 3 -#define RADIOLIB_SX128X_GFSK_FLRC_PACKET_FIXED 0x00 // 7 0 GFSK/FLRC packet length mode: fixed -#define RADIOLIB_SX128X_GFSK_FLRC_PACKET_VARIABLE 0x20 // 7 0 variable -#define RADIOLIB_SX128X_GFSK_FLRC_CRC_OFF 0x00 // 7 0 GFSK/FLRC packet CRC: none -#define RADIOLIB_SX128X_GFSK_FLRC_CRC_1_BYTE 0x10 // 7 0 1 byte -#define RADIOLIB_SX128X_GFSK_FLRC_CRC_2_BYTE 0x20 // 7 0 2 bytes -#define RADIOLIB_SX128X_GFSK_FLRC_CRC_3_BYTE 0x30 // 7 0 3 bytes (FLRC only) -#define RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON 0x00 // 7 0 GFSK/BLE whitening: enabled -#define RADIOLIB_SX128X_GFSK_BLE_WHITENING_OFF 0x08 // 7 0 disabled -#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_31 0x00 // 7 0 BLE maximum payload length: 31 bytes -#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_37 0x20 // 7 0 37 bytes -#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_TEST 0x40 // 7 0 63 bytes (test mode) -#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_255 0x80 // 7 0 255 bytes (Bluetooth 4.2 and above) -#define RADIOLIB_SX128X_BLE_CRC_OFF 0x00 // 7 0 BLE packet CRC: none -#define RADIOLIB_SX128X_BLE_CRC_3_BYTE 0x10 // 7 0 3 byte -#define RADIOLIB_SX128X_BLE_PRBS_9 0x00 // 7 0 BLE test payload contents: PRNG sequence using x^9 + x^5 + x -#define RADIOLIB_SX128X_BLE_EYELONG 0x04 // 7 0 repeated 0xF0 -#define RADIOLIB_SX128X_BLE_EYESHORT 0x08 // 7 0 repeated 0xAA -#define RADIOLIB_SX128X_BLE_PRBS_15 0x0C // 7 0 PRNG sequence using x^15 + x^14 + x^13 + x^12 + x^2 + x + 1 -#define RADIOLIB_SX128X_BLE_ALL_1 0x10 // 7 0 repeated 0xFF -#define RADIOLIB_SX128X_BLE_ALL_0 0x14 // 7 0 repeated 0x00 -#define RADIOLIB_SX128X_BLE_EYELONG_INV 0x18 // 7 0 repeated 0x0F -#define RADIOLIB_SX128X_BLE_EYESHORT_INV 0x1C // 7 0 repeated 0x55 -#define RADIOLIB_SX128X_FLRC_SYNC_WORD_OFF 0x00 // 7 0 FLRC sync word: disabled -#define RADIOLIB_SX128X_FLRC_SYNC_WORD_ON 0x04 // 7 0 enabled -#define RADIOLIB_SX128X_LORA_HEADER_EXPLICIT 0x00 // 7 0 LoRa header mode: explicit -#define RADIOLIB_SX128X_LORA_HEADER_IMPLICIT 0x80 // 7 0 implicit -#define RADIOLIB_SX128X_LORA_CRC_OFF 0x00 // 7 0 LoRa packet CRC: disabled -#define RADIOLIB_SX128X_LORA_CRC_ON 0x20 // 7 0 enabled -#define RADIOLIB_SX128X_LORA_IQ_STANDARD 0x40 // 7 0 LoRa IQ: standard -#define RADIOLIB_SX128X_LORA_IQ_INVERTED 0x00 // 7 0 inverted +#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_OFF 0x00 // 7 0 GFSK/FLRC sync word used: none +#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1 0x10 // 7 0 sync word 1 +#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_2 0x20 // 7 0 sync word 2 +#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_2 0x30 // 7 0 sync words 1 and 2 +#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_3 0x40 // 7 0 sync word 3 +#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_3 0x50 // 7 0 sync words 1 and 3 +#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_2_3 0x60 // 7 0 sync words 2 and 3 +#define RADIOLIB_SX128X_GFSK_FLRC_SYNC_WORD_1_2_3 0x70 // 7 0 sync words 1, 2 and 3 +#define RADIOLIB_SX128X_GFSK_FLRC_PACKET_FIXED 0x00 // 7 0 GFSK/FLRC packet length mode: fixed +#define RADIOLIB_SX128X_GFSK_FLRC_PACKET_VARIABLE 0x20 // 7 0 variable +#define RADIOLIB_SX128X_GFSK_FLRC_CRC_OFF 0x00 // 7 0 GFSK/FLRC packet CRC: none +#define RADIOLIB_SX128X_GFSK_FLRC_CRC_1_BYTE 0x10 // 7 0 1 byte +#define RADIOLIB_SX128X_GFSK_FLRC_CRC_2_BYTE 0x20 // 7 0 2 bytes +#define RADIOLIB_SX128X_GFSK_FLRC_CRC_3_BYTE 0x30 // 7 0 3 bytes (FLRC only) +#define RADIOLIB_SX128X_GFSK_BLE_WHITENING_ON 0x00 // 7 0 GFSK/BLE whitening: enabled +#define RADIOLIB_SX128X_GFSK_BLE_WHITENING_OFF 0x08 // 7 0 disabled +#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_31 0x00 // 7 0 BLE maximum payload length: 31 bytes +#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_37 0x20 // 7 0 37 bytes +#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_TEST 0x40 // 7 0 63 bytes (test mode) +#define RADIOLIB_SX128X_BLE_PAYLOAD_LENGTH_MAX_255 0x80 // 7 0 255 bytes (Bluetooth 4.2 and above) +#define RADIOLIB_SX128X_BLE_CRC_OFF 0x00 // 7 0 BLE packet CRC: none +#define RADIOLIB_SX128X_BLE_CRC_3_BYTE 0x10 // 7 0 3 byte +#define RADIOLIB_SX128X_BLE_PRBS_9 0x00 // 7 0 BLE test payload contents: PRNG sequence using x^9 + x^5 + x +#define RADIOLIB_SX128X_BLE_EYELONG 0x04 // 7 0 repeated 0xF0 +#define RADIOLIB_SX128X_BLE_EYESHORT 0x08 // 7 0 repeated 0xAA +#define RADIOLIB_SX128X_BLE_PRBS_15 0x0C // 7 0 PRNG sequence using x^15 + x^14 + x^13 + x^12 + x^2 + x + 1 +#define RADIOLIB_SX128X_BLE_ALL_1 0x10 // 7 0 repeated 0xFF +#define RADIOLIB_SX128X_BLE_ALL_0 0x14 // 7 0 repeated 0x00 +#define RADIOLIB_SX128X_BLE_EYELONG_INV 0x18 // 7 0 repeated 0x0F +#define RADIOLIB_SX128X_BLE_EYESHORT_INV 0x1C // 7 0 repeated 0x55 +#define RADIOLIB_SX128X_FLRC_SYNC_WORD_OFF 0x00 // 7 0 FLRC sync word: disabled +#define RADIOLIB_SX128X_FLRC_SYNC_WORD_ON 0x04 // 7 0 enabled +#define RADIOLIB_SX128X_LORA_HEADER_EXPLICIT 0x00 // 7 0 LoRa header mode: explicit +#define RADIOLIB_SX128X_LORA_HEADER_IMPLICIT 0x80 // 7 0 implicit +#define RADIOLIB_SX128X_LORA_CRC_OFF 0x00 // 7 0 LoRa packet CRC: disabled +#define RADIOLIB_SX128X_LORA_CRC_ON 0x20 // 7 0 enabled +#define RADIOLIB_SX128X_LORA_IQ_STANDARD 0x40 // 7 0 LoRa IQ: standard +#define RADIOLIB_SX128X_LORA_IQ_INVERTED 0x00 // 7 0 inverted //RADIOLIB_SX128X_CMD_GET_PACKET_STATUS -#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_ERROR 0b01000000 // 6 6 packet status errors byte: sync word error -#define RADIOLIB_SX128X_PACKET_STATUS_LENGTH_ERROR 0b00100000 // 5 5 packet length error -#define RADIOLIB_SX128X_PACKET_STATUS_CRC_ERROR 0b00010000 // 4 4 CRC error -#define RADIOLIB_SX128X_PACKET_STATUS_ABORT_ERROR 0b00001000 // 3 3 packet reception aborted -#define RADIOLIB_SX128X_PACKET_STATUS_HEADER_RECEIVED 0b00000100 // 2 2 header received -#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_RECEIVED 0b00000010 // 1 1 packet received -#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_CTRL_BUSY 0b00000001 // 0 0 packet controller is busy -#define RADIOLIB_SX128X_PACKET_STATUS_RX_PID 0b11000000 // 7 6 packet status status byte: PID field of the received packet -#define RADIOLIB_SX128X_PACKET_STATUS_NO_ACK 0b00100000 // 5 5 NO_ACK field of the received packet -#define RADIOLIB_SX128X_PACKET_STATUS_RX_PID_ERROR 0b00010000 // 4 4 PID field error -#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_SENT 0b00000001 // 0 0 packet sent -#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_ERROR 0b00000000 // 2 0 packet status sync byte: sync word detection error -#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_1 0b00000001 // 2 0 detected sync word 1 -#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_2 0b00000010 // 2 0 detected sync word 2 -#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_3 0b00000100 // 2 0 detected sync word 3 +#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_ERROR 0b01000000 // 6 6 packet status errors byte: sync word error +#define RADIOLIB_SX128X_PACKET_STATUS_LENGTH_ERROR 0b00100000 // 5 5 packet length error +#define RADIOLIB_SX128X_PACKET_STATUS_CRC_ERROR 0b00010000 // 4 4 CRC error +#define RADIOLIB_SX128X_PACKET_STATUS_ABORT_ERROR 0b00001000 // 3 3 packet reception aborted +#define RADIOLIB_SX128X_PACKET_STATUS_HEADER_RECEIVED 0b00000100 // 2 2 header received +#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_RECEIVED 0b00000010 // 1 1 packet received +#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_CTRL_BUSY 0b00000001 // 0 0 packet controller is busy +#define RADIOLIB_SX128X_PACKET_STATUS_RX_PID 0b11000000 // 7 6 packet status status byte: PID field of the received packet +#define RADIOLIB_SX128X_PACKET_STATUS_NO_ACK 0b00100000 // 5 5 NO_ACK field of the received packet +#define RADIOLIB_SX128X_PACKET_STATUS_RX_PID_ERROR 0b00010000 // 4 4 PID field error +#define RADIOLIB_SX128X_PACKET_STATUS_PACKET_SENT 0b00000001 // 0 0 packet sent +#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_ERROR 0b00000000 // 2 0 packet status sync byte: sync word detection error +#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_1 0b00000001 // 2 0 detected sync word 1 +#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_2 0b00000010 // 2 0 detected sync word 2 +#define RADIOLIB_SX128X_PACKET_STATUS_SYNC_DET_3 0b00000100 // 2 0 detected sync word 3 //RADIOLIB_SX128X_CMD_SET_DIO_IRQ_PARAMS -#define RADIOLIB_SX128X_IRQ_RADIOLIB_PREAMBLE_DETECTED 0x8000 // 15 15 interrupt source: preamble detected -#define RADIOLIB_SX128X_IRQ_ADVANCED_RANGING_DONE 0x8000 // 15 15 advanced ranging done -#define RADIOLIB_SX128X_IRQ_RX_TX_TIMEOUT 0x4000 // 14 14 Rx or Tx timeout -#define RADIOLIB_SX128X_IRQ_CAD_DETECTED 0x2000 // 13 13 channel activity detected -#define RADIOLIB_SX128X_IRQ_CAD_DONE 0x1000 // 12 12 CAD finished -#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_REQ_VALID 0x0800 // 11 11 ranging request valid (slave) -#define RADIOLIB_SX128X_IRQ_RANGING_MASTER_TIMEOUT 0x0400 // 10 10 ranging timeout (master) -#define RADIOLIB_SX128X_IRQ_RANGING_MASTER_RES_VALID 0x0200 // 9 9 ranging result valid (master) -#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_REQ_DISCARD 0x0100 // 8 8 ranging result valid (master) -#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_RESP_DONE 0x0080 // 7 7 ranging response complete (slave) -#define RADIOLIB_SX128X_IRQ_CRC_ERROR 0x0040 // 6 6 CRC error -#define RADIOLIB_SX128X_IRQ_HEADER_ERROR 0x0020 // 5 5 header error -#define RADIOLIB_SX128X_IRQ_HEADER_VALID 0x0010 // 4 4 header valid -#define RADIOLIB_SX128X_IRQ_SYNC_WORD_ERROR 0x0008 // 3 3 sync word error -#define RADIOLIB_SX128X_IRQ_SYNC_WORD_VALID 0x0004 // 2 2 sync word valid -#define RADIOLIB_SX128X_IRQ_RX_DONE 0x0002 // 1 1 Rx done -#define RADIOLIB_SX128X_IRQ_TX_DONE 0x0001 // 0 0 Tx done -#define RADIOLIB_SX128X_IRQ_RX_DEFAULT 0x4062 // 15 0 default for Rx (RX_DONE, RX_TX_TIMEOUT, CRC_ERROR and HEADER_ERROR) -#define RADIOLIB_SX128X_IRQ_NONE 0x0000 // 15 0 none -#define RADIOLIB_SX128X_IRQ_ALL 0xFFFF // 15 0 all +#define RADIOLIB_SX128X_IRQ_RADIOLIB_PREAMBLE_DETECTED 0x8000 // 15 15 interrupt source: preamble detected +#define RADIOLIB_SX128X_IRQ_ADVANCED_RANGING_DONE 0x8000 // 15 15 advanced ranging done +#define RADIOLIB_SX128X_IRQ_RX_TX_TIMEOUT 0x4000 // 14 14 Rx or Tx timeout +#define RADIOLIB_SX128X_IRQ_CAD_DETECTED 0x2000 // 13 13 channel activity detected +#define RADIOLIB_SX128X_IRQ_CAD_DONE 0x1000 // 12 12 CAD finished +#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_REQ_VALID 0x0800 // 11 11 ranging request valid (slave) +#define RADIOLIB_SX128X_IRQ_RANGING_MASTER_TIMEOUT 0x0400 // 10 10 ranging timeout (master) +#define RADIOLIB_SX128X_IRQ_RANGING_MASTER_RES_VALID 0x0200 // 9 9 ranging result valid (master) +#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_REQ_DISCARD 0x0100 // 8 8 ranging result valid (master) +#define RADIOLIB_SX128X_IRQ_RANGING_SLAVE_RESP_DONE 0x0080 // 7 7 ranging response complete (slave) +#define RADIOLIB_SX128X_IRQ_CRC_ERROR 0x0040 // 6 6 CRC error +#define RADIOLIB_SX128X_IRQ_HEADER_ERROR 0x0020 // 5 5 header error +#define RADIOLIB_SX128X_IRQ_HEADER_VALID 0x0010 // 4 4 header valid +#define RADIOLIB_SX128X_IRQ_SYNC_WORD_ERROR 0x0008 // 3 3 sync word error +#define RADIOLIB_SX128X_IRQ_SYNC_WORD_VALID 0x0004 // 2 2 sync word valid +#define RADIOLIB_SX128X_IRQ_RX_DONE 0x0002 // 1 1 Rx done +#define RADIOLIB_SX128X_IRQ_TX_DONE 0x0001 // 0 0 Tx done +#define RADIOLIB_SX128X_IRQ_RX_DEFAULT 0x4062 // 15 0 default for Rx (RX_DONE, RX_TX_TIMEOUT, CRC_ERROR and HEADER_ERROR) +#define RADIOLIB_SX128X_IRQ_NONE 0x0000 // 15 0 none +#define RADIOLIB_SX128X_IRQ_ALL 0xFFFF // 15 0 all //RADIOLIB_SX128X_CMD_SET_REGULATOR_MODE -#define RADIOLIB_SX128X_REGULATOR_LDO 0x00 // 7 0 set regulator mode: LDO (default) -#define RADIOLIB_SX128X_REGULATOR_DC_DC 0x01 // 7 0 DC-DC +#define RADIOLIB_SX128X_REGULATOR_LDO 0x00 // 7 0 set regulator mode: LDO (default) +#define RADIOLIB_SX128X_REGULATOR_DC_DC 0x01 // 7 0 DC-DC //RADIOLIB_SX128X_CMD_SET_RANGING_ROLE -#define RADIOLIB_SX128X_RANGING_ROLE_MASTER 0x01 // 7 0 ranging role: master -#define RADIOLIB_SX128X_RANGING_ROLE_SLAVE 0x00 // 7 0 slave +#define RADIOLIB_SX128X_RANGING_ROLE_MASTER 0x01 // 7 0 ranging role: master +#define RADIOLIB_SX128X_RANGING_ROLE_SLAVE 0x00 // 7 0 slave //RADIOLIB_SX128X_REG_LORA_SYNC_WORD_1 - RADIOLIB_SX128X_REG_LORA_SYNC_WORD_2 -#define RADIOLIB_SX128X_SYNC_WORD_PRIVATE 0x12 +#define RADIOLIB_SX128X_SYNC_WORD_PRIVATE 0x12 /*! \class SX128x - \brief Base class for %SX128x series. All derived classes for %SX128x (e.g. SX1280 or SX1281) inherit from this base class. This class should not be instantiated directly from Arduino sketch, only from its derived classes. */ @@ -358,7 +357,6 @@ class SX128x: public PhysicalLayer { /*! \brief Default constructor. - \param mod Instance of Module that will be used to communicate with the radio. */ SX128x(Module* mod); @@ -369,84 +367,55 @@ class SX128x: public PhysicalLayer { /*! \brief Initialization method for LoRa modem. - \param freq Carrier frequency in MHz. Defaults to 2400.0 MHz. - \param bw LoRa bandwidth in kHz. Defaults to 812.5 kHz. - \param sf LoRa spreading factor. Defaults to 9. - \param cr LoRa coding rate denominator. Defaults to 7 (coding rate 4/7). - \param syncWord 2-byte LoRa sync word. Defaults to RADIOLIB_SX128X_SYNC_WORD_PRIVATE (0x12). - - \param power Output power in dBm. Defaults to 10 dBm. - + \param pwr Output power in dBm. Defaults to 10 dBm. \param preambleLength LoRa preamble length in symbols. Defaults to 12 symbols. - \returns \ref status_codes */ - int16_t begin(float freq = 2400.0, float bw = 812.5, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX128X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 12); + int16_t begin(float freq = 2400.0, float bw = 812.5, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX128X_SYNC_WORD_PRIVATE, int8_t pwr = 10, uint16_t preambleLength = 12); /*! \brief Initialization method for GFSK modem. - \param freq Carrier frequency in MHz. Defaults to 2400.0 MHz. - \param br FSK bit rate in kbps. Defaults to 800 kbps. - \param freqDev Frequency deviation from carrier frequency in kHz. Defaults to 400.0 kHz. - - \param power Output power in dBm. Defaults to 10 dBm. - + \param pwr Output power in dBm. Defaults to 10 dBm. \param preambleLength FSK preamble length in bits. Defaults to 16 bits. - \returns \ref status_codes */ - int16_t beginGFSK(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t power = 10, uint16_t preambleLength = 16); + int16_t beginGFSK(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t pwr = 10, uint16_t preambleLength = 16); /*! \brief Initialization method for BLE modem. - \param freq Carrier frequency in MHz. Defaults to 2400.0 MHz. - \param br BLE bit rate in kbps. Defaults to 800 kbps. - \param freqDev Frequency deviation from carrier frequency in kHz. Defaults to 400.0 kHz. - - \param power Output power in dBm. Defaults to 10 dBm. - + \param pwr Output power in dBm. Defaults to 10 dBm. \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5. - \returns \ref status_codes */ - int16_t beginBLE(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t power = 10, uint8_t dataShaping = RADIOLIB_SHAPING_0_5); + int16_t beginBLE(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t pwr = 10, uint8_t dataShaping = RADIOLIB_SHAPING_0_5); /*! \brief Initialization method for FLRC modem. - \param freq Carrier frequency in MHz. Defaults to 2400.0 MHz. - \param br FLRC bit rate in kbps. Defaults to 650 kbps. - \param cr FLRC coding rate. Defaults to 3 (coding rate 3/4). - - \param power Output power in dBm. Defaults to 10 dBm. - + \param pwr Output power in dBm. Defaults to 10 dBm. \param preambleLength FLRC preamble length in bits. Defaults to 16 bits. - \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5. - \returns \ref status_codes */ - int16_t beginFLRC(float freq = 2400.0, uint16_t br = 650, uint8_t cr = 3, int8_t power = 10, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5); + int16_t beginFLRC(float freq = 2400.0, uint16_t br = 650, uint8_t cr = 3, int8_t pwr = 10, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5); /*! \brief Reset method. Will reset the chip to the default state using RST pin. - \param verify Whether correct module startup should be verified. When set to true, RadioLib will attempt to verify the module has started correctly by repeatedly issuing setStandby command. Enabled by default. - \returns \ref status_codes */ int16_t reset(bool verify = true); @@ -454,13 +423,9 @@ class SX128x: public PhysicalLayer { /*! \brief Blocking binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. - \param data Binary data to be sent. - \param len Number of bytes to send. - \param addr Address to send the data to. Unsupported, compatibility only. - \returns \ref status_codes */ int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override; @@ -468,60 +433,50 @@ class SX128x: public PhysicalLayer { /*! \brief Blocking binary receive method. Overloads for string-based transmissions are implemented in PhysicalLayer. - \param data Binary data to be sent. - \param len Number of bytes to send. - \returns \ref status_codes */ int16_t receive(uint8_t* data, size_t len) override; /*! \brief Starts direct mode transmission. - \param frf Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY. - \returns \ref status_codes */ int16_t transmitDirect(uint32_t frf = 0) override; /*! - \brief Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as %SX128x series does not support direct mode reception. - Will always return RADIOLIB_ERR_UNKNOWN. - + \brief Starts direct mode reception. Only implemented for PhysicalLayer compatibility, + as %SX128x series does not support direct mode reception. Will always return RADIOLIB_ERR_UNKNOWN. \returns \ref status_codes */ int16_t receiveDirect() override; /*! \brief Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. - \returns \ref status_codes */ int16_t scanChannel(); /*! \brief Sets the module to sleep mode. - - \param retainConfig Set to true to retain configuration and data buffer or to false to discard current configuration and data buffer. Defaults to true. - + \param retainConfig Set to true to retain configuration and data buffer or to false + to discard current configuration and data buffer. Defaults to true. \returns \ref status_codes */ int16_t sleep(bool retainConfig = true); /*! \brief Sets the module to standby mode (overload for PhysicalLayer compatibility, uses 13 MHz RC oscillator). - \returns \ref status_codes */ int16_t standby() override; /*! \brief Sets the module to standby mode. - - \param mode Oscillator to be used in standby mode. Can be set to RADIOLIB_SX128X_STANDBY_RC (13 MHz RC oscillator) or RADIOLIB_SX128X_STANDBY_XOSC (52 MHz external crystal oscillator). - + \param mode Oscillator to be used in standby mode. Can be set to RADIOLIB_SX128X_STANDBY_RC + (13 MHz RC oscillator) or RADIOLIB_SX128X_STANDBY_XOSC (52 MHz external crystal oscillator). \returns \ref status_codes */ int16_t standby(uint8_t mode); @@ -530,7 +485,6 @@ class SX128x: public PhysicalLayer { /*! \brief Sets interrupt service routine to call when DIO1 activates. - \param func ISR to call. */ void setDio1Action(void (*func)(void)); @@ -543,36 +497,29 @@ class SX128x: public PhysicalLayer { /*! \brief Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer. - \param data Binary data to be sent. - \param len Number of bytes to send. - \param addr Address to send the data to. Unsupported, compatibility only. - \returns \ref status_codes */ int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Clean up after transmission is done. - \returns \ref status_codes */ int16_t finishTransmit() override; /*! \brief Interrupt-driven receive method. DIO1 will be activated when full packet is received. - - \param timeout Raw timeout value, expressed as multiples of 15.625 us. Defaults to RADIOLIB_SX128X_RX_TIMEOUT_INF for infinite timeout (Rx continuous mode), set to RADIOLIB_SX128X_RX_TIMEOUT_NONE for no timeout (Rx single mode). + \param timeout Raw timeout value, expressed as multiples of 15.625 us. Defaults to + RADIOLIB_SX128X_RX_TIMEOUT_INF for infinite timeout (Rx continuous mode), + set to RADIOLIB_SX128X_RX_TIMEOUT_NONE for no timeout (Rx single mode). If timeout other than infinite is set, signal will be generated on DIO1. \param irqFlags Sets the IRQ flags, defaults to RADIOLIB_SX128X_IRQ_RX_DEFAULT. - \param irqMask Sets the mask of IRQ flags that will trigger DIO1, defaults to RADIOLIB_SX128X_IRQ_RX_DONE. - \param len Only for PhysicalLayer compatibility, not used. - \returns \ref status_codes */ int16_t startReceive(uint16_t timeout = RADIOLIB_SX128X_RX_TIMEOUT_INF, uint16_t irqFlags = RADIOLIB_SX128X_IRQ_RX_DEFAULT, uint16_t irqMask = RADIOLIB_SX128X_IRQ_RX_DONE, size_t len = 0); @@ -585,12 +532,9 @@ class SX128x: public PhysicalLayer { /*! \brief Reads data received after calling startReceive method. - \param data Pointer to array to save the received binary data. - \param len Number of bytes that will be read. When set to 0, the packet length will be retreived automatically. When more bytes than received are requested, only the number of bytes requested will be returned. - \returns \ref status_codes */ int16_t readData(uint8_t* data, size_t len) override; @@ -599,74 +543,59 @@ class SX128x: public PhysicalLayer { /*! \brief Sets carrier frequency. Allowed values are in range from 2400.0 to 2500.0 MHz. - \param freq Carrier frequency to be set in MHz. - \returns \ref status_codes */ int16_t setFrequency(float freq); /*! \brief Sets LoRa bandwidth. Allowed values are 203.125, 406.25, 812.5 and 1625.0 kHz. - \param bw LoRa bandwidth to be set in kHz. - \returns \ref status_codes */ int16_t setBandwidth(float bw); /*! \brief Sets LoRa spreading factor. Allowed values range from 5 to 12. - \param sf LoRa spreading factor to be set. - \returns \ref status_codes */ int16_t setSpreadingFactor(uint8_t sf); /*! \brief Sets LoRa coding rate denominator. Allowed values range from 5 to 8. - \param cr LoRa coding rate denominator to be set. - - \param longInterleaving Whether to enable long interleaving mode. Not available for coding rate 4/7, defaults to false. - + \param longInterleaving Whether to enable long interleaving mode. Not available for coding rate 4/7, + defaults to false. \returns \ref status_codes */ int16_t setCodingRate(uint8_t cr, bool longInterleaving = false); /*! \brief Sets output power. Allowed values are in range from -18 to 13 dBm. - - \param power Output power to be set in dBm. - + \param pwr Output power to be set in dBm. \returns \ref status_codes */ - int16_t setOutputPower(int8_t power); + int16_t setOutputPower(int8_t pwr); /*! \brief Sets preamble length for currently active modem. Allowed values range from 1 to 65535. - \param preambleLength Preamble length to be set in symbols (LoRa) or bits (FSK/BLE/FLRC). - \returns \ref status_codes */ int16_t setPreambleLength(uint32_t preambleLength); /*! - \brief Sets FSK or FLRC bit rate. Allowed values are 125, 250, 400, 500, 800, 1000, 1600 and 2000 kbps (for FSK modem) or 260, 325, 520, 650, 1000 and 1300 (for FLRC modem). - + \brief Sets FSK or FLRC bit rate. Allowed values are 125, 250, 400, 500, 800, 1000, + 1600 and 2000 kbps (for FSK modem) or 260, 325, 520, 650, 1000 and 1300 (for FLRC modem). \param br FSK/FLRC bit rate to be set in kbps. - \returns \ref status_codes */ int16_t setBitRate(float br); /*! \brief Sets FSK frequency deviation. Allowed values range from 0.0 to 3200.0 kHz. - \param freqDev FSK frequency deviation to be set in kHz. - \returns \ref status_codes */ int16_t setFrequencyDeviation(float freqDev) override; @@ -674,144 +603,113 @@ class SX128x: public PhysicalLayer { /*! \brief Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. - \param sh Time-bandwidth product of Gaussian filter to be set. - \returns \ref status_codes */ int16_t setDataShaping(uint8_t sh) override; /*! - \brief Sets FSK/FLRC sync word in the form of array of up to 5 bytes (FSK). For FLRC modem, the sync word must be exactly 4 bytes long - + \brief Sets FSK/FLRC sync word in the form of array of up to 5 bytes (FSK). For FLRC modem, + the sync word must be exactly 4 bytes long \param syncWord Sync word to be set. - \param len Sync word length in bytes. - \returns \ref status_codes */ int16_t setSyncWord(uint8_t* syncWord, uint8_t len); /*! \brief Sets LoRa sync word. - \param syncWord LoRa sync word to be set. - \param controlBits Undocumented control bits, required for compatibility purposes. - \returns \ref status_codes */ int16_t setSyncWord(uint8_t syncWord, uint8_t controlBits = 0x44); /*! \brief Sets CRC configuration. - \param len CRC length in bytes, Allowed values are 1, 2 or 3, set to 0 to disable CRC. - \param initial Initial CRC value. Defaults to 0x1D0F (CCIT CRC), not available for LoRa modem. - \param polynomial Polynomial for CRC calculation. Defaults to 0x1021 (CCIT CRC), not available for LoRa or BLE modem. - \returns \ref status_codes */ int16_t setCRC(uint8_t len, uint32_t initial = 0x1D0F, uint16_t polynomial = 0x1021); /*! \brief Sets whitening parameters, not available for LoRa or FLRC modem. - \param enabled Set to true to enable whitening. - \returns \ref status_codes */ int16_t setWhitening(bool enabled); /*! \brief Sets BLE access address. - \param addr BLE access address. - \returns \ref status_codes */ int16_t setAccessAddress(uint32_t addr); /*! \brief Enables or disables receiver high sensitivity mode. - - \param True to enable and false to disable. - - \returns 0 + \param enable True to enable and false to disable. + \returns \ref status_codes */ - int16_t setHighSensitivityMode(bool hsm = false); + int16_t setHighSensitivityMode(bool enable); /*! \brief Enables or disables receiver manual gain control. - \param gain Use 0 for automatic gain, 1 for minimum gain and up to 13 for maximum gain. - - \returns 0 + \returns \ref status_codes */ int16_t setGainControl(uint8_t gain = 0); /*! \brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. - \returns RSSI of the last received packet in dBm. */ float getRSSI(); /*! \brief Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa or ranging modem. - \returns SNR of the last received packet in dB. */ float getSNR(); /*! \brief Gets frequency error of the latest received packet. - \returns Frequency error in Hz. */ float getFrequencyError(); /*! \brief Query modem for the packet length of received payload. - \param update Update received packet length. Will return cached value when set to false. - \returns Length of last received packet in bytes. */ size_t getPacketLength(bool update = true) override; /*! \brief Get expected time-on-air for a given size of payload. - \param len Payload length in bytes. - \returns Expected time-on-air in microseconds. */ uint32_t getTimeOnAir(size_t len); /*! \brief Set implicit header mode for future reception/transmission. - \returns \ref status_codes */ int16_t implicitHeader(size_t len); /*! \brief Set explicit header mode for future reception/transmission. - \param len Payload length in bytes. - \returns \ref status_codes */ int16_t explicitHeader(); /*! \brief Sets transmission encoding. Serves only as alias for PhysicalLayer compatibility. - \param encoding Encoding to be used. Set to 0 for NRZ, and 2 for whitening. - \returns \ref status_codes */ int16_t setEncoding(uint8_t encoding) override; @@ -824,31 +722,26 @@ class SX128x: public PhysicalLayer { /*! \brief Dummy random method, to ensure PhysicalLayer compatibility. - \returns Always returns 0. */ uint8_t randomByte(); /*! \brief Enable/disable inversion of the I and Q signals - - \param invertIQ QI inversion enabled (true) or disabled (false); - + \param enable QI inversion enabled (true) or disabled (false); \returns \ref status_codes */ - int16_t invertIQ(bool invertIQ); + int16_t invertIQ(bool enable); #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Dummy method, to ensure PhysicalLayer compatibility. - \param func Ignored. */ void setDirectAction(void (*func)(void)); /*! \brief Dummy method, to ensure PhysicalLayer compatibility. - \param pin Ignored. */ void readBit(uint32_t pin); @@ -857,16 +750,16 @@ class SX128x: public PhysicalLayer { #if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) protected: #endif - Module* _mod; + Module* mod; #if !defined(RADIOLIB_GODMODE) protected: #endif // cached LoRa parameters - float _bwKhz = 0; - uint8_t _bw = 0, _sf = 0, _cr = 0; - uint8_t _preambleLengthLoRa = 0, _headerType = 0, _payloadLen = 0, _crcLoRa = 0; + float bandwidthKhz = 0; + uint8_t bandwidth = 0, spreadingFactor = 0, codingRateLoRa = 0; + uint8_t preambleLengthLoRa = 0, headerType = 0, payloadLen = 0, crcLoRa = 0; // SX128x SPI command implementations uint8_t getStatus(); @@ -879,18 +772,18 @@ class SX128x: public PhysicalLayer { int16_t setCad(); uint8_t getPacketType(); int16_t setRfFrequency(uint32_t frf); - int16_t setTxParams(uint8_t power, uint8_t rampTime = RADIOLIB_SX128X_PA_RAMP_10_US); + int16_t setTxParams(uint8_t pwr, uint8_t rampTime = RADIOLIB_SX128X_PA_RAMP_10_US); int16_t setBufferBaseAddress(uint8_t txBaseAddress = 0x00, uint8_t rxBaseAddress = 0x00); int16_t setModulationParams(uint8_t modParam1, uint8_t modParam2, uint8_t modParam3); - int16_t setPacketParamsGFSK(uint8_t preambleLen, uint8_t syncWordLen, uint8_t syncWordMatch, uint8_t crcLen, uint8_t whitening, uint8_t payloadLen = 0xFF, uint8_t headerType = RADIOLIB_SX128X_GFSK_FLRC_PACKET_VARIABLE); - int16_t setPacketParamsBLE(uint8_t connState, uint8_t crcLen, uint8_t bleTestPayload, uint8_t whitening); - int16_t setPacketParamsLoRa(uint8_t preambleLen, uint8_t headerType, uint8_t payloadLen, uint8_t crc, uint8_t invertIQ = RADIOLIB_SX128X_LORA_IQ_STANDARD); + int16_t setPacketParamsGFSK(uint8_t preambleLen, uint8_t syncLen, uint8_t syncMatch, uint8_t crcLen, uint8_t whiten, uint8_t payLen = 0xFF, uint8_t hdrType = RADIOLIB_SX128X_GFSK_FLRC_PACKET_VARIABLE); + int16_t setPacketParamsBLE(uint8_t connState, uint8_t crcLen, uint8_t bleTest, uint8_t whiten); + int16_t setPacketParamsLoRa(uint8_t preambleLen, uint8_t hdrType, uint8_t payLen, uint8_t crc, uint8_t invIQ = RADIOLIB_SX128X_LORA_IQ_STANDARD); int16_t setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask = RADIOLIB_SX128X_IRQ_NONE, uint16_t dio3Mask = RADIOLIB_SX128X_IRQ_NONE); int16_t clearIrqStatus(uint16_t clearIrqParams = RADIOLIB_SX128X_IRQ_ALL); int16_t setRangingRole(uint8_t role); int16_t setPacketType(uint8_t type); - int16_t setHeaderType(uint8_t headerType, size_t len = 0xFF); + int16_t setHeaderType(uint8_t hdrType, size_t len = 0xFF); #if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) private: @@ -903,22 +796,22 @@ class SX128x: public PhysicalLayer { private: #endif // common parameters - uint8_t _pwr = 0; + uint8_t power = 0; // cached LoRa parameters - uint8_t _invertIQ = RADIOLIB_SX128X_LORA_IQ_STANDARD; + uint8_t invertIQEnabled = RADIOLIB_SX128X_LORA_IQ_STANDARD; // cached GFSK parameters - float _modIndexReal = 0; - uint16_t _brKbps = 0; - uint8_t _br = 0, _modIndex = 0, _shaping = 0; - uint8_t _preambleLengthGFSK = 0, _syncWordLen = 0, _syncWordMatch = 0, _crcGFSK = 0, _whitening = 0; + float modIndexReal = 0; + uint16_t bitRateKbps = 0; + uint8_t bitRate = 0, modIndex = 0, shaping = 0; + uint8_t preambleLengthGFSK = 0, syncWordLen = 0, syncWordMatch = 0, crcGFSK = 0, whitening = 0; // cached FLRC parameters - uint8_t _crFLRC = 0; + uint8_t codingRateFLRC = 0; // cached BLE parameters - uint8_t _connectionState = 0, _crcBLE = 0, _bleTestPayload = 0; + uint8_t connectionState = 0, crcBLE = 0, bleTestPayload = 0; int16_t config(uint8_t modem); };