From b6f6718f1ff0fac5e0938cead16ea4ad1453a738 Mon Sep 17 00:00:00 2001 From: StevenCellist <47155822+StevenCellist@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:43:56 +0100 Subject: [PATCH 01/32] [LoRaWAN] Add datarate into event structure (#885) * [LoRaWAN] Move TX power logic to function * Update keywords * [LoRaWAN] Add datarate into event structure --- .../LoRaWAN_End_Device_Reference.ino | 2 ++ src/protocols/LoRaWAN/LoRaWAN.cpp | 2 ++ src/protocols/LoRaWAN/LoRaWAN.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/examples/LoRaWAN/LoRaWAN_End_Device_Reference/LoRaWAN_End_Device_Reference.ino b/examples/LoRaWAN/LoRaWAN_End_Device_Reference/LoRaWAN_End_Device_Reference.ino index c31752e7..bf70f139 100644 --- a/examples/LoRaWAN/LoRaWAN_End_Device_Reference/LoRaWAN_End_Device_Reference.ino +++ b/examples/LoRaWAN/LoRaWAN_End_Device_Reference/LoRaWAN_End_Device_Reference.ino @@ -214,6 +214,8 @@ void loop() { Serial.println(event.confirmed); Serial.print(F("[LoRaWAN] Confirming:\t")); Serial.println(event.confirming); + Serial.print(F("[LoRaWAN] Datarate:\t")); + Serial.print(event.datarate); Serial.print(F("[LoRaWAN] Frequency:\t")); Serial.print(event.freq, 3); Serial.println(F(" MHz")); diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index a8f1fd2b..99c93549 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -904,6 +904,7 @@ int16_t LoRaWANNode::uplink(uint8_t* data, size_t len, uint8_t port, bool isConf event->dir = RADIOLIB_LORAWAN_CHANNEL_DIR_UPLINK; event->confirmed = isConfirmed; event->confirming = isConfirmingDown; + event->datarate = this->dataRates[RADIOLIB_LORAWAN_CHANNEL_DIR_UPLINK]; event->freq = currentChannels[event->dir].freq; event->power = this->txPwrCur; event->fcnt = this->fcntUp; @@ -1262,6 +1263,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) event->dir = RADIOLIB_LORAWAN_CHANNEL_DIR_DOWNLINK; event->confirmed = isConfirmedDown; event->confirming = isConfirmingUp; + event->datarate = this->dataRates[RADIOLIB_LORAWAN_CHANNEL_DIR_DOWNLINK]; event->freq = currentChannels[event->dir].freq; event->power = this->txPwrCur; event->fcnt = isAppDownlink ? this->aFcntDown : this->nFcntDown; diff --git a/src/protocols/LoRaWAN/LoRaWAN.h b/src/protocols/LoRaWAN/LoRaWAN.h index 6e4523d0..30ff2512 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.h +++ b/src/protocols/LoRaWAN/LoRaWAN.h @@ -325,6 +325,9 @@ struct LoRaWANEvent_t { /*! \brief Whether the event is confirming a previous request (e.g., server downlink reply to confirmed uplink sent by user application)*/ bool confirming; + + /*! \brief Datarate */ + uint8_t datarate; /*! \brief Frequency in MHz */ float freq; From f4938ea5854e006eb731555023ecae34bec82c6e Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 27 Nov 2023 11:45:18 -0600 Subject: [PATCH 02/32] Check for RADIOLIB_SPI_PARANOID = 1 rather than just defined (#883) * Update BuildOpt.h to set RADIOLIB_SPI_PARANOID to 1 by default * Update Module.cpp to check for RADIOLIB_SPI_PARANOID set to 1 --- src/BuildOpt.h | 4 ++-- src/Module.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 813dac83..ee8fab54 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -358,13 +358,13 @@ #endif /* - * Uncomment to enable "paranoid" SPI mode + * Comment to disable "paranoid" SPI mode, or set RADIOLIB_SPI_PARANOID to 0 * Every write to an SPI register using SPI set function will be verified by a subsequent read operation. * This improves reliability, but slightly slows down communication. * Note: Enabled by default. */ #if !defined(RADIOLIB_SPI_PARANOID) - #define RADIOLIB_SPI_PARANOID + #define RADIOLIB_SPI_PARANOID 1 #endif /* diff --git a/src/Module.cpp b/src/Module.cpp index 0848a746..cd710eaa 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -75,7 +75,7 @@ int16_t Module::SPIsetRegValue(uint16_t reg, uint8_t value, uint8_t msb, uint8_t uint8_t newValue = (currentValue & ~mask) | (value & mask); SPIwriteRegister(reg, newValue); - #if defined(RADIOLIB_SPI_PARANOID) + #if RADIOLIB_SPI_PARANOID // check register value each millisecond until check interval is reached // some registers need a bit of time to process the change (e.g. SX127X_REG_OP_MODE) uint32_t start = this->hal->micros(); @@ -240,7 +240,7 @@ int16_t Module::SPIwriteStream(uint8_t* cmd, uint8_t cmdLen, uint8_t* data, size int16_t Module::SPIcheckStream() { int16_t state = RADIOLIB_ERR_NONE; - #if defined(RADIOLIB_SPI_PARANOID) + #if RADIOLIB_SPI_PARANOID // get the status uint8_t spiStatus = 0; uint8_t cmd = this->SPIstatusCommand; From a2e2003001120b50f8bae3e8f41e94fcd71ddf17 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:38:10 +0100 Subject: [PATCH 03/32] Reworked macro configuration system --- src/ArduinoHal.h | 2 +- src/BuildOpt.h | 294 +++++++++++++++++++++++---------------------- src/BuildOptUser.h | 4 +- src/Module.cpp | 28 ++--- src/Module.h | 10 +- src/RadioLib.h | 6 +- 6 files changed, 173 insertions(+), 171 deletions(-) diff --git a/src/ArduinoHal.h b/src/ArduinoHal.h index 2b650db8..bcda95ae 100644 --- a/src/ArduinoHal.h +++ b/src/ArduinoHal.h @@ -62,7 +62,7 @@ class ArduinoHal : public RadioLibHal { void yield() override; uint32_t pinToInterrupt(uint32_t pin) override; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif SPIClass* spi = NULL; diff --git a/src/BuildOpt.h b/src/BuildOpt.h index ee8fab54..f2b9bc31 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -1,6 +1,132 @@ #if !defined(_RADIOLIB_BUILD_OPTIONS_H) #define _RADIOLIB_BUILD_OPTIONS_H +/* RadioLib build configuration options */ + +/* + * Debug output enable. + * Warning: Debug output will slow down the whole system significantly. + * Also, it will result in larger compiled binary. + * Levels: debug - only main info + * verbose - full transcript of all SPI communication + */ +#if !defined(RADIOLIB_DEBUG) + #define RADIOLIB_DEBUG (0) +#endif +#if !defined(RADIOLIB_VERBOSE) + #define RADIOLIB_VERBOSE (0) +#endif + +// set which output port should be used for debug output +// may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms) +#if !defined(RADIOLIB_DEBUG_PORT) + #define RADIOLIB_DEBUG_PORT Serial +#endif + +/* + * Comment to disable "paranoid" SPI mode, or set RADIOLIB_SPI_PARANOID to 0 + * Every write to an SPI register using SPI set function will be verified by a subsequent read operation. + * This improves reliability, but slightly slows down communication. + * Note: Enabled by default. + */ +#if !defined(RADIOLIB_SPI_PARANOID) + #define RADIOLIB_SPI_PARANOID (1) +#endif + +/* + * Comment to disable parameter range checking + * RadioLib will check provided parameters (such as frequency) against limits determined by the device manufacturer. + * It is highly advised to keep this macro defined, removing it will allow invalid values to be set, + * possibly leading to bricked module and/or program crashing. + * Note: Enabled by default. + */ +#if !defined(RADIOLIB_CHECK_PARAMS) + #define RADIOLIB_CHECK_PARAMS (1) +#endif + +/* + * SX127x errata fix enable + * Warning: SX127x errata fix has been reported to cause issues with LoRa bandwidths lower than 62.5 kHz. + * It should only be enabled if you really are observing some errata-related issue. + * Note: Disabled by default. + */ +#if !defined(RADIOLIB_FIX_ERRATA_SX127X) + #define RADIOLIB_FIX_ERRATA_SX127X (0) +#endif + +/* + * God mode enable - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code. + * Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing. + * Failure to heed the above warning may result in bricked module. + */ +#if !defined(RADIOLIB_GODMODE) + #define RADIOLIB_GODMODE (0) +#endif + +/* + * Low-level hardware access enable + * This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite" + * Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this. + */ +#if !defined(RADIOLIB_LOW_LEVEL) + #define RADIOLIB_LOW_LEVEL (0) +#endif + +/* + * Enable pre-defined modules when using RadioShield, disabled by default. + */ +#if !defined(RADIOLIB_RADIOSHIELD) + #define RADIOLIB_RADIOSHIELD (0) +#endif + +/* + * Enable interrupt-based timing control + * For details, see https://github.com/jgromes/RadioLib/wiki/Interrupt-Based-Timing + */ +#if !defined(RADIOLIB_INTERRUPT_TIMING) + #define RADIOLIB_INTERRUPT_TIMING (0) +#endif + +/* + * Enable static-only memory management: no dynamic allocation will be performed. + * Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode. + */ +#if !defined(RADIOLIB_STATIC_ONLY) + #define RADIOLIB_STATIC_ONLY (0) +#endif + +// set the size of static arrays to use +#if !defined(RADIOLIB_STATIC_ARRAY_SIZE) + #define RADIOLIB_STATIC_ARRAY_SIZE (256) +#endif + +// the base address for persistent storage +// some protocols (e.g. LoRaWAN) require a method +// to store some data persistently +// on Arduino, this will use EEPROM, on non-Arduino platform, +// it will use anything provided by the hardware abstraction layer +// RadioLib will place these starting at this address +#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_BASE) + #define RADIOLIB_HAL_PERSISTENT_STORAGE_BASE (0) +#endif + +// the amount of space allocated to the persistent storage +#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE) + #define RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE (0x0180) +#endif + +/* + * Uncomment on boards whose clock runs too slow or too fast + * Set the value according to the following scheme: + * Enable timestamps on your terminal + * Print something to terminal, wait 1000 milliseconds, print something again + * If the difference is e.g. 1014 milliseconds between the prints, set this value to 14 + * Or, for more accuracy, wait for 100,000 milliseconds and divide the total drift by 100 + */ +#if !defined(RADIOLIB_CLOCK_DRIFT_MS) + //#define RADIOLIB_CLOCK_DRIFT_MS (0) +#endif + #if ARDUINO >= 100 // Arduino build #include "Arduino.h" @@ -61,23 +187,23 @@ // NOTE: Some of the exclusion macros are dependent on each other. For example, it is not possible to exclude RF69 // while keeping SX1231 (because RF69 is the base class for SX1231). The dependency is always uni-directional, // so excluding SX1231 and keeping RF69 is valid. - //#define RADIOLIB_EXCLUDE_CC1101 - //#define RADIOLIB_EXCLUDE_NRF24 - //#define RADIOLIB_EXCLUDE_RF69 - //#define RADIOLIB_EXCLUDE_SX1231 // dependent on RADIOLIB_EXCLUDE_RF69 - //#define RADIOLIB_EXCLUDE_SI443X - //#define RADIOLIB_EXCLUDE_RFM2X // dependent on RADIOLIB_EXCLUDE_SI443X - //#define RADIOLIB_EXCLUDE_SX127X - //#define RADIOLIB_EXCLUDE_SX126X - //#define RADIOLIB_EXCLUDE_STM32WLX // dependent on RADIOLIB_EXCLUDE_SX126X - //#define RADIOLIB_EXCLUDE_SX128X - //#define RADIOLIB_EXCLUDE_AFSK - //#define RADIOLIB_EXCLUDE_AX25 - //#define RADIOLIB_EXCLUDE_HELLSCHREIBER - //#define RADIOLIB_EXCLUDE_MORSE - //#define RADIOLIB_EXCLUDE_RTTY - //#define RADIOLIB_EXCLUDE_SSTV - //#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE + //#define RADIOLIB_EXCLUDE_CC1101 (1) + //#define RADIOLIB_EXCLUDE_NRF24 (1) + //#define RADIOLIB_EXCLUDE_RF69 (1) + //#define RADIOLIB_EXCLUDE_SX1231 (1) // dependent on RADIOLIB_EXCLUDE_RF69 + //#define RADIOLIB_EXCLUDE_SI443X (1) + //#define RADIOLIB_EXCLUDE_RFM2X (1) // dependent on RADIOLIB_EXCLUDE_SI443X + //#define RADIOLIB_EXCLUDE_SX127X (1) + //#define RADIOLIB_EXCLUDE_SX126X (1) + //#define RADIOLIB_EXCLUDE_STM32WLX (1) // dependent on RADIOLIB_EXCLUDE_SX126X + //#define RADIOLIB_EXCLUDE_SX128X (1) + //#define RADIOLIB_EXCLUDE_AFSK (1) + //#define RADIOLIB_EXCLUDE_AX25 (1) + //#define RADIOLIB_EXCLUDE_HELLSCHREIBER (1) + //#define RADIOLIB_EXCLUDE_MORSE (1) + //#define RADIOLIB_EXCLUDE_RTTY (1) + //#define RADIOLIB_EXCLUDE_SSTV (1) + //#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE (1) #elif defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR)) // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. @@ -337,137 +463,13 @@ #endif -/* - * Uncomment to enable debug output. - * Warning: Debug output will slow down the whole system significantly. - * Also, it will result in larger compiled binary. - * Levels: debug - only main info - * verbose - full transcript of all SPI communication - */ -#if !defined(RADIOLIB_DEBUG) - //#define RADIOLIB_DEBUG -#endif -#if !defined(RADIOLIB_VERBOSE) - //#define RADIOLIB_VERBOSE -#endif - -// set which output port should be used for debug output -// may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms) -#if defined(RADIOLIB_BUILD_ARDUINO) && !defined(RADIOLIB_DEBUG_PORT) - #define RADIOLIB_DEBUG_PORT Serial -#endif - -/* - * Comment to disable "paranoid" SPI mode, or set RADIOLIB_SPI_PARANOID to 0 - * Every write to an SPI register using SPI set function will be verified by a subsequent read operation. - * This improves reliability, but slightly slows down communication. - * Note: Enabled by default. - */ -#if !defined(RADIOLIB_SPI_PARANOID) - #define RADIOLIB_SPI_PARANOID 1 -#endif - -/* - * Uncomment to enable parameter range checking - * RadioLib will check provided parameters (such as frequency) against limits determined by the device manufacturer. - * It is highly advised to keep this macro defined, removing it will allow invalid values to be set, - * possibly leading to bricked module and/or program crashing. - * Note: Enabled by default. - */ -#if !defined(RADIOLIB_CHECK_PARAMS) - #define RADIOLIB_CHECK_PARAMS -#endif - -/* - * Uncomment to enable SX127x errata fix - * Warning: SX127x errata fix has been reported to cause issues with LoRa bandwidths lower than 62.5 kHz. - * It should only be enabled if you really are observing some errata-related issue. - * Note: Disabled by default. - */ -#if !defined(RADIOLIB_FIX_ERRATA_SX127X) - //#define RADIOLIB_FIX_ERRATA_SX127X -#endif - -/* - * Uncomment to enable god mode - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code. - * Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing. - * Failure to heed the above warning may result in bricked module. - */ -#if !defined(RADIOLIB_GODMODE) - //#define RADIOLIB_GODMODE -#endif - -/* - * Uncomment to enable low-level hardware access - * This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite" - * Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this. - */ -#if !defined(RADIOLIB_LOW_LEVEL) - //#define RADIOLIB_LOW_LEVEL -#endif - -/* - * Uncomment to enable pre-defined modules when using RadioShield. - */ -#if !defined(RADIOLIB_RADIOSHIELD) - //#define RADIOLIB_RADIOSHIELD -#endif - -/* - * Uncomment to enable interrupt-based timing control - * For details, see https://github.com/jgromes/RadioLib/wiki/Interrupt-Based-Timing - */ -#if !defined(RADIOLIB_INTERRUPT_TIMING) - //#define RADIOLIB_INTERRUPT_TIMING -#endif - -/* - * Uncomment to enable static-only memory management: no dynamic allocation will be performed. - * Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode. - */ -#if !defined(RADIOLIB_STATIC_ONLY) - //#define RADIOLIB_STATIC_ONLY -#endif - -// set the size of static arrays to use -#if !defined(RADIOLIB_STATIC_ARRAY_SIZE) - #define RADIOLIB_STATIC_ARRAY_SIZE (256) -#endif - -// the base address for persistent storage -// some protocols (e.g. LoRaWAN) require a method -// to store some data persistently -// on Arduino, this will use EEPROM, on non-Arduino platform, -// it will use anything provided by the hardware abstraction layer -// RadioLib will place these starting at this address -#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_BASE) - #define RADIOLIB_HAL_PERSISTENT_STORAGE_BASE (0) -#endif - -// the amount of space allocated to the persistent storage -#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE) - #define RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE (0x0180) -#endif - -/* - * Uncomment on boards whose clock runs too slow or too fast - * Set the value according to the following scheme: - * Enable timestamps on your terminal - * Print something to terminal, wait 1000 milliseconds, print something again - * If the difference is e.g. 1014 milliseconds between the prints, set this value to 14 - * Or, for more accuracy, wait for 100,000 milliseconds and divide the total drift by 100 - */ -#if !defined(RADIOLIB_CLOCK_DRIFT_MS) - //#define RADIOLIB_CLOCK_DRIFT_MS (0) -#endif - // This only compiles on STM32 boards with SUBGHZ module, but also // include when generating docs #if (!defined(ARDUINO_ARCH_STM32) || !defined(SUBGHZSPI_BASE)) && !defined(DOXYGEN) - #define RADIOLIB_EXCLUDE_STM32WLX + #define RADIOLIB_EXCLUDE_STM32WLX (1) #endif -#if defined(RADIOLIB_DEBUG) +#if RADIOLIB_DEBUG #if defined(RADIOLIB_BUILD_ARDUINO) #define RADIOLIB_DEBUG_PRINT(...) Module::serialPrintf(__VA_ARGS__) #define RADIOLIB_DEBUG_PRINTLN(M, ...) Module::serialPrintf(M "\n", ##__VA_ARGS__) @@ -491,7 +493,7 @@ #define RADIOLIB_DEBUG_HEXDUMP(...) {} #endif -#if defined(RADIOLIB_VERBOSE) +#if RADIOLIB_VERBOSE #define RADIOLIB_VERBOSE_PRINT(...) RADIOLIB_DEBUG_PRINT(__VA_ARGS__) #define RADIOLIB_VERBOSE_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN(__VA_ARGS__) #else @@ -507,13 +509,13 @@ /*! \brief Macro to check variable is within constraints - this is commonly used to check parameter ranges. Requires RADIOLIB_CHECK_RANGE to be enabled */ -#if defined(RADIOLIB_CHECK_PARAMS) +#if RADIOLIB_CHECK_PARAMS #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } } #else #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) {} #endif -#if defined(RADIOLIB_FIX_ERRATA_SX127X) +#if RADIOLIB_FIX_ERRATA_SX127X #define RADIOLIB_ERRATA_SX127X(...) { errataFix(__VA_ARGS__); } #else #define RADIOLIB_ERRATA_SX127X(...) {} diff --git a/src/BuildOptUser.h b/src/BuildOptUser.h index 5df3c2be..fc1a5657 100644 --- a/src/BuildOptUser.h +++ b/src/BuildOptUser.h @@ -5,7 +5,7 @@ // most commonly, RADIOLIB_EXCLUDE_* macros // or enabling debug output -//#define RADIOLIB_DEBUG -//#define RADIOLIB_VERBOSE +//#define RADIOLIB_DEBUG (1) +//#define RADIOLIB_VERBOSE (1) #endif diff --git a/src/Module.cpp b/src/Module.cpp index cd710eaa..b6f8583d 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -5,7 +5,7 @@ #include #include -#if defined(RADIOLIB_DEBUG) +#if RADIOLIB_DEBUG // needed for debug print #include #endif @@ -145,7 +145,7 @@ void Module::SPIwriteRegister(uint16_t reg, uint8_t data) { void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* dataIn, size_t numBytes) { // prepare the buffers size_t buffLen = this->SPIaddrWidth/8 + numBytes; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t buffOut[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t buffIn[RADIOLIB_STATIC_ARRAY_SIZE]; #else @@ -182,7 +182,7 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d } // print debug information - #if defined(RADIOLIB_VERBOSE) + #if RADIOLIB_VERBOSE uint8_t* debugBuffPtr = NULL; if(cmd == SPIwriteCommand) { RADIOLIB_VERBOSE_PRINT("W\t%X\t", reg); @@ -197,7 +197,7 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d RADIOLIB_VERBOSE_PRINTLN(); #endif - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] buffOut; delete[] buffIn; #endif @@ -262,7 +262,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint if(!write) { buffLen++; } - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t buffOut[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t buffIn[RADIOLIB_STATIC_ARRAY_SIZE]; #else @@ -292,7 +292,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint this->hal->yield(); if(this->hal->millis() - start >= timeout) { RADIOLIB_DEBUG_PRINTLN("GPIO pre-transfer timeout, is it connected?"); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] buffOut; delete[] buffIn; #endif @@ -319,7 +319,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint this->hal->yield(); if(this->hal->millis() - start >= timeout) { RADIOLIB_DEBUG_PRINTLN("GPIO post-transfer timeout, is it connected?"); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] buffOut; delete[] buffIn; #endif @@ -342,7 +342,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint } // print debug information - #if defined(RADIOLIB_VERBOSE) + #if RADIOLIB_VERBOSE // print command byte(s) RADIOLIB_VERBOSE_PRINT("CMD"); if(write) { @@ -369,7 +369,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint RADIOLIB_VERBOSE_PRINTLN(); #endif - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] buffOut; delete[] buffIn; #endif @@ -378,7 +378,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint } void Module::waitForMicroseconds(uint32_t start, uint32_t len) { - #if defined(RADIOLIB_INTERRUPT_TIMING) + #if RADIOLIB_INTERRUPT_TIMING (void)start; if((this->TimerSetupCb != nullptr) && (len != this->prevTimingLen)) { prevTimingLen = len; @@ -403,7 +403,7 @@ uint32_t Module::reflect(uint32_t in, uint8_t bits) { return(res); } -#if defined(RADIOLIB_DEBUG) +#if RADIOLIB_DEBUG void Module::hexdump(uint8_t* data, size_t len, uint32_t offset, uint8_t width, bool be) { size_t rem_len = len; for(size_t i = 0; i < len; i+=16) { @@ -450,20 +450,20 @@ void Module::hexdump(uint8_t* data, size_t len, uint32_t offset, uint8_t width, } void Module::regdump(uint16_t start, size_t len) { - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t buff[RADIOLIB_STATIC_ARRAY_SIZE]; #else uint8_t* buff = new uint8_t[len]; #endif SPIreadRegisterBurst(start, len, buff); hexdump(buff, len, start); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] buff; #endif } #endif -#if defined(RADIOLIB_DEBUG) and defined(RADIOLIB_BUILD_ARDUINO) +#if RADIOLIB_DEBUG && defined(RADIOLIB_BUILD_ARDUINO) // https://github.com/esp8266/Arduino/blob/65579d29081cb8501e4d7f786747bf12e7b37da2/cores/esp8266/Print.cpp#L50 size_t Module::serialPrintf(const char* format, ...) { va_list arg; diff --git a/src/Module.h b/src/Module.h index 56697ac9..c67aaf6a 100644 --- a/src/Module.h +++ b/src/Module.h @@ -168,7 +168,7 @@ class Module { */ SPIparseStatusCb_t SPIparseStatusCb = nullptr; - #if defined(RADIOLIB_INTERRUPT_TIMING) + #if RADIOLIB_INTERRUPT_TIMING /*! \brief Timer interrupt setup callback typedef. @@ -468,7 +468,7 @@ class Module { */ static uint32_t reflect(uint32_t in, uint8_t bits); - #if defined(RADIOLIB_DEBUG) + #if RADIOLIB_DEBUG /*! \brief Function to dump data as hex into the debug port. \param data Data to dump. @@ -486,11 +486,11 @@ class Module { void regdump(uint16_t start, size_t len); #endif - #if defined(RADIOLIB_DEBUG) and defined(RADIOLIB_BUILD_ARDUINO) + #if RADIOLIB_DEBUG and defined(RADIOLIB_BUILD_ARDUINO) static size_t serialPrintf(const char* format, ...); #endif -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif uint32_t csPin = RADIOLIB_NC; @@ -502,7 +502,7 @@ class Module { uint32_t rfSwitchPins[RFSWITCH_MAX_PINS] = { RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC }; const RfSwitchMode_t *rfSwitchTable = nullptr; - #if defined(RADIOLIB_INTERRUPT_TIMING) + #if RADIOLIB_INTERRUPT_TIMING uint32_t prevTimingLen = 0; #endif }; diff --git a/src/RadioLib.h b/src/RadioLib.h index 735309d2..3fd9632a 100644 --- a/src/RadioLib.h +++ b/src/RadioLib.h @@ -47,7 +47,7 @@ // warnings are printed in this file since BuildOpt.h is compiled in multiple places // check God mode -#if defined(RADIOLIB_GODMODE) +#if RADIOLIB_GODMODE #warning "God mode active, I hope it was intentional. Buckle up, lads." #endif @@ -120,7 +120,7 @@ #include "utils/Cryptography.h" // only create Radio class when using RadioShield -#if defined(RADIOLIB_RADIOSHIELD) +#if RADIOLIB_RADIOSHIELD // RadioShield pin definitions #define RADIOSHIELD_CS_A 10 @@ -152,7 +152,7 @@ class Radio { ModuleB = new Module(RADIOSHIELD_CS_B, RADIOSHIELD_IRQ_B, RADIOSHIELD_RST_B, RADIOSHIELD_GPIO_B); } -#if defined(RADIOLIB_GODMODE) +#if RADIOLIB_GODMODE private: #endif From 1d77d8bd556efe75c92a74e297a6e385f1868985 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:38:30 +0100 Subject: [PATCH 04/32] [FEC] Reworked macro configuration system --- src/utils/FEC.cpp | 26 +++++++++++++------------- src/utils/FEC.h | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/utils/FEC.cpp b/src/utils/FEC.cpp index e8cf260e..39d7f5d5 100644 --- a/src/utils/FEC.cpp +++ b/src/utils/FEC.cpp @@ -14,7 +14,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) { this->n = n; this->k = k; this->poly = poly; - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY this->alphaTo = new int32_t[n + 1]; this->indexOf = new int32_t[n + 1]; this->generator = new int32_t[n - k + 1]; @@ -115,7 +115,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) { // Search for roots 1, 2, ..., m-1 in cycle sets int32_t rdncy = 0; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY int32_t min[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1]; #else int32_t* min = new int32_t[this->n - this->k + 1]; @@ -139,7 +139,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) { } int32_t noterms = kaux; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY int32_t zeros[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1]; #else int32_t* zeros = new int32_t[this->n - this->k + 1]; @@ -153,7 +153,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) { } } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] min; #endif @@ -173,7 +173,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) { this->generator[0] = this->alphaTo[(this->indexOf[this->generator[0]] + zeros[ii]) % this->n]; } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] zeros; #endif } @@ -185,7 +185,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) { */ uint32_t RadioLibBCH::encode(uint32_t dataword) { // we only use the "k" most significant bits - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY int32_t data[RADIOLIB_BCH_MAX_K]; #else int32_t* data = new int32_t[this->k]; @@ -200,7 +200,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) { } // reset the M(x)+r array elements - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY int32_t Mr[RADIOLIB_BCH_MAX_N]; #else int32_t* Mr = new int32_t[this->n]; @@ -227,7 +227,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) { } } - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY int32_t bb[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1]; #else int32_t* bb = new int32_t[this->n - this->k + 1]; @@ -238,12 +238,12 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) { ++j; } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] Mr; #endif int32_t iEvenParity = 0; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY int32_t recd[RADIOLIB_BCH_MAX_N + 1]; #else int32_t* recd = new int32_t[this->n + 1]; @@ -255,7 +255,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) { } } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] data; #endif @@ -266,7 +266,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) { } } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] bb; #endif @@ -283,7 +283,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) { } } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] recd; #endif diff --git a/src/utils/FEC.h b/src/utils/FEC.h index 76f2bcad..0716fe11 100644 --- a/src/utils/FEC.h +++ b/src/utils/FEC.h @@ -12,7 +12,7 @@ #define RADIOLIB_PAGER_BCH_K (21) #define RADIOLIB_PAGER_BCH_PRIMITIVE_POLY (0x25) -#if defined(RADIOLIB_STATIC_ONLY) +#if RADIOLIB_STATIC_ONLY #define RADIOLIB_BCH_MAX_N (63) #define RADIOLIB_BCH_MAX_K (31) #endif @@ -52,7 +52,7 @@ class RadioLibBCH { uint32_t poly; uint8_t m; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY int32_t alphaTo[RADIOLIB_BCH_MAX_N + 1]; int32_t indexOf[RADIOLIB_BCH_MAX_N + 1]; int32_t generator[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1]; From 0c436e5ed8885fdfd42e119b316d51ba876b532f Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:39:24 +0100 Subject: [PATCH 05/32] [CC1101] Reworked macro configuration system --- src/modules/CC1101/CC1101.cpp | 4 ++-- src/modules/CC1101/CC1101.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index be2056b2..6cae666a 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -1,6 +1,6 @@ #include "CC1101.h" #include -#if !defined(RADIOLIB_EXCLUDE_CC1101) +#if !RADIOLIB_EXCLUDE_CC1101 CC1101::CC1101(Module* module) : PhysicalLayer(RADIOLIB_CC1101_FREQUENCY_STEP_SIZE, RADIOLIB_CC1101_MAX_PACKET_LENGTH) { this->mod = module; @@ -935,7 +935,7 @@ int16_t CC1101::getChipVersion() { return(SPIgetRegValue(RADIOLIB_CC1101_REG_VERSION)); } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE void CC1101::setDirectAction(void (*func)(void)) { setGdo0Action(func, this->mod->hal->GpioInterruptRising); } diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 2e83d926..53652f35 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -1,4 +1,4 @@ -#if !defined(_RADIOLIB_CC1101_H) && !defined(RADIOLIB_EXCLUDE_CC1101) +#if !defined(_RADIOLIB_CC1101_H) && !RADIOLIB_EXCLUDE_CC1101 #define _RADIOLIB_CC1101_H #include "../../TypeDef.h" @@ -922,7 +922,7 @@ class CC1101: public PhysicalLayer { */ int16_t getChipVersion(); - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE /*! \brief Set interrupt service routine function to call when data bit is receveid in direct mode. \param func Pointer to interrupt service routine. @@ -944,7 +944,7 @@ class CC1101: public PhysicalLayer { */ int16_t setDIOMapping(uint32_t pin, uint32_t value); - #if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) + #if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: #endif Module* mod; @@ -959,7 +959,7 @@ class CC1101: public PhysicalLayer { void SPIsendCommand(uint8_t cmd); - #if !defined(RADIOLIB_GODMODE) + #if !RADIOLIB_GODMODE protected: #endif From 509b8204f1281c32add627763b0c13a6dfbb0f3b Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:39:35 +0100 Subject: [PATCH 06/32] [LLCC68] Reworked macro configuration system --- src/modules/LLCC68/LLCC68.cpp | 2 +- src/modules/LLCC68/LLCC68.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/LLCC68/LLCC68.cpp b/src/modules/LLCC68/LLCC68.cpp index 03483584..30c12ec8 100644 --- a/src/modules/LLCC68/LLCC68.cpp +++ b/src/modules/LLCC68/LLCC68.cpp @@ -1,5 +1,5 @@ #include "LLCC68.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X LLCC68::LLCC68(Module* mod) : SX1262(mod) { chipType = RADIOLIB_LLCC68_CHIP_TYPE; diff --git a/src/modules/LLCC68/LLCC68.h b/src/modules/LLCC68/LLCC68.h index 1cec96f1..0ed55902 100644 --- a/src/modules/LLCC68/LLCC68.h +++ b/src/modules/LLCC68/LLCC68.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X #include "../../Module.h" #include "../SX126x/SX1262.h" @@ -56,7 +56,7 @@ class LLCC68: public SX1262 { */ int16_t setSpreadingFactor(uint8_t sf); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif From 63287ab6fda74435fd7ee19122c8739acef1711a Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:40:00 +0100 Subject: [PATCH 07/32] [nRF24] Reworked macro configuration system --- src/modules/nRF24/nRF24.cpp | 6 +++--- src/modules/nRF24/nRF24.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index c48b5b17..e4923bcd 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -1,6 +1,6 @@ #include "nRF24.h" #include -#if !defined(RADIOLIB_EXCLUDE_NRF24) +#if !RADIOLIB_EXCLUDE_NRF24 nRF24::nRF24(Module* mod) : PhysicalLayer(RADIOLIB_NRF24_FREQUENCY_STEP_SIZE, RADIOLIB_NRF24_MAX_PACKET_LENGTH) { this->mod = mod; @@ -617,7 +617,7 @@ void nRF24::SPIwriteTxPayload(uint8_t* data, uint8_t numBytes) { void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* dataIn, uint8_t numBytes) { // prepare the buffers size_t buffLen = 1 + numBytes; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t buffOut[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t buffIn[RADIOLIB_STATIC_ARRAY_SIZE]; #else @@ -648,7 +648,7 @@ void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* data memcpy(dataIn, &buffIn[1], numBytes); } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] buffOut; delete[] buffIn; #endif diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index 5a59877f..d6f9346a 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -1,4 +1,4 @@ -#if !defined(_RADIOLIB_NRF24_H) && !defined(RADIOLIB_EXCLUDE_NRF24) +#if !defined(_RADIOLIB_NRF24_H) && !RADIOLIB_EXCLUDE_NRF24 #define _RADIOLIB_NRF24_H #include "../../Module.h" @@ -467,7 +467,7 @@ class nRF24: public PhysicalLayer { */ int16_t setEncoding(uint8_t encoding) override; -#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) +#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: #endif Module* mod; @@ -476,7 +476,7 @@ class nRF24: public PhysicalLayer { void SPIwriteTxPayload(uint8_t* data, uint8_t numBytes); void SPItransfer(uint8_t cmd, bool write = false, uint8_t* dataOut = NULL, uint8_t* dataIn = NULL, uint8_t numBytes = 0); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif From 2e1ce8ce8988820cf5892540afe386085ec9d787 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:40:19 +0100 Subject: [PATCH 08/32] [RF69] Reworked macro configuration system --- src/modules/RF69/RF69.cpp | 4 ++-- src/modules/RF69/RF69.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 6af30fae..b414d0f3 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -1,6 +1,6 @@ #include "RF69.h" #include -#if !defined(RADIOLIB_EXCLUDE_RF69) +#if !RADIOLIB_EXCLUDE_RF69 RF69::RF69(Module* module) : PhysicalLayer(RADIOLIB_RF69_FREQUENCY_STEP_SIZE, RADIOLIB_RF69_MAX_PACKET_LENGTH) { this->mod = module; @@ -960,7 +960,7 @@ uint8_t RF69::randomByte() { return(randByte); } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE void RF69::setDirectAction(void (*func)(void)) { setDio1Action(func); } diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 8ecb2a85..93d1dff3 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_RF69) +#if !RADIOLIB_EXCLUDE_RF69 #include "../../Module.h" @@ -973,7 +973,7 @@ class RF69: public PhysicalLayer { */ int16_t getChipVersion(); - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE /*! \brief Set interrupt service routine function to call when data bit is received in direct mode. \param func Pointer to interrupt service routine. @@ -995,12 +995,12 @@ class RF69: public PhysicalLayer { */ int16_t setDIOMapping(uint32_t pin, uint32_t value); -#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) +#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: #endif Module* mod; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif @@ -1025,7 +1025,7 @@ class RF69: public PhysicalLayer { int16_t directMode(); int16_t setPacketMode(uint8_t mode, uint8_t len); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif int16_t setMode(uint8_t mode); From f0f9200269dc8e20d0aae021ebed400cf97b45b5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:40:32 +0100 Subject: [PATCH 09/32] [RFM2x] Reworked macro configuration system --- src/modules/RFM2x/RFM22.h | 2 +- src/modules/RFM2x/RFM23.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/RFM2x/RFM22.h b/src/modules/RFM2x/RFM22.h index f1055a8d..12317017 100644 --- a/src/modules/RFM2x/RFM22.h +++ b/src/modules/RFM2x/RFM22.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_RFM2X) +#if !RADIOLIB_EXCLUDE_RFM2X #include "../../Module.h" #include "../Si443x/Si443x.h" diff --git a/src/modules/RFM2x/RFM23.h b/src/modules/RFM2x/RFM23.h index 3fd33362..fb7f0591 100644 --- a/src/modules/RFM2x/RFM23.h +++ b/src/modules/RFM2x/RFM23.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_RFM2X) +#if !RADIOLIB_EXCLUDE_RFM2X #include "../../Module.h" #include "../Si443x/Si443x.h" From 77c9b2875d028915d71ae8151036feacadc78294 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:40:57 +0100 Subject: [PATCH 10/32] [Si443x] Reworked macro configuration system --- src/modules/Si443x/Si4430.cpp | 2 +- src/modules/Si443x/Si4430.h | 6 +++--- src/modules/Si443x/Si4431.cpp | 2 +- src/modules/Si443x/Si4431.h | 6 +++--- src/modules/Si443x/Si4432.cpp | 2 +- src/modules/Si443x/Si4432.h | 6 +++--- src/modules/Si443x/Si443x.cpp | 4 ++-- src/modules/Si443x/Si443x.h | 10 +++++----- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/modules/Si443x/Si4430.cpp b/src/modules/Si443x/Si4430.cpp index 9de46ae1..c8b030cb 100644 --- a/src/modules/Si443x/Si4430.cpp +++ b/src/modules/Si443x/Si4430.cpp @@ -1,5 +1,5 @@ #include "Si4430.h" -#if !defined(RADIOLIB_EXCLUDE_SI443X) +#if !RADIOLIB_EXCLUDE_SI443X Si4430::Si4430(Module* mod) : Si4432(mod) { diff --git a/src/modules/Si443x/Si4430.h b/src/modules/Si443x/Si4430.h index 5b073509..6acac97d 100644 --- a/src/modules/Si443x/Si4430.h +++ b/src/modules/Si443x/Si4430.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SI443X) +#if !RADIOLIB_EXCLUDE_SI443X #include "../../Module.h" #include "Si4432.h" @@ -53,11 +53,11 @@ class Si4430: public Si4432 { */ int16_t setOutputPower(int8_t power); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif }; diff --git a/src/modules/Si443x/Si4431.cpp b/src/modules/Si443x/Si4431.cpp index 566b245a..953c888f 100644 --- a/src/modules/Si443x/Si4431.cpp +++ b/src/modules/Si443x/Si4431.cpp @@ -1,5 +1,5 @@ #include "Si4431.h" -#if !defined(RADIOLIB_EXCLUDE_SI443X) +#if !RADIOLIB_EXCLUDE_SI443X Si4431::Si4431(Module* mod) : Si4432(mod) { diff --git a/src/modules/Si443x/Si4431.h b/src/modules/Si443x/Si4431.h index 8ca35a34..8d3d9dd9 100644 --- a/src/modules/Si443x/Si4431.h +++ b/src/modules/Si443x/Si4431.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SI443X) +#if !RADIOLIB_EXCLUDE_SI443X #include "../../Module.h" #include "Si4432.h" @@ -46,11 +46,11 @@ class Si4431: public Si4432 { */ int16_t setOutputPower(int8_t power); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif }; diff --git a/src/modules/Si443x/Si4432.cpp b/src/modules/Si443x/Si4432.cpp index 0f679d67..12c212ef 100644 --- a/src/modules/Si443x/Si4432.cpp +++ b/src/modules/Si443x/Si4432.cpp @@ -1,5 +1,5 @@ #include "Si4432.h" -#if !defined(RADIOLIB_EXCLUDE_SI443X) +#if !RADIOLIB_EXCLUDE_SI443X Si4432::Si4432(Module* mod) : Si443x(mod) { diff --git a/src/modules/Si443x/Si4432.h b/src/modules/Si443x/Si4432.h index 3903a5ac..b0a8cb87 100644 --- a/src/modules/Si443x/Si4432.h +++ b/src/modules/Si443x/Si4432.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SI443X) +#if !RADIOLIB_EXCLUDE_SI443X #include "../../Module.h" #include "Si443x.h" @@ -53,11 +53,11 @@ class Si4432: public Si443x { */ int16_t setOutputPower(int8_t power); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif }; diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 2b2bf835..95ad385a 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -1,6 +1,6 @@ #include "Si443x.h" #include -#if !defined(RADIOLIB_EXCLUDE_SI443X) +#if !RADIOLIB_EXCLUDE_SI443X Si443x::Si443x(Module* mod) : PhysicalLayer(RADIOLIB_SI443X_FREQUENCY_STEP_SIZE, RADIOLIB_SI443X_MAX_PACKET_LENGTH) { this->mod = mod; @@ -623,7 +623,7 @@ int16_t Si443x::getChipVersion() { return(this->mod->SPIgetRegValue(RADIOLIB_SI443X_REG_DEVICE_VERSION)); } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE void Si443x::setDirectAction(void (*func)(void)) { setIrqAction(func); } diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 463b6851..ca83ba12 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SI443X) +#if !RADIOLIB_EXCLUDE_SI443X #include "../../Module.h" @@ -797,7 +797,7 @@ class Si443x: public PhysicalLayer { */ int16_t getChipVersion(); - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE /*! \brief Set interrupt service routine function to call when data bit is received in direct mode. \param func Pointer to interrupt service routine. @@ -825,12 +825,12 @@ class Si443x: public PhysicalLayer { */ int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_SI443X_MAX_PACKET_LENGTH); -#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) +#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: #endif Module* mod; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif @@ -845,7 +845,7 @@ class Si443x: public PhysicalLayer { int16_t setFrequencyRaw(float newFreq); int16_t setPacketMode(uint8_t mode, uint8_t len); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif bool findChip(); From 49feff6df297016036feefb068e1904098ca8a74 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 19:43:01 +0100 Subject: [PATCH 11/32] [SX126x] Reworked macro configuration system --- src/modules/SX126x/STM32WLx.cpp | 4 ++-- src/modules/SX126x/STM32WLx.h | 10 +++++----- src/modules/SX126x/STM32WLx_Module.cpp | 4 ++-- src/modules/SX126x/STM32WLx_Module.h | 6 +++--- src/modules/SX126x/SX1261.cpp | 2 +- src/modules/SX126x/SX1261.h | 4 ++-- src/modules/SX126x/SX1262.cpp | 2 +- src/modules/SX126x/SX1262.h | 4 ++-- src/modules/SX126x/SX1268.cpp | 2 +- src/modules/SX126x/SX1268.h | 4 ++-- src/modules/SX126x/SX126x.cpp | 14 +++++++------- src/modules/SX126x/SX126x.h | 10 +++++----- src/modules/SX126x/patches/SX126x_patch_scan.h | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/modules/SX126x/STM32WLx.cpp b/src/modules/SX126x/STM32WLx.cpp index f64b4933..313f8343 100644 --- a/src/modules/SX126x/STM32WLx.cpp +++ b/src/modules/SX126x/STM32WLx.cpp @@ -6,7 +6,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT */ #include "STM32WLx.h" -#if !defined(RADIOLIB_EXCLUDE_STM32WLX) +#if !RADIOLIB_EXCLUDE_STM32WLX STM32WLx::STM32WLx(STM32WLx_Module* mod) : SX1262(mod) { } @@ -150,4 +150,4 @@ void STM32WLx::clearChannelScanAction() { this->clearDio1Action(); } -#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX) +#endif diff --git a/src/modules/SX126x/STM32WLx.h b/src/modules/SX126x/STM32WLx.h index cab2fc54..16c88cc9 100644 --- a/src/modules/SX126x/STM32WLx.h +++ b/src/modules/SX126x/STM32WLx.h @@ -10,7 +10,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_STM32WLX) +#if !RADIOLIB_EXCLUDE_STM32WLX #include "../../Module.h" #include "SX1262.h" @@ -153,16 +153,16 @@ class STM32WLx : public SX1262 { */ void clearChannelScanAction(); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif virtual int16_t clearIrqStatus(uint16_t clearIrqParams) override; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif }; -#endif // !defined(RADIOLIB_EXCLUDE_SX126X) +#endif -#endif // _RADIOLIB_STM32WLX_MODULE_H +#endif diff --git a/src/modules/SX126x/STM32WLx_Module.cpp b/src/modules/SX126x/STM32WLx_Module.cpp index 1336325b..57d0445c 100644 --- a/src/modules/SX126x/STM32WLx_Module.cpp +++ b/src/modules/SX126x/STM32WLx_Module.cpp @@ -7,7 +7,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT #include "STM32WLx_Module.h" -#if !defined(RADIOLIB_EXCLUDE_STM32WLX) +#if !RADIOLIB_EXCLUDE_STM32WLX #include "../../ArduinoHal.h" @@ -103,4 +103,4 @@ STM32WLx_Module::STM32WLx_Module(): RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY ) {} -#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX) +#endif diff --git a/src/modules/SX126x/STM32WLx_Module.h b/src/modules/SX126x/STM32WLx_Module.h index f7d1d64d..878ba775 100644 --- a/src/modules/SX126x/STM32WLx_Module.h +++ b/src/modules/SX126x/STM32WLx_Module.h @@ -10,7 +10,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_STM32WLX) +#if !RADIOLIB_EXCLUDE_STM32WLX #include "../../Module.h" @@ -33,6 +33,6 @@ class STM32WLx_Module : public Module { STM32WLx_Module(); }; -#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX) +#endif -#endif // _RADIOLIB_STM32WLX_MODULE_H +#endif diff --git a/src/modules/SX126x/SX1261.cpp b/src/modules/SX126x/SX1261.cpp index 999f4f9f..dd39bfef 100644 --- a/src/modules/SX126x/SX1261.cpp +++ b/src/modules/SX126x/SX1261.cpp @@ -1,5 +1,5 @@ #include "SX1261.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X SX1261::SX1261(Module* mod): SX1262(mod) { chipType = RADIOLIB_SX1261_CHIP_TYPE; diff --git a/src/modules/SX126x/SX1261.h b/src/modules/SX126x/SX1261.h index 8d7663e5..01375d55 100644 --- a/src/modules/SX126x/SX1261.h +++ b/src/modules/SX126x/SX1261.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X #include "../../Module.h" #include "SX126x.h" @@ -34,7 +34,7 @@ class SX1261 : public SX1262 { */ int16_t setOutputPower(int8_t power); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index baa27ae8..d24e0f43 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -1,5 +1,5 @@ #include "SX1262.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X SX1262::SX1262(Module* mod) : SX126x(mod) { chipType = RADIOLIB_SX1262_CHIP_TYPE; diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index d3b67ae5..f47b1a81 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X #include "../../Module.h" #include "SX126x.h" @@ -87,7 +87,7 @@ class SX1262: public SX126x { */ virtual int16_t setOutputPower(int8_t power); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index a2f60f23..596ce7e4 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -1,5 +1,5 @@ #include "SX1268.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X SX1268::SX1268(Module* mod) : SX126x(mod) { chipType = RADIOLIB_SX1268_CHIP_TYPE; diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h index c3e2a607..08b3eb41 100644 --- a/src/modules/SX126x/SX1268.h +++ b/src/modules/SX126x/SX1268.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X #include "../../Module.h" #include "SX126x.h" @@ -85,7 +85,7 @@ class SX1268: public SX126x { */ int16_t setOutputPower(int8_t power); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 51e1b8ae..797968a8 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1,7 +1,7 @@ #include "SX126x.h" #include #include -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X SX126x::SX126x(Module* mod) : PhysicalLayer(RADIOLIB_SX126X_FREQUENCY_STEP_SIZE, RADIOLIB_SX126X_MAX_PACKET_LENGTH) { this->mod = mod; @@ -1547,7 +1547,7 @@ int16_t SX126x::invertIQ(bool enable) { return(setPacketParams(this->preambleLengthLoRa, this->crcTypeLoRa, this->implicitLen, this->headerType, this->invertIQEnabled)); } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE void SX126x::setDirectAction(void (*func)(void)) { setDio1Action(func); } @@ -1563,7 +1563,7 @@ int16_t SX126x::uploadPatch(const uint32_t* patch, size_t len, bool nonvolatile) RADIOLIB_ASSERT(state); // check the version - #if defined(RADIOLIB_DEBUG) + #if RADIOLIB_DEBUG char ver_pre[16]; this->mod->SPIreadRegisterBurst(RADIOLIB_SX126X_REG_VERSION_STRING, 16, (uint8_t*)ver_pre); RADIOLIB_DEBUG_PRINTLN("Pre-update version string: %s", ver_pre); @@ -1595,7 +1595,7 @@ int16_t SX126x::uploadPatch(const uint32_t* patch, size_t len, bool nonvolatile) this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_PRAM_UPDATE, NULL, 0); // check the version again - #if defined(RADIOLIB_DEBUG) + #if RADIOLIB_DEBUG char ver_post[16]; this->mod->SPIreadRegisterBurst(RADIOLIB_SX126X_REG_VERSION_STRING, 16, (uint8_t*)ver_post); RADIOLIB_DEBUG_PRINTLN("Post-update version string: %s", ver_post); @@ -1839,7 +1839,7 @@ int16_t SX126x::calibrateImage(uint8_t* data) { int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_CALIBRATE_IMAGE, data, 2); // if something failed, show the device errors - #if defined(RADIOLIB_DEBUG) + #if RADIOLIB_DEBUG if(state != RADIOLIB_ERR_NONE) { // unless mode is forced to standby, device errors will be 0 standby(); @@ -2099,7 +2099,7 @@ int16_t SX126x::config(uint8_t modem) { state = this->mod->SPIcheckStream(); // if something failed, show the device errors - #if defined(RADIOLIB_DEBUG) + #if RADIOLIB_DEBUG if(state != RADIOLIB_ERR_NONE) { // unless mode is forced to standby, device errors will be 0 standby(); @@ -2142,7 +2142,7 @@ bool SX126x::findChip(const char* verStr) { RADIOLIB_DEBUG_PRINTLN(); flagFound = true; } else { - #if defined(RADIOLIB_DEBUG) + #if RADIOLIB_DEBUG RADIOLIB_DEBUG_PRINTLN("SX126x not found! (%d of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING:", i + 1); RADIOLIB_DEBUG_HEXDUMP((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING); RADIOLIB_DEBUG_PRINTLN("Expected string: %s", verStr); diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 0c2f9e20..5e8c03b6 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X #include "../../Module.h" @@ -1039,7 +1039,7 @@ class SX126x: public PhysicalLayer { */ int16_t invertIQ(bool enable) override; - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE /*! \brief Set interrupt service routine function to call when data bit is received in direct mode. \param func Pointer to interrupt service routine. @@ -1104,7 +1104,7 @@ class SX126x: public PhysicalLayer { */ int16_t setPaConfig(uint8_t paDutyCycle, uint8_t deviceSel, uint8_t hpMax = RADIOLIB_SX126X_PA_CONFIG_HP_MAX, uint8_t paLut = RADIOLIB_SX126X_PA_CONFIG_PA_LUT); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif // SX126x SPI command implementations @@ -1146,7 +1146,7 @@ class SX126x: public PhysicalLayer { int16_t fixImplicitTimeout(); int16_t fixInvertedIQ(uint8_t iqConfig); -#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) +#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: #endif Module* mod; @@ -1154,7 +1154,7 @@ class SX126x: public PhysicalLayer { // common low-level SPI interface static int16_t SPIparseStatus(uint8_t in); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif diff --git a/src/modules/SX126x/patches/SX126x_patch_scan.h b/src/modules/SX126x/patches/SX126x_patch_scan.h index 3dff7be8..bc918749 100644 --- a/src/modules/SX126x/patches/SX126x_patch_scan.h +++ b/src/modules/SX126x/patches/SX126x_patch_scan.h @@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX126X) +#if !RADIOLIB_EXCLUDE_SX126X // the following is a binary patch to the SX1262 // this patch is needed to enable spectral scan functionality From 34c861cfbe771f2ed2e1d41cf31bc5fc40139d2e Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:14:33 +0100 Subject: [PATCH 12/32] [SX127x] Reworked macro configuration system --- src/modules/SX127x/SX1272.cpp | 2 +- src/modules/SX127x/SX1272.h | 6 +++--- src/modules/SX127x/SX1273.cpp | 2 +- src/modules/SX127x/SX1273.h | 4 ++-- src/modules/SX127x/SX1276.cpp | 2 +- src/modules/SX127x/SX1276.h | 4 ++-- src/modules/SX127x/SX1277.cpp | 2 +- src/modules/SX127x/SX1277.h | 4 ++-- src/modules/SX127x/SX1278.cpp | 2 +- src/modules/SX127x/SX1278.h | 6 +++--- src/modules/SX127x/SX1279.cpp | 2 +- src/modules/SX127x/SX1279.h | 4 ++-- src/modules/SX127x/SX127x.cpp | 4 ++-- src/modules/SX127x/SX127x.h | 10 +++++----- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 45bf8802..ae900a2a 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -1,6 +1,6 @@ #include "SX1272.h" #include -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X SX1272::SX1272(Module* mod) : SX127x(mod) { diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index f389230b..974fa16b 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X #include "../../Module.h" #include "SX127x.h" @@ -271,7 +271,7 @@ class SX1272: public SX127x { */ int16_t explicitHeader(); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif int16_t setBandwidthRaw(uint8_t newBandwidth); @@ -282,7 +282,7 @@ class SX1272: public SX127x { int16_t configFSK(); void errataFix(bool rx); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif bool ldroAuto = true; diff --git a/src/modules/SX127x/SX1273.cpp b/src/modules/SX127x/SX1273.cpp index ea021c66..c3ae5eda 100644 --- a/src/modules/SX127x/SX1273.cpp +++ b/src/modules/SX127x/SX1273.cpp @@ -1,5 +1,5 @@ #include "SX1273.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X SX1273::SX1273(Module* mod) : SX1272(mod) { diff --git a/src/modules/SX127x/SX1273.h b/src/modules/SX127x/SX1273.h index 2ceb58bc..12bd05df 100644 --- a/src/modules/SX127x/SX1273.h +++ b/src/modules/SX127x/SX1273.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X #include "SX1272.h" @@ -56,7 +56,7 @@ class SX1273: public SX1272 { */ int16_t setDataRate(DataRate_t dr) override; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX127x/SX1276.cpp b/src/modules/SX127x/SX1276.cpp index b20fd7d1..d45826fc 100644 --- a/src/modules/SX127x/SX1276.cpp +++ b/src/modules/SX127x/SX1276.cpp @@ -1,5 +1,5 @@ #include "SX1276.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X SX1276::SX1276(Module* mod) : SX1278(mod) { diff --git a/src/modules/SX127x/SX1276.h b/src/modules/SX127x/SX1276.h index aaf2cc4b..dd9907d5 100644 --- a/src/modules/SX127x/SX1276.h +++ b/src/modules/SX127x/SX1276.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X #include "SX1278.h" @@ -63,7 +63,7 @@ class SX1276: public SX1278 { */ int16_t setFrequency(float freq); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX127x/SX1277.cpp b/src/modules/SX127x/SX1277.cpp index 5875bd9f..76bbb0f6 100644 --- a/src/modules/SX127x/SX1277.cpp +++ b/src/modules/SX127x/SX1277.cpp @@ -1,5 +1,5 @@ #include "SX1277.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X SX1277::SX1277(Module* mod) : SX1278(mod) { diff --git a/src/modules/SX127x/SX1277.h b/src/modules/SX127x/SX1277.h index 15804d61..0289021f 100644 --- a/src/modules/SX127x/SX1277.h +++ b/src/modules/SX127x/SX1277.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X #include "SX1278.h" @@ -77,7 +77,7 @@ class SX1277: public SX1278 { */ int16_t setDataRate(DataRate_t dr) override; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 90325ff0..57c9f6f9 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -1,6 +1,6 @@ #include "SX1278.h" #include -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X SX1278::SX1278(Module* mod) : SX127x(mod) { diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index c9f966a2..685f08ee 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X #include "../../Module.h" #include "SX127x.h" @@ -282,7 +282,7 @@ class SX1278: public SX127x { */ int16_t explicitHeader(); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif int16_t setBandwidthRaw(uint8_t newBandwidth); @@ -293,7 +293,7 @@ class SX1278: public SX127x { int16_t configFSK(); void errataFix(bool rx); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif bool ldroAuto = true; diff --git a/src/modules/SX127x/SX1279.cpp b/src/modules/SX127x/SX1279.cpp index 4fdd4daa..9f9ac037 100644 --- a/src/modules/SX127x/SX1279.cpp +++ b/src/modules/SX127x/SX1279.cpp @@ -1,5 +1,5 @@ #include "SX1279.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X SX1279::SX1279(Module* mod) : SX1278(mod) { diff --git a/src/modules/SX127x/SX1279.h b/src/modules/SX127x/SX1279.h index 1b01368f..e802e9c4 100644 --- a/src/modules/SX127x/SX1279.h +++ b/src/modules/SX127x/SX1279.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X #include "SX1278.h" @@ -63,7 +63,7 @@ class SX1279: public SX1278 { */ int16_t setFrequency(float freq); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index fe953f33..a3ca76c8 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -1,6 +1,6 @@ #include "SX127x.h" #include -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X SX127x::SX127x(Module* mod) : PhysicalLayer(RADIOLIB_SX127X_FREQUENCY_STEP_SIZE, RADIOLIB_SX127X_MAX_PACKET_LENGTH) { this->mod = mod; @@ -1628,7 +1628,7 @@ int16_t SX127x::invertIQ(bool enable) { return(state); } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE void SX127x::setDirectAction(void (*func)(void)) { setDio1Action(func, this->mod->hal->GpioInterruptRising); } diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index fa4ab65b..721c5d48 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX127X) +#if !RADIOLIB_EXCLUDE_SX127X #include "../../Module.h" @@ -1150,7 +1150,7 @@ class SX127x: public PhysicalLayer { */ int16_t invertIQ(bool enable) override; - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE /*! \brief Set interrupt service routine function to call when data bit is received in direct mode. \param func Pointer to interrupt service routine. @@ -1218,12 +1218,12 @@ class SX127x: public PhysicalLayer { */ int16_t setRSSIThreshold(float dbm); -#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) +#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: #endif Module* mod; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif @@ -1245,7 +1245,7 @@ class SX127x: public PhysicalLayer { int16_t directMode(); int16_t setPacketMode(uint8_t mode, uint8_t len); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif float dataRate = 0; From 827aac593807cc728b0a1b3bc20e8df3e7f5eb22 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:15:07 +0100 Subject: [PATCH 13/32] [SX128x] Reworked macro configuration system --- src/modules/SX128x/SX1280.cpp | 2 +- src/modules/SX128x/SX1280.h | 4 ++-- src/modules/SX128x/SX1281.cpp | 2 +- src/modules/SX128x/SX1281.h | 4 ++-- src/modules/SX128x/SX1282.cpp | 2 +- src/modules/SX128x/SX1282.h | 4 ++-- src/modules/SX128x/SX128x.cpp | 4 ++-- src/modules/SX128x/SX128x.h | 12 ++++++------ 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/modules/SX128x/SX1280.cpp b/src/modules/SX128x/SX1280.cpp index b53c1a62..cc4c9798 100644 --- a/src/modules/SX128x/SX1280.cpp +++ b/src/modules/SX128x/SX1280.cpp @@ -1,6 +1,6 @@ #include "SX1280.h" #include -#if !defined(RADIOLIB_EXCLUDE_SX128X) +#if !RADIOLIB_EXCLUDE_SX128X SX1280::SX1280(Module* mod) : SX1281(mod) { diff --git a/src/modules/SX128x/SX1280.h b/src/modules/SX128x/SX1280.h index 51bb7c0b..c798f044 100644 --- a/src/modules/SX128x/SX1280.h +++ b/src/modules/SX128x/SX1280.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX128X) +#if !RADIOLIB_EXCLUDE_SX128X #include "../../Module.h" #include "SX128x.h" @@ -45,7 +45,7 @@ class SX1280: public SX1281 { */ float getRangingResult(); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX128x/SX1281.cpp b/src/modules/SX128x/SX1281.cpp index c6b2b5eb..71e7476e 100644 --- a/src/modules/SX128x/SX1281.cpp +++ b/src/modules/SX128x/SX1281.cpp @@ -1,5 +1,5 @@ #include "SX1281.h" -#if !defined(RADIOLIB_EXCLUDE_SX128X) +#if !RADIOLIB_EXCLUDE_SX128X SX1281::SX1281(Module* mod) : SX128x(mod) { diff --git a/src/modules/SX128x/SX1281.h b/src/modules/SX128x/SX1281.h index 04a9eb19..3a41b60a 100644 --- a/src/modules/SX128x/SX1281.h +++ b/src/modules/SX128x/SX1281.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX128X) +#if !RADIOLIB_EXCLUDE_SX128X #include "../../Module.h" #include "SX128x.h" @@ -20,7 +20,7 @@ class SX1281: public SX128x { */ SX1281(Module* mod); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX128x/SX1282.cpp b/src/modules/SX128x/SX1282.cpp index 33deee97..d58ba3d3 100644 --- a/src/modules/SX128x/SX1282.cpp +++ b/src/modules/SX128x/SX1282.cpp @@ -1,5 +1,5 @@ #include "SX1282.h" -#if !defined(RADIOLIB_EXCLUDE_SX128X) +#if !RADIOLIB_EXCLUDE_SX128X /// \todo implement advanced ranging SX1282::SX1282(Module* mod) : SX1280(mod) { diff --git a/src/modules/SX128x/SX1282.h b/src/modules/SX128x/SX1282.h index 864e463d..091bf133 100644 --- a/src/modules/SX128x/SX1282.h +++ b/src/modules/SX128x/SX1282.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX128X) +#if !RADIOLIB_EXCLUDE_SX128X #include "../../Module.h" #include "SX128x.h" @@ -21,7 +21,7 @@ class SX1282: public SX1280 { */ SX1282(Module* mod); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 3e26382e..6f14b536 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1,6 +1,6 @@ #include "SX128x.h" #include -#if !defined(RADIOLIB_EXCLUDE_SX128X) +#if !RADIOLIB_EXCLUDE_SX128X SX128x::SX128x(Module* mod) : PhysicalLayer(RADIOLIB_SX128X_FREQUENCY_STEP_SIZE, RADIOLIB_SX128X_MAX_PACKET_LENGTH) { this->mod = mod; @@ -1333,7 +1333,7 @@ int16_t SX128x::invertIQ(bool enable) { return(setPacketParamsLoRa(this->preambleLengthLoRa, this->headerType, this->payloadLen, this->crcLoRa, this->invertIQEnabled)); } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE void SX128x::setDirectAction(void (*func)(void)) { // SX128x is unable to perform direct mode reception // this method is implemented only for PhysicalLayer compatibility diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index 1aa69115..b2e63bbd 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX128X) +#if !RADIOLIB_EXCLUDE_SX128X #include "../../Module.h" @@ -765,7 +765,7 @@ class SX128x: public PhysicalLayer { */ int16_t invertIQ(bool enable); - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE /*! \brief Dummy method, to ensure PhysicalLayer compatibility. \param func Ignored. @@ -779,12 +779,12 @@ class SX128x: public PhysicalLayer { void readBit(uint32_t pin); #endif -#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) +#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: #endif Module* mod; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif @@ -817,14 +817,14 @@ class SX128x: public PhysicalLayer { int16_t setHeaderType(uint8_t hdrType, size_t len = 0xFF); -#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) +#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL private: #endif // common low-level SPI interface static int16_t SPIparseStatus(uint8_t in); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif // common parameters From 379c475d5e9eda4e82198c35bf252052476058af Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:15:21 +0100 Subject: [PATCH 14/32] [SX1231] Reworked macro configuration system --- src/modules/SX1231/SX1231.cpp | 2 +- src/modules/SX1231/SX1231.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index cc9e3409..7cce2cce 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -1,5 +1,5 @@ #include "SX1231.h" -#if !defined(RADIOLIB_EXCLUDE_SX1231) +#if !RADIOLIB_EXCLUDE_SX1231 SX1231::SX1231(Module* mod) : RF69(mod) { diff --git a/src/modules/SX1231/SX1231.h b/src/modules/SX1231/SX1231.h index 60540345..e9631a87 100644 --- a/src/modules/SX1231/SX1231.h +++ b/src/modules/SX1231/SX1231.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SX1231) +#if !RADIOLIB_EXCLUDE_SX1231 #include "../../Module.h" #include "../RF69/RF69.h" @@ -110,7 +110,7 @@ class SX1231: public RF69 { */ int16_t begin(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 125.0, int8_t power = 10, uint8_t preambleLen = 16); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif uint8_t chipRevision = 0; From fe0136b15c3dd10ead46b3c858f198bd979a7801 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:15:52 +0100 Subject: [PATCH 15/32] [AFSK] Reworked macro configuration system --- src/protocols/AFSK/AFSK.cpp | 2 +- src/protocols/AFSK/AFSK.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/protocols/AFSK/AFSK.cpp b/src/protocols/AFSK/AFSK.cpp index 6d7e518d..bf0ddc4c 100644 --- a/src/protocols/AFSK/AFSK.cpp +++ b/src/protocols/AFSK/AFSK.cpp @@ -1,5 +1,5 @@ #include "AFSK.h" -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK AFSKClient::AFSKClient(PhysicalLayer* phy, uint32_t pin): outPin(pin) { phyLayer = phy; diff --git a/src/protocols/AFSK/AFSK.h b/src/protocols/AFSK/AFSK.h index 3b69f308..ea48630e 100644 --- a/src/protocols/AFSK/AFSK.h +++ b/src/protocols/AFSK/AFSK.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK #include "../../Module.h" @@ -49,7 +49,7 @@ class AFSKClient { */ int16_t noTone(bool keepOn = false); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif PhysicalLayer* phyLayer; From 98054055bd128956f950585ce9d3977d1165ed5e Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:16:13 +0100 Subject: [PATCH 16/32] [APRS] Reworked macro configuration system --- src/protocols/APRS/APRS.cpp | 10 +++++----- src/protocols/APRS/APRS.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/protocols/APRS/APRS.cpp b/src/protocols/APRS/APRS.cpp index 3458272e..55b034d1 100644 --- a/src/protocols/APRS/APRS.cpp +++ b/src/protocols/APRS/APRS.cpp @@ -2,7 +2,7 @@ #include #include #include -#if !defined(RADIOLIB_EXCLUDE_APRS) +#if !RADIOLIB_EXCLUDE_APRS APRSClient::APRSClient(AX25Client* ax) { axClient = ax; @@ -42,7 +42,7 @@ int16_t APRSClient::sendPosition(char* destCallsign, uint8_t destSSID, char* lat if(time != NULL) { len += strlen(time); } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY char* info = new char[len + 1]; #else char info[RADIOLIB_STATIC_ARRAY_SIZE]; @@ -66,7 +66,7 @@ int16_t APRSClient::sendPosition(char* destCallsign, uint8_t destSSID, char* lat // send the frame int16_t state = sendFrame(destCallsign, destSSID, info); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] info; #endif return(state); @@ -89,7 +89,7 @@ int16_t APRSClient::sendMicE(float lat, float lon, uint16_t heading, uint16_t sp // prepare buffers char destCallsign[7]; - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY size_t infoLen = 10; if(telemLen > 0) { infoLen += 1 + telemLen; @@ -231,7 +231,7 @@ int16_t APRSClient::sendMicE(float lat, float lon, uint16_t heading, uint16_t sp destSSID = 1; } int16_t state = sendFrame(destCallsign, destSSID, info); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] info; #endif return(state); diff --git a/src/protocols/APRS/APRS.h b/src/protocols/APRS/APRS.h index ee74cfa0..8369a6f3 100644 --- a/src/protocols/APRS/APRS.h +++ b/src/protocols/APRS/APRS.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_APRS) +#if !RADIOLIB_EXCLUDE_APRS #include "../PhysicalLayer/PhysicalLayer.h" #include "../AX25/AX25.h" @@ -128,7 +128,7 @@ class APRSClient { */ int16_t sendFrame(char* destCallsign, uint8_t destSSID, char* info); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif AX25Client* axClient; From 6c07552f8433dda7c38c7d5888ef7b9068609681 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:16:34 +0100 Subject: [PATCH 17/32] [AX25] Reworked macro configuration system --- src/protocols/AX25/AX25.cpp | 30 +++++++++++++++--------------- src/protocols/AX25/AX25.h | 10 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index fc3e24e0..3c60072e 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -1,6 +1,6 @@ #include "AX25.h" #include -#if !defined(RADIOLIB_EXCLUDE_AX25) +#if !RADIOLIB_EXCLUDE_AX25 AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control) : AX25Frame(destCallsign, destSSID, srcCallsign, srcSSID, control, 0, NULL, 0) { @@ -25,7 +25,7 @@ AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* src // set repeaters this->numRepeaters = 0; - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY this->repeaterCallsigns = NULL; this->repeaterSSIDs = NULL; #endif @@ -43,7 +43,7 @@ AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* src // info field this->infoLen = infoLen; if(infoLen > 0) { - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY this->info = new uint8_t[infoLen]; #endif memcpy(this->info, info, infoLen); @@ -55,7 +55,7 @@ AX25Frame::AX25Frame(const AX25Frame& frame) { } AX25Frame::~AX25Frame() { - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY // deallocate info field if(infoLen > 0) { delete[] this->info; @@ -124,7 +124,7 @@ int16_t AX25Frame::setRepeaters(char** repeaterCallsigns, uint8_t* repeaterSSIDs } // create buffers - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY this->repeaterCallsigns = new char*[numRepeaters]; for(uint8_t i = 0; i < numRepeaters; i++) { this->repeaterCallsigns[i] = new char[strlen(repeaterCallsigns[i]) + 1]; @@ -153,12 +153,12 @@ void AX25Frame::setSendSequence(uint8_t seqNumber) { AX25Client::AX25Client(PhysicalLayer* phy) { phyLayer = phy; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK bellModem = nullptr; #endif } -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK AX25Client::AX25Client(AFSKClient* audio) { phyLayer = audio->phyLayer; bellModem = new BellClient(audio); @@ -194,7 +194,7 @@ int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t preL preambleLen = preLen; // configure for direct mode - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(bellModem != nullptr) { return(phyLayer->startDirect()); } @@ -226,7 +226,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { } // check repeater configuration - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY if(!(((frame->repeaterCallsigns == NULL) && (frame->repeaterSSIDs == NULL) && (frame->numRepeaters == 0)) || ((frame->repeaterCallsigns != NULL) && (frame->repeaterSSIDs != NULL) && (frame->numRepeaters != 0)))) { return(RADIOLIB_ERR_INVALID_NUM_REPEATERS); @@ -241,7 +241,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { // calculate frame length without FCS (destination address, source address, repeater addresses, control, PID, info) size_t frameBuffLen = ((2 + frame->numRepeaters)*(RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1)) + 1 + 1 + frame->infoLen; // create frame buffer without preamble, start or stop flags - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY uint8_t* frameBuff = new uint8_t[frameBuffLen + 2]; #else uint8_t frameBuff[RADIOLIB_STATIC_ARRAY_SIZE]; @@ -323,7 +323,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { *(frameBuffPtr++) = (uint8_t)(fcs & 0xFF); // prepare buffer for the final frame (stuffed, with added preamble + flags and NRZI-encoded) - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY // worst-case scenario: sequence of 1s, will have 120% of the original length, stuffed frame also includes both flags uint8_t* stuffedFrameBuff = new uint8_t[preambleLen + 1 + (6*frameBuffLen)/5 + 2]; #else @@ -367,7 +367,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { } // deallocate memory - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] frameBuff; #endif @@ -413,7 +413,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { // transmit int16_t state = RADIOLIB_ERR_NONE; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(bellModem != nullptr) { bellModem->idle(); @@ -427,12 +427,12 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { } else { #endif state = phyLayer->transmit(stuffedFrameBuff, stuffedFrameBuffLen); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK } #endif // deallocate memory - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] stuffedFrameBuff; #endif diff --git a/src/protocols/AX25/AX25.h b/src/protocols/AX25/AX25.h index 9d6c60a6..28ddd5aa 100644 --- a/src/protocols/AX25/AX25.h +++ b/src/protocols/AX25/AX25.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_AX25) +#if !RADIOLIB_EXCLUDE_AX25 #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -125,7 +125,7 @@ class AX25Frame { */ uint16_t sendSeqNumber; - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY /*! \brief The info field. */ @@ -243,7 +243,7 @@ class AX25Client { */ explicit AX25Client(PhysicalLayer* phy); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. @@ -303,13 +303,13 @@ class AX25Client { */ int16_t sendFrame(AX25Frame* frame); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif friend class APRSClient; PhysicalLayer* phyLayer; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK BellClient* bellModem; #endif From f85abafe19c1f057d13c4ccdd6c2edb93044d97d Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:16:43 +0100 Subject: [PATCH 18/32] [Bell] Reworked macro configuration system --- src/protocols/BellModem/BellModem.cpp | 2 +- src/protocols/BellModem/BellModem.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/protocols/BellModem/BellModem.cpp b/src/protocols/BellModem/BellModem.cpp index 087bde17..8d08943e 100644 --- a/src/protocols/BellModem/BellModem.cpp +++ b/src/protocols/BellModem/BellModem.cpp @@ -1,5 +1,5 @@ #include "BellModem.h" -#if !defined(RADIOLIB_EXCLUDE_BELL) +#if !RADIOLIB_EXCLUDE_BELL const struct BellModem_t Bell101 { .freqMark = 1270, diff --git a/src/protocols/BellModem/BellModem.h b/src/protocols/BellModem/BellModem.h index 13ab7106..b98479e4 100644 --- a/src/protocols/BellModem/BellModem.h +++ b/src/protocols/BellModem/BellModem.h @@ -7,7 +7,7 @@ #include "../../ArduinoHal.h" #endif -#if !defined(RADIOLIB_EXCLUDE_BELL) +#if !RADIOLIB_EXCLUDE_BELL #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -116,7 +116,7 @@ class BellClient: public AFSKClient, public RadioLibPrint { */ int16_t standby(); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif BellModem_t modemType; From 71dbf371e7d57eca2878e2094a7d171f18315613 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:16:56 +0100 Subject: [PATCH 19/32] [FSK4] Reworked macro configuration system --- src/protocols/FSK4/FSK4.cpp | 10 +++++----- src/protocols/FSK4/FSK4.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/protocols/FSK4/FSK4.cpp b/src/protocols/FSK4/FSK4.cpp index bb24e5be..f589f459 100644 --- a/src/protocols/FSK4/FSK4.cpp +++ b/src/protocols/FSK4/FSK4.cpp @@ -1,15 +1,15 @@ #include "FSK4.h" #include -#if !defined(RADIOLIB_EXCLUDE_FSK4) +#if !RADIOLIB_EXCLUDE_FSK4 FSK4Client::FSK4Client(PhysicalLayer* phy) { phyLayer = phy; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK audioClient = nullptr; #endif } -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK FSK4Client::FSK4Client(AFSKClient* audio) { phyLayer = audio->phyLayer; audioClient = audio; @@ -87,7 +87,7 @@ void FSK4Client::tone(uint8_t i) { } int16_t FSK4Client::transmitDirect(uint32_t freq, uint32_t freqHz) { - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { return(audioClient->tone(freqHz)); } @@ -99,7 +99,7 @@ int16_t FSK4Client::standby() { // ensure everything is stopped in interrupt timing mode Module* mod = phyLayer->getMod(); mod->waitForMicroseconds(0, 0); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { return(audioClient->noTone()); } diff --git a/src/protocols/FSK4/FSK4.h b/src/protocols/FSK4/FSK4.h index d466d642..a1e91e37 100644 --- a/src/protocols/FSK4/FSK4.h +++ b/src/protocols/FSK4/FSK4.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_FSK4) +#if !RADIOLIB_EXCLUDE_FSK4 #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -20,7 +20,7 @@ class FSK4Client { */ explicit FSK4Client(PhysicalLayer* phy); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. @@ -74,11 +74,11 @@ class FSK4Client { */ int16_t standby(); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif PhysicalLayer* phyLayer; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK AFSKClient* audioClient; #endif From ac18a2c8f79b3d1c6b2d1a954f9163791f854bf1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:17:06 +0100 Subject: [PATCH 20/32] [Hell] Reworked macro configuration system --- src/protocols/Hellschreiber/Hellschreiber.cpp | 10 +++++----- src/protocols/Hellschreiber/Hellschreiber.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/protocols/Hellschreiber/Hellschreiber.cpp b/src/protocols/Hellschreiber/Hellschreiber.cpp index 06eaae79..f23bc40f 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.cpp +++ b/src/protocols/Hellschreiber/Hellschreiber.cpp @@ -1,16 +1,16 @@ #include "Hellschreiber.h" -#if !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER) +#if !RADIOLIB_EXCLUDE_HELLSCHREIBER HellClient::HellClient(PhysicalLayer* phy) { phyLayer = phy; lineFeed = " "; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK audioClient = nullptr; #endif } -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK HellClient::HellClient(AFSKClient* audio) { phyLayer = audio->phyLayer; lineFeed = " "; @@ -82,7 +82,7 @@ size_t HellClient::write(uint8_t b) { } int16_t HellClient::transmitDirect(uint32_t freq, uint32_t freqHz) { - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { return(audioClient->tone(freqHz)); } @@ -91,7 +91,7 @@ int16_t HellClient::transmitDirect(uint32_t freq, uint32_t freqHz) { } int16_t HellClient::standby() { - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { return(audioClient->noTone(invert)); } diff --git a/src/protocols/Hellschreiber/Hellschreiber.h b/src/protocols/Hellschreiber/Hellschreiber.h index 7855dee8..3ee42174 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.h +++ b/src/protocols/Hellschreiber/Hellschreiber.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER) +#if !RADIOLIB_EXCLUDE_HELLSCHREIBER #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -95,7 +95,7 @@ class HellClient: public RadioLibPrint { */ explicit HellClient(PhysicalLayer* phy); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. @@ -132,11 +132,11 @@ class HellClient: public RadioLibPrint { */ size_t write(uint8_t b); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif PhysicalLayer* phyLayer; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK AFSKClient* audioClient; #endif From 670e70bd9fb8054b219193e26f121ed8d5414d88 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:17:26 +0100 Subject: [PATCH 21/32] [LoRaWAN] Reworked macro configuration system --- src/protocols/LoRaWAN/LoRaWAN.cpp | 34 +++++++++++++------------- src/protocols/LoRaWAN/LoRaWAN.h | 4 +-- src/protocols/LoRaWAN/LoRaWANBands.cpp | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index 99c93549..575943c7 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -1,7 +1,7 @@ #include "LoRaWAN.h" #include -#if !defined(RADIOLIB_EXCLUDE_LORAWAN) +#if !RADIOLIB_EXCLUDE_LORAWAN #if defined(RADIOLIB_EEPROM_UNSUPPORTED) #warning "Persistent storage not supported!" @@ -65,7 +65,7 @@ int16_t LoRaWANNode::restore() { // check the magic value if(mod->hal->getPersistentParameter(RADIOLIB_PERSISTENT_PARAM_LORAWAN_MAGIC_ID) != RADIOLIB_LORAWAN_MAGIC) { - #if defined(RADIOLIB_DEBUG) + #if RADIOLIB_DEBUG RADIOLIB_DEBUG_PRINTLN("magic id not set (no saved session)"); RADIOLIB_DEBUG_PRINTLN("first 16 bytes of NVM:"); uint8_t nvmBuff[16]; @@ -148,7 +148,7 @@ int16_t LoRaWANNode::restoreFcntUp() { uint8_t fcntBuffStart = mod->hal->getPersistentAddr(RADIOLIB_PERSISTENT_PARAM_LORAWAN_FCNT_UP_ID); uint8_t fcntBuffEnd = mod->hal->getPersistentAddr(RADIOLIB_PERSISTENT_PARAM_LORAWAN_FCNT_UP_ID + 1); uint8_t buffSize = fcntBuffEnd - fcntBuffStart; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t fcntBuff[RADIOLIB_STATIC_ARRAY_SIZE]; #else uint8_t* fcntBuff = new uint8_t[buffSize]; @@ -182,7 +182,7 @@ int16_t LoRaWANNode::restoreFcntUp() { } } uint32_t bits_7_0 = (uint32_t)fcntBuff[idx-1] & 0x7F; - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] fcntBuff; #endif @@ -764,7 +764,7 @@ int16_t LoRaWANNode::uplink(uint8_t* data, size_t len, uint8_t port, bool isConf // build the uplink message // the first 16 bytes are reserved for MIC calculation blocks size_t uplinkMsgLen = RADIOLIB_LORAWAN_FRAME_LEN(len, foptsBufSize); - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t uplinkMsg[RADIOLIB_STATIC_ARRAY_SIZE]; #else uint8_t* uplinkMsg = new uint8_t[uplinkMsgLen]; @@ -891,7 +891,7 @@ int16_t LoRaWANNode::uplink(uint8_t* data, size_t len, uint8_t port, bool isConf this->rxDelayStart = mod->hal->millis(); RADIOLIB_DEBUG_PRINTLN("Uplink sent <-- Rx Delay start"); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] uplinkMsg; #endif RADIOLIB_ASSERT(state); @@ -1060,7 +1060,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) // build the buffer for the downlink message // the first 16 bytes are reserved for MIC calculation block - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY uint8_t* downlinkMsg = new uint8_t[RADIOLIB_AES128_BLOCK_SIZE + downlinkMsgLen]; #else uint8_t downlinkMsg[RADIOLIB_STATIC_ARRAY_SIZE]; @@ -1082,7 +1082,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) } if(state != RADIOLIB_ERR_NONE) { - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] downlinkMsg; #endif return(state); @@ -1127,7 +1127,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) uint32_t fcnt32 = fcnt16; if(fcntDownPrev > 0) { if((fcnt16 <= fcntDownPrev) && ((0xFFFF - (uint16_t)fcntDownPrev + fcnt16) > RADIOLIB_LORAWAN_MAX_FCNT_GAP)) { - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] downlinkMsg; #endif if (isAppDownlink) { @@ -1143,7 +1143,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) // check the MIC if(!verifyMIC(downlinkMsg, RADIOLIB_AES128_BLOCK_SIZE + downlinkMsgLen, this->sNwkSIntKey)) { - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] downlinkMsg; #endif return(RADIOLIB_ERR_CRC_MISMATCH); @@ -1167,7 +1167,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) uint32_t addr = LoRaWANNode::ntoh(&downlinkMsg[RADIOLIB_LORAWAN_FHDR_DEV_ADDR_POS]); if(addr != this->devAddr) { RADIOLIB_DEBUG_PRINTLN("Device address mismatch, expected 0x%08X, got 0x%08X", this->devAddr, addr); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] downlinkMsg; #endif return(RADIOLIB_ERR_DOWNLINK_MALFORMED); @@ -1209,7 +1209,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) // if FOptsLen for the next uplink is larger than can be piggybacked onto an uplink, send separate uplink if(this->commandsUp.len > 15) { size_t foptsBufSize = this->commandsUp.len; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t foptsBuff[RADIOLIB_STATIC_ARRAY_SIZE]; #else uint8_t* foptsBuff = new uint8_t[foptsBufSize]; @@ -1236,18 +1236,18 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) this->isMACPayload = true; this->uplink(foptsBuff, foptsBufSize, RADIOLIB_LORAWAN_FPORT_MAC_COMMAND); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] foptsBuff; #endif - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t strDown[RADIOLIB_STATIC_ARRAY_SIZE]; #else uint8_t* strDown = new uint8_t[this->band->payloadLenMax[this->dataRates[RADIOLIB_LORAWAN_CHANNEL_DIR_DOWNLINK]]]; #endif size_t lenDown = 0; state = this->downlink(strDown, &lenDown); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] strDown; #endif RADIOLIB_ASSERT(state); @@ -1274,7 +1274,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) if(payLen <= 0) { // no payload *len = 0; - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] downlinkMsg; #endif @@ -1288,7 +1288,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) // TODO it COULD be the case that the assumed rollover is incorrect, then figure out a way to catch this and retry with just fcnt16 processAES(&downlinkMsg[RADIOLIB_LORAWAN_FRAME_PAYLOAD_POS(foptsLen)], payLen - 1, this->appSKey, data, fcnt32, RADIOLIB_LORAWAN_CHANNEL_DIR_DOWNLINK, 0x00, true); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] downlinkMsg; #endif diff --git a/src/protocols/LoRaWAN/LoRaWAN.h b/src/protocols/LoRaWAN/LoRaWAN.h index 30ff2512..ee1d6b95 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.h +++ b/src/protocols/LoRaWAN/LoRaWAN.h @@ -1,4 +1,4 @@ -#if !defined(_RADIOLIB_LORAWAN_H) && !defined(RADIOLIB_EXCLUDE_LORAWAN) +#if !defined(_RADIOLIB_LORAWAN_H) && !RADIOLIB_EXCLUDE_LORAWAN #define _RADIOLIB_LORAWAN_H #include "../../TypeDef.h" @@ -572,7 +572,7 @@ class LoRaWANNode { */ void setCSMA(uint8_t backoffMax, uint8_t difsSlots, bool enableCSMA = false); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif PhysicalLayer* phyLayer = NULL; diff --git a/src/protocols/LoRaWAN/LoRaWANBands.cpp b/src/protocols/LoRaWAN/LoRaWANBands.cpp index 8e36f9c2..7b0e04cf 100644 --- a/src/protocols/LoRaWAN/LoRaWANBands.cpp +++ b/src/protocols/LoRaWAN/LoRaWANBands.cpp @@ -1,6 +1,6 @@ #include "LoRaWAN.h" -#if !defined(RADIOLIB_EXCLUDE_LORAWAN) +#if !RADIOLIB_EXCLUDE_LORAWAN const LoRaWANBand_t EU868 = { .bandType = RADIOLIB_LORAWAN_BAND_DYNAMIC, From 8f5cff0cd41a49e1a887762ba87d28832851e614 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:17:35 +0100 Subject: [PATCH 22/32] [Morse] Reworked macro configuration system --- src/protocols/Morse/Morse.cpp | 12 ++++++------ src/protocols/Morse/Morse.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/protocols/Morse/Morse.cpp b/src/protocols/Morse/Morse.cpp index 27cb5eac..8ec0c469 100644 --- a/src/protocols/Morse/Morse.cpp +++ b/src/protocols/Morse/Morse.cpp @@ -2,17 +2,17 @@ #include -#if !defined(RADIOLIB_EXCLUDE_MORSE) +#if !RADIOLIB_EXCLUDE_MORSE MorseClient::MorseClient(PhysicalLayer* phy) { phyLayer = phy; lineFeed = "^"; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK audioClient = nullptr; #endif } -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK MorseClient::MorseClient(AFSKClient* audio) { phyLayer = audio->phyLayer; lineFeed = "^"; @@ -59,7 +59,7 @@ char MorseClient::decode(uint8_t symbol, uint8_t len) { return(RADIOLIB_MORSE_UNSUPPORTED); } -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK int MorseClient::read(uint8_t* symbol, uint8_t* len, float low, float high) { Module* mod = phyLayer->getMod(); @@ -167,7 +167,7 @@ size_t MorseClient::write(uint8_t b) { } int16_t MorseClient::transmitDirect(uint32_t freq, uint32_t freqHz) { - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { return(audioClient->tone(freqHz)); } @@ -176,7 +176,7 @@ int16_t MorseClient::transmitDirect(uint32_t freq, uint32_t freqHz) { } int16_t MorseClient::standby() { - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { return(audioClient->noTone(true)); } diff --git a/src/protocols/Morse/Morse.h b/src/protocols/Morse/Morse.h index df44bc1f..3c995c42 100644 --- a/src/protocols/Morse/Morse.h +++ b/src/protocols/Morse/Morse.h @@ -1,4 +1,4 @@ -#if !defined(_RADIOLIB_RADIOLIB_MORSE_H) && !defined(RADIOLIB_EXCLUDE_MORSE) +#if !defined(_RADIOLIB_RADIOLIB_MORSE_H) && !RADIOLIB_EXCLUDE_MORSE #define _RADIOLIB_RADIOLIB_MORSE_H #include "../../TypeDef.h" @@ -98,7 +98,7 @@ class MorseClient: public RadioLibPrint { */ explicit MorseClient(PhysicalLayer* phy); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. @@ -139,7 +139,7 @@ class MorseClient: public RadioLibPrint { \returns 0 if not enough symbols were decoded, 1 if inter-character space was detected, 2 if inter-word space was detected. */ - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK int read(uint8_t* symbol, uint8_t* len, float low = 0.75f, float high = 1.25f); #endif @@ -150,11 +150,11 @@ class MorseClient: public RadioLibPrint { */ size_t write(uint8_t b); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif PhysicalLayer* phyLayer; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK AFSKClient* audioClient; #endif From 074b707924cfe5bd047555221e49f4fe64da6731 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:17:45 +0100 Subject: [PATCH 23/32] [Pager] Reworked macro configuration system --- src/protocols/Pager/Pager.cpp | 18 +++++++++--------- src/protocols/Pager/Pager.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/protocols/Pager/Pager.cpp b/src/protocols/Pager/Pager.cpp index 1416247a..6b9ade4f 100644 --- a/src/protocols/Pager/Pager.cpp +++ b/src/protocols/Pager/Pager.cpp @@ -1,9 +1,9 @@ #include "Pager.h" #include #include -#if !defined(RADIOLIB_EXCLUDE_PAGER) +#if !RADIOLIB_EXCLUDE_PAGER -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE // this is a massive hack, but we need a global-scope ISR to manage the bit reading // let's hope nobody ever tries running two POCSAG receivers at the same time static PhysicalLayer* readBitInstance = NULL; @@ -21,7 +21,7 @@ static void PagerClientReadBit(void) { PagerClient::PagerClient(PhysicalLayer* phy) { phyLayer = phy; - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE readBitInstance = phyLayer; #endif } @@ -127,7 +127,7 @@ int16_t PagerClient::transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t // calculate message length in 32-bit code words size_t msgLen = RADIOLIB_PAGER_PREAMBLE_LENGTH + (1 + RADIOLIB_PAGER_BATCH_LEN) * numBatches; - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint32_t msg[RADIOLIB_STATIC_ARRAY_SIZE]; #else uint32_t* msg = new uint32_t[msgLen]; @@ -225,7 +225,7 @@ int16_t PagerClient::transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t // transmit the message PagerClient::write(msg, msgLen); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] msg; #endif @@ -235,7 +235,7 @@ int16_t PagerClient::transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t return(RADIOLIB_ERR_NONE); } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE int16_t PagerClient::startReceive(uint32_t pin, uint32_t addr, uint32_t mask) { // save the variables readBitPin = pin; @@ -289,7 +289,7 @@ int16_t PagerClient::readData(String& str, size_t len, uint32_t* addr) { } // build a temporary buffer - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1]; #else uint8_t* data = new uint8_t[length + 1]; @@ -316,7 +316,7 @@ int16_t PagerClient::readData(String& str, size_t len, uint32_t* addr) { } // deallocate temporary buffer - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] data; #endif @@ -496,7 +496,7 @@ void PagerClient::write(uint32_t codeWord) { } } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE uint32_t PagerClient::read() { uint32_t codeWord = 0; codeWord |= (uint32_t)phyLayer->read() << 24; diff --git a/src/protocols/Pager/Pager.h b/src/protocols/Pager/Pager.h index a7ecef46..11b9c4dd 100644 --- a/src/protocols/Pager/Pager.h +++ b/src/protocols/Pager/Pager.h @@ -1,4 +1,4 @@ -#if !defined(_RADIOLIB_PAGER_H) && !defined(RADIOLIB_EXCLUDE_PAGER) +#if !defined(_RADIOLIB_PAGER_H) && !RADIOLIB_EXCLUDE_PAGER #define _RADIOLIB_PAGER_H #include "../../TypeDef.h" @@ -119,7 +119,7 @@ class PagerClient { */ int16_t transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t encoding = RADIOLIB_PAGER_BCD, uint8_t function = RADIOLIB_PAGER_FUNC_AUTO); - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE /*! \brief Start reception of POCSAG packets. \param pin Pin to receive digital data on (e.g., DIO2 for SX127x). @@ -162,7 +162,7 @@ class PagerClient { int16_t readData(uint8_t* data, size_t* len, uint32_t* addr = NULL); #endif -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif PhysicalLayer* phyLayer; @@ -180,7 +180,7 @@ class PagerClient { void write(uint32_t* data, size_t len); void write(uint32_t codeWord); -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE uint32_t read(); #endif From 395101ec2045cec8a7631581e3e35fa74b00ec2c Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:17:58 +0100 Subject: [PATCH 24/32] [PHY] Reworked macro configuration system --- src/protocols/PhysicalLayer/PhysicalLayer.cpp | 18 +++++++++--------- src/protocols/PhysicalLayer/PhysicalLayer.h | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index 0bb634f9..8b999325 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -4,7 +4,7 @@ PhysicalLayer::PhysicalLayer(float step, size_t maxLen) { this->freqStep = step; this->maxPacketLength = maxLen; - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE this->bufferBitPos = 0; this->bufferWritePos = 0; #endif @@ -24,7 +24,7 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) { } // dynamically allocate memory - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY char str[RADIOLIB_STATIC_ARRAY_SIZE]; #else char* str = new char[len]; @@ -38,7 +38,7 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) { // transmit string int16_t state = transmit(str, addr); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] str; #endif return(state); @@ -68,7 +68,7 @@ int16_t PhysicalLayer::receive(String& str, size_t len) { size_t length = len; // build a temporary buffer - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1]; #else uint8_t* data = NULL; @@ -101,7 +101,7 @@ int16_t PhysicalLayer::receive(String& str, size_t len) { } // deallocate temporary buffer - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] data; #endif @@ -175,7 +175,7 @@ int16_t PhysicalLayer::readData(String& str, size_t len) { } // build a temporary buffer - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1]; #else uint8_t* data = new uint8_t[length + 1]; @@ -198,7 +198,7 @@ int16_t PhysicalLayer::readData(String& str, size_t len) { } // deallocate temporary buffer - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] data; #endif @@ -366,7 +366,7 @@ int16_t PhysicalLayer::startDirect() { return(state); } -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE int16_t PhysicalLayer::available() { return(this->bufferWritePos); } @@ -477,7 +477,7 @@ void PhysicalLayer::clearChannelScanAction() { } -#if defined(RADIOLIB_INTERRUPT_TIMING) +#if RADIOLIB_INTERRUPT_TIMING void PhysicalLayer::setInterruptSetup(void (*func)(uint32_t)) { Module* mod = getMod(); mod->TimerSetupCb = func; diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.h b/src/protocols/PhysicalLayer/PhysicalLayer.h index 741cdb8c..513a3e1d 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.h +++ b/src/protocols/PhysicalLayer/PhysicalLayer.h @@ -380,7 +380,7 @@ class PhysicalLayer { */ int16_t startDirect(); - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE /*! \brief Set sync word to be used to determine start of packet in direct reception mode. \param syncWord Sync word bits. @@ -463,7 +463,7 @@ class PhysicalLayer { */ virtual void clearChannelScanAction(); - #if defined(RADIOLIB_INTERRUPT_TIMING) + #if RADIOLIB_INTERRUPT_TIMING /*! \brief Set function to be called to set up the timing interrupt. @@ -480,18 +480,18 @@ class PhysicalLayer { #endif -#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) +#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE protected: void updateDirectBuffer(uint8_t bit); #endif -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif float freqStep; size_t maxPacketLength; - #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) + #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE uint8_t bufferBitPos; uint8_t bufferWritePos; uint8_t bufferReadPos; From e6a6923b25d96904e95c27b70bad76f0f7c4974a Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:18:10 +0100 Subject: [PATCH 25/32] [Print] Reworked macro configuration system --- src/protocols/Print/ITA2String.cpp | 10 +++++----- src/protocols/Print/ITA2String.h | 4 ++-- src/protocols/Print/Print.cpp | 4 ++-- src/protocols/Print/Print.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/protocols/Print/ITA2String.cpp b/src/protocols/Print/ITA2String.cpp index b162b259..4f2d99a7 100644 --- a/src/protocols/Print/ITA2String.cpp +++ b/src/protocols/Print/ITA2String.cpp @@ -4,7 +4,7 @@ ITA2String::ITA2String(char c) { asciiLen = 1; - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY strAscii = new char[1]; #endif strAscii[0] = c; @@ -13,7 +13,7 @@ ITA2String::ITA2String(char c) { ITA2String::ITA2String(const char* str) { asciiLen = strlen(str); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY strAscii = new char[asciiLen + 1]; #endif strcpy(strAscii, str); @@ -21,7 +21,7 @@ ITA2String::ITA2String(const char* str) { } ITA2String::~ITA2String() { - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] strAscii; #endif } @@ -40,7 +40,7 @@ size_t ITA2String::length() { uint8_t* ITA2String::byteArr() { // create temporary array 2x the string length (figures may be 3 bytes) - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY uint8_t temp[RADIOLIB_STATIC_ARRAY_SIZE*2 + 1]; #else uint8_t* temp = new uint8_t[asciiLen*2 + 1]; @@ -87,7 +87,7 @@ uint8_t* ITA2String::byteArr() { uint8_t* arr = new uint8_t[arrayLen]; memcpy(arr, temp, arrayLen); - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] temp; #endif diff --git a/src/protocols/Print/ITA2String.h b/src/protocols/Print/ITA2String.h index 556c0a3b..579bb1c4 100644 --- a/src/protocols/Print/ITA2String.h +++ b/src/protocols/Print/ITA2String.h @@ -53,10 +53,10 @@ class ITA2String { */ uint8_t* byteArr(); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY char strAscii[RADIOLIB_STATIC_ARRAY_SIZE]; #else char* strAscii; diff --git a/src/protocols/Print/Print.cpp b/src/protocols/Print/Print.cpp index f944ec75..94b7b334 100644 --- a/src/protocols/Print/Print.cpp +++ b/src/protocols/Print/Print.cpp @@ -42,7 +42,7 @@ size_t RadioLibPrint::print(const __FlashStringHelper* fstr) { } // dynamically allocate memory - #if defined(RADIOLIB_STATIC_ONLY) + #if RADIOLIB_STATIC_ONLY char str[RADIOLIB_STATIC_ARRAY_SIZE]; #else char* str = new char[len]; @@ -61,7 +61,7 @@ size_t RadioLibPrint::print(const __FlashStringHelper* fstr) { } else { n = write((uint8_t*)str, len); } - #if !defined(RADIOLIB_STATIC_ONLY) + #if !RADIOLIB_STATIC_ONLY delete[] str; #endif return(n); diff --git a/src/protocols/Print/Print.h b/src/protocols/Print/Print.h index a132cf61..48bd7e70 100644 --- a/src/protocols/Print/Print.h +++ b/src/protocols/Print/Print.h @@ -53,7 +53,7 @@ class RadioLibPrint { size_t println(double, int = 2); size_t println(void); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE protected: #endif uint8_t encoding = RADIOLIB_ASCII_EXTENDED; From eddde76371dcee46eb42f87540b2976756f5da9a Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:18:20 +0100 Subject: [PATCH 26/32] [RTTY] Reworked macro configuration system --- src/protocols/RTTY/RTTY.cpp | 10 +++++----- src/protocols/RTTY/RTTY.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index eff2d7ad..c823fb28 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -2,17 +2,17 @@ #include -#if !defined(RADIOLIB_EXCLUDE_RTTY) +#if !RADIOLIB_EXCLUDE_RTTY RTTYClient::RTTYClient(PhysicalLayer* phy) { phyLayer = phy; lineFeed = "\r\n"; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK audioClient = nullptr; #endif } -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK RTTYClient::RTTYClient(AFSKClient* audio) { phyLayer = audio->phyLayer; lineFeed = "\r\n"; @@ -104,7 +104,7 @@ void RTTYClient::space() { } int16_t RTTYClient::transmitDirect(uint32_t freq, uint32_t freqHz) { - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { return(audioClient->tone(freqHz)); } @@ -116,7 +116,7 @@ int16_t RTTYClient::standby() { // ensure everything is stopped in interrupt timing mode Module* mod = phyLayer->getMod(); mod->waitForMicroseconds(0, 0); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { return(audioClient->noTone()); } diff --git a/src/protocols/RTTY/RTTY.h b/src/protocols/RTTY/RTTY.h index 4ebbc7cc..4da4ca63 100644 --- a/src/protocols/RTTY/RTTY.h +++ b/src/protocols/RTTY/RTTY.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_RTTY) +#if !RADIOLIB_EXCLUDE_RTTY #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -22,7 +22,7 @@ class RTTYClient: public RadioLibPrint { */ explicit RTTYClient(PhysicalLayer* phy); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. @@ -61,11 +61,11 @@ class RTTYClient: public RadioLibPrint { */ size_t write(uint8_t b); -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif PhysicalLayer* phyLayer; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK AFSKClient* audioClient; #endif From 974c027452afa896300004795b9009b04c125ae6 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:19:04 +0100 Subject: [PATCH 27/32] [SSTV] Reworked macro configuration system --- src/protocols/SSTV/SSTV.cpp | 10 +++++----- src/protocols/SSTV/SSTV.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index 107674fd..b06df297 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -1,5 +1,5 @@ #include "SSTV.h" -#if !defined(RADIOLIB_EXCLUDE_SSTV) +#if !RADIOLIB_EXCLUDE_SSTV const SSTVMode_t Scottie1 { .visCode = RADIOLIB_SSTV_SCOTTIE_1, @@ -156,19 +156,19 @@ const SSTVMode_t PasokonP7 { SSTVClient::SSTVClient(PhysicalLayer* phy) { phyLayer = phy; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK audioClient = nullptr; #endif } -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK SSTVClient::SSTVClient(AFSKClient* audio) { phyLayer = audio->phyLayer; audioClient = audio; } #endif -#if !defined(RADIOLIB_EXCLUDE_AFSK) +#if !RADIOLIB_EXCLUDE_AFSK int16_t SSTVClient::begin(const SSTVMode_t& mode) { if(audioClient == nullptr) { // this initialization method can only be used in AFSK mode @@ -292,7 +292,7 @@ uint16_t SSTVClient::getPictureHeight() const { void SSTVClient::tone(float freq, uint32_t len) { Module* mod = phyLayer->getMod(); uint32_t start = mod->hal->micros(); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK if(audioClient != nullptr) { audioClient->tone(freq, false); } else { diff --git a/src/protocols/SSTV/SSTV.h b/src/protocols/SSTV/SSTV.h index df73d8f2..cbf69d8c 100644 --- a/src/protocols/SSTV/SSTV.h +++ b/src/protocols/SSTV/SSTV.h @@ -3,7 +3,7 @@ #include "../../TypeDef.h" -#if !defined(RADIOLIB_EXCLUDE_SSTV) +#if !RADIOLIB_EXCLUDE_SSTV #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -122,7 +122,7 @@ class SSTVClient { */ explicit SSTVClient(PhysicalLayer* phy); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. @@ -141,7 +141,7 @@ class SSTVClient { */ int16_t begin(float base, const SSTVMode_t& mode); - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK /*! \brief Initialization method for AFSK. \param mode SSTV mode to be used. Currently supported modes are Scottie1, Scottie2, @@ -182,11 +182,11 @@ class SSTVClient { */ uint16_t getPictureHeight() const; -#if !defined(RADIOLIB_GODMODE) +#if !RADIOLIB_GODMODE private: #endif PhysicalLayer* phyLayer; - #if !defined(RADIOLIB_EXCLUDE_AFSK) + #if !RADIOLIB_EXCLUDE_AFSK AFSKClient* audioClient; #endif From 34d2bc85b3fd12e5b05f93eba385a742b41f250e Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Nov 2023 21:24:32 +0100 Subject: [PATCH 28/32] Print debug info correctly --- src/RadioLib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RadioLib.h b/src/RadioLib.h index 3fd9632a..df54fc51 100644 --- a/src/RadioLib.h +++ b/src/RadioLib.h @@ -52,7 +52,7 @@ #endif // print debug info -#if defined(RADIOLIB_DEBUG) +#if RADIOLIB_DEBUG #define RADIOLIB_VALUE_TO_STRING(x) #x #define RADIOLIB_VALUE(x) RADIOLIB_VALUE_TO_STRING(x) #pragma message("\nRadioLib Debug Info\nVersion: \"" \ From 94bd83329d4c5e73acd21815f40dfd538e3d7501 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 29 Nov 2023 17:31:00 +0100 Subject: [PATCH 29/32] Bump version to 6.3.0 --- library.json | 2 +- library.properties | 2 +- src/BuildOpt.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 55a0bc46..9822a1c0 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "RadioLib", - "version": "6.2.0", + "version": "6.3.0", "description": "Universal wireless communication library. User-friendly library for sub-GHz radio modules (SX1278, RF69, CC1101, SX1268, and many others), as well as ham radio digital modes (RTTY, SSTV, AX.25 etc.) and other protocols (Pagers, LoRaWAN).", "keywords": "radio, communication, morse, cc1101, aprs, sx1276, sx1278, sx1272, rtty, ax25, afsk, nrf24, rfm96, sx1231, rfm96, rfm98, sstv, sx1278, sx1272, sx1276, sx1280, sx1281, sx1282, sx1261, sx1262, sx1268, si4432, rfm22, llcc68, pager, pocsag, lorawan", "homepage": "https://github.com/jgromes/RadioLib", diff --git a/library.properties b/library.properties index 1a4c6ebe..8dda9bb6 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=6.2.0 +version=6.3.0 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library diff --git a/src/BuildOpt.h b/src/BuildOpt.h index f2b9bc31..308dc896 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -528,7 +528,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR 6 -#define RADIOLIB_VERSION_MINOR 2 +#define RADIOLIB_VERSION_MINOR 3 #define RADIOLIB_VERSION_PATCH 0 #define RADIOLIB_VERSION_EXTRA 0 From 14a2238ca6b19987a420534d306d685d77780efb Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:18:13 +0000 Subject: [PATCH 30/32] Update SX128x.h --- src/modules/SX128x/SX128x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index b2e63bbd..4029635f 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -310,7 +310,7 @@ #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_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 From ed15ce3569082ce1e6cab867ac16f0dfe27c5626 Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:23:45 +0000 Subject: [PATCH 31/32] Remove double '_RADIOLIB's --- src/protocols/APRS/APRS.h | 4 ++-- src/protocols/AX25/AX25.h | 4 ++-- src/protocols/Morse/Morse.h | 4 ++-- src/protocols/SSTV/SSTV.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/protocols/APRS/APRS.h b/src/protocols/APRS/APRS.h index 8369a6f3..66555334 100644 --- a/src/protocols/APRS/APRS.h +++ b/src/protocols/APRS/APRS.h @@ -1,5 +1,5 @@ -#if !defined(_RADIOLIB_RADIOLIB_APRS_H) -#define _RADIOLIB_RADIOLIB_APRS_H +#if !defined(_RADIOLIB_APRS_H) +#define _RADIOLIB_APRS_H #include "../../TypeDef.h" diff --git a/src/protocols/AX25/AX25.h b/src/protocols/AX25/AX25.h index 28ddd5aa..d1688d9e 100644 --- a/src/protocols/AX25/AX25.h +++ b/src/protocols/AX25/AX25.h @@ -1,5 +1,5 @@ -#if !defined(_RADIOLIB_RADIOLIB_AX25_H) -#define _RADIOLIB_RADIOLIB_AX25_H +#if !defined(_RADIOLIB_AX25_H) +#define _RADIOLIB_AX25_H #include "../../TypeDef.h" diff --git a/src/protocols/Morse/Morse.h b/src/protocols/Morse/Morse.h index 3c995c42..3edb0bea 100644 --- a/src/protocols/Morse/Morse.h +++ b/src/protocols/Morse/Morse.h @@ -1,5 +1,5 @@ -#if !defined(_RADIOLIB_RADIOLIB_MORSE_H) && !RADIOLIB_EXCLUDE_MORSE -#define _RADIOLIB_RADIOLIB_MORSE_H +#if !defined(_RADIOLIB_MORSE_H) && !RADIOLIB_EXCLUDE_MORSE +#define _RADIOLIB_MORSE_H #include "../../TypeDef.h" #include "../PhysicalLayer/PhysicalLayer.h" diff --git a/src/protocols/SSTV/SSTV.h b/src/protocols/SSTV/SSTV.h index cbf69d8c..986dd0cb 100644 --- a/src/protocols/SSTV/SSTV.h +++ b/src/protocols/SSTV/SSTV.h @@ -1,5 +1,5 @@ -#if !defined(_RADIOLIB_RADIOLIB_SSTV_H) -#define _RADIOLIB_RADIOLIB_SSTV_H +#if !defined(_RADIOLIB_SSTV_H) +#define _RADIOLIB_SSTV_H #include "../../TypeDef.h" From 79fbe9be8e9924c86d595e00c16edc70e1ee5a28 Mon Sep 17 00:00:00 2001 From: Andrzej Perczak Date: Fri, 8 Dec 2023 18:34:21 +0100 Subject: [PATCH 32/32] LoRaWAN: Fix uninitialized variables --- src/protocols/LoRaWAN/LoRaWAN.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocols/LoRaWAN/LoRaWAN.h b/src/protocols/LoRaWAN/LoRaWAN.h index ee1d6b95..82960f53 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.h +++ b/src/protocols/LoRaWAN/LoRaWAN.h @@ -350,7 +350,7 @@ class LoRaWANNode { public: // Offset between TX and RX1 (such that RX1 has equal or lower DR) - uint8_t rx1DrOffset; + uint8_t rx1DrOffset = 0; // RX2 channel properties - may be changed by MAC command LoRaWANChannel_t rx2; @@ -616,7 +616,7 @@ class LoRaWANNode { uint32_t adrFcnt = 0; // whether the current configured channel is in FSK mode - bool FSK; + bool FSK = false; // flag that shows whether the device is joined and there is an ongoing session bool isJoinedFlag = false;