From ebfa2f8e3611a6a825f71ece12059c4a1cd56e89 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 14 Apr 2020 10:54:44 +0200 Subject: [PATCH 001/455] [Hell] Added missing link to docs --- src/RadioLib.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/RadioLib.h b/src/RadioLib.h index 04ea18e7..cc9bc83c 100644 --- a/src/RadioLib.h +++ b/src/RadioLib.h @@ -22,6 +22,7 @@ - Morse Code (MorseClient) - AX.25 (AX25Client) - SSTV (SSTVClient) + - Hellschreiber (HellClient) - TransportLayer protocols - HTTP (HTTPClient) - MQTT (MQTTClient) From 976cd8734cabd15b9bbb5627023dac039829cad7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 14 Apr 2020 10:59:13 +0200 Subject: [PATCH 002/455] Bump version to 3.5.0 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 21975e9d..9113c270 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=3.4.0 +version=3.5.0 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 063a8e05..ff46595a 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -189,7 +189,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x03) -#define RADIOLIB_VERSION_MINOR (0x04) +#define RADIOLIB_VERSION_MINOR (0x05) #define RADIOLIB_VERSION_PATCH (0x00) #define RADIOLIB_VERSION_EXTRA (0x00) From a089452e0fc31808a65bca854e518e4046ab20bd Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 14 Apr 2020 15:01:19 +0200 Subject: [PATCH 003/455] [CC1101] Fixed example --- .../CC1101_Receive_Interrupt.ino | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino b/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino index b57c4102..e036d71e 100644 --- a/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino +++ b/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino @@ -24,7 +24,7 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(5, 2, RADIOLIB_NC, 3); +CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield @@ -105,25 +105,22 @@ void loop() { receivedFlag = false; // you can read received data as an Arduino String - //String str; - //int state = cc.readData(str); + String str; + int state = cc.readData(str); // you can also read received data as byte array - + /* byte byteArr[8]; int state = cc.readData(byteArr, 8); - + */ if (state == ERR_NONE) { // packet was successfully received Serial.println(F("[CC1101] Received packet!")); // print data of the packet - Serial.println(F("[CC1101] Data:\t\t")); - //Serial.println(str); - for(uint8_t i = 0; i < 8; i++) { - Serial.println(byteArr[i], HEX); - } + Serial.print(F("[CC1101] Data:\t\t")); + Serial.println(str); // print RSSI (Received Signal Strength Indicator) // of the last received packet From e9f879aea63cbcb273241b1f089693eefadc9462 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 14 Apr 2020 15:01:39 +0200 Subject: [PATCH 004/455] [SX1231] Fixed typo in debug message --- src/modules/SX1231/SX1231.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index b7412bcb..da54a919 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -20,9 +20,9 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po _chipRevision = version; } else { #ifdef RADIOLIB_DEBUG - RADIOLIB_DEBUG_PRINT(F("SX127x not found! (")); + RADIOLIB_DEBUG_PRINT(F("SX1231 not found! (")); RADIOLIB_DEBUG_PRINT(i + 1); - RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SX127X_REG_VERSION == ")); + RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RF69_REG_VERSION == ")); char buffHex[7]; sprintf(buffHex, "0x%04X", version); From 9f8ec689dd2fd8fda38c6ac1e9f788ecad748118 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 14 Apr 2020 15:02:33 +0200 Subject: [PATCH 005/455] [RF69] Replaced RSSI member variable with getRSSI method --- examples/RF69/RF69_Receive/RF69_Receive.ino | 6 ++++++ .../RF69_Receive_Interrupt.ino | 8 +++++++- src/modules/RF69/RF69.cpp | 9 +++++---- src/modules/RF69/RF69.h | 12 +++++++----- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/examples/RF69/RF69_Receive/RF69_Receive.ino b/examples/RF69/RF69_Receive/RF69_Receive.ino index 597ee63e..161173e3 100644 --- a/examples/RF69/RF69_Receive/RF69_Receive.ino +++ b/examples/RF69/RF69_Receive/RF69_Receive.ino @@ -68,6 +68,12 @@ void loop() { Serial.print(F("[RF69] Data:\t\t")); Serial.println(str); + // print RSSI (Received Signal Strength Indicator) + // of the last received packet + Serial.print(F("[RF69] RSSI:\t\t")); + Serial.print(rf.getRSSI()); + Serial.println(F(" dBm")); + } else if (state == ERR_RX_TIMEOUT) { // timeout occurred while waiting for a packet Serial.println(F("timeout!")); diff --git a/examples/RF69/RF69_Receive_Interrupt/RF69_Receive_Interrupt.ino b/examples/RF69/RF69_Receive_Interrupt/RF69_Receive_Interrupt.ino index 32aef55f..e028a678 100644 --- a/examples/RF69/RF69_Receive_Interrupt/RF69_Receive_Interrupt.ino +++ b/examples/RF69/RF69_Receive_Interrupt/RF69_Receive_Interrupt.ino @@ -112,9 +112,15 @@ void loop() { Serial.println(F("[RF69] Received packet!")); // print data of the packet - Serial.print(F("[RF69] Data:\t\t\t")); + Serial.print(F("[RF69] Data:\t\t")); Serial.println(str); + // print RSSI (Received Signal Strength Indicator) + // of the last received packet + Serial.print(F("[RF69] RSSI:\t\t")); + Serial.print(rf.getRSSI()); + Serial.println(F(" dBm")); + } else if (state == ERR_CRC_MISMATCH) { // packet was received, but is malformed Serial.println(F("CRC error!")); diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index c9e9fa90..35bb2070 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -147,7 +147,7 @@ int16_t RF69::receive(uint8_t* data, size_t len) { uint32_t start = micros(); while(!digitalRead(_mod->getIrq())) { yield(); - + if(micros() - start > timeout) { standby(); clearIRQFlags(); @@ -330,9 +330,6 @@ int16_t RF69::readData(uint8_t* data, size_t len) { // read packet data _mod->SPIreadRegisterBurst(RF69_REG_FIFO, length, data); - // update RSSI - lastPacketRSSI = -1.0 * (_mod->SPIgetRegValue(RF69_REG_RSSI_VALUE)/2.0); - // clear internal flag so getPacketLength can return the new packet length _packetLengthQueried = false; @@ -701,6 +698,10 @@ int16_t RF69::setEncoding(uint8_t encoding) { } } +float RF69::getRSSI() { + return(-1.0 * (_mod->SPIgetRegValue(RF69_REG_RSSI_VALUE)/2.0)); +} + int16_t RF69::config() { int16_t state = ERR_NONE; diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 1a40e5dc..9f465df6 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -441,11 +441,6 @@ class RF69: public PhysicalLayer { */ RF69(Module* module); - /*! - \brief RSSI value of the last received packet. - */ - float lastPacketRSSI; - // basic methods /*! @@ -791,6 +786,13 @@ class RF69: public PhysicalLayer { */ int16_t setEncoding(uint8_t encoding); + /*! + \brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. + + \returns Last packet RSSI in dBm. + */ + float getRSSI(); + #ifndef RADIOLIB_GODMODE protected: #endif From d94eeaae27c2a8b6aa5f8fb2b2dd48603dbaea77 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 08:44:58 +0200 Subject: [PATCH 006/455] [Travis] Formatting change --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8e36b9cb..be6e3618 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,12 @@ before_install: - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # install 3rd party boards - - arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json,https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1 + - arduino --pref 'boardsmanager.additional.urls=' \ + 'http://arduino.esp8266.com/stable/package_esp8266com_index.json,' \ + 'https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,' \ + 'https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,' \ + 'https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json' \ + --save-prefs 2>&1 - if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then arduino --install-boards esp8266:esp8266; export SKIP_PAT='(HTTP|MQTT).*ino'; From 4c2cfe44140ba3a3a4209820154afa46ff965ca3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 08:52:05 +0200 Subject: [PATCH 007/455] [Travis] Fix multiline string --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index be6e3618..62b20862 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,12 +30,12 @@ before_install: - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # install 3rd party boards - - arduino --pref 'boardsmanager.additional.urls=' \ - 'http://arduino.esp8266.com/stable/package_esp8266com_index.json,' \ - 'https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,' \ - 'https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,' \ - 'https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json' \ - --save-prefs 2>&1 + - additionalUrls="boardsmanager.additional.urls=\ + http://arduino.esp8266.com/stable/package_esp8266com_index.json,\ + https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,\ + https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,\ + https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json,\" + - arduino --pref "$additionalUrls" --save-prefs 2>&1 - if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then arduino --install-boards esp8266:esp8266; export SKIP_PAT='(HTTP|MQTT).*ino'; From cfa98b6a324830acdb5d51ebd33a879272d271a4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 08:54:14 +0200 Subject: [PATCH 008/455] [Travis] Fix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 62b20862..821fae80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ before_install: http://arduino.esp8266.com/stable/package_esp8266com_index.json,\ https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,\ https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,\ - https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json,\" + https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" - arduino --pref "$additionalUrls" --save-prefs 2>&1 - if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then arduino --install-boards esp8266:esp8266; From 1592a137eb17a371477d765abee524cd1f75f61f Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 09:06:47 +0200 Subject: [PATCH 009/455] [Travis] Attempt to fix multiline string --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 821fae80..55892e74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,8 +34,8 @@ before_install: http://arduino.esp8266.com/stable/package_esp8266com_index.json,\ https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,\ https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,\ - https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" - - arduino --pref "$additionalUrls" --save-prefs 2>&1 + https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json"; + arduino --pref "$additionalUrls" --save-prefs 2>&1; - if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then arduino --install-boards esp8266:esp8266; export SKIP_PAT='(HTTP|MQTT).*ino'; From c907e967b4550dd852257dabb61c5cde58a3a3cc Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 09:14:34 +0200 Subject: [PATCH 010/455] [Travis] Anotehr fix attempt --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 55892e74..6ed87d2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,8 @@ before_install: - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # install 3rd party boards - - additionalUrls="boardsmanager.additional.urls=\ + - | + additionalUrls="boardsmanager.additional.urls=\ http://arduino.esp8266.com/stable/package_esp8266com_index.json,\ https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,\ https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,\ From 61e5a9e7076936fc668c0187e3d75e4c94d2ce10 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 09:29:05 +0200 Subject: [PATCH 011/455] [Travis] Build only for Uno --- .travis.yml | 59 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ed87d2b..8fca349c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,29 +29,36 @@ before_install: - sudo iptables -A OUTPUT -o lo -j ACCEPT - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT - # install 3rd party boards - - | - additionalUrls="boardsmanager.additional.urls=\ - http://arduino.esp8266.com/stable/package_esp8266com_index.json,\ - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,\ - https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,\ - https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json"; - arduino --pref "$additionalUrls" --save-prefs 2>&1; - - if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then + # check every board in matrix and install 3rd aprty definitions + - if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then + export BUILD_EXAMPLES=true + elif [[ "$BOARD" =~ "arduino:avr:mega" ]]; then + elif [[ "$BOARD" =~ "arduino:avr:leonardo" ]]; then + elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then + arduino --pref "http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs 2>&1; arduino --install-boards esp8266:esp8266; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then + arduino --pref "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; arduino --install-boards esp32:esp32; elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then + arduino --pref "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; arduino --install-boards STM32:stm32; elif [[ "$BOARD" =~ "arduino:samd:" ]]; then + arduino --pref "https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; arduino --install-boards arduino:samd; elif [[ "$BOARD" =~ "arduino:sam:" ]]; then arduino --install-boards arduino:sam; elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then + arduino --pref "https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1; arduino --install-boards SparkFun:apollo3; fi + # check if this release commit (or forced build) and if so, build for every board + - if [[ "$TRAVIS_COMMIT_MESSAGE" =~ "Bump version to" ] || [ "$TRAVIS_COMMIT_MESSAGE" =~ "TRAVIS_FORCE_BUILD" ]]; then + export BUILD_EXAMPLES=true + fi + # create directory to save the library and create symbolic link install: - mkdir -p $HOME/Arduino/libraries @@ -65,23 +72,27 @@ branches: script: # build all example sketches - | - for example in $(find $PWD/examples -name '*.ino' | sort); do - # check whether to skip this sketch - if [ ! -z "$SKIP_PAT" ] && [[ ${example} =~ $SKIP_PAT ]]; then - # skip sketch - echo -e "\n\033[1;33mSkipped ${example##*/} (matched with $SKIP_PAT)\033[0m"; - else - # build sketch - echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino --verify --board $BOARD $example; - if [ $? -ne 0 ]; then - echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; - exit 1; + if [ "$BUILD_EXAMPLES" = true ] ; then + for example in $(find $PWD/examples -name '*.ino' | sort); do + # check whether to skip this sketch + if [ ! -z "$SKIP_PAT" ] && [[ ${example} =~ $SKIP_PAT ]]; then + # skip sketch + echo -e "\n\033[1;33mSkipped ${example##*/} (matched with $SKIP_PAT)\033[0m"; else - echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n"; + # build sketch + echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; + arduino --verify --board $BOARD $example; + if [ $? -ne 0 ]; then + echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; + exit 1; + else + echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n"; + fi fi - fi - done + done + else + echo -e "\n\033[1;33mExample build skipped for $BOARD\033[0m"; + fi # generate Doxygen documentation (only for Arduino UNO) - if [ $BOARD = "arduino:avr:uno" ]; then From 84938f276d5d9e1a1485072718acb7f9794ed502 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 09:32:39 +0200 Subject: [PATCH 012/455] [Travis] Fixed missing semicolons --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8fca349c..cc4076b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ before_install: # check every board in matrix and install 3rd aprty definitions - if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then - export BUILD_EXAMPLES=true + export BUILD_EXAMPLES=true; elif [[ "$BOARD" =~ "arduino:avr:mega" ]]; then elif [[ "$BOARD" =~ "arduino:avr:leonardo" ]]; then elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then @@ -56,7 +56,7 @@ before_install: # check if this release commit (or forced build) and if so, build for every board - if [[ "$TRAVIS_COMMIT_MESSAGE" =~ "Bump version to" ] || [ "$TRAVIS_COMMIT_MESSAGE" =~ "TRAVIS_FORCE_BUILD" ]]; then - export BUILD_EXAMPLES=true + export BUILD_EXAMPLES=true; fi # create directory to save the library and create symbolic link From bbc35b969bea7e0dee010cca3710247ef11f1e97 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 09:36:29 +0200 Subject: [PATCH 013/455] [Travis] Explicitly set build flag --- .travis.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc4076b2..6cba81a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,29 +33,37 @@ before_install: - if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then export BUILD_EXAMPLES=true; elif [[ "$BOARD" =~ "arduino:avr:mega" ]]; then + export BUILD_EXAMPLES=false; elif [[ "$BOARD" =~ "arduino:avr:leonardo" ]]; then + export BUILD_EXAMPLES=false; elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then + export BUILD_EXAMPLES=false; arduino --pref "http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs 2>&1; arduino --install-boards esp8266:esp8266; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then + export BUILD_EXAMPLES=false; arduino --pref "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; arduino --install-boards esp32:esp32; elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then + export BUILD_EXAMPLES=false; arduino --pref "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; arduino --install-boards STM32:stm32; elif [[ "$BOARD" =~ "arduino:samd:" ]]; then + export BUILD_EXAMPLES=false; arduino --pref "https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; arduino --install-boards arduino:samd; elif [[ "$BOARD" =~ "arduino:sam:" ]]; then + export BUILD_EXAMPLES=false; arduino --install-boards arduino:sam; elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then + export BUILD_EXAMPLES=false; arduino --pref "https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1; arduino --install-boards SparkFun:apollo3; fi # check if this release commit (or forced build) and if so, build for every board - - if [[ "$TRAVIS_COMMIT_MESSAGE" =~ "Bump version to" ] || [ "$TRAVIS_COMMIT_MESSAGE" =~ "TRAVIS_FORCE_BUILD" ]]; then + - if [[ "$TRAVIS_COMMIT_MESSAGE" =~ "Bump version to" || "$TRAVIS_COMMIT_MESSAGE" =~ "TRAVIS_FORCE_BUILD" ]]; then export BUILD_EXAMPLES=true; fi @@ -72,7 +80,7 @@ branches: script: # build all example sketches - | - if [ "$BUILD_EXAMPLES" = true ] ; then + if [ ! -z "$BUILD_EXAMPLES" ] && [ "$BUILD_EXAMPLES" = true ] ; then for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch if [ ! -z "$SKIP_PAT" ] && [[ ${example} =~ $SKIP_PAT ]]; then @@ -91,7 +99,7 @@ script: fi done else - echo -e "\n\033[1;33mExample build skipped for $BOARD\033[0m"; + echo -e "\n\033[1;33mExample builds skipped for $BOARD\033[0m"; fi # generate Doxygen documentation (only for Arduino UNO) From e070029f44a06164883877c4eadf99c1eda0fef9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 09:39:34 +0200 Subject: [PATCH 014/455] [Travis] Fixed incorrect board URL format --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6cba81a8..b40a2c19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,27 +38,27 @@ before_install: export BUILD_EXAMPLES=false; elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs 2>&1; + arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs 2>&1; arduino --install-boards esp8266:esp8266; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; + arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; arduino --install-boards esp32:esp32; elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; + arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; arduino --install-boards STM32:stm32; elif [[ "$BOARD" =~ "arduino:samd:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; + arduino --pref "boardsmanager.additional.urls=https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; arduino --install-boards arduino:samd; elif [[ "$BOARD" =~ "arduino:sam:" ]]; then export BUILD_EXAMPLES=false; arduino --install-boards arduino:sam; elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1; + arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1; arduino --install-boards SparkFun:apollo3; fi From 7cbb248ee678a9eba235ce92eb45db1ca93e2ae1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 09:42:55 +0200 Subject: [PATCH 015/455] [Travis] Fixed wrong URL for STM32 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b40a2c19..10a431ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,11 +47,10 @@ before_install: arduino --install-boards esp32:esp32; elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; + arduino --pref "boardsmanager.additional.urls=https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; arduino --install-boards STM32:stm32; elif [[ "$BOARD" =~ "arduino:samd:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; arduino --install-boards arduino:samd; elif [[ "$BOARD" =~ "arduino:sam:" ]]; then export BUILD_EXAMPLES=false; From 57f63bff9153adb29ac52e7d55a97c543a8220ec Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 09:47:18 +0200 Subject: [PATCH 016/455] [Travis] Rebuld all using TRAVIS_FORCE_BUILD --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10a431ab..58252507 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,15 +4,15 @@ env: matrix: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt + - BOARD="arduino:avr:uno" + - BOARD="arduino:avr:mega:cpu=atmega2560" + - BOARD="arduino:avr:leonardo" + - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" - BOARD="esp32:esp32:esp32" - BOARD="STM32:stm32:GenF3:pnum=BLACKPILL_F303CC" - - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" - # - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:samd:arduino_zero_native" - BOARD="arduino:sam:arduino_due_x" - - BOARD="arduino:avr:uno" - - BOARD="arduino:avr:leonardo" - - BOARD="arduino:avr:mega:cpu=atmega2560" + # - BOARD="SparkFun:apollo3:amap3redboard" before_install: # install Arduino IDE From 0daa14175df1bfe86cdb7b0a9696e68ed3956a98 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 10:01:39 +0200 Subject: [PATCH 017/455] [Travis] Added all platforms from readme TRAVIS_FORCE_BUILD --- .travis.yml | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 58252507..d46ac61b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,11 @@ env: - BOARD="STM32:stm32:GenF3:pnum=BLACKPILL_F303CC" - BOARD="arduino:samd:arduino_zero_native" - BOARD="arduino:sam:arduino_due_x" - # - BOARD="SparkFun:apollo3:amap3redboard" + - BOARD="adafruit:nrf52:feather52832" + - BOARD="Intel:arc32:arduino_101" + - BOARD="arduino:megaavr:uno2018" + - BOARD="SparkFun:apollo3:amap3redboard" + - BOARD="arduino:mbed:nano33ble" before_install: # install Arduino IDE @@ -29,36 +33,62 @@ before_install: - sudo iptables -A OUTPUT -o lo -j ACCEPT - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT - # check every board in matrix and install 3rd aprty definitions + # check every board in matrix and install 3rd party definitions - if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then export BUILD_EXAMPLES=true; + elif [[ "$BOARD" =~ "arduino:avr:mega" ]]; then export BUILD_EXAMPLES=false; + elif [[ "$BOARD" =~ "arduino:avr:leonardo" ]]; then export BUILD_EXAMPLES=false; + elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then export BUILD_EXAMPLES=false; arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs 2>&1; arduino --install-boards esp8266:esp8266; export SKIP_PAT='(HTTP|MQTT).*ino'; + elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then export BUILD_EXAMPLES=false; arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; arduino --install-boards esp32:esp32; + elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then export BUILD_EXAMPLES=false; arduino --pref "boardsmanager.additional.urls=https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; arduino --install-boards STM32:stm32; + elif [[ "$BOARD" =~ "arduino:samd:" ]]; then export BUILD_EXAMPLES=false; arduino --install-boards arduino:samd; + elif [[ "$BOARD" =~ "arduino:sam:" ]]; then export BUILD_EXAMPLES=false; arduino --install-boards arduino:sam; + + elif [[ "$BOARD" =~ "adafruit:nrf52:" ]]; then + export BUILD_EXAMPLES=false; + arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; + arduino --install-boards adafruit:nrf52; + + elif [[ "$BOARD" =~ "Intel:arc32:" ]]; then + export BUILD_EXAMPLES=false; + arduino --install-boards Intel:arc32; + + elif [[ "$BOARD" =~ "arduino:megaavr:" ]]; then + export BUILD_EXAMPLES=false; + arduino --install-boards arduino:megaavr; + elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then export BUILD_EXAMPLES=false; arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1; arduino --install-boards SparkFun:apollo3; + + elif [[ "$BOARD" =~ "arduino:mbed:" ]]; then + export BUILD_EXAMPLES=false; + arduino --install-boards arduino:mbed; + fi # check if this release commit (or forced build) and if so, build for every board From c3d6ebce755df836b7c9ff29cb6c73a0e2660923 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 10:48:59 +0200 Subject: [PATCH 018/455] [Travis] Added missing parameters for some platforms TRAVIS_FORCE_BUILD --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d46ac61b..6916a505 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,9 @@ env: - BOARD="STM32:stm32:GenF3:pnum=BLACKPILL_F303CC" - BOARD="arduino:samd:arduino_zero_native" - BOARD="arduino:sam:arduino_due_x" - - BOARD="adafruit:nrf52:feather52832" + - BOARD="adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0" - BOARD="Intel:arc32:arduino_101" - - BOARD="arduino:megaavr:uno2018" + - BOARD="arduino:megaavr:uno2018:mode=on" - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:mbed:nano33ble" @@ -88,6 +88,7 @@ before_install: elif [[ "$BOARD" =~ "arduino:mbed:" ]]; then export BUILD_EXAMPLES=false; arduino --install-boards arduino:mbed; + export SKIP_PAT='(HTTP|MQTT).*ino'; fi From c17509db4dd84d5f49bdeeb5cb38b8ec3afbc2ca Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 11:38:20 +0200 Subject: [PATCH 019/455] [Travis] Added missing tool for nRF52 TRAVIS_FORCE_BUILD --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6916a505..a2785c20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,13 @@ env: - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:mbed:nano33ble" +addons: + apt: + packages: + - python3 + - python3-pip + - python3-setuptools + before_install: # install Arduino IDE - wget https://downloads.arduino.cc/arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz @@ -68,6 +75,7 @@ before_install: arduino --install-boards arduino:sam; elif [[ "$BOARD" =~ "adafruit:nrf52:" ]]; then + pip3 install --user adafruit-nrfutil export BUILD_EXAMPLES=false; arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; arduino --install-boards adafruit:nrf52; From 87d5103563920cb4a3cfeeacb4db29cdf58de2c3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 15 Apr 2020 12:25:39 +0200 Subject: [PATCH 020/455] [Travis] Added missing semicolon TRAVIS_FORCE_BUILD --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a2785c20..9552fd5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ before_install: arduino --install-boards arduino:sam; elif [[ "$BOARD" =~ "adafruit:nrf52:" ]]; then - pip3 install --user adafruit-nrfutil + pip3 install --user adafruit-nrfutil; export BUILD_EXAMPLES=false; arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; arduino --install-boards adafruit:nrf52; From b778aa2e47b5be1df28f01d9e8b75fabf6fc3023 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 16 Apr 2020 07:11:56 +0200 Subject: [PATCH 021/455] Updated readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c62b393a..ffc80347 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,12 @@ RadioLib was originally created as a driver for [__RadioShield__](https://github * __Arduino SAMD__ - Arduino Zero, Arduino MKR boards, M0 Pro etc. * __Arduino SAM__ - Arduino Due * __Adafruit nRF52__ - Adafruit Bluefruit Feather etc. -* _Intel Curie_ - Arduino 101 -* _Arduino megaAVR_ - Arduino Uno WiFi Rev.2 etc. -* _Apollo3_ - SparkFun Artemis Redboard etc. -* _Arduino nRF52_ - Arduino Nano 33 BLE +* __Intel Curie__ - Arduino 101 +* __Arduino megaAVR__ - Arduino Uno WiFi Rev.2 etc. +* __Apollo3__ - SparkFun Artemis Redboard etc. +* __Arduino nRF52__ - Arduino Nano 33 BLE -The list above is by no means exhaustive. Most of RadioLib code is independent of the used platform, so as long as your board is running some Arduino-compatible core, RadioLib should work. Compilation of all examples is tested for all platforms in __bold__ on each git push. Platforms in _italic_ are not tested on each push, but do compile and should be working. +The list above is by no means exhaustive. Most of RadioLib code is independent of the used platform, so as long as your board is running some Arduino-compatible core, RadioLib should work. Compilation of all examples is tested for all platforms prior to releasing new version. ### In development: * __SIM800C__ GSM module From e8857fd8d734179764790be2dbea5ebee6a071e5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 17 Apr 2020 07:50:15 +0200 Subject: [PATCH 022/455] [SX128x] Fixed unsupported bit rate value in example --- examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino b/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino index 166215b7..abf6a582 100644 --- a/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino +++ b/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino @@ -58,7 +58,7 @@ void setup() { // the following settings can also // be modified at run-time state = ble.setFrequency(2410.5); - state = ble.setBitRate(200); + state = ble.setBitRate(250); state = ble.setFrequencyDeviation(100.0); state = ble.setOutputPower(5); state = ble.setDataShaping(1.0); @@ -90,7 +90,7 @@ void loop() { } else if (state == ERR_TX_TIMEOUT) { Serial.println(F("[SX1280] Timed out while transmitting!")); } else { - Serial.println(F("[SX1280] Failed to transmit packet, code ")); + Serial.print(F("[SX1280] Failed to transmit packet, code ")); Serial.println(state); } From dcf31e481dbe8d01f0158ae7644e45f543210347 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 17 Apr 2020 07:51:06 +0200 Subject: [PATCH 023/455] [SX128x] Fixed BLE access address configuration (#135) --- src/modules/SX128x/SX128x.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index e4dae862..4b2409a5 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -950,9 +950,9 @@ int16_t SX128x::setAccessAddress(uint32_t addr) { return(ERR_WRONG_MODEM); } - // use setSyncWord to set the address - uint8_t syncWord[] = { (uint8_t)((addr >> 24) & 0xFF), (uint8_t)((addr >> 16) & 0xFF), (uint8_t)((addr >> 8) & 0xFF), (uint8_t)(addr & 0xFF) }; - return(setSyncWord(syncWord, 4)); + // set the address + uint8_t addrBuff[] = { (uint8_t)((addr >> 24) & 0xFF), (uint8_t)((addr >> 16) & 0xFF), (uint8_t)((addr >> 8) & 0xFF), (uint8_t)(addr & 0xFF) }; + return(SX128x::writeRegister(SX128X_REG_ACCESS_ADDRESS_BYTE_3, addrBuff, 4)); } float SX128x::getRSSI() { From 1aef03c473e2af6c3e754a5440e04ded98f0b5c0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 17 Apr 2020 07:51:29 +0200 Subject: [PATCH 024/455] [SX128x] Added missing BLE modem check --- src/modules/SX128x/SX128x.cpp | 12 ++++++++++-- src/modules/SX128x/SX128x.h | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 4b2409a5..098d783f 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -444,6 +444,8 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { state = setPacketParamsLoRa(_preambleLengthLoRa, _headerType, len, _crcLoRa); } else if((modem == SX128X_PACKET_TYPE_GFSK) || (modem == SX128X_PACKET_TYPE_FLRC)) { state = setPacketParamsGFSK(_preambleLengthGFSK, _syncWordLen, _syncWordMatch, _crcGFSK, _whitening, len); + } else if(modem == SX128X_PACKET_TYPE_BLE) { + state = setPacketParamsBLE(_connectionState, _crcBLE, _bleTestPayload, _whitening); } else { return(ERR_WRONG_MODEM); } @@ -458,8 +460,14 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // write packet to buffer - state = writeBuffer(data, len); - RADIOLIB_ASSERT(state); + if(modem == SX128X_PACKET_TYPE_BLE) { + // first 2 bytes of BLE payload are PDU header + state = writeBuffer(data, len, 2); + RADIOLIB_ASSERT(state); + } else { + state = writeBuffer(data, len); + RADIOLIB_ASSERT(state); + } // set DIO mapping state = setDioIrqParams(SX128X_IRQ_TX_DONE | SX128X_IRQ_RX_TX_TIMEOUT, SX128X_IRQ_TX_DONE); diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index f093a3c9..a5aea25c 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -442,7 +442,7 @@ class SX128x: public PhysicalLayer { \param len Number of bytes to send. - \param addr Address to send the data to. Will only be added if address filtering was enabled. + \param addr Address to send the data to. Unsupported, compatibility only. \returns \ref status_codes */ @@ -531,7 +531,7 @@ class SX128x: public PhysicalLayer { \param len Number of bytes to send. - \param addr Address to send the data to. Will only be added if address filtering was enabled. + \param addr Address to send the data to. Unsupported, compatibility only. \returns \ref status_codes */ @@ -745,7 +745,7 @@ class SX128x: public PhysicalLayer { protected: #endif Module* _mod; - + // cached LoRa parameters float _bwKhz; uint8_t _bw, _sf, _cr; From 9ad020750a248b247eab91dd8991d3c2ddbef031 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 17 Apr 2020 08:35:47 +0200 Subject: [PATCH 025/455] [SX128x] Fixed unsupported FLRC bit rate --- examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino b/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino index 1f28b834..af680b50 100644 --- a/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino +++ b/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino @@ -57,7 +57,7 @@ void setup() { // the following settings can also // be modified at run-time state = flrc.setFrequency(2410.5); - state = flrc.setBitRate(200); + state = flrc.setBitRate(520); state = flrc.setCodingRate(2); state = flrc.setOutputPower(5); state = flrc.setDataShaping(1.0); From bd5be7729e281aee5f686ada78dabecec2de83b7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 21 Apr 2020 12:00:23 +0200 Subject: [PATCH 026/455] [RF69] Extended power configuration (#133) --- examples/RF69/RF69_Transmit/RF69_Transmit.ino | 17 +++++++ .../RF69_Transmit_Interrupt.ino | 17 +++++++ src/modules/RF69/RF69.cpp | 50 +++++++++++++++---- src/modules/RF69/RF69.h | 9 ++-- 4 files changed, 79 insertions(+), 14 deletions(-) diff --git a/examples/RF69/RF69_Transmit/RF69_Transmit.ino b/examples/RF69/RF69_Transmit/RF69_Transmit.ino index 05879c0b..5d39f6f2 100644 --- a/examples/RF69/RF69_Transmit/RF69_Transmit.ino +++ b/examples/RF69/RF69_Transmit/RF69_Transmit.ino @@ -43,6 +43,23 @@ void setup() { Serial.println(state); while (true); } + + // NOTE: some RF69 modules use high power output, + // those are usually marked RF69H(C/CW). + // To configure RadioLib for these modules, + // you must call setOutputPower() with + // second argument set to true. + /* + Serial.print(F("[RF69] Setting high power module ... ")); + state = rf.setOutputPower(20, true); + if (state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while (true); + } + */ } void loop() { diff --git a/examples/RF69/RF69_Transmit_Interrupt/RF69_Transmit_Interrupt.ino b/examples/RF69/RF69_Transmit_Interrupt/RF69_Transmit_Interrupt.ino index 3e83042a..e07b41ec 100644 --- a/examples/RF69/RF69_Transmit_Interrupt/RF69_Transmit_Interrupt.ino +++ b/examples/RF69/RF69_Transmit_Interrupt/RF69_Transmit_Interrupt.ino @@ -52,6 +52,23 @@ void setup() { // when packet transmission is finished rf.setDio0Action(setFlag); + // NOTE: some RF69 modules use high power output, + // those are usually marked RF69H(C/CW). + // To configure RadioLib for these modules, + // you must call setOutputPower() with + // second argument set to true. + /* + Serial.print(F("[RF69] Setting high power module ... ")); + state = rf.setOutputPower(20, true); + if (state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while (true); + } + */ + // start transmitting the first packet Serial.print(F("[RF69] Sending first packet ... ")); diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 35bb2070..ba7bfcb7 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -239,9 +239,12 @@ int16_t RF69::startReceive() { clearIRQFlags(); // set mode to receive - state = _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_NORMAL); + state = _mod->SPIsetRegValue(RF69_REG_OCP, RF69_OCP_ON | RF69_OCP_TRIM); + state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_NORMAL); state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA2, RF69_PA2_NORMAL); - state |= setMode(RF69_RX); + RADIOLIB_ASSERT(state); + + state = setMode(RF69_RX); return(state); } @@ -303,10 +306,16 @@ int16_t RF69::startTransmit(uint8_t* data, size_t len, uint8_t addr) { // write packet to FIFO _mod->SPIwriteRegisterBurst(RF69_REG_FIFO, data, len); + // enable +20 dBm operation + if(_power > 17) { + state = _mod->SPIsetRegValue(RF69_REG_OCP, RF69_OCP_OFF | 0x0F); + state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_20_DBM); + state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA2, RF69_PA2_20_DBM); + RADIOLIB_ASSERT(state); + } + // set mode to transmit - state = _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_20_DBM); - state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA2, RF69_PA2_20_DBM); - state |= setMode(RF69_TX); + state = setMode(RF69_TX); return(state); } @@ -493,22 +502,41 @@ int16_t RF69::setFrequencyDeviation(float freqDev) { return(state); } -int16_t RF69::setOutputPower(int8_t power) { - RADIOLIB_CHECK_RANGE(power, -18, 17, ERR_INVALID_OUTPUT_POWER); +int16_t RF69::setOutputPower(int8_t power, bool highPower) { + if(highPower) { + RADIOLIB_CHECK_RANGE(power, -2, 20, ERR_INVALID_OUTPUT_POWER); + } else { + RADIOLIB_CHECK_RANGE(power, -18, 13, ERR_INVALID_OUTPUT_POWER); + } // set mode to standby setMode(RF69_STANDBY); // set output power int16_t state; - if(power > 13) { - // requested output power is higher than 13 dBm, enable PA2 + PA1 on PA_BOOST - state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_OFF | RF69_PA1_ON | RF69_PA2_ON | (power + 14), 7, 0); + if(highPower) { + // check if both PA1 and PA2 are needed + if(power <= 10) { + // -2 to 13 dBm, PA1 is enough + state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_OFF | RF69_PA1_ON | RF69_PA2_OFF | (power + 18), 7, 0); + } else if(power <= 17) { + // 13 to 17 dBm, both PAs required + state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_OFF | RF69_PA1_ON | RF69_PA2_ON | (power + 14), 7, 0); + } else { + // 18 - 20 dBm, both PAs and hig power settings required + state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_OFF | RF69_PA1_ON | RF69_PA2_ON | (power + 11), 7, 0); + } + } else { - // requested output power is lower than 13 dBm, enable PA0 on RFIO + // low power module, use only PA0 state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_ON | RF69_PA1_OFF | RF69_PA2_OFF | (power + 18), 7, 0); } + // cache the power value + if(state == ERR_NONE) { + _power = power; + } + return(state); } diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 9f465df6..18aa8df4 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -188,7 +188,7 @@ // RF69_REG_OCP #define RF69_OCP_OFF 0b00000000 // 4 4 PA overload current protection disabled -#define RF69_OCP_ON 0b00100000 // 4 4 PA overload current protection enabled +#define RF69_OCP_ON 0b00010000 // 4 4 PA overload current protection enabled #define RF69_OCP_TRIM 0b00001010 // 3 0 OCP current: I_max(OCP_TRIM = 0b1010) = 95 mA // RF69_REG_LNA @@ -646,13 +646,15 @@ class RF69: public PhysicalLayer { int16_t setFrequencyDeviation(float freqDev); /*! - \brief Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm. + \brief Sets output power. Allowed values range from -18 to 13 dBm for low power modules (RF69C/CW) or -2 to 20 dBm (RF69H/HC/HCW). \param power Output power to be set in dBm. + \param highPower Set to true when using modules high power port (RF69H/HC/HCW). Defaults to false (models without high power port - RF69C/CW). + \returns \ref status_codes */ - int16_t setOutputPower(int8_t power); + int16_t setOutputPower(int8_t power, bool highPower = false); /*! \brief Sets sync word. Up to 8 bytes can be set as sync word. @@ -801,6 +803,7 @@ class RF69: public PhysicalLayer { float _br; float _rxBw; int16_t _tempOffset; + int8_t _power; size_t _packetLength; bool _packetLengthQueried; From 271f5bd62cd02e98818a4b7268b5da03ab4c29be Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 14:55:02 +0200 Subject: [PATCH 027/455] [ESP8266] Replaced itoa() with sprintf() --- src/modules/ESP8266/ESP8266.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index 1aa959a9..f55d7c9d 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -83,9 +83,9 @@ int16_t ESP8266::join(const char* ssid, const char* password) { int16_t ESP8266::openTransportConnection(const char* host, const char* protocol, uint16_t port, uint16_t tcpKeepAlive) { char portStr[6]; - itoa(port, portStr, 10); + sprintf(portStr, "%d", port); char tcpKeepAliveStr[6]; - itoa(tcpKeepAlive, tcpKeepAliveStr, 10); + sprintf(tcpKeepAliveStr, "%d", tcpKeepAlive); // build AT command const char* atStr = "AT+CIPSTART=\""; @@ -132,7 +132,7 @@ int16_t ESP8266::closeTransportConnection() { int16_t ESP8266::send(const char* data) { // build AT command char lenStr[8]; - itoa(strlen(data), lenStr, 10); + sprintf(lenStr, "%d", strlen(data)); const char* atStr = "AT+CIPSEND="; #ifdef RADIOLIB_STATIC_ONLY char cmd[RADIOLIB_STATIC_ARRAY_SIZE]; @@ -162,7 +162,7 @@ int16_t ESP8266::send(const char* data) { int16_t ESP8266::send(uint8_t* data, uint32_t len) { // build AT command char lenStr[8]; - itoa(len, lenStr, 10); + sprintf(lenStr, "%lu", len); const char atStr[] = "AT+CIPSEND="; #ifdef RADIOLIB_STATIC_ONLY char cmd[RADIOLIB_STATIC_ARRAY_SIZE]; From 6f0989993e092119508c2578f79ee972dbc1b2bd Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 14:55:23 +0200 Subject: [PATCH 028/455] [HTTP] Replaced itoa() with sprintf() --- src/protocols/HTTP/HTTP.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocols/HTTP/HTTP.cpp b/src/protocols/HTTP/HTTP.cpp index 9200acb0..00b046d2 100644 --- a/src/protocols/HTTP/HTTP.cpp +++ b/src/protocols/HTTP/HTTP.cpp @@ -140,8 +140,8 @@ int16_t HTTPClient::post(const char* url, const char* content, String& response, } // build the POST request - char contentLengthStr[8]; - itoa(strlen(content), contentLengthStr, 10); + char contentLengthStr[12]; + sprintf(contentLengthStr, "%d", strlen(content)); char* request = new char[strlen(endpoint) + strlen(host) + strlen(contentType) + strlen(contentLengthStr) + strlen(content) + 64 + 1]; strcpy(request, "POST "); strcat(request, endpoint); From 2eb3df5c897e3a5ccbe7ea1b6f51b8be2c1c719b Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 14:57:51 +0200 Subject: [PATCH 029/455] Added interrupt pin status macro --- src/BuildOpt.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index ff46595a..17fccab4 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -13,6 +13,7 @@ * RADIOLIB_PIN_TYPE - which type should be used for pin numbers in functions like digitalRead(). * RADIOLIB_PIN_MODE - which type should be used for pin modes in functions like pinMode(). * RADIOLIB_PIN_STATUS - which type should be used for pin values in functions like digitalWrite(). + * RADIOLIB_INTERRUPT_STATUS - which type should be used for pin changes in functions like attachInterrupt(). * RADIOLIB_NC - alias for unused pin, usually the largest possible value of RADIOLIB_PIN_TYPE. * RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - defined if the specific platform does not support SoftwareSerial. * RADIOLIB_HARDWARE_SERIAL_PORT - which hardware serial port should be used on platform that do not have SoftwareSerial support. @@ -24,6 +25,7 @@ #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFF) #elif defined(ESP8266) @@ -31,6 +33,7 @@ #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFF) // RadioLib has ESPS8266 driver, this must be disabled to use ESP8266 as platform @@ -41,6 +44,7 @@ #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -50,6 +54,7 @@ #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -59,6 +64,7 @@ #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -68,6 +74,7 @@ #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -77,6 +84,7 @@ #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFFFFFFFF) #elif defined(ARDUINO_ARC32_TOOLS) @@ -84,6 +92,7 @@ #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFF) #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) @@ -91,6 +100,7 @@ #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE PinMode #define RADIOLIB_PIN_STATUS PinStatus + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFF) #elif defined(AM_PART_APOLLO3) @@ -98,6 +108,7 @@ #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -107,6 +118,7 @@ #define RADIOLIB_PIN_TYPE pin_size_t #define RADIOLIB_PIN_MODE PinMode #define RADIOLIB_PIN_STATUS PinStatus + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -120,6 +132,7 @@ #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_NC (0xFF) #endif From 75cc35171417e099c10f8df7213fb3f936f66a9c Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 14:58:47 +0200 Subject: [PATCH 030/455] Added platform name printing in debug mpde --- src/BuildOpt.h | 15 ++++++++++++++- src/RadioLib.h | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 17fccab4..6c14e783 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -10,6 +10,7 @@ /* * Platform-specific configuration. * + * RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected, * RADIOLIB_PIN_TYPE - which type should be used for pin numbers in functions like digitalRead(). * RADIOLIB_PIN_MODE - which type should be used for pin modes in functions like pinMode(). * RADIOLIB_PIN_STATUS - which type should be used for pin values in functions like digitalWrite(). @@ -22,6 +23,7 @@ */ #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. + #define RADIOLIB_PLATFORM "Arduino AVR" #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t @@ -30,6 +32,7 @@ #elif defined(ESP8266) // ESP8266 boards + #define RADIOLIB_PLATFORM "ESP8266" #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t @@ -41,6 +44,7 @@ #elif defined(ESP32) // ESP32 boards + #define RADIOLIB_PLATFORM "ESP32" #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t @@ -50,7 +54,8 @@ #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #elif defined(ARDUINO_ARCH_STM32) - // STM32duino boards + // official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32) + #define RADIOLIB_PLATFORM "Arduino STM32 (official)" #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t @@ -61,6 +66,7 @@ #elif defined(SAMD_SERIES) // Arduino SAMD boards - Zero, MKR, etc. + #define RADIOLIB_PLATFORM "Arduino SAMD" #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t @@ -71,6 +77,7 @@ #elif defined(__SAM3X8E__) // Arduino Due + #define RADIOLIB_PLATFORM "Arduino Due" #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t @@ -81,6 +88,7 @@ #elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE) // Adafruit nRF52 boards + #define RADIOLIB_PLATFORM "Adafruit nRF52" #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t @@ -89,6 +97,7 @@ #elif defined(ARDUINO_ARC32_TOOLS) // Intel Curie + #define RADIOLIB_PLATFORM "Intel Curie" #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t @@ -97,6 +106,7 @@ #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) // Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every + #define RADIOLIB_PLATFORM "Arduino megaAVR" #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE PinMode #define RADIOLIB_PIN_STATUS PinStatus @@ -105,6 +115,7 @@ #elif defined(AM_PART_APOLLO3) // Sparkfun Artemis boards + #define RADIOLIB_PLATFORM "Sparkfun Artemis" #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t @@ -115,6 +126,7 @@ #elif defined(ARDUINO_ARDUINO_NANO33BLE) // Arduino Nano 33 BLE + #define RADIOLIB_PLATFORM "Arduino Nano 33 BLE" #define RADIOLIB_PIN_TYPE pin_size_t #define RADIOLIB_PIN_MODE PinMode #define RADIOLIB_PIN_STATUS PinStatus @@ -128,6 +140,7 @@ #else // other platforms not covered by the above list - this may or may not work + #define RADIOLIB_PLATFORM "Unknown" #define RADIOLIB_UNKNOWN_PLATFORM #define RADIOLIB_PIN_TYPE uint8_t #define RADIOLIB_PIN_MODE uint8_t diff --git a/src/RadioLib.h b/src/RadioLib.h index cc9bc83c..b9446834 100644 --- a/src/RadioLib.h +++ b/src/RadioLib.h @@ -50,6 +50,11 @@ #warning "God mode active, I hope it was intentional. Buckle up, lads." #endif +// print debug info +#ifdef RADIOLIB_DEBUG + #pragma message "RADIOLIB_PLATFORM: " RADIOLIB_PLATFORM +#endif + // check unknown/unsupported platform #ifdef RADIOLIB_UNKNOWN_PLATFORM #warning "RadioLib might not be compatible with this Arduino board - check supported platforms at https://github.com/jgromes/RadioLib!" From 332a981c230d155091814bd62ea81b949d0f65ed Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 14:59:17 +0200 Subject: [PATCH 031/455] [CC1101] Changed interrupt pin macro --- src/modules/CC1101/CC1101.cpp | 4 ++-- src/modules/CC1101/CC1101.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index f05fa32e..039c155d 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -179,7 +179,7 @@ int16_t CC1101::packetMode() { return(state); } -void CC1101::setGdo0Action(void (*func)(void), RADIOLIB_PIN_STATUS dir) { +void CC1101::setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, dir); } @@ -187,7 +187,7 @@ void CC1101::clearGdo0Action() { detachInterrupt(digitalPinToInterrupt(_mod->getIrq())); } -void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_PIN_STATUS dir) { +void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { if(_mod->getGpio() != RADIOLIB_NC) { return; } diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index c1969d27..d6cfe45c 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -600,7 +600,7 @@ class CC1101: public PhysicalLayer { \param dir Signal change direction. Defaults to FALLING. */ - void setGdo0Action(void (*func)(void), RADIOLIB_PIN_STATUS dir = FALLING); + void setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = FALLING); /*! \brief Clears interrupt service routine to call when GDO0 activates. @@ -614,7 +614,7 @@ class CC1101: public PhysicalLayer { \param dir Signal change direction. Defaults to FALLING. */ - void setGdo2Action(void (*func)(void), RADIOLIB_PIN_STATUS dir = FALLING); + void setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = FALLING); /*! \brief Clears interrupt service routine to call when GDO0 activates. From 26ff33a8acba8d0855162845404e28ef0050061a Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 15:00:44 +0200 Subject: [PATCH 032/455] Added support for Roger Clark's STM32duino core TRAVIS_FORCE_BUILD --- .travis.yml | 13 +++++++++++++ src/BuildOpt.h | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9552fd5e..af3e371b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,10 +17,13 @@ env: - BOARD="arduino:megaavr:uno2018:mode=on" - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:mbed:nano33ble" + - BOARD="stm32duino:STM32F1:mapleMini" + #- BOARD="stm32duino:STM32F4:discovery_f407" addons: apt: packages: + # required for Adafruit nRF52 (adafruit-nrfutil package) - python3 - python3-pip - python3-setuptools @@ -98,6 +101,16 @@ before_install: arduino --install-boards arduino:mbed; export SKIP_PAT='(HTTP|MQTT).*ino'; + elif [[ "$BOARD" =~ "stm32duino:STM32F1:" ]]; then + export BUILD_EXAMPLES=false; + arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; + arduino --install-boards stm32duino:STM32F1; + + elif [[ "$BOARD" =~ "stm32duino:STM32F4:" ]]; then + export BUILD_EXAMPLES=false; + arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; + arduino --install-boards stm32duino:STM32F4; + fi # check if this release commit (or forced build) and if so, build for every board diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 6c14e783..8273cd3f 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -138,6 +138,17 @@ // Nano 33 BLE uses mbed libraries, which already contain ESP8266 driver #define _RADIOLIB_ESP8266_H +#elif defined(__STM32F4__) || defined(__STM32F1__) + // Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32) + #define RADIOLIB_PLATFORM "STM32duino (unofficial)" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE WiringPinMode + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS ExtIntTriggerMode + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #else // other platforms not covered by the above list - this may or may not work #define RADIOLIB_PLATFORM "Unknown" From 7d56a8021f13562336a315564cac51fe356041c5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 15:57:56 +0200 Subject: [PATCH 033/455] Travis set Maple parameters --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index af3e371b..3ef815e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ env: matrix: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt + - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" - BOARD="arduino:avr:uno" - BOARD="arduino:avr:mega:cpu=atmega2560" - BOARD="arduino:avr:leonardo" @@ -17,7 +18,6 @@ env: - BOARD="arduino:megaavr:uno2018:mode=on" - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:mbed:nano33ble" - - BOARD="stm32duino:STM32F1:mapleMini" #- BOARD="stm32duino:STM32F4:discovery_f407" addons: From 27ec766e6200912dfa99a601349f15c74c3a644b Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 15:59:21 +0200 Subject: [PATCH 034/455] Forcing build TRAVIS_FORCE_BUILD --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3ef815e6..be97ffec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ env: matrix: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt - - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" - BOARD="arduino:avr:uno" + - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" - BOARD="arduino:avr:mega:cpu=atmega2560" - BOARD="arduino:avr:leonardo" - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" From 54fc5533716ad971b61ff468438a2b6aa78c7c79 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 22 Apr 2020 16:02:14 +0200 Subject: [PATCH 035/455] Travis fixed build order TRAVIS_FORCE_BUILD --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index be97ffec..a7381d87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ env: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt - BOARD="arduino:avr:uno" - - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" - BOARD="arduino:avr:mega:cpu=atmega2560" - BOARD="arduino:avr:leonardo" - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" @@ -18,6 +17,7 @@ env: - BOARD="arduino:megaavr:uno2018:mode=on" - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:mbed:nano33ble" + - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" #- BOARD="stm32duino:STM32F4:discovery_f407" addons: From 9bd1a63bbad86c14d3b6ffe4d0b52eefad886e59 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 13:34:35 +0200 Subject: [PATCH 036/455] Organized platform list --- README.md | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ffc80347..b56ab927 100644 --- a/README.md +++ b/README.md @@ -37,17 +37,29 @@ RadioLib was originally created as a driver for [__RadioShield__](https://github * [__Hellschreiber__](https://www.sigidwiki.com/wiki/Hellschreiber) for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x ### Supported platforms: -* __Arduino AVR__ - tested with hardware on Uno, Mega and Leonardo -* __ESP8266__ - tested with hardware on NodeMCU and Wemos D1 -* __ESP32__ - tested with hardware on ESP-WROOM-32 -* __STM32__ - tested with hardware on Nucleo L452RE-P -* __Arduino SAMD__ - Arduino Zero, Arduino MKR boards, M0 Pro etc. -* __Arduino SAM__ - Arduino Due -* __Adafruit nRF52__ - Adafruit Bluefruit Feather etc. -* __Intel Curie__ - Arduino 101 -* __Arduino megaAVR__ - Arduino Uno WiFi Rev.2 etc. -* __Apollo3__ - SparkFun Artemis Redboard etc. -* __Arduino nRF52__ - Arduino Nano 33 BLE +* __Arduino__ + * [__AVR__](https://github.com/arduino/ArduinoCore-avr) - Arduino Uno, Mega, Leonardo, Pro Mini, Nano etc. + * [__mbed__](https://github.com/arduino/ArduinoCore-nRF528x-mbedos) - Arduino Nano 33 BLE + * [__megaAVR__](https://github.com/arduino/ArduinoCore-megaavr) - Arduino Uno WiFi Rev.2 and Nano Every + * [__SAM__](https://github.com/arduino/ArduinoCore-sam) - Arduino Due + * [__SAMD__](https://github.com/arduino/ArduinoCore-samd) - Arduino Zero, MKR boards, M0 Pro etc. + +* __Adafruit__ + * [__nRF52__](https://github.com/adafruit/Adafruit_nRF52_Arduino) - Adafruit Feather nRF528x, Bluefruit and CLUE + +* __Espressif__ + * [__ESP32__](https://github.com/espressif/arduino-esp32) - ESP32-based boards + * [__ESP8266__](https://github.com/esp8266/Arduino) - ESP8266-based boards + +* __Intel__ + * [__Curie__](https://github.com/arduino/ArduinoCore-arc32) - Arduino 101 + +* __SparkFun__ + * [__Apollo3__](https://github.com/sparkfun/Arduino_Apollo3) - Sparkfun Artemis Redboard + +* __ST Microelectronics__ + * [__STM32__ (official core)](https://github.com/stm32duino/Arduino_Core_STM32) - STM32 Nucleo, Discovery, Maple, BluePill, BlackPill etc. + * [__STM32__ (unofficial core)](https://github.com/rogerclarkmelbourne/Arduino_STM32) - STM32F1 and STM32F4-based boards The list above is by no means exhaustive. Most of RadioLib code is independent of the used platform, so as long as your board is running some Arduino-compatible core, RadioLib should work. Compilation of all examples is tested for all platforms prior to releasing new version. From 325d925e9f48b825cae121f18d006a5c08c99e63 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 13:46:50 +0200 Subject: [PATCH 037/455] Travis added configuration for stm32duino F4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a7381d87..a35b2190 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ env: - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:mbed:nano33ble" - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" - #- BOARD="stm32duino:STM32F4:discovery_f407" + - BOARD="stm32duino:STM32F4:discovery_f407:usb_cfg=usb_serial" addons: apt: From 6215330858ff09a4f2636d92f5f579ffe7d20b66 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 17:07:28 +0200 Subject: [PATCH 038/455] Added tone support --- src/BuildOpt.h | 5 +++++ src/Module.cpp | 16 ++++++++++++++++ src/Module.h | 16 ++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 8273cd3f..5ea12a5e 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -18,6 +18,7 @@ * RADIOLIB_NC - alias for unused pin, usually the largest possible value of RADIOLIB_PIN_TYPE. * RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - defined if the specific platform does not support SoftwareSerial. * RADIOLIB_HARDWARE_SERIAL_PORT - which hardware serial port should be used on platform that do not have SoftwareSerial support. + * RADIOLIB_TONE_UNSUPPORTED - some platforms do not have tone()/noTone(), which is required for AFSK. * * In addition, some platforms may require RadioLib to disable specific drivers (such as ESP8266). */ @@ -52,6 +53,7 @@ #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #define RADIOLIB_TONE_UNSUPPORTED #elif defined(ARDUINO_ARCH_STM32) // official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32) @@ -85,6 +87,7 @@ #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #define RADIOLIB_TONE_UNSUPPORTED #elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE) // Adafruit nRF52 boards @@ -123,6 +126,7 @@ #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #define RADIOLIB_TONE_UNSUPPORTED #elif defined(ARDUINO_ARDUINO_NANO33BLE) // Arduino Nano 33 BLE @@ -148,6 +152,7 @@ #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #define RADIOLIB_TONE_UNSUPPORTED #else // other platforms not covered by the above list - this may or may not work diff --git a/src/Module.cpp b/src/Module.cpp index 8482e32c..67ac9ac8 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -294,3 +294,19 @@ RADIOLIB_PIN_STATUS Module::digitalRead(RADIOLIB_PIN_TYPE pin) { } return(LOW); } + +void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { + #ifndef RADIOLIB_TONE_UNSUPPORTED + if(pin != RADIOLIB_NC) { + ::tone(pin, value); + } + #endif +} + +void Module::noTone(RADIOLIB_PIN_TYPE pin) { + #ifndef RADIOLIB_TONE_UNSUPPORTED + if(pin != RADIOLIB_NC) { + ::noTone(pin); + } + #endif +} diff --git a/src/Module.h b/src/Module.h index ebc81986..f6855a05 100644 --- a/src/Module.h +++ b/src/Module.h @@ -368,6 +368,22 @@ class Module { */ static RADIOLIB_PIN_STATUS digitalRead(RADIOLIB_PIN_TYPE pin); + /*! + \brief Arduino core tone override that checks RADIOLIB_NC as alias for unused pin and RADIOLIB_TONE_UNSUPPORTED to make sure the platform does support tone. + + \param pin Pin to write to. + + \param value Frequency to output. + */ + static void tone(RADIOLIB_PIN_TYPE pin, uint16_t value); + + /*! + \brief Arduino core noTone override that checks RADIOLIB_NC as alias for unused pin and RADIOLIB_TONE_UNSUPPORTED to make sure the platform does support tone. + + \param pin Pin to write to. + */ + static void noTone(RADIOLIB_PIN_TYPE pin); + #ifndef RADIOLIB_GODMODE private: #endif From 072e4288c96a45337be533b8459aec121a793693 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 17:09:25 +0200 Subject: [PATCH 039/455] [AFSK] Added AFSK support (#139) --- examples/AFSK/AFSK_Tone/AFSK_Tone.ino | 80 +++++++++++++++++++++++++++ keywords.txt | 5 ++ src/RadioLib.h | 1 + src/protocols/AFSK/AFSK.cpp | 21 +++++++ src/protocols/AFSK/AFSK.h | 57 +++++++++++++++++++ 5 files changed, 164 insertions(+) create mode 100644 examples/AFSK/AFSK_Tone/AFSK_Tone.ino create mode 100644 src/protocols/AFSK/AFSK.cpp create mode 100644 src/protocols/AFSK/AFSK.h diff --git a/examples/AFSK/AFSK_Tone/AFSK_Tone.ino b/examples/AFSK/AFSK_Tone/AFSK_Tone.ino new file mode 100644 index 00000000..09e66c28 --- /dev/null +++ b/examples/AFSK/AFSK_Tone/AFSK_Tone.ino @@ -0,0 +1,80 @@ +/* + RadioLib AFSK Example + + This example shows hot to send audio FSK tones + using SX1278's FSK modem. + + Other modules that can be used for AFSK: + - SX127x/RFM9x + - RF69 + - SX1231 + - CC1101 + - Si443x/RFM2x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// RESET pin: 9 +// DIO1 pin: 3 +SX1278 fsk = new Module(10, 2, 9, 3); + +// create AFSK client instance using the FSK module +// this requires connection to the module direct +// input pin, here connected to Arduino pin 5 +// SX127x/RFM9x: DIO2 +// RF69: DIO2 +// SX1231: DIO2 +// CC1101: GDO2 +// Si443x/RFM2x: GPIO +AFSKClient audio(&fsk, 5); + +void setup() { + Serial.begin(9600); + + // initialize SX1278 + Serial.print(F("[SX1278] Initializing ... ")); + // carrier frequency: 434.0 MHz + // bit rate: 48.0 kbps + // frequency deviation: 50.0 kHz + // Rx bandwidth: 125.0 kHz + // output power: 13 dBm + // current limit: 100 mA + int state = fsk.beginFSK(); + + // when using one of the non-LoRa modules for AFSK + // (RF69, CC1101,, Si4432 etc.), use the basic begin() method + // int state = fsk.begin(); + + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } +} + +void loop() { + // AFSKClient can be used to transmit tones, + // same as Arduino tone() function + + // 400 Hz tone + audio.tone(400); + delay(1000); + + // silence + audio.noTone(); + delay(1000); + + // AFSKClient can also be used to transmit HAM-friendly + // RTTY, Morse code, Hellschreiber, SSTV and AX.25. + // Details on how to use AFSK are in the example + // folders for each of the above modes. +} diff --git a/keywords.txt b/keywords.txt index 21e58818..53b945b0 100644 --- a/keywords.txt +++ b/keywords.txt @@ -53,6 +53,7 @@ AX25Client KEYWORD1 AX25Frame KEYWORD1 SSTVClient KEYWORD1 HellClient KEYWORD1 +AFSKClient KEYWORD1 # SSTV modes Scottie1 KEYWORD1 @@ -225,6 +226,10 @@ getRangingResult KEYWORD2 # Hellschreiber printGlyph KEYWORD2 +# AFSK +tone KEYWORD2 +noTone KEYWORD2 + ####################################### # Constants (LITERAL1) ####################################### diff --git a/src/RadioLib.h b/src/RadioLib.h index b9446834..c6afae7a 100644 --- a/src/RadioLib.h +++ b/src/RadioLib.h @@ -91,6 +91,7 @@ // physical layer protocols #include "protocols/PhysicalLayer/PhysicalLayer.h" +#include "protocols/AFSK/AFSK.h" #include "protocols/AX25/AX25.h" #include "protocols/Hellschreiber/Hellschreiber.h" #include "protocols/Morse/Morse.h" diff --git a/src/protocols/AFSK/AFSK.cpp b/src/protocols/AFSK/AFSK.cpp new file mode 100644 index 00000000..a8453925 --- /dev/null +++ b/src/protocols/AFSK/AFSK.cpp @@ -0,0 +1,21 @@ +#include "AFSK.h" + +AFSKClient::AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin) { + _phy = phy; + _pin = pin; +} + +int16_t AFSKClient::tone(uint16_t freq, bool autoStart) { + if(autoStart) { + int16_t state = _phy->transmitDirect(); + RADIOLIB_ASSERT(state); + } + + Module::tone(_pin, freq); + return(ERR_NONE); +} + +int16_t AFSKClient::noTone() { + Module::noTone(_pin); + return(_phy->standby()); +} diff --git a/src/protocols/AFSK/AFSK.h b/src/protocols/AFSK/AFSK.h new file mode 100644 index 00000000..c5c71221 --- /dev/null +++ b/src/protocols/AFSK/AFSK.h @@ -0,0 +1,57 @@ +#ifndef _RADIOLIB_AFSK_H +#define _RADIOLIB_AFSK_H + +#include "../../TypeDef.h" +#include "../../Module.h" + +#include "../PhysicalLayer/PhysicalLayer.h" + +/*! + \class AFSKClient + + \brief Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direct mode transmission using DIO pins. +*/ +class AFSKClient { + public: + /*! + \brief Default contructor. + + \param phy Pointer to the wireless module providing PhysicalLayer communication. + + \param pin The pin that will be used for audio output. + */ + AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin); + + /*! + \brief Start transmitting audio tone. + + \param freq Frequency of the tone in Hz. + + \param autoStart Whether to automatically enter transmission mode. Defaults to true. + + \returns \ref status_codes + */ + int16_t tone(uint16_t freq, bool autoStart = true); + + /*! + \brief Stops transmitting audio tone. + + \returns \ref status_codes + */ + int16_t noTone(); + +#ifndef RADIOLIB_GODMODE + private: +#endif + PhysicalLayer* _phy; + RADIOLIB_PIN_TYPE _pin; + + // allow specific classes access the private PhysicalLayer pointer + friend class RTTYClient; + friend class MorseClient; + friend class HellClient; + friend class SSTVClient; + friend class AX25Client; +}; + +#endif From ed699310410811a16ee8b01c5bf99b788bdcb97c Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 17:10:21 +0200 Subject: [PATCH 040/455] [AX25] Added AFSK support --- examples/AX25/AX25_Frames/AX25_Frames.ino | 3 + examples/AX25/AX25_Transmit/AX25_Transmit.ino | 7 +- .../AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino | 100 ++++++++++++++++++ src/protocols/AX25/AX25.cpp | 46 ++++++-- src/protocols/AX25/AX25.h | 18 +++- 5 files changed, 165 insertions(+), 9 deletions(-) create mode 100644 examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino diff --git a/examples/AX25/AX25_Frames/AX25_Frames.ino b/examples/AX25/AX25_Frames/AX25_Frames.ino index c6af0ad8..45cbba32 100644 --- a/examples/AX25/AX25_Frames/AX25_Frames.ino +++ b/examples/AX25/AX25_Frames/AX25_Frames.ino @@ -19,6 +19,9 @@ Frames shown in this example are not exhaustive; all possible AX.25 frames should be supported. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library diff --git a/examples/AX25/AX25_Transmit/AX25_Transmit.ino b/examples/AX25/AX25_Transmit/AX25_Transmit.ino index 0a462eff..6ab9c59e 100644 --- a/examples/AX25/AX25_Transmit/AX25_Transmit.ino +++ b/examples/AX25/AX25_Transmit/AX25_Transmit.ino @@ -12,6 +12,9 @@ - SX126x - nRF24 - Si443x/RFM2x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -37,8 +40,8 @@ void setup() { // initialize SX1278 Serial.print(F("[SX1278] Initializing ... ")); // carrier frequency: 434.0 MHz - // bit rate: 1.2 kbps (1200 baud AFSK AX.25) - // frequency deviation: 0.5 kHz (1200 baud AFSK AX.25) + // bit rate: 1.2 kbps (1200 baud 2-FSK AX.25) + // frequency deviation: 0.5 kHz (1200 baud 2-FSK AX.25) int state = fsk.beginFSK(434.0, 1.2, 0.5); // when using one of the non-LoRa modules for AX.25 diff --git a/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino b/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino new file mode 100644 index 00000000..aa9d82f4 --- /dev/null +++ b/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino @@ -0,0 +1,100 @@ +/* + RadioLib AX.25 Transmit AFSK Example + + This example sends AX.25 messages using + SX1278's FSK modem. The data is modulated + as AFSK at 1200 baud using Bell 202 tones. + + Other modules that can be used for AX.25 + with AFSK modulation: + - SX127x/RFM9x + - RF69 + - SX1231 + - CC1101 + - nRF24 + - Si443x/RFM2x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// RESET pin: 9 +// DIO1 pin: 3 +SX1278 fsk = new Module(10, 2, 9, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 fsk = RadioShield.ModuleA; + +// create AFSK client instance using the FSK module +// pin 5 is connected to SX1278 DIO2 +AFSKClient audio(&fsk, 5); + +// create AX.25 client instance using the AFSK instance +AX25Client ax25(&audio); + +void setup() { + Serial.begin(9600); + + // initialize SX1278 + Serial.print(F("[SX1278] Initializing ... ")); + // carrier frequency: 434.0 MHz + // bit rate: 48.0 kbps + // frequency deviation: 50.0 kHz + // Rx bandwidth: 125.0 kHz + // output power: 13 dBm + // current limit: 100 mA + int state = fsk.beginFSK(434.0); + + // when using one of the non-LoRa modules for AX.25 + // (RF69, CC1101,, Si4432 etc.), use the basic begin() method + // int state = fsk.begin(); + + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } + + // initialize AX.25 client + Serial.print(F("[AX.25] Initializing ... ")); + // source station callsign: "N7LEM" + // source station SSID: 0 + // preamble length: 8 bytes + state = ax25.begin("N7LEM"); + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } +} + +void loop() { + // send AX.25 unnumbered information frame + Serial.print(F("[AX.25] Sending UI frame ... ")); + // destination station callsign: "NJ7P" + // destination station SSID: 0 + int state = ax25.transmit("Hello World!", "NJ7P"); + if (state == ERR_NONE) { + // the packet was successfully transmitted + Serial.println(F("success!")); + + } else { + // some error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + + } + + delay(1000); +} diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index 7c6a7933..1693cbe7 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -112,6 +112,12 @@ void AX25Frame::setSendSequence(uint8_t seqNumber) { AX25Client::AX25Client(PhysicalLayer* phy) { _phy = phy; + _audio = nullptr; +} + +AX25Client::AX25Client(AFSKClient* audio) { + _phy = audio->_phy; + _audio = audio; } int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t preambleLen) { @@ -130,11 +136,14 @@ int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t prea // save preamble length _preambleLen = preambleLen; - // disable physical layer data shaping and set encoding to NRZ - int16_t state = _phy->setDataShaping(0.0); - RADIOLIB_ASSERT(state); + // set module frequency deviation to 0 if using FSK + int16_t state = ERR_NONE; + if(_audio == nullptr) { + state = _phy->setFrequencyDeviation(0); + RADIOLIB_ASSERT(state); - state = _phy->setEncoding(0); + state = _phy->setEncoding(0); + } return(state); } @@ -154,7 +163,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { if(strlen(frame->destCallsign) > AX25_MAX_CALLSIGN_LEN) { return(ERR_INVALID_CALLSIGN); } - + // check repeater configuration #ifndef RADIOLIB_STATIC_ONLY if(!(((frame->repeaterCallsigns == NULL) && (frame->repeaterSSIDs == NULL) && (frame->numRepeaters == 0)) || @@ -333,7 +342,32 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { } // transmit - int16_t state = _phy->transmit(stuffedFrameBuff, stuffedFrameBuffLen); + int16_t state = ERR_NONE; + if(_audio == nullptr) { + state = _phy->transmit(stuffedFrameBuff, stuffedFrameBuffLen); + } else { + _phy->transmitDirect(); + + // iterate over all bytes in the buffer + for(uint32_t i = 0; i < stuffedFrameBuffLen; i++) { + + // check each bit + for(uint16_t mask = 0x80; mask >= 0x01; mask >>= 1) { + uint32_t start = micros(); + if(stuffedFrameBuff[i] & mask) { + _audio->tone(AX25_AFSK_MARK, false); + } else { + _audio->tone(AX25_AFSK_SPACE, false); + } + while(micros() - start < 833) { + yield(); + } + } + + } + + _audio->noTone(); + } // deallocate memory #ifndef RADIOLIB_STATIC_ONLY diff --git a/src/protocols/AX25/AX25.h b/src/protocols/AX25/AX25.h index bfe322af..dc385dfa 100644 --- a/src/protocols/AX25/AX25.h +++ b/src/protocols/AX25/AX25.h @@ -3,6 +3,7 @@ #include "../../TypeDef.h" #include "../PhysicalLayer/PhysicalLayer.h" +#include "../AFSK/AFSK.h" // macros to access bits in byte array, from http://www.mathcs.emory.edu/~cheung/Courses/255/Syllabus/1-C-intro/bit-array.html #define SET_BIT_IN_ARRAY(A, k) ( A[(k/8)] |= (1 << (k%8)) ) @@ -69,6 +70,13 @@ #define AX25_PID_NO_LAYER_3 0xF0 #define AX25_PID_ESCAPE_CHARACTER 0xFF +// AFSK tones in Hz +#define AX25_AFSK_MARK 1200 +#define AX25_AFSK_SPACE 2200 + +// tone duration in us (for 1200 baud AFSK) +#define AX25_AFSK_TONE_DURATION 833 + /*! \class AX25Frame @@ -254,12 +262,19 @@ class AX25Frame { class AX25Client { public: /*! - \brief Default constructor. + \brief Constructor for 2-FSK mode. \param phy Pointer to the wireless module providing PhysicalLayer communication. */ AX25Client(PhysicalLayer* phy); + /*! + \brief Constructor for AFSK mode. + + \param audio Pointer to the AFSK instance providing audio. + */ + AX25Client(AFSKClient* audio); + // basic methods /*! @@ -301,6 +316,7 @@ class AX25Client { private: #endif PhysicalLayer* _phy; + AFSKClient* _audio; char _srcCallsign[AX25_MAX_CALLSIGN_LEN + 1]; uint8_t _srcSSID; From 21c0703383706aee05f9cb5e6c13255defbdb873 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 17:10:37 +0200 Subject: [PATCH 041/455] [Hell] Added AFSK support --- .../Hellschreiber_Transmit.ino | 3 + .../Hellschreiber_Transmit_AFSK.ino | 122 ++++++++++++++++++ src/protocols/Hellschreiber/Hellschreiber.cpp | 36 +++++- src/protocols/Hellschreiber/Hellschreiber.h | 18 ++- 4 files changed, 171 insertions(+), 8 deletions(-) create mode 100644 examples/Hellschreiber/Hellschreiber_Transmit_AFSK/Hellschreiber_Transmit_AFSK.ino diff --git a/examples/Hellschreiber/Hellschreiber_Transmit/Hellschreiber_Transmit.ino b/examples/Hellschreiber/Hellschreiber_Transmit/Hellschreiber_Transmit.ino index c1d74d31..a8dda9f0 100644 --- a/examples/Hellschreiber/Hellschreiber_Transmit/Hellschreiber_Transmit.ino +++ b/examples/Hellschreiber/Hellschreiber_Transmit/Hellschreiber_Transmit.ino @@ -13,6 +13,9 @@ - nRF24 - Si443x/RFM2x - SX128x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library diff --git a/examples/Hellschreiber/Hellschreiber_Transmit_AFSK/Hellschreiber_Transmit_AFSK.ino b/examples/Hellschreiber/Hellschreiber_Transmit_AFSK/Hellschreiber_Transmit_AFSK.ino new file mode 100644 index 00000000..ec2aa4e7 --- /dev/null +++ b/examples/Hellschreiber/Hellschreiber_Transmit_AFSK/Hellschreiber_Transmit_AFSK.ino @@ -0,0 +1,122 @@ +/* + RadioLib Hellschreiber Transmit AFSK Example + + This example sends Hellschreiber message using + SX1278's FSK modem. The data is modulated + as AFSK. + + Other modules that can be used for Hellschreiber + with AFSK modulation: + - SX127x/RFM9x + - RF69 + - SX1231 + - CC1101 + - Si443x/RFM2x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// RESET pin: 9 +// DIO1 pin: 3 +SX1278 fsk = new Module(10, 2, 9, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 fsk = RadioShield.ModuleA; + +// create AFSK client instance using the FSK module +// pin 5 is connected to SX1278 DIO2 +AFSKClient audio(&fsk, 5); + +// create Hellschreiber client instance using the AFSK instance +HellClient hell(&audio); + +void setup() { + Serial.begin(9600); + + // initialize SX1278 + Serial.print(F("[SX1278] Initializing ... ")); + // carrier frequency: 434.0 MHz + // bit rate: 48.0 kbps + // frequency deviation: 50.0 kHz + // Rx bandwidth: 125.0 kHz + // output power: 13 dBm + // current limit: 100 mA + int state = fsk.beginFSK(); + + // when using one of the non-LoRa modules for Morse code + // (RF69, CC1101, Si4432 etc.), use the basic begin() method + // int state = fsk.begin(); + + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } + + // initialize Hellschreiber client + Serial.print(F("[Hell] Initializing ... ")); + // AFSK tone frequency: 400 Hz + // speed: 122.5 Baud ("Feld Hell") + state = hell.begin(400); + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } +} + +void loop() { + Serial.print(F("[Hell] Sending Hellschreiber data ... ")); + + // HellClient supports all methods of the Serial class + // NOTE: Lower case letter will be capitalized. + + // Arduino String class + String aStr = "Arduino String"; + hell.print(aStr); + + // character array (C-String) + hell.print("C-String"); + + // string saved in flash + hell.print(F("Flash String")); + + // character + hell.print('c'); + + // byte + // formatting DEC/HEX/OCT/BIN is supported for + // any integer type (byte/int/long) + hell.print(255, HEX); + + // integer number + int i = 1000; + hell.print(i); + + // floating point number + // NOTE: println() has no effect on the transmission, + // and is only kept for compatibility reasons. + float f = -3.1415; + hell.println(f, 3); + + // custom glyph - must be a 7 byte array of rows 7 pixels long + uint8_t customGlyph[] = { 0b0000000, 0b0010100, 0b0010100, 0b0000000, 0b0100010, 0b0011100, 0b0000000 }; + hell.printGlyph(customGlyph); + + Serial.println(F("done!")); + + // wait for a second before transmitting again + delay(1000); +} diff --git a/src/protocols/Hellschreiber/Hellschreiber.cpp b/src/protocols/Hellschreiber/Hellschreiber.cpp index ffc30ee3..3f769add 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.cpp +++ b/src/protocols/Hellschreiber/Hellschreiber.cpp @@ -2,17 +2,27 @@ HellClient::HellClient(PhysicalLayer* phy) { _phy = phy; + _audio = nullptr; +} + +HellClient::HellClient(AFSKClient* audio) { + _phy = audio->_phy; + _audio = audio; } int16_t HellClient::begin(float base, float rate) { // calculate 24-bit frequency + _baseHz = base; _base = (base * 1000000.0) / _phy->getFreqStep(); // calculate "pixel" duration _pixelDuration = 1000000.0/rate; - // set module frequency deviation to 0 - int16_t state = _phy->setFrequencyDeviation(0); + // set module frequency deviation to 0 if using FSK + int16_t state = ERR_NONE; + if(_audio == nullptr) { + state = _phy->setFrequencyDeviation(0); + } return(state); } @@ -23,16 +33,16 @@ size_t HellClient::printGlyph(uint8_t* buff) { for(int8_t i = HELL_FONT_HEIGHT - 1; i >= 0; i--) { uint32_t start = micros(); if(buff[i] & mask) { - _phy->transmitDirect(_base); + transmitDirect(_base, _baseHz); } else { - _phy->standby(); + standby(); } while(micros() - start < _pixelDuration); } } // make sure transmitter is off - _phy->standby(); + standby(); return(1); } @@ -269,3 +279,19 @@ size_t HellClient::printFloat(double number, uint8_t digits) { return n; } + +int16_t HellClient::transmitDirect(uint32_t freq, uint32_t freqHz) { + if(_audio != nullptr) { + return(_audio->tone(freqHz)); + } else { + return(_phy->transmitDirect(freq)); + } +} + +int16_t HellClient::standby() { + if(_audio != nullptr) { + return(_audio->noTone()); + } else { + return(_phy->standby()); + } +} diff --git a/src/protocols/Hellschreiber/Hellschreiber.h b/src/protocols/Hellschreiber/Hellschreiber.h index 9b14c27e..8756df5f 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.h +++ b/src/protocols/Hellschreiber/Hellschreiber.h @@ -3,6 +3,7 @@ #include "../../TypeDef.h" #include "../PhysicalLayer/PhysicalLayer.h" +#include "../AFSK/AFSK.h" #define HELL_FONT_WIDTH 7 #define HELL_FONT_HEIGHT 7 @@ -85,18 +86,25 @@ static const uint8_t HellFont[64][HELL_FONT_WIDTH - 2] PROGMEM = { class HellClient { public: /*! - \brief Default constructor. + \brief Constructor for 2-FSK mode. \param phy Pointer to the wireless module providing PhysicalLayer communication. */ HellClient(PhysicalLayer* phy); + /*! + \brief Constructor for AFSK mode. + + \param audio Pointer to the AFSK instance providing audio. + */ + HellClient(AFSKClient* audio); + // basic methods /*! \brief Initialization method. - \param base Base RF frequency to be used in MHz. + \param base Base RF frequency to be used in MHz (in 2-FSK mode), or the tone frequency in Hz (in AFSK mode). \param rate Baud rate to be used during transmission. Defaults to 122.5 ("Feld Hell") */ @@ -140,12 +148,16 @@ class HellClient { private: #endif PhysicalLayer* _phy; + AFSKClient* _audio; - uint32_t _base; + uint32_t _base, _baseHz; uint32_t _pixelDuration; size_t printNumber(unsigned long, uint8_t); size_t printFloat(double, uint8_t); + + int16_t transmitDirect(uint32_t freq = 0, uint32_t freqHz = 0); + int16_t standby(); }; #endif From 0a705f5bb9a54833c7fdc01d24bf4083f1e28c8f Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 17:10:54 +0200 Subject: [PATCH 042/455] [Morse] Added AFSK support --- .../Morse/Morse_Transmit/Morse_Transmit.ino | 3 + .../Morse_Transmit_AFSK.ino | 123 ++++++++++++++++++ src/protocols/Morse/Morse.cpp | 40 +++++- src/protocols/Morse/Morse.h | 19 ++- 4 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino diff --git a/examples/Morse/Morse_Transmit/Morse_Transmit.ino b/examples/Morse/Morse_Transmit/Morse_Transmit.ino index e0d6d1fe..4f3c07e4 100644 --- a/examples/Morse/Morse_Transmit/Morse_Transmit.ino +++ b/examples/Morse/Morse_Transmit/Morse_Transmit.ino @@ -13,6 +13,9 @@ - nRF24 - Si443x/RFM2x - SX128x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library diff --git a/examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino b/examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino new file mode 100644 index 00000000..3dbb5d6f --- /dev/null +++ b/examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino @@ -0,0 +1,123 @@ +/* + RadioLib Morse Transmit AFSK Example + + This example sends Morse code message using + SX1278's FSK modem. The data is modulated + as AFSK. + + Other modules that can be used for Morse Code + with AFSK modulation: + - SX127x/RFM9x + - RF69 + - SX1231 + - CC1101 + - Si443x/RFM2x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// RESET pin: 9 +// DIO1 pin: 3 +SX1278 fsk = new Module(10, 2, 9, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 fsk = RadioShield.ModuleA; + +// create AFSK client instance using the FSK module +// pin 5 is connected to SX1278 DIO2 +AFSKClient audio(&fsk, 5); + +// create Morse client instance using the AFSK instance +MorseClient morse(&audio); + +void setup() { + Serial.begin(9600); + + // initialize SX1278 + Serial.print(F("[SX1278] Initializing ... ")); + // carrier frequency: 434.0 MHz + // bit rate: 48.0 kbps + // frequency deviation: 50.0 kHz + // Rx bandwidth: 125.0 kHz + // output power: 13 dBm + // current limit: 100 mA + int state = fsk.beginFSK(); + + // when using one of the non-LoRa modules for Morse code + // (RF69, CC1101, Si4432 etc.), use the basic begin() method + // int state = fsk.begin(); + + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } + + // initialize Morse client + Serial.print(F("[Morse] Initializing ... ")); + // AFSK tone frequency: 400 MHz + // speed: 20 words per minute + state = morse.begin(400); + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } +} + +void loop() { + Serial.print(F("[Morse] Sending Morse data ... ")); + + // MorseClient supports all methods of the Serial class + // NOTE: Characters that do not have ITU-R M.1677-1 + // representation will not be sent! Lower case + // letters will be capitalized. + + // send start signal first + morse.startSignal(); + + // Arduino String class + String aStr = "Arduino String"; + morse.print(aStr); + + // character array (C-String) + morse.print("C-String"); + + // string saved in flash + morse.print(F("Flash String")); + + // character + morse.print('c'); + + // byte + // formatting DEC/HEX/OCT/BIN is supported for + // any integer type (byte/int/long) + morse.print(255, HEX); + + // integer number + int i = 1000; + morse.print(i); + + // floating point number + // NOTE: When using println(), the transmission will be + // terminated with end-of-work signal (...-.-). + float f = -3.1415; + morse.println(f, 3); + + Serial.println(F("done!")); + + // wait for a second before transmitting again + delay(1000); +} diff --git a/src/protocols/Morse/Morse.cpp b/src/protocols/Morse/Morse.cpp index 6b3e0c16..fe516132 100644 --- a/src/protocols/Morse/Morse.cpp +++ b/src/protocols/Morse/Morse.cpp @@ -2,17 +2,27 @@ MorseClient::MorseClient(PhysicalLayer* phy) { _phy = phy; + _audio = nullptr; +} + +MorseClient::MorseClient(AFSKClient* audio) { + _phy = audio->_phy; + _audio = audio; } int16_t MorseClient::begin(float base, uint8_t speed) { // calculate 24-bit frequency + _baseHz = base; _base = (base * 1000000.0) / _phy->getFreqStep(); // calculate dot length (assumes PARIS as typical word) _dotLength = 1200 / speed; - // set module frequency deviation to 0 - int16_t state = _phy->setFrequencyDeviation(0); + // set module frequency deviation to 0 if using FSK + int16_t state = ERR_NONE; + if(_audio == nullptr) { + state = _phy->setFrequencyDeviation(0); + } return(state); } @@ -46,7 +56,7 @@ size_t MorseClient::write(uint8_t b) { // inter-word pause (space) if(b == ' ') { RADIOLIB_DEBUG_PRINTLN(F("space")); - _phy->standby(); + standby(); delay(4 * _dotLength); return(1); } @@ -65,16 +75,16 @@ size_t MorseClient::write(uint8_t b) { // send dot or dash if (code & MORSE_DASH) { RADIOLIB_DEBUG_PRINT('-'); - _phy->transmitDirect(_base); + transmitDirect(_base, _baseHz); delay(3 * _dotLength); } else { RADIOLIB_DEBUG_PRINT('.'); - _phy->transmitDirect(_base); + transmitDirect(_base, _baseHz); delay(_dotLength); } // symbol space - _phy->standby(); + standby(); delay(_dotLength); // move onto the next bit @@ -82,7 +92,7 @@ size_t MorseClient::write(uint8_t b) { } // letter space - _phy->standby(); + standby(); delay(2 * _dotLength); RADIOLIB_DEBUG_PRINTLN(); @@ -283,3 +293,19 @@ size_t MorseClient::printFloat(double number, uint8_t digits) { return n; } + +int16_t MorseClient::transmitDirect(uint32_t freq, uint32_t freqHz) { + if(_audio != nullptr) { + return(_audio->tone(freqHz)); + } else { + return(_phy->transmitDirect(freq)); + } +} + +int16_t MorseClient::standby() { + if(_audio != nullptr) { + return(_audio->noTone()); + } else { + return(_phy->standby()); + } +} diff --git a/src/protocols/Morse/Morse.h b/src/protocols/Morse/Morse.h index 66df3280..e09fece0 100644 --- a/src/protocols/Morse/Morse.h +++ b/src/protocols/Morse/Morse.h @@ -3,6 +3,7 @@ #include "../../TypeDef.h" #include "../PhysicalLayer/PhysicalLayer.h" +#include "../AFSK/AFSK.h" #define MORSE_DOT 0b0 #define MORSE_DASH 0b1 @@ -88,18 +89,25 @@ static const uint8_t MorseTable[] PROGMEM = { class MorseClient { public: /*! - \brief Default constructor. + \brief Constructor for 2-FSK mode. \param phy Pointer to the wireless module providing PhysicalLayer communication. */ MorseClient(PhysicalLayer* phy); + /*! + \brief Constructor for AFSK mode. + + \param audio Pointer to the AFSK instance providing audio. + */ + MorseClient(AFSKClient* audio); + // basic methods /*! \brief Initialization method. - \param base Base RF frequency to be used in MHz. + \param base Base RF frequency to be used in MHz (in 2-FSK mode), or the tone frequency in Hz (in AFSK mode) \param speed Coding speed in words per minute. @@ -145,11 +153,16 @@ class MorseClient { private: #endif PhysicalLayer* _phy; - uint32_t _base; + AFSKClient* _audio; + + uint32_t _base, _baseHz; uint16_t _dotLength; size_t printNumber(unsigned long, uint8_t); size_t printFloat(double, uint8_t); + + int16_t transmitDirect(uint32_t freq = 0, uint32_t freqHz = 0); + int16_t standby(); }; #endif From f7f81cd41e44ac06e19495e370e3aa5513cdecd9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 17:11:09 +0200 Subject: [PATCH 043/455] [RTTY] Added AFSK support --- .../RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino | 133 ++++++++++++++++++ src/protocols/RTTY/RTTY.cpp | 40 +++++- src/protocols/RTTY/RTTY.h | 20 ++- 3 files changed, 182 insertions(+), 11 deletions(-) create mode 100644 examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino diff --git a/examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino b/examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino new file mode 100644 index 00000000..d836821e --- /dev/null +++ b/examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino @@ -0,0 +1,133 @@ +/* + RadioLib RTTY Transmit AFSK Example + + This example sends RTTY message using SX1278's + FSK modem. The data is modulated as AFSK. + + Other modules that can be used for RTTY: + - SX127x/RFM9x + - RF69 + - SX1231 + - CC1101 + - Si443x/RFM2x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// RESET pin: 9 +// DIO1 pin: 3 +SX1278 fsk = new Module(10, 2, 9, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 fsk = RadioShield.ModuleA; + +// create AFSK client instance using the FSK module +// pin 5 is connected to SX1278 DIO2 +AFSKClient audio(&fsk, 5); + +// create RTTY client instance using the AFSK instance +RTTYClient rtty(&audio); + +void setup() { + Serial.begin(9600); + + // initialize SX1278 + Serial.print(F("[SX1278] Initializing ... ")); + // carrier frequency: 434.0 MHz + // bit rate: 48.0 kbps + // frequency deviation: 50.0 kHz + // Rx bandwidth: 125.0 kHz + // output power: 13 dBm + // current limit: 100 mA + int state = fsk.beginFSK(); + + // when using one of the non-LoRa modules for RTTY + // (RF69, CC1101, Si4432 etc.), use the basic begin() method + // int state = fsk.begin(); + + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } + + // initialize RTTY client + // NOTE: Unlike FSK RTTY, AFSK requires no rounding of + // the frequency shift. + Serial.print(F("[RTTY] Initializing ... ")); + // space frequency: 400 Hz + // frequency shift: 170 Hz + // baud rate: 45 baud + // encoding: ASCII (7-bit) + // stop bits: 1 + state = rtty.begin(400, 170, 45); + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } + + /* + // RadioLib also provides ITA2 ("Baudot") support + rtty.begin(400, 170, 45, ITA2); + + // All transmissions in loop() (strings and numbers) + // will now be encoded using ITA2 code + + // ASCII characters that do not have ITA2 equivalent + // will be sent as NUL (including lower case letters!) + */ +} + +void loop() { + Serial.print(F("[RTTY] Sending RTTY data ... ")); + + // send out idle condition for 500 ms + rtty.idle(); + delay(500); + + // RTTYClient supports all methods of the Serial class + + // Arduino String class + String aStr = "Arduino String"; + rtty.println(aStr); + + // character array (C-String) + rtty.println("C-String"); + + // string saved in flash + rtty.println(F("Flash String")); + + // character + rtty.println('c'); + + // byte + // formatting DEC/HEX/OCT/BIN is supported for + // any integer type (byte/int/long) + rtty.println(255, HEX); + + // integer number + int i = 1000; + rtty.println(i); + + // floating point number + float f = -3.1415; + rtty.println(f, 3); + + Serial.println(F("done!")); + + // wait for a second before transmitting again + delay(1000); +} diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 085d3794..1a96d5e2 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -106,12 +106,20 @@ uint16_t ITA2String::getBits(char c) { RTTYClient::RTTYClient(PhysicalLayer* phy) { _phy = phy; + _audio = nullptr; +} + +RTTYClient::RTTYClient(AFSKClient* audio) { + _phy = audio->_phy; + _audio = audio; } int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t encoding, uint8_t stopBits) { // save configuration _encoding = encoding; _stopBits = stopBits; + _baseHz = base; + _shiftHz = shift; switch(encoding) { case ASCII: @@ -148,15 +156,17 @@ int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t enc // calculate 24-bit frequency _base = (base * 1000000.0) / _phy->getFreqStep(); - // set module frequency deviation to 0 - int16_t state = _phy->setFrequencyDeviation(0); + // set module frequency deviation to 0 if using FSK + int16_t state = ERR_NONE; + if(_audio == nullptr) { + state = _phy->setFrequencyDeviation(0); + } return(state); } void RTTYClient::idle() { - _phy->transmitDirect(); - + transmitDirect(); mark(); } @@ -190,7 +200,7 @@ size_t RTTYClient::write(uint8_t b) { mark(); } - _phy->standby(); + standby(); return(1); } @@ -391,7 +401,7 @@ size_t RTTYClient::println(double d, int digits) { void RTTYClient::mark() { uint32_t start = micros(); - _phy->transmitDirect(_base + _shift); + transmitDirect(_base + _shift, _baseHz + _shiftHz); while(micros() - start < _bitDuration) { yield(); } @@ -399,7 +409,7 @@ void RTTYClient::mark() { void RTTYClient::space() { uint32_t start = micros(); - _phy->transmitDirect(_base); + transmitDirect(_base, _baseHz); while(micros() - start < _bitDuration) { yield(); } @@ -505,3 +515,19 @@ size_t RTTYClient::printFloat(double number, uint8_t digits) { return n; } + +int16_t RTTYClient::transmitDirect(uint32_t freq, uint32_t freqHz) { + if(_audio != nullptr) { + return(_audio->tone(freqHz)); + } else { + return(_phy->transmitDirect(freq)); + } +} + +int16_t RTTYClient::standby() { + if(_audio != nullptr) { + return(_audio->noTone()); + } else { + return(_phy->standby()); + } +} diff --git a/src/protocols/RTTY/RTTY.h b/src/protocols/RTTY/RTTY.h index 5c22568c..1e6120c1 100644 --- a/src/protocols/RTTY/RTTY.h +++ b/src/protocols/RTTY/RTTY.h @@ -3,6 +3,7 @@ #include "../../TypeDef.h" #include "../PhysicalLayer/PhysicalLayer.h" +#include "../AFSK/AFSK.h" #define ITA2_FIGS 0x1B #define ITA2_LTRS 0x1F @@ -84,18 +85,25 @@ class ITA2String { class RTTYClient { public: /*! - \brief Default constructor. + \brief Constructor for 2-FSK mode. \param phy Pointer to the wireless module providing PhysicalLayer communication. */ RTTYClient(PhysicalLayer* phy); + /*! + \brief Constructor for AFSK mode. + + \param audio Pointer to the AFSK instance providing audio. + */ + RTTYClient(AFSKClient* audio); + // basic methods /*! \brief Initialization method. - \param base Base (space) RF frequency to be used in MHz. + \param base Base (space) frequency to be used in MHz (in 2-FSK mode), or the space tone frequency in Hz (in AFSK mode) \param shift Frequency shift between mark and space in Hz. @@ -147,10 +155,11 @@ class RTTYClient { private: #endif PhysicalLayer* _phy; + AFSKClient* _audio; uint8_t _encoding; - uint32_t _base; - uint32_t _shift; + uint32_t _base, _baseHz; + uint32_t _shift, _shiftHz; uint32_t _bitDuration; uint8_t _dataBits; uint8_t _stopBits; @@ -160,6 +169,9 @@ class RTTYClient { size_t printNumber(unsigned long, uint8_t); size_t printFloat(double, uint8_t); + + int16_t transmitDirect(uint32_t freq = 0, uint32_t freqHz = 0); + int16_t standby(); }; #endif From 0a07f22e931efe61ceb0c61993214a0a73791892 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 17:11:24 +0200 Subject: [PATCH 044/455] [SSTV] Added AFSK support --- .../SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino | 155 ++++++++++++++++++ src/protocols/SSTV/SSTV.cpp | 30 +++- src/protocols/SSTV/SSTV.h | 30 +++- 3 files changed, 209 insertions(+), 6 deletions(-) create mode 100644 examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino diff --git a/examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino b/examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino new file mode 100644 index 00000000..b43c3743 --- /dev/null +++ b/examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino @@ -0,0 +1,155 @@ +/* + RadioLib SSTV Transmit AFSK Example + + The following example sends SSTV picture using + SX1278's FSK modem. The data is modulated + as AFSK. + + Other modules that can be used for SSTV: + with AFSK modulation: + - SX127x/RFM9x + - RF69 + - SX1231 + - CC1101 + - Si443x/RFM2x + + NOTE: Some platforms (such as Arduino Uno) + might not be fast enough to correctly + send pictures via high-speed modes + like Scottie2 or Martin2. For those, + lower speed modes such as Wrasse, + Scottie1 or Martin1 are recommended. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// RESET pin: 9 +// DIO1 pin: 3 +SX1278 fsk = new Module(10, 2, 9, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 fsk = RadioShield.ModuleA; + +// create AFSK client instance using the FSK module +// pin 5 is connected to SX1278 DIO2 +AFSKClient audio(&fsk, 5); + +// create SSTV client instance using the AFSK instance +SSTVClient sstv(&audio); + +// test "image" - actually just a single 320px line +// will be sent over and over again, to create vertical color stripes at the receiver +uint32_t line[320] = { + // black + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + + // blue + 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, + 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, + + // green + 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, + 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, + + // cyan + 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, + 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, + + // red + 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, + 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, + + // magenta + 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, + 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, + + // yellow + 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, + 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, + + // white + 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, + 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF +}; + +void setup() { + Serial.begin(9600); + + // initialize SX1278 + Serial.print(F("[SX1278] Initializing ... ")); + // carrier frequency: 434.0 MHz + // bit rate: 48.0 kbps + // frequency deviation: 50.0 kHz + // Rx bandwidth: 125.0 kHz + // output power: 13 dBm + // current limit: 100 mA + int state = fsk.beginFSK(); + if (state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while (true); + } + + // when using one of the non-LoRa modules for SSTV + // (RF69, SX1231 etc.), use the basic begin() method + // int state = fsk.begin(); + + // initialize SSTV client + Serial.print(F("[SSTV] Initializing ... ")); + // SSTV mode: Wrasse (SC2-180) + // correction factor: 0.95 + // NOTE: Due to different speeds of various platforms + // supported by RadioLib (Arduino Uno, ESP32 etc), + // and because SSTV is analog protocol, incorrect + // timing of pulses can lead to distortions. + // To compensate, correction factor can be used + // to adjust the length of timing pulses + // (lower number = shorter pulses). + // The value is usually around 0.95 (95%). + state = sstv.begin(Wrasse, 0.95); + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } + + // to help tune the receiver, SSTVClient can send + // continuous 1900 Hz beep + /* + sstv.idle(); + while(true); + */ +} + +void loop() { + // send picture with 8 color stripes + Serial.print(F("[SSTV] Sending test picture ... ")); + + // send synchronization header first + sstv.sendHeader(); + + // send all picture lines + for(uint16_t i = 0; i < sstv.getPictureHeight(); i++) { + sstv.sendLine(line); + } + + // turn off transmitter + fsk.standby(); + + Serial.println(F("done!")); + + delay(30000); +} diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index c3843ad8..4bc16902 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -155,6 +155,21 @@ const SSTVMode_t PasokonP7 { SSTVClient::SSTVClient(PhysicalLayer* phy) { _phy = phy; + _audio = nullptr; +} + +SSTVClient::SSTVClient(AFSKClient* audio) { + _phy = audio->_phy; + _audio = audio; +} + +int16_t SSTVClient::begin(SSTVMode_t mode, float correction) { + if(_audio == nullptr) { + // this initialization method can only be used in AFSK mode + return(ERR_WRONG_MODEM); + } + + return(begin(0, mode, correction)); } int16_t SSTVClient::begin(float base, SSTVMode_t mode, float correction) { @@ -170,19 +185,24 @@ int16_t SSTVClient::begin(float base, SSTVMode_t mode, float correction) { // calculate 24-bit frequency _base = (base * 1000000.0) / _phy->getFreqStep(); - // set module frequency deviation to 0 - int16_t state = _phy->setFrequencyDeviation(0); + // set module frequency deviation to 0 if using FSK + int16_t state = ERR_NONE; + if(_audio == nullptr) { + state = _phy->setFrequencyDeviation(0); + } return(state); } void SSTVClient::idle() { + _phy->transmitDirect(); tone(SSTV_TONE_LEADER); } void SSTVClient::sendHeader() { // save first header flag for Scottie modes _firstLine = true; + _phy->transmitDirect(); // send the first part of header (leader-break-leader) tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH); @@ -261,7 +281,11 @@ uint16_t SSTVClient::getPictureHeight() { void SSTVClient::tone(float freq, uint32_t len) { uint32_t start = micros(); - _phy->transmitDirect(_base + (freq / _phy->getFreqStep())); + if(_audio != nullptr) { + _audio->tone(freq, false); + } else { + _phy->transmitDirect(_base + (freq / _phy->getFreqStep())); + } while(micros() - start < len) { yield(); } diff --git a/src/protocols/SSTV/SSTV.h b/src/protocols/SSTV/SSTV.h index d8dc0c8b..4c6777d0 100644 --- a/src/protocols/SSTV/SSTV.h +++ b/src/protocols/SSTV/SSTV.h @@ -3,6 +3,7 @@ #include "../../TypeDef.h" #include "../PhysicalLayer/PhysicalLayer.h" +#include "../AFSK/AFSK.h" // the following implementation is based on information from // http://www.barberdsp.com/downloads/Dayton%20Paper.pdf @@ -116,23 +117,45 @@ extern const SSTVMode_t PasokonP7; class SSTVClient { public: /*! - \brief Default constructor. + \brief Constructor for 2-FSK mode. \param phy Pointer to the wireless module providing PhysicalLayer communication. */ SSTVClient(PhysicalLayer* phy); + /*! + \brief Constructor for AFSK mode. + + \param audio Pointer to the AFSK instance providing audio. + */ + SSTVClient(AFSKClient* phy); + // basic methods /*! - \brief Initialization method. + \brief Initialization method for 2-FSK. - \param base Base RF frequency to be used in MHz. In USB modulation, this corresponds to "0 Hz tone". + \param base Base "0 Hz tone" RF frequency to be used in MHz. \param mode SSTV mode to be used. Currently supported modes are Scottie1, Scottie2, ScottieDX, Martin1, Martin2, Wrasse, PasokonP3, PasokonP5 and PasokonP7. + + \param correction Timing correction factor, used to adjust the length of timing pulses. Less than 1.0 leads to shorter timing pulses, defaults to 1.0 (no correction). + + \returns \ref status_codes */ int16_t begin(float base, SSTVMode_t mode, float correction = 1.0); + /*! + \brief Initialization method for AFSK. + + \param mode SSTV mode to be used. Currently supported modes are Scottie1, Scottie2, ScottieDX, Martin1, Martin2, Wrasse, PasokonP3, PasokonP5 and PasokonP7. + + \param correction Timing correction factor, used to adjust the length of timing pulses. Less than 1.0 leads to shorter timing pulses, defaults to 1.0 (no correction). + + \returns \ref status_codes + */ + int16_t begin(SSTVMode_t mode, float correction = 1.0); + /*! \brief Sends out tone at 1900 Hz. */ @@ -161,6 +184,7 @@ class SSTVClient { private: #endif PhysicalLayer* _phy; + AFSKClient* _audio; uint32_t _base; SSTVMode_t _mode; From c389e68ee8b4d9bddccd57b0d959de54db2d4141 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 17:11:54 +0200 Subject: [PATCH 045/455] Added notes about AFSK TRAVIS_FORCE_BUILD --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b56ab927..884d0c1f 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,20 @@ RadioLib was originally created as a driver for [__RadioShield__](https://github * __XBee__ modules (S2B) ### Supported protocols and digital modes: -* __MQTT__ for modules: ESP8266 -* __HTTP__ for modules: ESP8266 -* __AX.25__ for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, RFM2x and Si443x -* [__RTTY__](https://www.sigidwiki.com/wiki/RTTY) for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x -* [__Morse Code__](https://www.sigidwiki.com/wiki/Morse_Code_(CW)) for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x -* [__SSTV__](https://www.sigidwiki.com/wiki/SSTV) for modules: SX127x, RFM9x, SX126x, RF69 and SX1231 -* [__Hellschreiber__](https://www.sigidwiki.com/wiki/Hellschreiber) for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x +* __MQTT__ for modules: +ESP8266 +* __HTTP__ for modules: +ESP8266 +* __AX.25__ using 2-FSK or AFSK for modules: +SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, RFM2x and Si443x +* [__RTTY__](https://www.sigidwiki.com/wiki/RTTY) using 2-FSK or AFSK for modules: +SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x +* [__Morse Code__](https://www.sigidwiki.com/wiki/Morse_Code_(CW)) using 2-FSK or AFSK for modules: +SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x +* [__SSTV__](https://www.sigidwiki.com/wiki/SSTV) using 2-FSK or AFSK for modules: +SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, RFM2x and Si443x +* [__Hellschreiber__](https://www.sigidwiki.com/wiki/Hellschreiber) using 2-FSK or AFSK for modules: +SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x ### Supported platforms: * __Arduino__ @@ -66,6 +73,7 @@ The list above is by no means exhaustive. Most of RadioLib code is independent o ### In development: * __SIM800C__ GSM module * __LoRaWAN__ protocol for SX127x, RFM9x and SX126x modules +* __APRS__ protocol for all the modules that can transmit AX.25 * ___and more!___ ## Frequently Asked Questions From 288d8a3051b70944117bcab9290d1acf5a444da3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 18:29:57 +0200 Subject: [PATCH 046/455] Travis attempt to fix exec not found error for STM32F4 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a35b2190..72221365 100644 --- a/.travis.yml +++ b/.travis.yml @@ -107,8 +107,9 @@ before_install: arduino --install-boards stm32duino:STM32F1; elif [[ "$BOARD" =~ "stm32duino:STM32F4:" ]]; then - export BUILD_EXAMPLES=false; + export BUILD_EXAMPLES=true; arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; + arduino --install-boards stm32duino:STM32F1; arduino --install-boards stm32duino:STM32F4; fi From c8e1c48c006987f54de8f16573da0a62da88b348 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 18:44:27 +0200 Subject: [PATCH 047/455] Travis trying different STM32F4 board --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 72221365..7c1f8700 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ env: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt - BOARD="arduino:avr:uno" + - BOARD="stm32duino:STM32F4:generic_f407v:usb_cfg=usb_serial" - BOARD="arduino:avr:mega:cpu=atmega2560" - BOARD="arduino:avr:leonardo" - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" @@ -18,7 +19,6 @@ env: - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:mbed:nano33ble" - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" - - BOARD="stm32duino:STM32F4:discovery_f407:usb_cfg=usb_serial" addons: apt: @@ -109,7 +109,6 @@ before_install: elif [[ "$BOARD" =~ "stm32duino:STM32F4:" ]]; then export BUILD_EXAMPLES=true; arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; - arduino --install-boards stm32duino:STM32F1; arduino --install-boards stm32duino:STM32F4; fi From 59fa831d996b0cbcb37c041c286b3211e0fdc91d Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 18:48:13 +0200 Subject: [PATCH 048/455] Travis added upload method to STM32F4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7c1f8700..619d72d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ env: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt - BOARD="arduino:avr:uno" - - BOARD="stm32duino:STM32F4:generic_f407v:usb_cfg=usb_serial" + - BOARD="stm32duino:STM32F4:generic_f407v:usb_cfg=usb_serial,upload_method=STLinkMethod" - BOARD="arduino:avr:mega:cpu=atmega2560" - BOARD="arduino:avr:leonardo" - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" From 9477789e9be195f5b036e61ed814a2cab13dbe7d Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 30 Apr 2020 18:51:21 +0200 Subject: [PATCH 049/455] Travis removed STM32F4 --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 619d72d1..dbb1da43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ env: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt - BOARD="arduino:avr:uno" - - BOARD="stm32duino:STM32F4:generic_f407v:usb_cfg=usb_serial,upload_method=STLinkMethod" - BOARD="arduino:avr:mega:cpu=atmega2560" - BOARD="arduino:avr:leonardo" - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" @@ -106,11 +105,6 @@ before_install: arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; arduino --install-boards stm32duino:STM32F1; - elif [[ "$BOARD" =~ "stm32duino:STM32F4:" ]]; then - export BUILD_EXAMPLES=true; - arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; - arduino --install-boards stm32duino:STM32F4; - fi # check if this release commit (or forced build) and if so, build for every board From eccf6e3865e2073bf17bf7b166e3a6c36d455442 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 1 May 2020 13:50:29 +0200 Subject: [PATCH 050/455] [ESP8266] Fixed format overflow warning --- src/modules/ESP8266/ESP8266.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index f55d7c9d..bc372ac6 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -131,7 +131,7 @@ int16_t ESP8266::closeTransportConnection() { int16_t ESP8266::send(const char* data) { // build AT command - char lenStr[8]; + char lenStr[12]; sprintf(lenStr, "%d", strlen(data)); const char* atStr = "AT+CIPSEND="; #ifdef RADIOLIB_STATIC_ONLY From e070cf9ef400c83464a0a90b9344b1dffd0708b6 Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 30 Apr 2020 21:13:37 -0700 Subject: [PATCH 051/455] No reason to wait 1s between probes (for a 4MHz spi bus). Change to 10ms so probing for parts doesn't slow our boot so much. --- src/modules/SX127x/SX127x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 727cf2b1..84cf1eb6 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -998,7 +998,7 @@ bool SX127x::findChip(uint8_t ver) { RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); RADIOLIB_DEBUG_PRINTLN(ver, HEX); #endif - delay(1000); + delay(10); i++; } } From 2c31adc4015a46697171c5911f7c60d4e24c7942 Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 30 Apr 2020 18:29:51 -0700 Subject: [PATCH 052/455] Set the min/max ranges per the Semtech SX1278/SX1276 datasheet --- src/modules/RFM9x/RFM95.cpp | 2 +- src/modules/RFM9x/RFM96.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/RFM9x/RFM95.cpp b/src/modules/RFM9x/RFM95.cpp index 49557190..fa5c684a 100644 --- a/src/modules/RFM9x/RFM95.cpp +++ b/src/modules/RFM9x/RFM95.cpp @@ -35,7 +35,7 @@ int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW } int16_t RFM95::setFrequency(float freq) { - RADIOLIB_CHECK_RANGE(freq, 868.0, 915.0, ERR_INVALID_FREQUENCY); + RADIOLIB_CHECK_RANGE(freq, 862.0, 1020.0, ERR_INVALID_FREQUENCY); // set frequency return(SX127x::setFrequencyRaw(freq)); diff --git a/src/modules/RFM9x/RFM96.cpp b/src/modules/RFM9x/RFM96.cpp index cf81ca40..1d5cdc74 100644 --- a/src/modules/RFM9x/RFM96.cpp +++ b/src/modules/RFM9x/RFM96.cpp @@ -35,7 +35,7 @@ int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW } int16_t RFM96::setFrequency(float freq) { - RADIOLIB_CHECK_RANGE(freq, 433.0, 470.0, ERR_INVALID_FREQUENCY); + RADIOLIB_CHECK_RANGE(freq, 410.0, 525.0, ERR_INVALID_FREQUENCY); // set frequency return(SX127x::setFrequencyRaw(freq)); From 601f6324e4bccaca2bc6db2932c1ab62f6872152 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 1 May 2020 20:26:53 +0200 Subject: [PATCH 053/455] [SX128x] Fixed unitialized variable warning --- src/modules/SX128x/SX128x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 098d783f..f7d104ff 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1009,7 +1009,7 @@ float SX128x::getSNR() { size_t SX128x::getPacketLength(bool update) { (void)update; - uint8_t rxBufStatus[2]; + uint8_t rxBufStatus[2] = {0, 0}; SPIreadCommand(SX128X_CMD_GET_RX_BUFFER_STATUS, rxBufStatus, 2); return((size_t)rxBufStatus[0]); } From 305d8809265080f2661e6ea4ee7dea84a505a39a Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 1 May 2020 20:52:59 +0200 Subject: [PATCH 054/455] [Xbee] Lowered findChip delay to 10 ms --- src/modules/XBee/XBee.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/XBee/XBee.cpp b/src/modules/XBee/XBee.cpp index aa365ea3..4bfcab40 100644 --- a/src/modules/XBee/XBee.cpp +++ b/src/modules/XBee/XBee.cpp @@ -35,7 +35,7 @@ int16_t XBee::begin(long speed) { RADIOLIB_DEBUG_PRINTLN(state); RADIOLIB_DEBUG_PRINTLN(F("Resetting ...")); reset(); - delay(1000); + delay(10); _mod->ATemptyBuffer(); i++; } From 9119020d0db20b5b6a19bebc7b73fe29ef590dac Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 1 May 2020 20:53:08 +0200 Subject: [PATCH 055/455] [Si443x] Lowered findChip delay to 10 ms --- src/modules/Si443x/Si443x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 13af7747..5a55a98f 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -551,7 +551,7 @@ bool Si443x::findChip() { RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); RADIOLIB_DEBUG_PRINTLN(SI443X_DEVICE_VERSION, HEX); #endif - delay(1000); + delay(10); i++; } } From 1fa483f98b1e7840192bcab6f668c6017f08cef9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 1 May 2020 20:53:15 +0200 Subject: [PATCH 056/455] [SX1231] Lowered findChip delay to 10 ms --- src/modules/SX1231/SX1231.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index da54a919..1e1388d7 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -30,7 +30,7 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po RADIOLIB_DEBUG_PRINT(F(", expected 0x0021 / 0x0022 / 0x0023")); RADIOLIB_DEBUG_PRINTLN(); #endif - delay(1000); + delay(10); i++; } } From 078ec4d13e0e63df660f992f6c30c8073864084d Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 1 May 2020 20:53:23 +0200 Subject: [PATCH 057/455] [RF69] Lowered findChip delay to 10 ms --- src/modules/RF69/RF69.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index ba7bfcb7..1eb2a146 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -40,7 +40,7 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe RADIOLIB_DEBUG_PRINT(F(", expected 0x0024")); RADIOLIB_DEBUG_PRINTLN(); #endif - delay(1000); + delay(10); i++; } } From d609c8ba5680c3700ef17f3dd41074971b67211f Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 1 May 2020 20:53:50 +0200 Subject: [PATCH 058/455] [CC1101] Lowered findChip delay to 10 ms --- src/modules/CC1101/CC1101.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 039c155d..c913aacd 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -35,7 +35,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po RADIOLIB_DEBUG_PRINT(F(", expected 0x0014")); RADIOLIB_DEBUG_PRINTLN(); #endif - delay(1000); + delay(10); i++; } } From ed0a6623a605e6cbc25b5c102f91c297b78afcc0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 3 May 2020 11:04:45 +0200 Subject: [PATCH 059/455] [AFSK] Executed Order 66 --- .../AFSK_Imperial_March.ino | 97 +++++++++++++ examples/AFSK/AFSK_Imperial_March/melody.h | 128 ++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino create mode 100644 examples/AFSK/AFSK_Imperial_March/melody.h diff --git a/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino b/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino new file mode 100644 index 00000000..82052f05 --- /dev/null +++ b/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino @@ -0,0 +1,97 @@ +/* + RadioLib AFSK Imperial March Example + + This example shows how to EXECUTE ORDER 66 + + Other modules that can be used for AFSK: + - SX127x/RFM9x + - RF69 + - SX1231 + - CC1101 + - Si443x/RFM2x + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ +*/ + +// include the library +#include + +// include the melody +#include "melody.h" + +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// RESET pin: 9 +// DIO1 pin: 3 +SX1278 fsk = new Module(10, 2, 9, 3); + +// create AFSK client instance using the FSK module +// this requires connection to the module direct +// input pin, here connected to Arduino pin 5 +// SX127x/RFM9x: DIO2 +// RF69: DIO2 +// SX1231: DIO2 +// CC1101: GDO2 +// Si443x/RFM2x: GPIO +AFSKClient audio(&fsk, 5); + +void setup() { + Serial.begin(9600); + + // initialize SX1278 + Serial.print(F("[SX1278] Initializing ... ")); + // carrier frequency: 434.0 MHz + // bit rate: 48.0 kbps + // frequency deviation: 50.0 kHz + // Rx bandwidth: 125.0 kHz + // output power: 13 dBm + // current limit: 100 mA + int state = fsk.beginFSK(); + + // when using one of the non-LoRa modules for AFSK + // (RF69, CC1101,, Si4432 etc.), use the basic begin() method + // int state = fsk.begin(); + + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } +} + +void loop() { + Serial.print(F("[AFSK] Executing Order 66 ... ")); + + // calculate whole note duration + int wholenote = (60000 * 4) / 120; + + // iterate over the melody + for(int note = 0; note < sizeof(melody) / sizeof(melody[0]); note += 2) { + // calculate the duration of each note + int noteDuration = 0; + int divider = melody[note + 1]; + if(divider > 0) { + // regular note, just proceed + noteDuration = wholenote / divider; + } else if(divider < 0) { + // dotted notes are represented with negative durations!! + noteDuration = wholenote / abs(divider); + noteDuration *= 1.5; // increases the duration in half for dotted notes + } + + // we only play the note for 90% of the duration, leaving 10% as a pause + audio.tone(melody[note]); + delay(noteDuration*0.9); + audio.noTone(); + delay(noteDuration*0.1); + } + + Serial.println(F("done!")); + + // wait for a second + delay(1000); +} diff --git a/examples/AFSK/AFSK_Imperial_March/melody.h b/examples/AFSK/AFSK_Imperial_March/melody.h new file mode 100644 index 00000000..e4b15169 --- /dev/null +++ b/examples/AFSK/AFSK_Imperial_March/melody.h @@ -0,0 +1,128 @@ +/* + Note definitions, melody and melody-related functions + adapted from https://github.com/robsoncouto/arduino-songs + by Robson Couto, 2019 +*/ + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 +#define REST 0 + +// notes of the moledy followed by the duration. +// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on +// !!negative numbers are used to represent dotted notes, +// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! +int melody[] = { + + // Darth Vader theme (Imperial March) - Star wars + // Score available at https://musescore.com/user/202909/scores/1141521 + // The tenor saxophone part was used + + NOTE_A4,-4, NOTE_A4,-4, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_F4,8, REST,8, + NOTE_A4,-4, NOTE_A4,-4, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_F4,8, REST,8, + NOTE_A4,4, NOTE_A4,4, NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, + + NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2,//4 + NOTE_E5,4, NOTE_E5,4, NOTE_E5,4, NOTE_F5,-8, NOTE_C5,16, + NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2, + + NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7 + NOTE_DS5,16, NOTE_D5,16, NOTE_DS5,8, REST,8, NOTE_A4,8, NOTE_DS5,4, NOTE_D5,-8, NOTE_CS5,16, + + NOTE_C5,16, NOTE_B4,16, NOTE_C5,16, REST,8, NOTE_F4,8, NOTE_GS4,4, NOTE_F4,-8, NOTE_A4,-16,//9 + NOTE_C5,4, NOTE_A4,-8, NOTE_C5,16, NOTE_E5,2, + + NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7 + NOTE_DS5,16, NOTE_D5,16, NOTE_DS5,8, REST,8, NOTE_A4,8, NOTE_DS5,4, NOTE_D5,-8, NOTE_CS5,16, + + NOTE_C5,16, NOTE_B4,16, NOTE_C5,16, REST,8, NOTE_F4,8, NOTE_GS4,4, NOTE_F4,-8, NOTE_A4,-16,//9 + NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2, + +}; From 79d8ff2ca03a43689f5be8662a8027e8ccc4bf3d Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 3 May 2020 11:04:51 +0200 Subject: [PATCH 060/455] [AFSK] Added check for zero tone frequency --- src/protocols/AFSK/AFSK.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/protocols/AFSK/AFSK.cpp b/src/protocols/AFSK/AFSK.cpp index a8453925..e2a90641 100644 --- a/src/protocols/AFSK/AFSK.cpp +++ b/src/protocols/AFSK/AFSK.cpp @@ -6,6 +6,10 @@ AFSKClient::AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin) { } int16_t AFSKClient::tone(uint16_t freq, bool autoStart) { + if(freq == 0) { + return(ERR_INVALID_FREQUENCY); + } + if(autoStart) { int16_t state = _phy->transmitDirect(); RADIOLIB_ASSERT(state); From 3719d6dd9251cf3661066f7a5fb6c9f268b52f3e Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:30:57 +0200 Subject: [PATCH 061/455] [AFSK] Removed redundant argument --- examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino b/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino index aa9d82f4..d55e14aa 100644 --- a/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino +++ b/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino @@ -50,7 +50,7 @@ void setup() { // Rx bandwidth: 125.0 kHz // output power: 13 dBm // current limit: 100 mA - int state = fsk.beginFSK(434.0); + int state = fsk.beginFSK(); // when using one of the non-LoRa modules for AX.25 // (RF69, CC1101,, Si4432 etc.), use the basic begin() method From 6721fad68a025a134e8bb4e652a2acd01289be86 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:31:47 +0200 Subject: [PATCH 062/455] Implemented custom digital pin to interrupt macro --- src/BuildOpt.h | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 5ea12a5e..4d47b7b1 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -23,25 +23,27 @@ * In addition, some platforms may require RadioLib to disable specific drivers (such as ESP8266). */ #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) - // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. - #define RADIOLIB_PLATFORM "Arduino AVR" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_NC (0xFF) + // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. + #define RADIOLIB_PLATFORM "Arduino AVR" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) #elif defined(ESP8266) - // ESP8266 boards - #define RADIOLIB_PLATFORM "ESP8266" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_NC (0xFF) + // ESP8266 boards + #define RADIOLIB_PLATFORM "ESP8266" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) - // RadioLib has ESPS8266 driver, this must be disabled to use ESP8266 as platform - #define _RADIOLIB_ESP8266_H + // RadioLib has ESP8266 driver, this must be disabled to use ESP8266 as platform + #define _RADIOLIB_ESP8266_H #elif defined(ESP32) // ESP32 boards @@ -50,6 +52,7 @@ #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -62,6 +65,7 @@ #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(digitalPinToPinName(p)) #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -73,6 +77,7 @@ #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -84,6 +89,7 @@ #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -96,6 +102,7 @@ #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) #elif defined(ARDUINO_ARC32_TOOLS) @@ -105,6 +112,7 @@ #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) @@ -114,6 +122,7 @@ #define RADIOLIB_PIN_MODE PinMode #define RADIOLIB_PIN_STATUS PinStatus #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #elif defined(AM_PART_APOLLO3) @@ -123,6 +132,7 @@ #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -135,6 +145,7 @@ #define RADIOLIB_PIN_MODE PinMode #define RADIOLIB_PIN_STATUS PinStatus #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -149,6 +160,7 @@ #define RADIOLIB_PIN_MODE WiringPinMode #define RADIOLIB_PIN_STATUS uint8_t #define RADIOLIB_INTERRUPT_STATUS ExtIntTriggerMode + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -162,6 +174,7 @@ #define RADIOLIB_PIN_MODE uint8_t #define RADIOLIB_PIN_STATUS uint8_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #endif @@ -213,7 +226,7 @@ * Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode. */ -//#define RADIOLIB_STATIC_ONLY +#define RADIOLIB_STATIC_ONLY // set the size of static arrays to use #define RADIOLIB_STATIC_ARRAY_SIZE 256 From f9c7e9e7f50073720c60e7154f66a6b5c5dc4db0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:32:17 +0200 Subject: [PATCH 063/455] [CC1101] Added digital pin to interrupt macro --- src/modules/CC1101/CC1101.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index c913aacd..d0259e4a 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -180,11 +180,11 @@ int16_t CC1101::packetMode() { } void CC1101::setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { - attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, dir); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, dir); } void CC1101::clearGdo0Action() { - detachInterrupt(digitalPinToInterrupt(_mod->getIrq())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { @@ -192,14 +192,14 @@ void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { return; } Module::pinMode(_mod->getGpio(), INPUT); - attachInterrupt(digitalPinToInterrupt(_mod->getGpio()), func, dir); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, dir); } void CC1101::clearGdo2Action() { if(_mod->getGpio() != RADIOLIB_NC) { return; } - detachInterrupt(digitalPinToInterrupt(_mod->getGpio())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); } int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { From 19028b64e0e51901a93023d62124ce03bc4d7a3d Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:32:26 +0200 Subject: [PATCH 064/455] [RF69] Added digital pin to interrupt macro --- src/modules/RF69/RF69.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 1eb2a146..08d6a12e 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -250,11 +250,11 @@ int16_t RF69::startReceive() { } void RF69::setDio0Action(void (*func)(void)) { - attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, RISING); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); } void RF69::clearDio0Action() { - detachInterrupt(digitalPinToInterrupt(_mod->getIrq())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } void RF69::setDio1Action(void (*func)(void)) { @@ -262,14 +262,14 @@ void RF69::setDio1Action(void (*func)(void)) { return; } Module::pinMode(_mod->getGpio(), INPUT); - attachInterrupt(digitalPinToInterrupt(_mod->getGpio()), func, RISING); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING); } void RF69::clearDio1Action() { if(_mod->getGpio() != RADIOLIB_NC) { return; } - detachInterrupt(digitalPinToInterrupt(_mod->getGpio())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); } int16_t RF69::startTransmit(uint8_t* data, size_t len, uint8_t addr) { From d0051124073aa1ebd3617f14afab09a3248ab0ca Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:32:32 +0200 Subject: [PATCH 065/455] [SX126x] Added digital pin to interrupt macro --- src/modules/SX126x/SX126x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 685163cf..e419761e 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -382,11 +382,11 @@ int16_t SX126x::standby(uint8_t mode) { } void SX126x::setDio1Action(void (*func)(void)) { - attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, RISING); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); } void SX126x::clearDio1Action() { - detachInterrupt(digitalPinToInterrupt(_mod->getIrq())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { From 9b0cf7abb298536a8be773d98c3c1bed0d4f0380 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:32:41 +0200 Subject: [PATCH 066/455] [SX127x] Added digital pin to interrupt macro --- src/modules/SX127x/SX127x.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 84cf1eb6..d0aaca44 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -373,25 +373,25 @@ int16_t SX127x::startReceive(uint8_t len, uint8_t mode) { } void SX127x::setDio0Action(void (*func)(void)) { - attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, RISING); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); } void SX127x::clearDio0Action() { - detachInterrupt(digitalPinToInterrupt(_mod->getIrq())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } void SX127x::setDio1Action(void (*func)(void)) { if(_mod->getGpio() != RADIOLIB_NC) { return; } - attachInterrupt(digitalPinToInterrupt(_mod->getGpio()), func, RISING); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING); } void SX127x::clearDio1Action() { if(_mod->getGpio() != RADIOLIB_NC) { return; } - detachInterrupt(digitalPinToInterrupt(_mod->getGpio())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); } int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { From e2689940a621f4d88fae18a265bba1fb48a6a0e4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:32:47 +0200 Subject: [PATCH 067/455] [SX128x] Added digital pin to interrupt macro --- src/modules/SX128x/SX128x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index f7d104ff..993ff9ec 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -421,11 +421,11 @@ int16_t SX128x::standby(uint8_t mode) { } void SX128x::setDio1Action(void (*func)(void)) { - attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, RISING); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); } void SX128x::clearDio1Action() { - detachInterrupt(digitalPinToInterrupt(_mod->getIrq())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { From 8b12def14d370913ee9f3094b92c616ae5d8e366 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:32:56 +0200 Subject: [PATCH 068/455] [Si443x] Added digital pin to interrupt macro --- src/modules/Si443x/Si443x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 5a55a98f..e1b253c5 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -184,11 +184,11 @@ int16_t Si443x::packetMode() { } void Si443x::setIrqAction(void (*func)(void)) { - attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, FALLING); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING); } void Si443x::clearIrqAction() { - detachInterrupt(digitalPinToInterrupt(_mod->getIrq())); + detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { From 3aae02e4ea7987d17c1e113d068bd6b697e098b0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 20:33:02 +0200 Subject: [PATCH 069/455] [nRF24] Added digital pin to interrupt macro --- src/modules/nRF24/nRF24.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index ab6cc6b6..76ce1afd 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -104,7 +104,7 @@ int16_t nRF24::receive(uint8_t* data, size_t len) { uint32_t start = micros(); while(digitalRead(_mod->getIrq())) { yield(); - + // check timeout: 15 retries * 4ms (max Tx time as per datasheet) if(micros() - start >= 60000) { standby(); @@ -139,7 +139,7 @@ int16_t nRF24::receiveDirect() { } void nRF24::setIrqAction(void (*func)(void)) { - attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, FALLING); + attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING); } int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) { From a7a2dcabd282e1f6fac2d807b982d827ea5c3521 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 11 May 2020 21:07:57 +0200 Subject: [PATCH 070/455] Added custom platform option --- src/BuildOpt.h | 286 +++++++++++++++++++++++++------------------------ 1 file changed, 146 insertions(+), 140 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 4d47b7b1..2864dedc 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -14,6 +14,7 @@ * RADIOLIB_PIN_TYPE - which type should be used for pin numbers in functions like digitalRead(). * RADIOLIB_PIN_MODE - which type should be used for pin modes in functions like pinMode(). * RADIOLIB_PIN_STATUS - which type should be used for pin values in functions like digitalWrite(). + * RADIOLIB_DIGITAL_PIN_TO_INTERRUPT - function to be used to convert digital pin number to interrupt pin number. * RADIOLIB_INTERRUPT_STATUS - which type should be used for pin changes in functions like attachInterrupt(). * RADIOLIB_NC - alias for unused pin, usually the largest possible value of RADIOLIB_PIN_TYPE. * RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - defined if the specific platform does not support SoftwareSerial. @@ -21,162 +22,167 @@ * RADIOLIB_TONE_UNSUPPORTED - some platforms do not have tone()/noTone(), which is required for AFSK. * * In addition, some platforms may require RadioLib to disable specific drivers (such as ESP8266). + * + * Users may also specify their own configuration by defining all of the platform-specific parameters + * and macro RADIOLIB_CUSTOM_PLATFORM prior to including the main library file (RadioLib.h). */ -#if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) - // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. - #define RADIOLIB_PLATFORM "Arduino AVR" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) +#if !defined(RADIOLIB_CUSTOM_PLATFORM) + #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) + // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. + #define RADIOLIB_PLATFORM "Arduino AVR" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) -#elif defined(ESP8266) - // ESP8266 boards - #define RADIOLIB_PLATFORM "ESP8266" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) + #elif defined(ESP8266) + // ESP8266 boards + #define RADIOLIB_PLATFORM "ESP8266" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) - // RadioLib has ESP8266 driver, this must be disabled to use ESP8266 as platform - #define _RADIOLIB_ESP8266_H + // RadioLib has ESP8266 driver, this must be disabled to use ESP8266 as platform + #define _RADIOLIB_ESP8266_H -#elif defined(ESP32) - // ESP32 boards - #define RADIOLIB_PLATFORM "ESP32" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) - #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - #define RADIOLIB_TONE_UNSUPPORTED + #elif defined(ESP32) + // ESP32 boards + #define RADIOLIB_PLATFORM "ESP32" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #define RADIOLIB_TONE_UNSUPPORTED -#elif defined(ARDUINO_ARCH_STM32) - // official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32) - #define RADIOLIB_PLATFORM "Arduino STM32 (official)" - #define RADIOLIB_PIN_TYPE uint32_t - #define RADIOLIB_PIN_MODE uint32_t - #define RADIOLIB_PIN_STATUS uint32_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(digitalPinToPinName(p)) - #define RADIOLIB_NC (0xFFFFFFFF) - #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(ARDUINO_ARCH_STM32) + // official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32) + #define RADIOLIB_PLATFORM "Arduino STM32 (official)" + #define RADIOLIB_PIN_TYPE uint32_t + #define RADIOLIB_PIN_MODE uint32_t + #define RADIOLIB_PIN_STATUS uint32_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(digitalPinToPinName(p)) + #define RADIOLIB_NC (0xFFFFFFFF) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 -#elif defined(SAMD_SERIES) - // Arduino SAMD boards - Zero, MKR, etc. - #define RADIOLIB_PLATFORM "Arduino SAMD" - #define RADIOLIB_PIN_TYPE uint32_t - #define RADIOLIB_PIN_MODE uint32_t - #define RADIOLIB_PIN_STATUS uint32_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFFFFFFFF) - #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(SAMD_SERIES) + // Arduino SAMD boards - Zero, MKR, etc. + #define RADIOLIB_PLATFORM "Arduino SAMD" + #define RADIOLIB_PIN_TYPE uint32_t + #define RADIOLIB_PIN_MODE uint32_t + #define RADIOLIB_PIN_STATUS uint32_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFFFFFFFF) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 -#elif defined(__SAM3X8E__) - // Arduino Due - #define RADIOLIB_PLATFORM "Arduino Due" - #define RADIOLIB_PIN_TYPE uint32_t - #define RADIOLIB_PIN_MODE uint32_t - #define RADIOLIB_PIN_STATUS uint32_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFFFFFFFF) - #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - #define RADIOLIB_TONE_UNSUPPORTED + #elif defined(__SAM3X8E__) + // Arduino Due + #define RADIOLIB_PLATFORM "Arduino Due" + #define RADIOLIB_PIN_TYPE uint32_t + #define RADIOLIB_PIN_MODE uint32_t + #define RADIOLIB_PIN_STATUS uint32_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFFFFFFFF) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #define RADIOLIB_TONE_UNSUPPORTED -#elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE) - // Adafruit nRF52 boards - #define RADIOLIB_PLATFORM "Adafruit nRF52" - #define RADIOLIB_PIN_TYPE uint32_t - #define RADIOLIB_PIN_MODE uint32_t - #define RADIOLIB_PIN_STATUS uint32_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFFFFFFFF) + #elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE) + // Adafruit nRF52 boards + #define RADIOLIB_PLATFORM "Adafruit nRF52" + #define RADIOLIB_PIN_TYPE uint32_t + #define RADIOLIB_PIN_MODE uint32_t + #define RADIOLIB_PIN_STATUS uint32_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFFFFFFFF) -#elif defined(ARDUINO_ARC32_TOOLS) - // Intel Curie - #define RADIOLIB_PLATFORM "Intel Curie" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) + #elif defined(ARDUINO_ARC32_TOOLS) + // Intel Curie + #define RADIOLIB_PLATFORM "Intel Curie" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) -#elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) - // Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every - #define RADIOLIB_PLATFORM "Arduino megaAVR" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE PinMode - #define RADIOLIB_PIN_STATUS PinStatus - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) + #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) + // Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every + #define RADIOLIB_PLATFORM "Arduino megaAVR" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE PinMode + #define RADIOLIB_PIN_STATUS PinStatus + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) -#elif defined(AM_PART_APOLLO3) - // Sparkfun Artemis boards - #define RADIOLIB_PLATFORM "Sparkfun Artemis" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) - #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - #define RADIOLIB_TONE_UNSUPPORTED + #elif defined(AM_PART_APOLLO3) + // Sparkfun Artemis boards + #define RADIOLIB_PLATFORM "Sparkfun Artemis" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #define RADIOLIB_TONE_UNSUPPORTED -#elif defined(ARDUINO_ARDUINO_NANO33BLE) - // Arduino Nano 33 BLE - #define RADIOLIB_PLATFORM "Arduino Nano 33 BLE" - #define RADIOLIB_PIN_TYPE pin_size_t - #define RADIOLIB_PIN_MODE PinMode - #define RADIOLIB_PIN_STATUS PinStatus - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) - #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(ARDUINO_ARDUINO_NANO33BLE) + // Arduino Nano 33 BLE + #define RADIOLIB_PLATFORM "Arduino Nano 33 BLE" + #define RADIOLIB_PIN_TYPE pin_size_t + #define RADIOLIB_PIN_MODE PinMode + #define RADIOLIB_PIN_STATUS PinStatus + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - // Nano 33 BLE uses mbed libraries, which already contain ESP8266 driver - #define _RADIOLIB_ESP8266_H + // Nano 33 BLE uses mbed libraries, which already contain ESP8266 driver + #define _RADIOLIB_ESP8266_H -#elif defined(__STM32F4__) || defined(__STM32F1__) - // Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32) - #define RADIOLIB_PLATFORM "STM32duino (unofficial)" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE WiringPinMode - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS ExtIntTriggerMode - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) - #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - #define RADIOLIB_TONE_UNSUPPORTED + #elif defined(__STM32F4__) || defined(__STM32F1__) + // Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32) + #define RADIOLIB_PLATFORM "STM32duino (unofficial)" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE WiringPinMode + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS ExtIntTriggerMode + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #define RADIOLIB_TONE_UNSUPPORTED -#else - // other platforms not covered by the above list - this may or may not work - #define RADIOLIB_PLATFORM "Unknown" - #define RADIOLIB_UNKNOWN_PLATFORM - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) + #else + // other platforms not covered by the above list - this may or may not work + #define RADIOLIB_PLATFORM "Unknown" + #define RADIOLIB_UNKNOWN_PLATFORM + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #endif #endif /* From 7503604765d5318b1194664f4c0e0dc4194eec2e Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 12 May 2020 08:39:28 +0200 Subject: [PATCH 071/455] [SX127x] Fixed sprintf buffer size --- src/modules/SX127x/SX127x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index d0aaca44..ca76b072 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -992,7 +992,7 @@ bool SX127x::findChip(uint8_t ver) { RADIOLIB_DEBUG_PRINT(i + 1); RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SX127X_REG_VERSION == ")); - char buffHex[5]; + char buffHex[12]; sprintf(buffHex, "0x%02X", version); RADIOLIB_DEBUG_PRINT(buffHex); RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); From 0c4f449181ecd625ddbed976d9946df8d0f15210 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 12 May 2020 08:40:31 +0200 Subject: [PATCH 072/455] Added default SPI instance to platform config --- src/BuildOpt.h | 19 ++++++++++++++++++- src/Module.h | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 2864dedc..8d013b5d 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -26,7 +26,11 @@ * Users may also specify their own configuration by defining all of the platform-specific parameters * and macro RADIOLIB_CUSTOM_PLATFORM prior to including the main library file (RadioLib.h). */ -#if !defined(RADIOLIB_CUSTOM_PLATFORM) +#if defined(RADIOLIB_CUSTOM_PLATFORM) + #if !defined(RADIOLIB_PLATFORM) + #define RADIOLIB_PLATFORM "Custom" + #endif +#else #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. #define RADIOLIB_PLATFORM "Arduino AVR" @@ -36,6 +40,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI #elif defined(ESP8266) // ESP8266 boards @@ -46,6 +51,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI // RadioLib has ESP8266 driver, this must be disabled to use ESP8266 as platform #define _RADIOLIB_ESP8266_H @@ -59,6 +65,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #define RADIOLIB_TONE_UNSUPPORTED @@ -72,6 +79,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(digitalPinToPinName(p)) #define RADIOLIB_NC (0xFFFFFFFF) + #define RADIOLIB_DEFAULT_SPI SPI #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -84,6 +92,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) + #define RADIOLIB_DEFAULT_SPI SPI #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -96,6 +105,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) + #define RADIOLIB_DEFAULT_SPI SPI #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #define RADIOLIB_TONE_UNSUPPORTED @@ -109,6 +119,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) + #define RADIOLIB_DEFAULT_SPI SPI #elif defined(ARDUINO_ARC32_TOOLS) // Intel Curie @@ -119,6 +130,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) // Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every @@ -129,6 +141,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI #elif defined(AM_PART_APOLLO3) // Sparkfun Artemis boards @@ -139,6 +152,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #define RADIOLIB_TONE_UNSUPPORTED @@ -152,6 +166,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -167,6 +182,7 @@ #define RADIOLIB_INTERRUPT_STATUS ExtIntTriggerMode #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #define RADIOLIB_TONE_UNSUPPORTED @@ -181,6 +197,7 @@ #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI #endif #endif diff --git a/src/Module.h b/src/Module.h index f6855a05..12247f3c 100644 --- a/src/Module.h +++ b/src/Module.h @@ -111,9 +111,9 @@ class Module { \param serial HardwareSerial to be used on ESP32 and SAMD. Defaults to 1 */ #ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = &RADIOLIB_HARDWARE_SERIAL_PORT); + Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = RADIOLIB_DEFAULT_SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = &RADIOLIB_HARDWARE_SERIAL_PORT); #else - Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = nullptr); + Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = RADIOLIB_DEFAULT_SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = nullptr); #endif From 9798de62724ccdf5cdb5130f56b2511729e5075c Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 12 May 2020 08:42:10 +0200 Subject: [PATCH 073/455] Added support for Adafruit SAMD boards --- .travis.yml | 6 ++++++ README.md | 1 + src/BuildOpt.h | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dbb1da43..ff2646a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ env: - BOARD="SparkFun:apollo3:amap3redboard" - BOARD="arduino:mbed:nano33ble" - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" + - BOARD="adafruit:samd:adafruit_feather_m0:usbstack=arduino,debug=off" addons: apt: @@ -105,6 +106,11 @@ before_install: arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; arduino --install-boards stm32duino:STM32F1; + elif [[ "$BOARD" =~ "adafruit:samd:" ]]; then + export BUILD_EXAMPLES=true; + arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; + arduino --install-boards adafruit:samd; + fi # check if this release commit (or forced build) and if so, build for every board diff --git a/README.md b/README.md index 884d0c1f..ad437969 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x * [__SAMD__](https://github.com/arduino/ArduinoCore-samd) - Arduino Zero, MKR boards, M0 Pro etc. * __Adafruit__ + * [__SAMD__](https://github.com/adafruit/ArduinoCore-samd) - Adafruit Feather M0 and M4 boards (Feather, Metro, Gemma, Trinket etc.) * [__nRF52__](https://github.com/adafruit/Adafruit_nRF52_Arduino) - Adafruit Feather nRF528x, Bluefruit and CLUE * __Espressif__ diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 8d013b5d..c593448d 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -84,8 +84,8 @@ #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #elif defined(SAMD_SERIES) - // Arduino SAMD boards - Zero, MKR, etc. - #define RADIOLIB_PLATFORM "Arduino SAMD" + // Arduino SAMD (Zero, MKR, etc.) and Adafruit SAMD boards (M0 and M4) + #define RADIOLIB_PLATFORM "Arduino/Adafruit SAMD" #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t From 4198551e5510dea09fc41daa0a89ac2d3d0abe00 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 12 May 2020 08:57:38 +0200 Subject: [PATCH 074/455] Disabled default build for Adafruit SAMD --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff2646a6..889773ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -107,7 +107,7 @@ before_install: arduino --install-boards stm32duino:STM32F1; elif [[ "$BOARD" =~ "adafruit:samd:" ]]; then - export BUILD_EXAMPLES=true; + export BUILD_EXAMPLES=false; arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; arduino --install-boards adafruit:samd; From 50cc06021b550d2161ac72ca2654474afa18be57 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 12 May 2020 16:00:13 +0200 Subject: [PATCH 075/455] Only stopping hardware interface on automated initialization (#143) --- src/Module.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Module.cpp b/src/Module.cpp index 67ac9ac8..eed3e298 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -103,7 +103,11 @@ void Module::init(uint8_t interface) { } void Module::term() { - // stop hardware interfaces + // stop hardware interfaces (if they were initialized by the library) + if(!_initInterface) { + return; + } + if(_spi != nullptr) { _spi->end(); } From 86da5780c3278ede864cb18d49996b3af73cf919 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 12 May 2020 16:04:29 +0200 Subject: [PATCH 076/455] Added missing RADIOLIB_DEFAULT_SPI parameter --- src/Module.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index eed3e298..ff03b1f3 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -6,7 +6,7 @@ Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rs _tx = RADIOLIB_NC; _irq = irq; _rst = rst; - _spi = &SPI; + _spi = &RADIOLIB_DEFAULT_SPI; _spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0); _initInterface = true; } @@ -17,7 +17,7 @@ Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rs _tx = RADIOLIB_NC; _irq = irq; _rst = rst; - _spi = &SPI; + _spi = &RADIOLIB_DEFAULT_SPI; _spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0); _initInterface = true; } From 2ebd6d355ca3652b251920669cc6dcdeaf203d09 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 12 May 2020 16:16:56 +0200 Subject: [PATCH 077/455] Bump version to 3.6.0 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 9113c270..f927739f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=3.5.0 +version=3.6.0 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index c593448d..b8d95197 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -267,7 +267,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x03) -#define RADIOLIB_VERSION_MINOR (0x05) +#define RADIOLIB_VERSION_MINOR (0x06) #define RADIOLIB_VERSION_PATCH (0x00) #define RADIOLIB_VERSION_EXTRA (0x00) From f588d3b3a2c39dd5bbc137fdebf83a6887e04b62 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 14 May 2020 19:53:46 +0200 Subject: [PATCH 078/455] Fixed static only build set by default --- src/BuildOpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index b8d95197..134b0b1f 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -249,7 +249,7 @@ * Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode. */ -#define RADIOLIB_STATIC_ONLY +//#define RADIOLIB_STATIC_ONLY // set the size of static arrays to use #define RADIOLIB_STATIC_ARRAY_SIZE 256 From a969517e0445a1c9d52a6bff73fdffa42a2c71ef Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 15 May 2020 09:56:40 +0200 Subject: [PATCH 079/455] Bump version to 3.6.1 (hotfix) --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index f927739f..1f6c35f8 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=3.6.0 +version=3.6.1 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 134b0b1f..eef56d8c 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -268,7 +268,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x03) #define RADIOLIB_VERSION_MINOR (0x06) -#define RADIOLIB_VERSION_PATCH (0x00) +#define RADIOLIB_VERSION_PATCH (0x01) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From da177c9b2a36580aaa2a4eecc14bd7354529c308 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 17 May 2020 20:26:57 +0200 Subject: [PATCH 080/455] Added interface argument to termination method --- src/Module.cpp | 6 +++--- src/Module.h | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index ff03b1f3..b4db0504 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -102,17 +102,17 @@ void Module::init(uint8_t interface) { } } -void Module::term() { +void Module::term(uint8_t interface) { // stop hardware interfaces (if they were initialized by the library) if(!_initInterface) { return; } - if(_spi != nullptr) { + if((interface == RADIOLIB_USE_SPI) && (_spi != nullptr)) { _spi->end(); } - if(ModuleSerial != nullptr) { + if(((interface == RADIOLIB_USE_UART) && ModuleSerial != nullptr)) { ModuleSerial->end(); } } diff --git a/src/Module.h b/src/Module.h index 12247f3c..a77d1a7e 100644 --- a/src/Module.h +++ b/src/Module.h @@ -159,8 +159,10 @@ class Module { /*! \brief Terminate low-level module control. + + \param interface Interface to be terminated. See \ref shield_config for details. */ - void term(); + void term(uint8_t interface); // AT methods From 3721d0a51b45a25c3e82581c7440050e91d306ee Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 17 May 2020 20:27:34 +0200 Subject: [PATCH 081/455] [CC1101] Added interface argument to Module::term --- src/modules/CC1101/CC1101.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index d0259e4a..2854fca8 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -42,7 +42,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po if(!flagFound) { RADIOLIB_DEBUG_PRINTLN(F("No CC1101 found!")); - _mod->term(); + _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { RADIOLIB_DEBUG_PRINTLN(F("Found CC1101! (match by CC1101_REG_VERSION == 0x14)")); From 657d7495cbbdcf2da828039b0db9163b18d3a430 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 17 May 2020 20:27:42 +0200 Subject: [PATCH 082/455] [RF69] Added interface argument to Module::term --- src/modules/RF69/RF69.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 08d6a12e..856101f2 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -47,7 +47,7 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe if(!flagFound) { RADIOLIB_DEBUG_PRINTLN(F("No RF69 found!")); - _mod->term(); + _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { RADIOLIB_DEBUG_PRINTLN(F("Found RF69! (match by RF69_REG_VERSION == 0x24)")); From e6caf3fc37bd5577390bd38735d6cf304b35d30f Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 17 May 2020 20:27:51 +0200 Subject: [PATCH 083/455] [nRF24] Added interface argument to Module::term --- src/modules/nRF24/nRF24.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 76ce1afd..73d25ee6 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -21,7 +21,7 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW int16_t val = _mod->SPIgetRegValue(NRF24_REG_SETUP_AW); if(!((val >= 0) && (val <= 3))) { RADIOLIB_DEBUG_PRINTLN(F("No nRF24 found!")); - _mod->term(); + _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } From b0a6b1db08a52aa02340edc4e7701041eb09bd65 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 17 May 2020 20:27:58 +0200 Subject: [PATCH 084/455] [Si443x] Added interface argument to Module::term --- src/modules/Si443x/Si443x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index e1b253c5..153e5c3e 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -16,7 +16,7 @@ int16_t Si443x::begin(float br, float freqDev, float rxBw) { // try to find the Si443x chip if(!Si443x::findChip()) { RADIOLIB_DEBUG_PRINTLN(F("No Si443x found!")); - _mod->term(); + _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { RADIOLIB_DEBUG_PRINTLN(F("Found Si443x!")); From 6e7554191f4e4c8ec07d363aa543431a9d4e2e10 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 17 May 2020 20:28:05 +0200 Subject: [PATCH 085/455] [SX1231] Added interface argument to Module::term --- src/modules/SX1231/SX1231.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index 1e1388d7..f42c584e 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -37,7 +37,7 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po if(!flagFound) { RADIOLIB_DEBUG_PRINTLN(F("No SX1231 found!")); - _mod->term(); + _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { RADIOLIB_DEBUG_PRINTLN(F("Found SX1231!")); From bff077af3cb41bf0884dcde997effc0ff98fd774 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 17 May 2020 20:28:22 +0200 Subject: [PATCH 086/455] [SX127x] Added interface argument to Module::term (#146) --- src/modules/SX127x/SX127x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index ca76b072..8ba220d1 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -14,7 +14,7 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimi // try to find the SX127x chip if(!SX127x::findChip(chipVersion)) { RADIOLIB_DEBUG_PRINTLN(F("No SX127x found!")); - _mod->term(); + _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { RADIOLIB_DEBUG_PRINTLN(F("Found SX127x!")); @@ -57,7 +57,7 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB // try to find the SX127x chip if(!SX127x::findChip(chipVersion)) { RADIOLIB_DEBUG_PRINTLN(F("No SX127x found!")); - _mod->term(); + _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { RADIOLIB_DEBUG_PRINTLN(F("Found SX127x!")); From 3682c6c9215891e3afb7672f1235fde1c3bd75fd Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 18 May 2020 07:17:08 +0200 Subject: [PATCH 087/455] Bump version to 3.6.2 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 1f6c35f8..733be1bd 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=3.6.1 +version=3.6.2 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index eef56d8c..45248a78 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -268,7 +268,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x03) #define RADIOLIB_VERSION_MINOR (0x06) -#define RADIOLIB_VERSION_PATCH (0x01) +#define RADIOLIB_VERSION_PATCH (0x02) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From 56dd0ab41d838f2194b2458b3b102eec4a957c2d Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 19 May 2020 21:11:12 +0200 Subject: [PATCH 088/455] Added guards to allow user redefinition of RADIOLIB_STATIC_ARRAY_SIZE --- src/BuildOpt.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 45248a78..a5de6898 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -252,7 +252,9 @@ //#define RADIOLIB_STATIC_ONLY // set the size of static arrays to use +#if !defined(RADIOLIB_STATIC_ARRAY_SIZE) #define RADIOLIB_STATIC_ARRAY_SIZE 256 +#endif /*! \brief A simple assert macro, will return on error. From 3a15335b590fdd55817472dbd87906284aa6b317 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 20 May 2020 11:17:40 +0200 Subject: [PATCH 089/455] [RFM9x] Added 0x12 as valid device ID --- src/modules/RFM9x/RFM95.cpp | 11 +++++++++-- src/modules/RFM9x/RFM95.h | 3 ++- src/modules/RFM9x/RFM96.cpp | 11 +++++++++-- src/modules/RFM9x/RFM96.h | 3 ++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/modules/RFM9x/RFM95.cpp b/src/modules/RFM9x/RFM95.cpp index fa5c684a..53f1eb7c 100644 --- a/src/modules/RFM9x/RFM95.cpp +++ b/src/modules/RFM9x/RFM95.cpp @@ -6,8 +6,15 @@ RFM95::RFM95(Module* mod) : SX1278(mod) { int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(RFM95_CHIP_VERSION, syncWord, currentLimit, preambleLength); - RADIOLIB_ASSERT(state); + int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, currentLimit, preambleLength); + if(state == ERR_CHIP_NOT_FOUND) { + // SX127X_REG_VERSION might be set 0x12 + state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, currentLimit, preambleLength); + RADIOLIB_ASSERT(state); + } else if(state != ERR_NONE) { + // some other error + return(state); + } // configure settings not accessible by API state = config(); diff --git a/src/modules/RFM9x/RFM95.h b/src/modules/RFM9x/RFM95.h index 78758971..fcbcf67d 100644 --- a/src/modules/RFM9x/RFM95.h +++ b/src/modules/RFM9x/RFM95.h @@ -7,7 +7,8 @@ #include "../SX127x/SX1278.h" // SX127X_REG_VERSION -#define RFM95_CHIP_VERSION 0x11 +#define RFM9X_CHIP_VERSION_OFFICIAL 0x11 +#define RFM9X_CHIP_VERSION_UNOFFICIAL 0x12 // according to datasheet, only 0x11 should be possible, but some modules seem to have 0x12 /*! \class RFM95 diff --git a/src/modules/RFM9x/RFM96.cpp b/src/modules/RFM9x/RFM96.cpp index 1d5cdc74..159c4995 100644 --- a/src/modules/RFM9x/RFM96.cpp +++ b/src/modules/RFM9x/RFM96.cpp @@ -6,8 +6,15 @@ RFM96::RFM96(Module* mod) : SX1278(mod) { int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(RFM9X_CHIP_VERSION, syncWord, currentLimit, preambleLength); - RADIOLIB_ASSERT(state); + int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, currentLimit, preambleLength); + if(state == ERR_CHIP_NOT_FOUND) { + // SX127X_REG_VERSION might be set 0x12 + state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, currentLimit, preambleLength); + RADIOLIB_ASSERT(state); + } else if(state != ERR_NONE) { + // some other error + return(state); + } // configure settings not accessible by API state = config(); diff --git a/src/modules/RFM9x/RFM96.h b/src/modules/RFM9x/RFM96.h index 1288c797..74b6d382 100644 --- a/src/modules/RFM9x/RFM96.h +++ b/src/modules/RFM9x/RFM96.h @@ -7,7 +7,8 @@ #include "../SX127x/SX1278.h" // SX127X_REG_VERSION -#define RFM9X_CHIP_VERSION 0x12 // according to datasheet, this should be 0x11, but all modules seem to have 0x12 +#define RFM9X_CHIP_VERSION_OFFICIAL 0x11 +#define RFM9X_CHIP_VERSION_UNOFFICIAL 0x12 // according to datasheet, only 0x11 should be possible, but some modules seem to have 0x12 /*! \class RFM96 From f068a150291f6716b0280dab5b0f1ff5a6458491 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 28 May 2020 21:07:23 +0200 Subject: [PATCH 090/455] [SX127x] Added getIRQFlags and getModemStatus methods (#145) --- keywords.txt | 2 ++ src/modules/SX127x/SX127x.cpp | 25 +++++++++++++++++++++++++ src/modules/SX127x/SX127x.h | 16 ++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/keywords.txt b/keywords.txt index 53b945b0..84b70c88 100644 --- a/keywords.txt +++ b/keywords.txt @@ -124,6 +124,8 @@ disableSyncWordFiltering KEYWORD2 setPromiscuous KEYWORD2 setRSSIConfig KEYWORD2 setEncoding KEYWORD2 +getIRQFlags KEYWORD2 +getModemStatus KEYWORD2 # RF69-specific setAESKey KEYWORD2 diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 8ba220d1..2a3a5121 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -909,6 +909,31 @@ int16_t SX127x::setEncoding(uint8_t encoding) { } } +uint16_t SX127x::getIRQFlags() { + // check active modem + if(getActiveModem() == SX127X_LORA) { + // LoRa, just 8-bit value + return((uint16_t)_mod->SPIreadRegister(SX127X_REG_IRQ_FLAGS)); + + } else { + // FSK, the IRQ flags are 16 bits in total + uint16_t flags = ((uint16_t)_mod->SPIreadRegister(SX127X_REG_IRQ_FLAGS_2)) << 8; + flags |= (uint16_t)_mod->SPIreadRegister(SX127X_REG_IRQ_FLAGS_1); + return(flags); + } + +} + +uint8_t SX127x::getModemStatus() { + // check active modem + if(getActiveModem() != SX127X_LORA) { + return(0x00); + } + + // read the register + return(_mod->SPIreadRegister(SX127X_REG_MODEM_STAT)); +} + int16_t SX127x::config() { // turn off frequency hopping int16_t state = _mod->SPIsetRegValue(SX127X_REG_HOP_PERIOD, SX127X_HOP_PERIOD_OFF); diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 1edf5917..7404427c 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -897,6 +897,22 @@ class SX127x: public PhysicalLayer { */ int16_t setEncoding(uint8_t encoding); + /*! + \brief Reads currently active IRQ flags, can be used to check which event caused an interrupt. + In LoRa mode, this is the content of SX127X_REG_IRQ_FLAGS register. + In FSK mode, this is the contents of SX127X_REG_IRQ_FLAGS_2 (MSB) and SX127X_REG_IRQ_FLAGS_1 (LSB) registers. + + \returns IRQ flags. + */ + uint16_t getIRQFlags(); + + /*! + \brief Reads modem status. Only available in LoRa mode. + + \returns Modem status. + */ + uint8_t getModemStatus(); + #ifdef RADIOLIB_DEBUG void regDump(); #endif From f534185cfbc66e3e2be73cc3bfa9f6ffea6dd261 Mon Sep 17 00:00:00 2001 From: gozu42 Date: Mon, 1 Jun 2020 14:26:30 +0200 Subject: [PATCH 091/455] [SX127x] add getTempRaw method Signed-off-by: gozu42 --- keywords.txt | 1 + src/modules/SX127x/SX127x.cpp | 52 +++++++++++++++++++++++++++++++++++ src/modules/SX127x/SX127x.h | 11 ++++++-- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/keywords.txt b/keywords.txt index 84b70c88..d7aa3950 100644 --- a/keywords.txt +++ b/keywords.txt @@ -126,6 +126,7 @@ setRSSIConfig KEYWORD2 setEncoding KEYWORD2 getIRQFlags KEYWORD2 getModemStatus KEYWORD2 +getTempRaw KEYWORD2 # RF69-specific setAESKey KEYWORD2 diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 2a3a5121..a26e0c60 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -934,6 +934,58 @@ uint8_t SX127x::getModemStatus() { return(_mod->SPIreadRegister(SX127X_REG_MODEM_STAT)); } +int8_t SX127x::getTempRaw() { + int8_t temp = 0; + uint8_t previousOpMode; + uint8_t ival; + + // save current Op Mode + previousOpMode = _mod->SPIgetRegValue(SX127X_REG_OP_MODE); + + // check if we need to step out of LoRa mode first + if ((previousOpMode & SX127X_LORA) == SX127X_LORA) { + _mod->SPIsetRegValue(SX127X_REG_OP_MODE, (SX127X_LORA | SX127X_SLEEP)); + } + + // put device in FSK sleep + _mod->SPIsetRegValue(SX127X_REG_OP_MODE, (SX127X_FSK_OOK | SX127X_SLEEP)); + + // put device in FSK RxSynth + _mod->SPIsetRegValue(SX127X_REG_OP_MODE, (SX127X_FSK_OOK | SX127X_FSRX)); + + // enable temperature reading + _mod->SPIsetRegValue(SX127X_REG_IMAGE_CAL, SX127X_TEMP_MONITOR_ON, 0, 0); + + // wait + delayMicroseconds(200); + + // disable temperature reading + _mod->SPIsetRegValue(SX127X_REG_IMAGE_CAL, SX127X_TEMP_MONITOR_OFF, 0, 0); + + // put device in FSK sleep + _mod->SPIsetRegValue(SX127X_REG_OP_MODE, (SX127X_FSK_OOK | SX127X_SLEEP)); + + // read temperature + ival = _mod->SPIgetRegValue(SX127X_REG_TEMP); + + // convert very raw value + if ((ival & 0x80) == 0x80) { + temp = 255 - ival; + } else { + temp = -1 * ival; + } + + // check if we need to step back into LoRa mode + if ((previousOpMode & SX127X_LORA) == SX127X_LORA) { + _mod->SPIsetRegValue(SX127X_REG_OP_MODE, (SX127X_LORA | SX127X_SLEEP)); + } + + // reload previous Op Mode + _mod->SPIsetRegValue(SX127X_REG_OP_MODE, previousOpMode); + + return(temp); +} + int16_t SX127x::config() { // turn off frequency hopping int16_t state = _mod->SPIsetRegValue(SX127X_REG_HOP_PERIOD, SX127X_HOP_PERIOD_OFF); diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 7404427c..7d2a00a2 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -459,8 +459,8 @@ #define SX127X_TEMP_THRESHOLD_10_DEG_C 0b00000010 // 2 1 10 deg. C (default) #define SX127X_TEMP_THRESHOLD_15_DEG_C 0b00000100 // 2 1 15 deg. C #define SX127X_TEMP_THRESHOLD_20_DEG_C 0b00000110 // 2 1 20 deg. C -#define SX127X_TEMP_MONITOR_OFF 0b00000000 // 0 0 temperature monitoring disabled (default) -#define SX127X_TEMP_MONITOR_ON 0b00000001 // 0 0 temperature monitoring enabled +#define SX127X_TEMP_MONITOR_ON 0b00000000 // 0 0 temperature monitoring enabled (default) +#define SX127X_TEMP_MONITOR_OFF 0b00000001 // 0 0 temperature monitoring disabled // SX127X_REG_LOW_BAT #define SX127X_LOW_BAT_OFF 0b00000000 // 3 3 low battery detector disabled @@ -913,6 +913,13 @@ class SX127x: public PhysicalLayer { */ uint8_t getModemStatus(); + /*! + \brief Reads uncalibrated temperature value. + + \returns Uncalibrated temperature sensor reading. + */ + int8_t getTempRaw(); + #ifdef RADIOLIB_DEBUG void regDump(); #endif From cec0c4d1e2256222b2bd0d7279feca24445a0af4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 1 Jun 2020 16:14:33 +0200 Subject: [PATCH 092/455] [SX127x] Added comment about op mode change --- src/modules/SX127x/SX127x.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 7d2a00a2..25a06a14 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -914,7 +914,8 @@ class SX127x: public PhysicalLayer { uint8_t getModemStatus(); /*! - \brief Reads uncalibrated temperature value. + \brief Reads uncalibrated temperature value. This function will change operating mode + and should not be called during Tx, Rx or CAD. \returns Uncalibrated temperature sensor reading. */ From 78022ce6add50f50ce81bda59c374410e879597b Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 18 Jun 2020 16:31:38 +0200 Subject: [PATCH 093/455] Added external RF switch control base --- keywords.txt | 1 + src/Module.cpp | 24 ++++++++++++++++++++++++ src/Module.h | 20 ++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/keywords.txt b/keywords.txt index d7aa3950..f55c7fbf 100644 --- a/keywords.txt +++ b/keywords.txt @@ -127,6 +127,7 @@ setEncoding KEYWORD2 getIRQFlags KEYWORD2 getModemStatus KEYWORD2 getTempRaw KEYWORD2 +setRfSwitchPins KEYWORD2 # RF69-specific setAESKey KEYWORD2 diff --git a/src/Module.cpp b/src/Module.cpp index b4db0504..af6415bb 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -314,3 +314,27 @@ void Module::noTone(RADIOLIB_PIN_TYPE pin) { } #endif } + +void Module::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { + _useRfSwitch = true; + _rxEn = rxEn; + _txEn = txEn; + Module::pinMode(rxEn, OUTPUT); + Module::pinMode(txEn, OUTPUT); +} + +void Module::setRfSwitchState(bool tx) { + // check RF switch control is enabled + if(!_useRfSwitch) { + return; + } + + // set pins + if(tx) { + Module::digitalWrite(_rxEn, LOW); + Module::digitalWrite(_txEn, HIGH); + } else { + Module::digitalWrite(_rxEn, HIGH); + Module::digitalWrite(_txEn, LOW); + } +} diff --git a/src/Module.h b/src/Module.h index a77d1a7e..41e25299 100644 --- a/src/Module.h +++ b/src/Module.h @@ -386,6 +386,23 @@ class Module { */ static void noTone(RADIOLIB_PIN_TYPE pin); + /*! + \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. + When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + + \param rxEn RX enable pin. + + \param txEn TX enable pin. + */ + void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + + /*! + \brief Set RF switch state. + + \param tx True to set RF switch to Tx, false to set switch to Rx. + */ + void setRfSwitchState(bool tx); + #ifndef RADIOLIB_GODMODE private: #endif @@ -399,6 +416,9 @@ class Module { SPIClass* _spi; SPISettings _spiSettings; + bool _useRfSwitch = false; + RADIOLIB_PIN_TYPE _rxEn, _txEn; + uint32_t _ATtimeout = 15000; }; From 3aafb2f5bf997ec56c28619f2c432e02c275edc1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 18 Jun 2020 16:32:11 +0200 Subject: [PATCH 094/455] [CC1101] Implemented RF switch control --- src/modules/CC1101/CC1101.cpp | 10 ++++++++++ src/modules/CC1101/CC1101.h | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 2854fca8..2e3f4dea 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -232,6 +232,9 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { // write packet to FIFO SPIwriteRegisterBurst(CC1101_REG_FIFO, data, len); + // set RF switch (if present) + _mod->setRfSwitchState(true); + // set mode to transmit SPIsendCommand(CC1101_CMD_TX); @@ -249,6 +252,9 @@ int16_t CC1101::startReceive() { int state = SPIsetRegValue(CC1101_REG_IOCFG0, CC1101_GDOX_SYNC_WORD_SENT_OR_RECEIVED); RADIOLIB_ASSERT(state); + // set RF switch (if present) + _mod->setRfSwitchState(false); + // set mode to receive SPIsendCommand(CC1101_CMD_RX); @@ -710,6 +716,10 @@ int16_t CC1101::setEncoding(uint8_t encoding) { } } +void CC1101::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { + _mod->setRfSwitchPins(rxEn, txEn); +} + int16_t CC1101::config() { // Reset the radio. Registers may be dirty from previous usage. SPIsendCommand(CC1101_CMD_RESET); diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index d6cfe45c..0ef0df29 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -864,6 +864,16 @@ class CC1101: public PhysicalLayer { */ int16_t setEncoding(uint8_t encoding); + /*! + \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. + When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + + \param rxEn RX enable pin. + + \param txEn TX enable pin. + */ + void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + #ifndef RADIOLIB_GODMODE private: #endif From 0f287a53e7013c1e9183e6c38a8e2259e5f7d6b1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 18 Jun 2020 16:32:30 +0200 Subject: [PATCH 095/455] [RF69] Implemented RF switch control --- src/modules/RF69/RF69.cpp | 10 ++++++++++ src/modules/RF69/RF69.h | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 856101f2..6b925eb6 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -238,6 +238,9 @@ int16_t RF69::startReceive() { // clear interrupt flags clearIRQFlags(); + // set RF switch (if present) + _mod->setRfSwitchState(false); + // set mode to receive state = _mod->SPIsetRegValue(RF69_REG_OCP, RF69_OCP_ON | RF69_OCP_TRIM); state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_NORMAL); @@ -314,6 +317,9 @@ int16_t RF69::startTransmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); } + // set RF switch (if present) + _mod->setRfSwitchState(true); + // set mode to transmit state = setMode(RF69_TX); @@ -730,6 +736,10 @@ float RF69::getRSSI() { return(-1.0 * (_mod->SPIgetRegValue(RF69_REG_RSSI_VALUE)/2.0)); } +void RF69::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { + _mod->setRfSwitchPins(rxEn, txEn); +} + int16_t RF69::config() { int16_t state = ERR_NONE; diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 18aa8df4..fa8362a5 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -795,6 +795,16 @@ class RF69: public PhysicalLayer { */ float getRSSI(); + /*! + \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. + When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + + \param rxEn RX enable pin. + + \param txEn TX enable pin. + */ + void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + #ifndef RADIOLIB_GODMODE protected: #endif From d1527b0d8cdef4c7350dabc860e73e71d1789da7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 18 Jun 2020 16:32:52 +0200 Subject: [PATCH 096/455] [Si443x] Implemented RF switch control --- src/modules/Si443x/Si443x.cpp | 10 ++++++++++ src/modules/Si443x/Si443x.h | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 153e5c3e..0ec47c9b 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -222,6 +222,9 @@ int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { // write packet to FIFO _mod->SPIwriteRegisterBurst(SI443X_REG_FIFO_ACCESS, data, len); + // set RF switch (if present) + _mod->setRfSwitchState(true); + // set mode to transmit _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_TX_ON); @@ -246,6 +249,9 @@ int16_t Si443x::startReceive() { // clear interrupt flags clearIRQFlags(); + // set RF switch (if present) + _mod->setRfSwitchState(false); + // set mode to receive _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON); @@ -504,6 +510,10 @@ int16_t Si443x::setDataShaping(float sh) { } } +void Si443x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { + _mod->setRfSwitchPins(rxEn, txEn); +} + int16_t Si443x::setFrequencyRaw(float newFreq) { // set mode to standby int16_t state = standby(); diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index df5ae4d0..1cfd2700 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -760,6 +760,16 @@ class Si443x: public PhysicalLayer { */ int16_t setDataShaping(float sh); + /*! + \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. + When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + + \param rxEn RX enable pin. + + \param txEn TX enable pin. + */ + void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + #ifndef RADIOLIB_GODMODE protected: #endif From 5a3d7a71731c60f4ecfc4d8c39ba359f982380af Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 18 Jun 2020 16:36:02 +0200 Subject: [PATCH 097/455] [SX128x] Implemented RF switch control --- examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino | 10 ++++++++++ src/modules/SX128x/SX128x.cpp | 10 ++++++++++ src/modules/SX128x/SX128x.h | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino b/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino index e8e777dc..b86259cf 100644 --- a/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino +++ b/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino @@ -47,6 +47,16 @@ void setup() { Serial.println(state); while (true); } + + // some modules have an external RF switch + // controlled via two pins (RX enable, TX enable) + // to enable automatic control of the switch, + // call the following method + // RX enable: 4 + // TX enable: 5 + /* + lora.setRfSwitchPins(4, 5); + */ } void loop() { diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 993ff9ec..d222b016 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -477,6 +477,9 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { state = clearIrqStatus(); RADIOLIB_ASSERT(state); + // set RF switch (if present) + _mod->setRfSwitchState(true); + // start transmission state = setTx(SX128X_TX_TIMEOUT_NONE); RADIOLIB_ASSERT(state); @@ -513,6 +516,9 @@ int16_t SX128x::startReceive(uint16_t timeout) { RADIOLIB_ASSERT(state); } + // set RF switch (if present) + _mod->setRfSwitchState(false); + // set mode to receive state = setRx(timeout); @@ -1090,6 +1096,10 @@ int16_t SX128x::setEncoding(uint8_t encoding) { return(setWhitening(encoding)); } +void SX128x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { + _mod->setRfSwitchPins(rxEn, txEn); +} + uint8_t SX128x::getStatus() { uint8_t data = 0; SPIreadCommand(SX128X_CMD_GET_STATUS, &data, 1); diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index a5aea25c..755bc443 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -741,6 +741,16 @@ class SX128x: public PhysicalLayer { */ int16_t setEncoding(uint8_t encoding); + /*! + \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. + When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + + \param rxEn RX enable pin. + + \param txEn TX enable pin. + */ + void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + #ifndef RADIOLIB_GODMODE protected: #endif From 4ad82f15725f475664d599ab5ad3b141365ba5d8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 18 Jun 2020 16:36:11 +0200 Subject: [PATCH 098/455] [SX127x] Implemented RF switch control --- examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino | 10 ++++++++++ src/modules/SX127x/SX127x.cpp | 13 +++++++++++++ src/modules/SX127x/SX127x.h | 10 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino b/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino index cd5ad220..265ee32f 100644 --- a/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino +++ b/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino @@ -49,6 +49,16 @@ void setup() { Serial.println(state); while (true); } + + // some modules have an external RF switch + // controlled via two pins (RX enable, TX enable) + // to enable automatic control of the switch, + // call the following method + // RX enable: 4 + // TX enable: 5 + /* + lora.setRfSwitchPins(4, 5); + */ } void loop() { diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index a26e0c60..ccc27da1 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -368,6 +368,9 @@ int16_t SX127x::startReceive(uint8_t len, uint8_t mode) { } } + // set RF switch (if present) + _mod->setRfSwitchState(false); + // set mode to receive return(setMode(mode)); } @@ -421,6 +424,9 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { // write packet to FIFO _mod->SPIwriteRegisterBurst(SX127X_REG_FIFO, data, len); + // set RF switch (if present) + _mod->setRfSwitchState(true); + // start transmission state |= setMode(SX127X_TX); RADIOLIB_ASSERT(state); @@ -451,6 +457,9 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { // write packet to FIFO _mod->SPIwriteRegisterBurst(SX127X_REG_FIFO, data, len); + // set RF switch (if present) + _mod->setRfSwitchState(true); + // start transmission state |= setMode(SX127X_TX); RADIOLIB_ASSERT(state); @@ -934,6 +943,10 @@ uint8_t SX127x::getModemStatus() { return(_mod->SPIreadRegister(SX127X_REG_MODEM_STAT)); } +void SX127x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { + _mod->setRfSwitchPins(rxEn, txEn); +} + int8_t SX127x::getTempRaw() { int8_t temp = 0; uint8_t previousOpMode; diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 25a06a14..7f075e9b 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -921,6 +921,16 @@ class SX127x: public PhysicalLayer { */ int8_t getTempRaw(); + /*! + \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. + When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + + \param rxEn RX enable pin. + + \param txEn TX enable pin. + */ + void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + #ifdef RADIOLIB_DEBUG void regDump(); #endif From d710a85985168b163267250d1cd5d814dc5968a9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 18 Jun 2020 16:38:30 +0200 Subject: [PATCH 099/455] [SX126x] Implemented RF switch control (#153) --- examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino | 10 ++++++++++ src/modules/SX126x/SX126x.cpp | 10 ++++++++++ src/modules/SX126x/SX126x.h | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino b/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino index 574fdff3..338bf3f5 100644 --- a/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino +++ b/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino @@ -51,6 +51,16 @@ void setup() { Serial.println(state); while (true); } + + // some modules have an external RF switch + // controlled via two pins (RX enable, TX enable) + // to enable automatic control of the switch, + // call the following method + // RX enable: 4 + // TX enable: 5 + /* + lora.setRfSwitchPins(4, 5); + */ } void loop() { diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index e419761e..efbecc10 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -435,6 +435,9 @@ int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { state = fixSensitivity(); RADIOLIB_ASSERT(state); + // set RF switch (if present) + _mod->setRfSwitchState(true); + // start transmission state = setTx(SX126X_TX_TIMEOUT_NONE); RADIOLIB_ASSERT(state); @@ -451,6 +454,9 @@ int16_t SX126x::startReceive(uint32_t timeout) { int16_t state = startReceiveCommon(); RADIOLIB_ASSERT(state); + // set RF switch (if present) + _mod->setRfSwitchState(true); + // set mode to receive state = setRx(timeout); @@ -1117,6 +1123,10 @@ int16_t SX126x::setEncoding(uint8_t encoding) { return(setWhitening(encoding)); } +void SX126x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { + _mod->setRfSwitchPins(rxEn, txEn); +} + int16_t SX126x::setTCXO(float voltage, uint32_t delay) { // set mode to standby standby(); diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index e6a7f078..ae2216d6 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -843,6 +843,16 @@ class SX126x: public PhysicalLayer { */ int16_t setEncoding(uint8_t encoding); + /*! + \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. + When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + + \param rxEn RX enable pin. + + \param txEn TX enable pin. + */ + void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + #ifndef RADIOLIB_GODMODE protected: #endif From bb7108a52bbc5178f3223dc97e344da8eaaa1b36 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 19 Jun 2020 08:23:28 +0200 Subject: [PATCH 100/455] [SX126x] Fixed RF switch state in Rx mode --- src/modules/SX126x/SX126x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index efbecc10..9a018b8e 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -455,7 +455,7 @@ int16_t SX126x::startReceive(uint32_t timeout) { RADIOLIB_ASSERT(state); // set RF switch (if present) - _mod->setRfSwitchState(true); + _mod->setRfSwitchState(false); // set mode to receive state = setRx(timeout); From 56360a2a0560e158074ecfd654b5d8996ebb6182 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 16:59:20 +0200 Subject: [PATCH 101/455] Changed setRfSwitchState to directly change switch pins --- src/Module.cpp | 11 +++-------- src/Module.h | 6 ++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index af6415bb..e24e6424 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -323,18 +323,13 @@ void Module::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { Module::pinMode(txEn, OUTPUT); } -void Module::setRfSwitchState(bool tx) { +void Module::setRfSwitchState(RADIOLIB_PIN_STATUS rxPinState, RADIOLIB_PIN_STATUS txPinState) { // check RF switch control is enabled if(!_useRfSwitch) { return; } // set pins - if(tx) { - Module::digitalWrite(_rxEn, LOW); - Module::digitalWrite(_txEn, HIGH); - } else { - Module::digitalWrite(_rxEn, HIGH); - Module::digitalWrite(_txEn, LOW); - } + Module::digitalWrite(_rxEn, rxPinState); + Module::digitalWrite(_txEn, txPinState); } diff --git a/src/Module.h b/src/Module.h index 41e25299..2a20b926 100644 --- a/src/Module.h +++ b/src/Module.h @@ -399,9 +399,11 @@ class Module { /*! \brief Set RF switch state. - \param tx True to set RF switch to Tx, false to set switch to Rx. + \param rxPinState Pin state to set on Tx enable pin (usually high to transmit). + + \param txPinState Pin state to set on Rx enable pin (usually high to receive). */ - void setRfSwitchState(bool tx); + void setRfSwitchState(RADIOLIB_PIN_STATUS rxPinState, RADIOLIB_PIN_STATUS txPinState); #ifndef RADIOLIB_GODMODE private: From 05f1e998d7050468c5058ea486168cfe1cbb2226 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 17:03:34 +0200 Subject: [PATCH 102/455] [CC1101] Added missing RF switch control --- src/modules/CC1101/CC1101.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 2e3f4dea..8074a37b 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -139,11 +139,18 @@ int16_t CC1101::receive(uint8_t* data, size_t len) { } int16_t CC1101::standby() { + // set idle mode SPIsendCommand(CC1101_CMD_IDLE); + + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); return(ERR_NONE); } int16_t CC1101::transmitDirect(uint32_t frf) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, HIGH); + // user requested to start transmitting immediately (required for RTTY) if(frf != 0) { SPIwriteRegister(CC1101_REG_FREQ2, (frf & 0xFF0000) >> 16); @@ -163,6 +170,9 @@ int16_t CC1101::transmitDirect(uint32_t frf) { } int16_t CC1101::receiveDirect() { + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // activate direct mode int16_t state = directMode(); RADIOLIB_ASSERT(state); @@ -233,7 +243,7 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { SPIwriteRegisterBurst(CC1101_REG_FIFO, data, len); // set RF switch (if present) - _mod->setRfSwitchState(true); + _mod->setRfSwitchState(LOW, HIGH); // set mode to transmit SPIsendCommand(CC1101_CMD_TX); @@ -253,7 +263,7 @@ int16_t CC1101::startReceive() { RADIOLIB_ASSERT(state); // set RF switch (if present) - _mod->setRfSwitchState(false); + _mod->setRfSwitchState(HIGH, LOW); // set mode to receive SPIsendCommand(CC1101_CMD_RX); From b68bd2f9f9f0df0e599e8db7fddc34853fe32418 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 17:03:42 +0200 Subject: [PATCH 103/455] [RF69] Added missing RF switch control --- src/modules/RF69/RF69.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 6b925eb6..2e57bf7f 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -160,16 +160,25 @@ int16_t RF69::receive(uint8_t* data, size_t len) { } int16_t RF69::sleep() { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + // set module to sleep return(setMode(RF69_SLEEP)); } int16_t RF69::standby() { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + // set module to standby return(setMode(RF69_STANDBY)); } int16_t RF69::transmitDirect(uint32_t frf) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, HIGH); + // user requested to start transmitting immediately (required for RTTY) if(frf != 0) { _mod->SPIwriteRegister(RF69_REG_FRF_MSB, (frf & 0xFF0000) >> 16); @@ -188,6 +197,9 @@ int16_t RF69::transmitDirect(uint32_t frf) { } int16_t RF69::receiveDirect() { + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // activate direct mode int16_t state = directMode(); RADIOLIB_ASSERT(state); @@ -239,7 +251,7 @@ int16_t RF69::startReceive() { clearIRQFlags(); // set RF switch (if present) - _mod->setRfSwitchState(false); + _mod->setRfSwitchState(HIGH, LOW); // set mode to receive state = _mod->SPIsetRegValue(RF69_REG_OCP, RF69_OCP_ON | RF69_OCP_TRIM); @@ -318,7 +330,7 @@ int16_t RF69::startTransmit(uint8_t* data, size_t len, uint8_t addr) { } // set RF switch (if present) - _mod->setRfSwitchState(true); + _mod->setRfSwitchState(LOW, HIGH); // set mode to transmit state = setMode(RF69_TX); @@ -330,6 +342,7 @@ int16_t RF69::readData(uint8_t* data, size_t len) { // set mode to standby int16_t state = standby(); RADIOLIB_ASSERT(state); + // get packet length size_t length = len; if(len == RF69_MAX_PACKET_LENGTH) { From 5f4481aef61e9c43d7d8fd1ef231021f5701daa0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 17:03:55 +0200 Subject: [PATCH 104/455] [Si443x] Added missing RF switch control --- src/modules/Si443x/Si443x.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 0ec47c9b..099fb866 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -114,6 +114,9 @@ int16_t Si443x::receive(uint8_t* data, size_t len) { } int16_t Si443x::sleep() { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + // disable wakeup timer interrupt int16_t state = _mod->SPIsetRegValue(SI443X_REG_INTERRUPT_ENABLE_1, 0x00); RADIOLIB_ASSERT(state); @@ -127,10 +130,16 @@ int16_t Si443x::sleep() { } int16_t Si443x::standby() { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + return(_mod->SPIsetRegValue(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_XTAL_ON, 7, 0, 10)); } int16_t Si443x::transmitDirect(uint32_t frf) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, HIGH); + // user requested to start transmitting immediately (required for RTTY) if(frf != 0) { // convert the 24-bit frequency to the format accepted by the module @@ -170,6 +179,9 @@ int16_t Si443x::transmitDirect(uint32_t frf) { } int16_t Si443x::receiveDirect() { + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // activate direct mode int16_t state = directMode(); RADIOLIB_ASSERT(state); @@ -223,7 +235,7 @@ int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { _mod->SPIwriteRegisterBurst(SI443X_REG_FIFO_ACCESS, data, len); // set RF switch (if present) - _mod->setRfSwitchState(true); + _mod->setRfSwitchState(LOW, HIGH); // set mode to transmit _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_TX_ON); @@ -250,7 +262,7 @@ int16_t Si443x::startReceive() { clearIRQFlags(); // set RF switch (if present) - _mod->setRfSwitchState(false); + _mod->setRfSwitchState(HIGH, LOW); // set mode to receive _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON); From 75197d78a0fe7afbe1dd98530c9370c692ae03aa Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 17:04:03 +0200 Subject: [PATCH 105/455] [SX128x] Added missing RF switch control --- src/modules/SX128x/SX128x.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index d222b016..97222c70 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -340,6 +340,9 @@ int16_t SX128x::receive(uint8_t* data, size_t len) { } int16_t SX128x::transmitDirect(uint32_t frf) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, HIGH); + // user requested to start transmitting immediately (required for RTTY) int16_t state = ERR_NONE; if(frf != 0) { @@ -352,6 +355,9 @@ int16_t SX128x::transmitDirect(uint32_t frf) { } int16_t SX128x::receiveDirect() { + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // SX128x is unable to output received data directly return(ERR_UNKNOWN); } @@ -374,6 +380,9 @@ int16_t SX128x::scanChannel() { state = clearIrqStatus(); RADIOLIB_ASSERT(state); + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // set mode to CAD state = setCad(); RADIOLIB_ASSERT(state); @@ -399,6 +408,9 @@ int16_t SX128x::scanChannel() { } int16_t SX128x::sleep(bool retainConfig) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + uint8_t sleepConfig = SX128X_SLEEP_DATA_BUFFER_RETAIN | SX128X_SLEEP_DATA_RAM_RETAIN; if(!retainConfig) { sleepConfig = SX128X_SLEEP_DATA_BUFFER_FLUSH | SX128X_SLEEP_DATA_RAM_FLUSH; @@ -416,6 +428,9 @@ int16_t SX128x::standby() { } int16_t SX128x::standby(uint8_t mode) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + uint8_t data[] = { mode }; return(SPIwriteCommand(SX128X_CMD_SET_STANDBY, data, 1)); } @@ -478,7 +493,7 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // set RF switch (if present) - _mod->setRfSwitchState(true); + _mod->setRfSwitchState(LOW, HIGH); // start transmission state = setTx(SX128X_TX_TIMEOUT_NONE); @@ -517,7 +532,7 @@ int16_t SX128x::startReceive(uint16_t timeout) { } // set RF switch (if present) - _mod->setRfSwitchState(false); + _mod->setRfSwitchState(HIGH, LOW); // set mode to receive state = setRx(timeout); From 3fe7da9788e59d6cf6e6d0a34cf744dbf77952a8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 17:04:11 +0200 Subject: [PATCH 106/455] [SX127x] Added missing RF switch control --- src/modules/SX127x/SX127x.cpp | 53 ++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index ccc27da1..45fe5f01 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -245,6 +245,9 @@ int16_t SX127x::scanChannel() { // clear interrupt flags clearIRQFlags(); + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // set mode to CAD state = setMode(SX127X_CAD); RADIOLIB_ASSERT(state); @@ -265,11 +268,17 @@ int16_t SX127x::scanChannel() { } int16_t SX127x::sleep() { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + // set mode to sleep return(setMode(SX127X_SLEEP)); } int16_t SX127x::standby() { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + // set mode to standby return(setMode(SX127X_STANDBY)); } @@ -280,6 +289,9 @@ int16_t SX127x::transmitDirect(uint32_t FRF) { return(ERR_WRONG_MODEM); } + // set RF switch (if present) + _mod->setRfSwitchState(LOW, HIGH); + // user requested to start transmitting immediately (required for RTTY) if(FRF != 0) { _mod->SPIwriteRegister(SX127X_REG_FRF_MSB, (FRF & 0xFF0000) >> 16); @@ -303,6 +315,9 @@ int16_t SX127x::receiveDirect() { return(ERR_WRONG_MODEM); } + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // activate direct mode int16_t state = directMode(); RADIOLIB_ASSERT(state); @@ -369,7 +384,7 @@ int16_t SX127x::startReceive(uint8_t len, uint8_t mode) { } // set RF switch (if present) - _mod->setRfSwitchState(false); + _mod->setRfSwitchState(HIGH, LOW); // set mode to receive return(setMode(mode)); @@ -421,18 +436,6 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { state |= _mod->SPIsetRegValue(SX127X_REG_FIFO_TX_BASE_ADDR, SX127X_FIFO_TX_BASE_ADDR_MAX); state |= _mod->SPIsetRegValue(SX127X_REG_FIFO_ADDR_PTR, SX127X_FIFO_TX_BASE_ADDR_MAX); - // write packet to FIFO - _mod->SPIwriteRegisterBurst(SX127X_REG_FIFO, data, len); - - // set RF switch (if present) - _mod->setRfSwitchState(true); - - // start transmission - state |= setMode(SX127X_TX); - RADIOLIB_ASSERT(state); - - return(ERR_NONE); - } else if(modem == SX127X_FSK_OOK) { // check packet length if(len >= SX127X_MAX_PACKET_LENGTH_FSK) { @@ -453,21 +456,19 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { if((filter == SX127X_ADDRESS_FILTERING_NODE) || (filter == SX127X_ADDRESS_FILTERING_NODE_BROADCAST)) { _mod->SPIwriteRegister(SX127X_REG_FIFO, addr); } - - // write packet to FIFO - _mod->SPIwriteRegisterBurst(SX127X_REG_FIFO, data, len); - - // set RF switch (if present) - _mod->setRfSwitchState(true); - - // start transmission - state |= setMode(SX127X_TX); - RADIOLIB_ASSERT(state); - - return(ERR_NONE); } - return(ERR_UNKNOWN); + // write packet to FIFO + _mod->SPIwriteRegisterBurst(SX127X_REG_FIFO, data, len); + + // set RF switch (if present) + _mod->setRfSwitchState(LOW, HIGH); + + // start transmission + state |= setMode(SX127X_TX); + RADIOLIB_ASSERT(state); + + return(ERR_NONE); } int16_t SX127x::readData(uint8_t* data, size_t len) { From 06c254bc6edd2e25cd04c1b37bfbec37ad645ad2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 17:04:17 +0200 Subject: [PATCH 107/455] [SX126x] Added missing RF switch control --- src/modules/SX126x/SX126x.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 9a018b8e..18d9ad81 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -300,6 +300,9 @@ int16_t SX126x::receive(uint8_t* data, size_t len) { } int16_t SX126x::transmitDirect(uint32_t frf) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, HIGH); + // user requested to start transmitting immediately (required for RTTY) int16_t state = ERR_NONE; if(frf != 0) { @@ -313,6 +316,9 @@ int16_t SX126x::transmitDirect(uint32_t frf) { } int16_t SX126x::receiveDirect() { + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // SX126x is unable to output received data directly return(ERR_UNKNOWN); } @@ -327,6 +333,9 @@ int16_t SX126x::scanChannel() { int16_t state = standby(); RADIOLIB_ASSERT(state); + // set RF switch (if present) + _mod->setRfSwitchState(HIGH, LOW); + // set DIO pin mapping state = setDioIrqParams(SX126X_IRQ_CAD_DETECTED | SX126X_IRQ_CAD_DONE, SX126X_IRQ_CAD_DETECTED | SX126X_IRQ_CAD_DONE); RADIOLIB_ASSERT(state); @@ -360,6 +369,9 @@ int16_t SX126x::scanChannel() { } int16_t SX126x::sleep(bool retainConfig) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + uint8_t sleepMode = SX126X_SLEEP_START_WARM | SX126X_SLEEP_RTC_OFF; if(!retainConfig) { sleepMode = SX126X_SLEEP_START_COLD | SX126X_SLEEP_RTC_OFF; @@ -377,6 +389,9 @@ int16_t SX126x::standby() { } int16_t SX126x::standby(uint8_t mode) { + // set RF switch (if present) + _mod->setRfSwitchState(LOW, LOW); + uint8_t data[] = {mode}; return(SPIwriteCommand(SX126X_CMD_SET_STANDBY, data, 1)); } @@ -436,7 +451,7 @@ int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // set RF switch (if present) - _mod->setRfSwitchState(true); + _mod->setRfSwitchState(LOW, HIGH); // start transmission state = setTx(SX126X_TX_TIMEOUT_NONE); @@ -455,7 +470,7 @@ int16_t SX126x::startReceive(uint32_t timeout) { RADIOLIB_ASSERT(state); // set RF switch (if present) - _mod->setRfSwitchState(false); + _mod->setRfSwitchState(HIGH, LOW); // set mode to receive state = setRx(timeout); From 6bdef760315c76cac2f6bfef249ce79eddf77d5f Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 21:09:12 +0200 Subject: [PATCH 108/455] [SX128x] Added SPI delay for SAMD cores --- src/modules/SX128x/SX128x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 97222c70..112417f5 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1412,7 +1412,7 @@ int16_t SX128x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d // some faster platforms require a short delay here // not sure why, but it seems that long enough SPI transaction // (e.g. setPacketParams for GFSK) will fail without it - #if defined(ARDUINO_ARCH_STM32) + #if defined(ARDUINO_ARCH_STM32) || defined(SAMD_SERIES) delay(1); #endif #endif From aa4f4c9ab41dcff153f90267b38a2eb46ab22a98 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 21:13:50 +0200 Subject: [PATCH 109/455] [SX126x] Added SPI delay for SAMD cores (#153) --- src/modules/SX126x/SX126x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 18d9ad81..3a8aecaa 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1658,7 +1658,7 @@ int16_t SX126x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d // some faster platforms require a short delay here // not sure why, but it seems that long enough SPI transaction // (e.g. setPacketParams for GFSK) will fail without it - #if defined(ARDUINO_ARCH_STM32) + #if defined(ARDUINO_ARCH_STM32) || defined(SAMD_SERIES) delay(1); #endif #endif From e356054f56235107892a7f8fbfa45cce2e76c795 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 21 Jun 2020 08:15:53 +0200 Subject: [PATCH 110/455] Bump version to 3.7.0 --- library.properties | 2 +- src/BuildOpt.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.properties b/library.properties index 733be1bd..f2c3def6 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=3.6.2 +version=3.7.0 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index a5de6898..8e4918ae 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -269,8 +269,8 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x03) -#define RADIOLIB_VERSION_MINOR (0x06) -#define RADIOLIB_VERSION_PATCH (0x02) +#define RADIOLIB_VERSION_MINOR (0x07) +#define RADIOLIB_VERSION_PATCH (0x00) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From 67925473a0faf9b73e77136fbfe94547814c01e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 27 Jun 2020 07:49:50 +0200 Subject: [PATCH 111/455] Update bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 49d358d7..94d6b531 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -11,7 +11,7 @@ assignees: '' Before submitting new issue, please check the [Wiki](https://github.com/jgromes/RadioLib/wiki) and the [API documentation](https://jgromes.github.io/RadioLib/). You might find a solution to your issue there. **Describe the bug** -A clear and concise description of what the bug is. When applicable, please include debug mode output: uncomment [debug macro definitions in BuildOpt.h](https://github.com/jgromes/RadioLib/blob/master/src/BuildOpt.h#L135) and post the output. +A clear and concise description of what the bug is. When applicable, please include [debug mode output](https://github.com/jgromes/RadioLib/wiki/Debug-mode). **To Reproduce** Minimal Arduino sketch to reproduce the behavior. Please user Markdown to style the code to make it readable (see [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code)). From 25dcf8c16117a0019d754b15d12ab68615db3a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 27 Jun 2020 18:04:33 +0200 Subject: [PATCH 112/455] Update bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 94d6b531..0258df19 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -24,6 +24,7 @@ If applicable, add screenshots to help explain your problem. **Additional info (please complete):** - MCU: [e.g. Arduino Uno, ESP8266 etc.] + - Link to Arduino core: [e.g. https://github.com/stm32duino/Arduino_Core_STM32 when using official STM32 core. See readme for links to all supported cores] - Wireless module type [e.g. CC1101, SX1268, etc.] - Arduino IDE version [e.g. 1.8.5] - Library version [e.g. 3.0.0] From 49259109d31368f54c66b19303685657ce992093 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 28 Jun 2020 20:36:16 +0200 Subject: [PATCH 113/455] Updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad437969..10da3c3f 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ The list above is by no means exhaustive. Most of RadioLib code is independent o ## Frequently Asked Questions ### Where should I start? -First of all, take a look at the [examples](https://github.com/jgromes/RadioLib/tree/master/examples) and the [Wiki](https://github.com/jgromes/RadioLib/wiki) - especially the [Basics](https://github.com/jgromes/RadioLib/wiki/Basics) page. There's a lot of useful information over there. Also, you should check out [RadioShield](https://github.com/jgromes/RadioShield) - open source Arduino shield that will allow you to easily connect any two wireless modules supported by RadioLib! +First of all, take a look at the [examples](https://github.com/jgromes/RadioLib/tree/master/examples) and the [Wiki](https://github.com/jgromes/RadioLib/wiki) - especially the [Basics](https://github.com/jgromes/RadioLib/wiki/Basics) page. There's a lot of useful information over there. If something isn't working as expected, try searching the [issues](https://github.com/jgromes/RadioLib/issues/). ### Help, my module isn't working! The fastest way to get help is by creating an [issue](https://github.com/jgromes/RadioLib/issues/new?assignees=&labels=&template=bug_report.md&title=) using the appropriate template. It is also highly recommended to try running the examples first - their functionality is tested from time to time and they should work. Finally, RadioLib is still under development, which means that sometimes, backwards-incompatible changes might be introduced. Though these are kept at minimum, sometimes it is unavoidable. You can check the [release changelog](https://github.com/jgromes/RadioLib/releases) to find out if there's been such a major change recently. From 738d7116987cb9505c0ea1fefad8e18b56d73f51 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 29 Jun 2020 08:13:41 +0200 Subject: [PATCH 114/455] Fixed debug conditionals --- src/BuildOpt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 8e4918ae..70a64e60 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -216,7 +216,7 @@ // set which Serial port should be used for debug output #define RADIOLIB_DEBUG_PORT Serial -#ifdef RADIOLIB_DEBUG +#if defined(RADIOLIB_DEBUG) #define RADIOLIB_DEBUG_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); } #define RADIOLIB_DEBUG_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); } #else @@ -224,7 +224,7 @@ #define RADIOLIB_DEBUG_PRINTLN(...) {} #endif -#ifdef RADIOLIB_VERBOSE +#if defined(RADIOLIB_VERBOSE) #define RADIOLIB_VERBOSE_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); } #define RADIOLIB_VERBOSE_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); } #else From 1749da28d7225cf3aff43f0ccd6e9e335b0004a0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 29 Jun 2020 09:54:26 +0200 Subject: [PATCH 115/455] Added custom platform template --- src/BuildOpt.h | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 70a64e60..d9ed675a 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -23,13 +23,34 @@ * * In addition, some platforms may require RadioLib to disable specific drivers (such as ESP8266). * - * Users may also specify their own configuration by defining all of the platform-specific parameters - * and macro RADIOLIB_CUSTOM_PLATFORM prior to including the main library file (RadioLib.h). + * Users may also specify their own configuration by uncommenting the RADIOLIB_CUSTOM_PLATFORM, + * and then specifying all platform parameters in the section below. This will override automatic + * platform detection. */ + +// uncomment to enable custom platform definition +#define RADIOLIB_CUSTOM_PLATFORM + #if defined(RADIOLIB_CUSTOM_PLATFORM) - #if !defined(RADIOLIB_PLATFORM) - #define RADIOLIB_PLATFORM "Custom" - #endif + // name for your platform + #define RADIOLIB_PLATFORM "Custom" + + // the following parameters must always be defined + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI + + // the following must be defined if the Arduino core does not support SoftwareSerial library + //#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + //#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + + // the following must be defined if the Arduino core does not support tone function + //#define RADIOLIB_TONE_UNSUPPORTED + #else #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. From 4ad5261a8333eabb7af332fc60df5e007bf22647 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 29 Jun 2020 09:55:02 +0200 Subject: [PATCH 116/455] Fixed custom platform enabled by default --- src/BuildOpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index d9ed675a..84c9b684 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -29,7 +29,7 @@ */ // uncomment to enable custom platform definition -#define RADIOLIB_CUSTOM_PLATFORM +//#define RADIOLIB_CUSTOM_PLATFORM #if defined(RADIOLIB_CUSTOM_PLATFORM) // name for your platform From 995d7054ef400c407173793c5a1f651f01847554 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:41:48 +0200 Subject: [PATCH 117/455] [CC1101] Reworked driver exlusion --- src/modules/CC1101/CC1101.cpp | 3 +++ src/modules/CC1101/CC1101.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 8074a37b..80b0c7db 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -1,4 +1,5 @@ #include "CC1101.h" +#if !defined(RADIOLIB_EXCLUDE_CC1101) CC1101::CC1101(Module* module) : PhysicalLayer(CC1101_FREQUENCY_STEP_SIZE, CC1101_MAX_PACKET_LENGTH) { _mod = module; @@ -857,3 +858,5 @@ void CC1101::SPIsendCommand(uint8_t cmd) { SPI.endTransaction(); Module::digitalWrite(_mod->getCs(), HIGH); } + +#endif diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 0ef0df29..2ba3089e 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_CC1101_H +#if !defined(_RADIOLIB_CC1101_H) && !defined(RADIOLIB_EXCLUDE_CC1101) #define _RADIOLIB_CC1101_H #include "../../TypeDef.h" From 36a44ed44defb890eafb87bb96855f3dc13e9c93 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:42:13 +0200 Subject: [PATCH 118/455] [ESP8266] Reworked driver exclusion --- src/modules/ESP8266/ESP8266.cpp | 2 +- src/modules/ESP8266/ESP8266.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index bc372ac6..63f7bca0 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -1,5 +1,5 @@ -#if !defined(ESP8266) && !defined(ARDUINO_ARDUINO_NANO33BLE) #include "ESP8266.h" +#if !defined(RADIOLIB_EXCLUDE_ESP8266) ESP8266::ESP8266(Module* module) { _mod = module; diff --git a/src/modules/ESP8266/ESP8266.h b/src/modules/ESP8266/ESP8266.h index e817038e..a825b984 100644 --- a/src/modules/ESP8266/ESP8266.h +++ b/src/modules/ESP8266/ESP8266.h @@ -1,4 +1,4 @@ -#if !defined(_RADIOLIB_ESP8266_H) +#if !defined(_RADIOLIB_ESP8266_H) && !defined(RADIOLIB_EXCLUDE_ESP8266) #define _RADIOLIB_ESP8266_H #include "../../Module.h" From 535e35a3db1750cb3504d12ad055c9bea9912d08 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:42:23 +0200 Subject: [PATCH 119/455] [HC05] Reworked driver exclusion --- src/modules/HC05/HC05.cpp | 3 +++ src/modules/HC05/HC05.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/HC05/HC05.cpp b/src/modules/HC05/HC05.cpp index 2aecab76..7a35ce71 100644 --- a/src/modules/HC05/HC05.cpp +++ b/src/modules/HC05/HC05.cpp @@ -1,4 +1,5 @@ #include "HC05.h" +#if !defined(RADIOLIB_EXCLUDE_HC05) HC05::HC05(Module* mod) : ISerial(mod) { @@ -9,3 +10,5 @@ void HC05::begin(long speed) { _mod->baudrate = speed; _mod->init(RADIOLIB_USE_UART); } + +#endif diff --git a/src/modules/HC05/HC05.h b/src/modules/HC05/HC05.h index 2bfacb48..7721a50a 100644 --- a/src/modules/HC05/HC05.h +++ b/src/modules/HC05/HC05.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_HC05_H +#if !defined(_RADIOLIB_HC05_H) && !defined(RADIOLIB_EXCLUDE_HC05) #define _RADIOLIB_HC05_H #include "../../ISerial.h" From 67e36f4ed93e0b286c9f4c4ad09a74b0c30ee401 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:42:37 +0200 Subject: [PATCH 120/455] [JDY08] Reworked driver exclusion --- src/modules/JDY08/JDY08.cpp | 3 +++ src/modules/JDY08/JDY08.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/JDY08/JDY08.cpp b/src/modules/JDY08/JDY08.cpp index 78bc596b..a94cb37d 100644 --- a/src/modules/JDY08/JDY08.cpp +++ b/src/modules/JDY08/JDY08.cpp @@ -1,3 +1,4 @@ +#if !defined(_RADIOLIB_JDY08_H) && !defined(RADIOLIB_EXCLUDE_JDY08) #include "JDY08.h" JDY08::JDY08(Module* mod) : ISerial(mod) { @@ -10,3 +11,5 @@ void JDY08::begin(long speed) { _mod->baudrate = speed; _mod->init(RADIOLIB_USE_UART); } + +#endif diff --git a/src/modules/JDY08/JDY08.h b/src/modules/JDY08/JDY08.h index be01ef19..7bb64011 100644 --- a/src/modules/JDY08/JDY08.h +++ b/src/modules/JDY08/JDY08.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_JDY08_H +#if !defined(_RADIOLIB_JDY08_H) && !defined(RADIOLIB_EXCLUDE_JDY08) #define _RADIOLIB_JDY08_H #include "../../ISerial.h" From 984cfac31969d4571594b650e88c4254fd0a9e3b Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:42:47 +0200 Subject: [PATCH 121/455] [RF69] Reworked driver exclusion --- src/modules/RF69/RF69.cpp | 5 ++++- src/modules/RF69/RF69.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 2e57bf7f..7b1cad43 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -1,4 +1,5 @@ #include "RF69.h" +#if !defined(RADIOLIB_EXCLUDE_RF69) RF69::RF69(Module* module) : PhysicalLayer(RF69_FREQUENCY_STEP_SIZE, RF69_MAX_PACKET_LENGTH) { _mod = module; @@ -342,7 +343,7 @@ int16_t RF69::readData(uint8_t* data, size_t len) { // set mode to standby int16_t state = standby(); RADIOLIB_ASSERT(state); - + // get packet length size_t length = len; if(len == RF69_MAX_PACKET_LENGTH) { @@ -836,3 +837,5 @@ void RF69::clearIRQFlags() { _mod->SPIwriteRegister(RF69_REG_IRQ_FLAGS_1, 0b11111111); _mod->SPIwriteRegister(RF69_REG_IRQ_FLAGS_2, 0b11111111); } + +#endif diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index fa8362a5..b82f607d 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_RF69_H +#if !defined(_RADIOLIB_RF69_H) && !defined(RADIOLIB_EXCLUDE_RF69) #define _RADIOLIB_RF69_H #include "../../TypeDef.h" From e6657cf2f013b0c317f7eab372df69763fa276fa Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:43:00 +0200 Subject: [PATCH 122/455] [RFM2x] Reworked driver exclusion --- 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 e3cd4a4d..bfad6cd7 100644 --- a/src/modules/RFM2x/RFM22.h +++ b/src/modules/RFM2x/RFM22.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_RFM22_H +#if !defined(_RADIOLIB_RFM22_H) && !defined(RADIOLIB_EXCLUDE_SI443X) #define _RADIOLIB_RFM22_H #include "../../TypeDef.h" diff --git a/src/modules/RFM2x/RFM23.h b/src/modules/RFM2x/RFM23.h index 4f72557d..506c3482 100644 --- a/src/modules/RFM2x/RFM23.h +++ b/src/modules/RFM2x/RFM23.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_RFM23_H +#if !defined(_RADIOLIB_RFM23_H) && !defined(RADIOLIB_EXCLUDE_SI443X) #define _RADIOLIB_RFM23_H #include "../../TypeDef.h" From 04ea05c7ec30da4b05614a77ae3152724a52dd52 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:43:14 +0200 Subject: [PATCH 123/455] [RFM9x] Reworked driver exclusion --- src/modules/RFM9x/RFM95.cpp | 3 +++ src/modules/RFM9x/RFM95.h | 2 +- src/modules/RFM9x/RFM96.cpp | 3 +++ src/modules/RFM9x/RFM96.h | 2 +- src/modules/RFM9x/RFM97.cpp | 3 +++ src/modules/RFM9x/RFM97.h | 2 +- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/RFM9x/RFM95.cpp b/src/modules/RFM9x/RFM95.cpp index 53f1eb7c..80db42a6 100644 --- a/src/modules/RFM9x/RFM95.cpp +++ b/src/modules/RFM9x/RFM95.cpp @@ -1,4 +1,5 @@ #include "RFM95.h" +#if !defined(RADIOLIB_EXCLUDE_RFM9X) RFM95::RFM95(Module* mod) : SX1278(mod) { @@ -47,3 +48,5 @@ int16_t RFM95::setFrequency(float freq) { // set frequency return(SX127x::setFrequencyRaw(freq)); } + +#endif diff --git a/src/modules/RFM9x/RFM95.h b/src/modules/RFM9x/RFM95.h index fcbcf67d..914ccad9 100644 --- a/src/modules/RFM9x/RFM95.h +++ b/src/modules/RFM9x/RFM95.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_RFM95_H +#if !defined(_RADIOLIB_RFM95_H) && !defined(RADIOLIB_EXCLUDE_RFM9X) #define _RADIOLIB_RFM95_H #include "../../TypeDef.h" diff --git a/src/modules/RFM9x/RFM96.cpp b/src/modules/RFM9x/RFM96.cpp index 159c4995..5ca6f594 100644 --- a/src/modules/RFM9x/RFM96.cpp +++ b/src/modules/RFM9x/RFM96.cpp @@ -1,4 +1,5 @@ #include "RFM96.h" +#if !defined(RADIOLIB_EXCLUDE_RFM9X) RFM96::RFM96(Module* mod) : SX1278(mod) { @@ -47,3 +48,5 @@ int16_t RFM96::setFrequency(float freq) { // set frequency return(SX127x::setFrequencyRaw(freq)); } + +#endif diff --git a/src/modules/RFM9x/RFM96.h b/src/modules/RFM9x/RFM96.h index 74b6d382..985fcf74 100644 --- a/src/modules/RFM9x/RFM96.h +++ b/src/modules/RFM9x/RFM96.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_RFM96_H +#if !defined(_RADIOLIB_RFM96_H) && !defined(RADIOLIB_EXCLUDE_RFM9X) #define _RADIOLIB_RFM96_H #include "../../TypeDef.h" diff --git a/src/modules/RFM9x/RFM97.cpp b/src/modules/RFM9x/RFM97.cpp index 102fecf9..ccf19134 100644 --- a/src/modules/RFM9x/RFM97.cpp +++ b/src/modules/RFM9x/RFM97.cpp @@ -1,4 +1,5 @@ #include "RFM97.h" +#if !defined(RADIOLIB_EXCLUDE_RFM9X) RFM97::RFM97(Module* mod) : RFM95(mod) { @@ -37,3 +38,5 @@ int16_t RFM97::setSpreadingFactor(uint8_t sf) { } return(state); } + +#endif diff --git a/src/modules/RFM9x/RFM97.h b/src/modules/RFM9x/RFM97.h index b5dcbbdf..90e59e42 100644 --- a/src/modules/RFM9x/RFM97.h +++ b/src/modules/RFM9x/RFM97.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_RFM97_H +#if !defined(_RADIOLIB_RFM97_H) && !defined(RADIOLIB_EXCLUDE_RFM9X) #define _RADIOLIB_RFM97_H #include "../../TypeDef.h" From 893d8a905f208797861d841168490f19a5ec47d8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:43:26 +0200 Subject: [PATCH 124/455] [SX1231] Reworked driver exclusion --- src/modules/SX1231/SX1231.cpp | 3 +++ src/modules/SX1231/SX1231.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index f42c584e..53981685 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -1,4 +1,5 @@ #include "SX1231.h" +#if !defined(RADIOLIB_EXCLUDE_RF69) SX1231::SX1231(Module* mod) : RF69(mod) { @@ -92,3 +93,5 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po return(ERR_NONE); } + +#endif diff --git a/src/modules/SX1231/SX1231.h b/src/modules/SX1231/SX1231.h index d048fd02..0761fa8e 100644 --- a/src/modules/SX1231/SX1231.h +++ b/src/modules/SX1231/SX1231.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1231_H +#if !defined(_RADIOLIB_SX1231_H) && !defined(RADIOLIB_EXCLUDE_RF69) #define _RADIOLIB_SX1231_H #include "../../TypeDef.h" From 58ddfb8b51772214c4a59c41aa0a81df119832f4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:43:41 +0200 Subject: [PATCH 125/455] [SX126x] Reworked driver exclusion --- src/modules/SX126x/SX1261.cpp | 3 +++ src/modules/SX126x/SX1261.h | 2 +- src/modules/SX126x/SX1262.cpp | 3 +++ src/modules/SX126x/SX1262.h | 2 +- src/modules/SX126x/SX1268.cpp | 3 +++ src/modules/SX126x/SX1268.h | 2 +- src/modules/SX126x/SX126x.cpp | 3 +++ src/modules/SX126x/SX126x.h | 2 +- 8 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/modules/SX126x/SX1261.cpp b/src/modules/SX126x/SX1261.cpp index a78d2578..b0b626c2 100644 --- a/src/modules/SX126x/SX1261.cpp +++ b/src/modules/SX126x/SX1261.cpp @@ -1,4 +1,5 @@ #include "SX1261.h" +#if !defined(RADIOLIB_EXCLUDE_SX126X) SX1261::SX1261(Module* mod): SX1262(mod) { @@ -24,3 +25,5 @@ int16_t SX1261::setOutputPower(int8_t power) { // restore OCP configuration return(writeRegister(SX126X_REG_OCP_CONFIGURATION, &ocp, 1)); } + +#endif diff --git a/src/modules/SX126x/SX1261.h b/src/modules/SX126x/SX1261.h index 2dca7ed1..5b6f9ef6 100644 --- a/src/modules/SX126x/SX1261.h +++ b/src/modules/SX126x/SX1261.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1261_H +#if !defined(_RADIOLIB_SX1261_H) && !defined(RADIOLIB_EXCLUDE_SX126X) #define _RADIOLIB_SX1261_H #include "../../TypeDef.h" diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index 7d1f6efe..1ce049af 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -1,4 +1,5 @@ #include "SX1262.h" +#if !defined(RADIOLIB_EXCLUDE_SX126X) SX1262::SX1262(Module* mod) : SX126x(mod) { @@ -90,3 +91,5 @@ int16_t SX1262::setOutputPower(int8_t power) { // restore OCP configuration return(writeRegister(SX126X_REG_OCP_CONFIGURATION, &ocp, 1)); } + +#endif diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index e33f568b..b268759b 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1262_H +#if !defined(_RADIOLIB_SX1262_H) && !defined(RADIOLIB_EXCLUDE_SX126X) #define _RADIOLIB_SX1262_H #include "../../TypeDef.h" diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index 6b7f3ad2..04cd370f 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -1,4 +1,5 @@ #include "SX1268.h" +#if !defined(RADIOLIB_EXCLUDE_SX126X) SX1268::SX1268(Module* mod) : SX126x(mod) { @@ -83,3 +84,5 @@ int16_t SX1268::setOutputPower(int8_t power) { // restore OCP configuration return(writeRegister(SX126X_REG_OCP_CONFIGURATION, &ocp, 1)); } + +#endif diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h index 5b203b72..76f01c1e 100644 --- a/src/modules/SX126x/SX1268.h +++ b/src/modules/SX126x/SX1268.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1268_H +#if !defined(_RADIOLIB_SX1268_H) && !defined(RADIOLIB_EXCLUDE_SX126X) #define _RADIOLIB_SX1268_H #include "../../TypeDef.h" diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 3a8aecaa..900a835c 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1,4 +1,5 @@ #include "SX126x.h" +#if !defined(RADIOLIB_EXCLUDE_SX126X) SX126x::SX126x(Module* mod) : PhysicalLayer(SX126X_FREQUENCY_STEP_SIZE, SX126X_MAX_PACKET_LENGTH) { _mod = mod; @@ -1677,3 +1678,5 @@ int16_t SX126x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d return(ERR_NONE); } } + +#endif diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index ae2216d6..26881c8c 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX126X_H +#if !defined(_RADIOLIB_SX126X_H) && !defined(RADIOLIB_EXCLUDE_SX126X) #define _RADIOLIB_SX126X_H #include "../../TypeDef.h" From 3dd3a471e50b942ed25ae83dcd2d31743a1c90ec Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:43:56 +0200 Subject: [PATCH 126/455] [SX127x] Reworked driver exclusion --- src/modules/SX127x/SX1272.cpp | 3 +++ src/modules/SX127x/SX1272.h | 4 ++-- src/modules/SX127x/SX1273.cpp | 3 +++ src/modules/SX127x/SX1273.h | 2 +- src/modules/SX127x/SX1276.cpp | 3 +++ src/modules/SX127x/SX1276.h | 2 +- src/modules/SX127x/SX1277.cpp | 3 +++ src/modules/SX127x/SX1277.h | 2 +- src/modules/SX127x/SX1278.cpp | 3 +++ src/modules/SX127x/SX1278.h | 4 ++-- src/modules/SX127x/SX1279.cpp | 3 +++ src/modules/SX127x/SX1279.h | 2 +- src/modules/SX127x/SX127x.cpp | 24 +----------------------- src/modules/SX127x/SX127x.h | 6 +----- 14 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 28fedba3..b37cf75e 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -1,4 +1,5 @@ #include "SX1272.h" +#if !defined(RADIOLIB_EXCLUDE_SX127X) SX1272::SX1272(Module* mod) : SX127x(mod) { @@ -417,3 +418,5 @@ int16_t SX1272::configFSK() { return(state); } + +#endif diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index a0f64541..547f2905 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1272_H +#if !defined(_RADIOLIB_SX1272_H) && !defined(RADIOLIB_EXCLUDE_SX127X) #define _RADIOLIB_SX1272_H #include "../../TypeDef.h" @@ -155,7 +155,7 @@ class SX1272: public SX127x { \returns \ref status_codes */ int16_t beginFSK(float freq = 915.0, float br = 48.0, float rxBw = 125.0, float freqDev = 50.0, int8_t power = 13, uint8_t currentLimit = 100, uint16_t preambleLength = 16, bool enableOOK = false); - + /*! \brief Reset method. Will reset the chip to the default state using RST pin. */ diff --git a/src/modules/SX127x/SX1273.cpp b/src/modules/SX127x/SX1273.cpp index ee0a48fc..b45ca0e5 100644 --- a/src/modules/SX127x/SX1273.cpp +++ b/src/modules/SX127x/SX1273.cpp @@ -1,4 +1,5 @@ #include "SX1273.h" +#if !defined(RADIOLIB_EXCLUDE_SX127X) SX1273::SX1273(Module* mod) : SX1272(mod) { @@ -68,3 +69,5 @@ int16_t SX1273::setSpreadingFactor(uint8_t sf) { return(state); } + +#endif diff --git a/src/modules/SX127x/SX1273.h b/src/modules/SX127x/SX1273.h index 52ffafd1..ac7fcd98 100644 --- a/src/modules/SX127x/SX1273.h +++ b/src/modules/SX127x/SX1273.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1273_H +#if !defined(_RADIOLIB_SX1273_H) && !defined(RADIOLIB_EXCLUDE_SX127X) #define _RADIOLIB_SX1273_H #include "../../TypeDef.h" diff --git a/src/modules/SX127x/SX1276.cpp b/src/modules/SX127x/SX1276.cpp index 2fecd63a..66510443 100644 --- a/src/modules/SX127x/SX1276.cpp +++ b/src/modules/SX127x/SX1276.cpp @@ -1,4 +1,5 @@ #include "SX1276.h" +#if !defined(RADIOLIB_EXCLUDE_SX127X) SX1276::SX1276(Module* mod) : SX1278(mod) { @@ -103,3 +104,5 @@ int16_t SX1276::setFrequency(float freq) { // set frequency return(SX127x::setFrequencyRaw(freq)); } + +#endif diff --git a/src/modules/SX127x/SX1276.h b/src/modules/SX127x/SX1276.h index 8a320ec8..55861cc3 100644 --- a/src/modules/SX127x/SX1276.h +++ b/src/modules/SX127x/SX1276.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1276_H +#if !defined(_RADIOLIB_SX1276_H) && !defined(RADIOLIB_EXCLUDE_SX127X) #define _RADIOLIB_SX1276_H #include "../../TypeDef.h" diff --git a/src/modules/SX127x/SX1277.cpp b/src/modules/SX127x/SX1277.cpp index 715d8853..fe187055 100644 --- a/src/modules/SX127x/SX1277.cpp +++ b/src/modules/SX127x/SX1277.cpp @@ -1,4 +1,5 @@ #include "SX1277.h" +#if !defined(RADIOLIB_EXCLUDE_SX127X) SX1277::SX1277(Module* mod) : SX1278(mod) { @@ -133,3 +134,5 @@ int16_t SX1277::setSpreadingFactor(uint8_t sf) { return(state); } + +#endif diff --git a/src/modules/SX127x/SX1277.h b/src/modules/SX127x/SX1277.h index cee312a3..afbfdc1f 100644 --- a/src/modules/SX127x/SX1277.h +++ b/src/modules/SX127x/SX1277.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1277_H +#if !defined(_RADIOLIB_SX1277_H) && !defined(RADIOLIB_EXCLUDE_SX127X) #define _RADIOLIB_SX1277_H #include "../../TypeDef.h" diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index af3fc0b3..698634f8 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -1,4 +1,5 @@ #include "SX1278.h" +#if !defined(RADIOLIB_EXCLUDE_SX127X) SX1278::SX1278(Module* mod) : SX127x(mod) { @@ -495,3 +496,5 @@ int16_t SX1278::configFSK() { return(state); } + +#endif diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index 77318e15..e2c5220a 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1278_H +#if !defined(_RADIOLIB_SX1278_H) && !defined(RADIOLIB_EXCLUDE_SX127X) #define _RADIOLIB_SX1278_H #include "../../TypeDef.h" @@ -169,7 +169,7 @@ class SX1278: public SX127x { \brief Reset method. Will reset the chip to the default state using RST pin. */ void reset(); - + // configuration methods /*! diff --git a/src/modules/SX127x/SX1279.cpp b/src/modules/SX127x/SX1279.cpp index 1b45c9b7..9d5562e5 100644 --- a/src/modules/SX127x/SX1279.cpp +++ b/src/modules/SX127x/SX1279.cpp @@ -1,4 +1,5 @@ #include "SX1279.h" +#if !defined(RADIOLIB_EXCLUDE_SX127X) SX1279::SX1279(Module* mod) : SX1278(mod) { @@ -40,3 +41,5 @@ int16_t SX1279::setFrequency(float freq) { // set frequency return(SX127x::setFrequencyRaw(freq)); } + +#endif diff --git a/src/modules/SX127x/SX1279.h b/src/modules/SX127x/SX1279.h index f0953ecd..9908b3eb 100644 --- a/src/modules/SX127x/SX1279.h +++ b/src/modules/SX127x/SX1279.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1279_H +#if !defined(_RADIOLIB_SX1279_H) && !defined(RADIOLIB_EXCLUDE_SX127X) #define _RADIOLIB_SX1279_H #include "../../TypeDef.h" diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 45fe5f01..c3d2dd7e 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -1,4 +1,5 @@ #include "SX127x.h" +#if !defined(RADIOLIB_EXCLUDE_SX127X) SX127x::SX127x(Module* mod) : PhysicalLayer(SX127X_FREQUENCY_STEP_SIZE, SX127X_MAX_PACKET_LENGTH) { _mod = mod; @@ -1134,27 +1135,4 @@ void SX127x::clearFIFO(size_t count) { } } -#ifdef RADIOLIB_DEBUG -void SX127x::regDump() { - RADIOLIB_DEBUG_PRINTLN(); - RADIOLIB_DEBUG_PRINTLN(F("ADDR\tVALUE")); - for(uint16_t addr = 0x01; addr <= 0x70; addr++) { - if(addr <= 0x0F) { - RADIOLIB_DEBUG_PRINT(F("0x0")); - } else { - RADIOLIB_DEBUG_PRINT(F("0x")); - } - RADIOLIB_DEBUG_PRINT(addr, HEX); - RADIOLIB_DEBUG_PRINT('\t'); - uint8_t val = _mod->SPIreadRegister(addr); - if(val <= 0x0F) { - RADIOLIB_DEBUG_PRINT(F("0x0")); - } else { - RADIOLIB_DEBUG_PRINT(F("0x")); - } - RADIOLIB_DEBUG_PRINTLN(val, HEX); - - delay(50); - } -} #endif diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 7f075e9b..0023e4d8 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX127X_H +#if !defined(_RADIOLIB_SX127X_H) && !defined(RADIOLIB_EXCLUDE_SX127X) #define _RADIOLIB_SX127X_H #include "../../TypeDef.h" @@ -931,10 +931,6 @@ class SX127x: public PhysicalLayer { */ void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); - #ifdef RADIOLIB_DEBUG - void regDump(); - #endif - #ifndef RADIOLIB_GODMODE protected: #endif From 515551e7bc1e8f4163bb195156c761d1f5087d7a Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:44:08 +0200 Subject: [PATCH 127/455] [SX128x] Reworked driver exclusion --- src/modules/SX128x/SX1280.cpp | 3 +++ src/modules/SX128x/SX1280.h | 2 +- src/modules/SX128x/SX1281.cpp | 3 +++ src/modules/SX128x/SX1281.h | 2 +- src/modules/SX128x/SX1282.cpp | 3 +++ src/modules/SX128x/SX1282.h | 2 +- src/modules/SX128x/SX128x.cpp | 3 +++ src/modules/SX128x/SX128x.h | 2 +- 8 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/modules/SX128x/SX1280.cpp b/src/modules/SX128x/SX1280.cpp index 2c4d09ee..b0d513ef 100644 --- a/src/modules/SX128x/SX1280.cpp +++ b/src/modules/SX128x/SX1280.cpp @@ -1,4 +1,5 @@ #include "SX1280.h" +#if !defined(RADIOLIB_EXCLUDE_SX128X) SX1280::SX1280(Module* mod) : SX1281(mod) { @@ -111,3 +112,5 @@ float SX1280::getRangingResult() { memcpy(&raw, data, sizeof(uint32_t)); return((float)raw * (150.0/(4.096 * _bwKhz))); } + +#endif diff --git a/src/modules/SX128x/SX1280.h b/src/modules/SX128x/SX1280.h index ea8c5a18..4c079ac4 100644 --- a/src/modules/SX128x/SX1280.h +++ b/src/modules/SX128x/SX1280.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1280_H +#if !defined(_RADIOLIB_SX1280_H) && !defined(RADIOLIB_EXCLUDE_SX128X) #define _RADIOLIB_SX1280_H #include "../../TypeDef.h" diff --git a/src/modules/SX128x/SX1281.cpp b/src/modules/SX128x/SX1281.cpp index 4aa09b0d..c6b2b5eb 100644 --- a/src/modules/SX128x/SX1281.cpp +++ b/src/modules/SX128x/SX1281.cpp @@ -1,5 +1,8 @@ #include "SX1281.h" +#if !defined(RADIOLIB_EXCLUDE_SX128X) SX1281::SX1281(Module* mod) : SX128x(mod) { } + +#endif diff --git a/src/modules/SX128x/SX1281.h b/src/modules/SX128x/SX1281.h index 88037a09..6cb85192 100644 --- a/src/modules/SX128x/SX1281.h +++ b/src/modules/SX128x/SX1281.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1281_H +#if !defined(_RADIOLIB_SX1281_H) && !defined(RADIOLIB_EXCLUDE_SX128X) #define _RADIOLIB_SX1281_H #include "../../TypeDef.h" diff --git a/src/modules/SX128x/SX1282.cpp b/src/modules/SX128x/SX1282.cpp index 847a36d1..2a77ffcd 100644 --- a/src/modules/SX128x/SX1282.cpp +++ b/src/modules/SX128x/SX1282.cpp @@ -1,5 +1,8 @@ #include "SX1282.h" +#if !defined(RADIOLIB_EXCLUDE_SX128X) SX1282::SX1282(Module* mod) : SX1280(mod) { } + +#endif diff --git a/src/modules/SX128x/SX1282.h b/src/modules/SX128x/SX1282.h index 09f92075..8b677d95 100644 --- a/src/modules/SX128x/SX1282.h +++ b/src/modules/SX128x/SX1282.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX1282_H +#if !defined(_RADIOLIB_SX1282_H) && !defined(RADIOLIB_EXCLUDE_SX128X) #define _RADIOLIB_SX1282_H #include "../../TypeDef.h" diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 112417f5..1dda7d8c 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1,4 +1,5 @@ #include "SX128x.h" +#if !defined(RADIOLIB_EXCLUDE_SX128X) SX128x::SX128x(Module* mod) : PhysicalLayer(SX128X_FREQUENCY_STEP_SIZE, SX128X_MAX_PACKET_LENGTH) { _mod = mod; @@ -1431,3 +1432,5 @@ int16_t SX128x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d return(ERR_NONE); } } + +#endif diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index 755bc443..bd403a29 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SX128X_H +#if !defined(_RADIOLIB_SX128X_H) && !defined(RADIOLIB_EXCLUDE_SX128X) #define _RADIOLIB_SX128X_H #include "../../TypeDef.h" From f05f1e9d82a4f9020ecabd91ad7e64ac584bda34 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:44:22 +0200 Subject: [PATCH 128/455] [Si443x] Reworked driver exclusion --- src/modules/Si443x/Si4430.cpp | 3 +++ src/modules/Si443x/Si4430.h | 2 +- src/modules/Si443x/Si4431.cpp | 3 +++ src/modules/Si443x/Si4431.h | 2 +- src/modules/Si443x/Si4432.cpp | 3 +++ src/modules/Si443x/Si4432.h | 2 +- src/modules/Si443x/Si443x.cpp | 3 +++ src/modules/Si443x/Si443x.h | 2 +- 8 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/modules/Si443x/Si4430.cpp b/src/modules/Si443x/Si4430.cpp index c59f1ea7..3f31370c 100644 --- a/src/modules/Si443x/Si4430.cpp +++ b/src/modules/Si443x/Si4430.cpp @@ -1,4 +1,5 @@ #include "Si4430.h" +#if !defined(RADIOLIB_EXCLUDE_SI443X) Si4430::Si4430(Module* mod) : Si4432(mod) { @@ -32,3 +33,5 @@ int16_t Si4430::setOutputPower(int8_t power) { // set output power return(_mod->SPIsetRegValue(SI443X_REG_TX_POWER, (uint8_t)((power + 8) / 3), 2, 0)); } + +#endif diff --git a/src/modules/Si443x/Si4430.h b/src/modules/Si443x/Si4430.h index 7e7f8b36..815ec7ad 100644 --- a/src/modules/Si443x/Si4430.h +++ b/src/modules/Si443x/Si4430.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SI4430_H +#if !defined(_RADIOLIB_SI4430_H) && !defined(RADIOLIB_EXCLUDE_SI443X) #define _RADIOLIB_SI4430_H #include "../../TypeDef.h" diff --git a/src/modules/Si443x/Si4431.cpp b/src/modules/Si443x/Si4431.cpp index 25c7baf9..54371858 100644 --- a/src/modules/Si443x/Si4431.cpp +++ b/src/modules/Si443x/Si4431.cpp @@ -1,4 +1,5 @@ #include "Si4431.h" +#if !defined(RADIOLIB_EXCLUDE_SI443X) Si4431::Si4431(Module* mod) : Si4432(mod) { @@ -25,3 +26,5 @@ int16_t Si4431::setOutputPower(int8_t power) { // set output power return(_mod->SPIsetRegValue(SI443X_REG_TX_POWER, (uint8_t)((power + 8) / 3), 2, 0)); } + +#endif diff --git a/src/modules/Si443x/Si4431.h b/src/modules/Si443x/Si4431.h index c033bcbd..5f8b3821 100644 --- a/src/modules/Si443x/Si4431.h +++ b/src/modules/Si443x/Si4431.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SI4431_H +#if !defined(_RADIOLIB_SI4431_H) && !defined(RADIOLIB_EXCLUDE_SI443X) #define _RADIOLIB_SI4431_H #include "../../TypeDef.h" diff --git a/src/modules/Si443x/Si4432.cpp b/src/modules/Si443x/Si4432.cpp index 38d42863..0c9dee43 100644 --- a/src/modules/Si443x/Si4432.cpp +++ b/src/modules/Si443x/Si4432.cpp @@ -1,4 +1,5 @@ #include "Si4432.h" +#if !defined(RADIOLIB_EXCLUDE_SI443X) Si4432::Si4432(Module* mod) : Si443x(mod) { @@ -32,3 +33,5 @@ int16_t Si4432::setOutputPower(int8_t power) { // set output power return(_mod->SPIsetRegValue(SI443X_REG_TX_POWER, (uint8_t)((power + 1) / 3), 2, 0)); } + +#endif diff --git a/src/modules/Si443x/Si4432.h b/src/modules/Si443x/Si4432.h index 01dd92c5..4b1d0af6 100644 --- a/src/modules/Si443x/Si4432.h +++ b/src/modules/Si443x/Si4432.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SI4432_H +#if !defined(_RADIOLIB_SI4432_H) && !defined(RADIOLIB_EXCLUDE_SI443X) #define _RADIOLIB_SI4432_H #include "../../TypeDef.h" diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 099fb866..45734b3a 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -1,4 +1,5 @@ #include "Si443x.h" +#if !defined(RADIOLIB_EXCLUDE_SI443X) Si443x::Si443x(Module* mod) : PhysicalLayer(SI443X_FREQUENCY_STEP_SIZE, SI443X_MAX_PACKET_LENGTH) { _mod = mod; @@ -689,3 +690,5 @@ int16_t Si443x::directMode() { state = _mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_2, SI443X_MODULATION_NONE, 1, 0); return(state); } + +#endif diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 1cfd2700..7fbe26b6 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SI443X_H +#if !defined(_RADIOLIB_SI443X_H) && !defined(RADIOLIB_EXCLUDE_SI443X) #define _RADIOLIB_SI443X_H #include "../../TypeDef.h" From 78c1f94233cd2b54d89f4195f32de879cc93abe5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:44:33 +0200 Subject: [PATCH 129/455] [XBee] Reworked driver exclusion --- src/modules/XBee/XBee.cpp | 3 +++ src/modules/XBee/XBee.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/XBee/XBee.cpp b/src/modules/XBee/XBee.cpp index 4bfcab40..919de28e 100644 --- a/src/modules/XBee/XBee.cpp +++ b/src/modules/XBee/XBee.cpp @@ -1,4 +1,5 @@ #include "XBee.h" +#if !defined(RADIOLIB_EXCLUDE_XBEE) XBee::XBee(Module* mod) { _mod = mod; @@ -481,3 +482,5 @@ uint16_t XBee::getNumBytes(uint32_t timeout, size_t minBytes) { return((resp[1] << 8) | resp[2]); } + +#endif diff --git a/src/modules/XBee/XBee.h b/src/modules/XBee/XBee.h index 1cb9607a..e9c970b2 100644 --- a/src/modules/XBee/XBee.h +++ b/src/modules/XBee/XBee.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_XBEE_H +#if !defined(_RADIOLIB_XBEE_H) && !defined(RADIOLIB_EXCLUDE_XBEE) #define _RADIOLIB_XBEE_H #include "../../ISerial.h" From 0e120a760a32a3f8f46fbc534af40c7c2878457b Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:44:41 +0200 Subject: [PATCH 130/455] [nRF24] Reworked driver exclusion --- src/modules/nRF24/nRF24.cpp | 3 +++ src/modules/nRF24/nRF24.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 73d25ee6..888b959f 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -1,4 +1,5 @@ #include "nRF24.h" +#if !defined(RADIOLIB_EXCLUDE_NRF24) nRF24::nRF24(Module* mod) : PhysicalLayer(NRF24_FREQUENCY_STEP_SIZE, NRF24_MAX_PACKET_LENGTH) { _mod = mod; @@ -568,3 +569,5 @@ void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* data spi->endTransaction(); digitalWrite(_mod->getCs(), HIGH); } + +#endif diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index a3205f78..55802bbe 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_NRF24_H +#if !defined(_RADIOLIB_NRF24_H) && !defined(RADIOLIB_EXCLUDE_NRF24) #define _RADIOLIB_NRF24_H #include "../../Module.h" From 6f6ff7d6371fa803c1203de98646ac89bb68b3e7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:44:48 +0200 Subject: [PATCH 131/455] [AFSK] Reworked driver exclusion --- src/protocols/AFSK/AFSK.cpp | 3 +++ src/protocols/AFSK/AFSK.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/protocols/AFSK/AFSK.cpp b/src/protocols/AFSK/AFSK.cpp index e2a90641..6cf64ac9 100644 --- a/src/protocols/AFSK/AFSK.cpp +++ b/src/protocols/AFSK/AFSK.cpp @@ -1,4 +1,5 @@ #include "AFSK.h" +#if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient::AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin) { _phy = phy; @@ -23,3 +24,5 @@ int16_t AFSKClient::noTone() { Module::noTone(_pin); return(_phy->standby()); } + +#endif diff --git a/src/protocols/AFSK/AFSK.h b/src/protocols/AFSK/AFSK.h index c5c71221..c487dd17 100644 --- a/src/protocols/AFSK/AFSK.h +++ b/src/protocols/AFSK/AFSK.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_AFSK_H +#if !defined(_RADIOLIB_AFSK_H) && !defined(RADIOLIB_EXCLUDE_AFSK) #define _RADIOLIB_AFSK_H #include "../../TypeDef.h" From 55ebbc348802618b1450928d7751d4718d2ccdca Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:45:00 +0200 Subject: [PATCH 132/455] [AX25] Reworked driver exclusion --- src/protocols/AX25/AX25.cpp | 5 +++++ src/protocols/AX25/AX25.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index 1693cbe7..579ed8f1 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -1,4 +1,5 @@ #include "AX25.h" +#if !defined(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) { @@ -115,10 +116,12 @@ AX25Client::AX25Client(PhysicalLayer* phy) { _audio = nullptr; } +#if !defined(RADIOLIB_EXCLUDE_AFSK) AX25Client::AX25Client(AFSKClient* audio) { _phy = audio->_phy; _audio = audio; } +#endif int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t preambleLen) { // set source SSID @@ -414,3 +417,5 @@ uint16_t AX25Client::flipBits16(uint16_t i) { i = (i & 0xAAAA) >> 1 | (i & 0x5555) << 1; return i; } + +#endif diff --git a/src/protocols/AX25/AX25.h b/src/protocols/AX25/AX25.h index dc385dfa..c751a7c1 100644 --- a/src/protocols/AX25/AX25.h +++ b/src/protocols/AX25/AX25.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_AX25_H +#if !defined(_RADIOLIB_AX25_H) && !defined(RADIOLIB_EXCLUDE_AX25) #define _RADIOLIB_AX25_H #include "../../TypeDef.h" @@ -268,12 +268,14 @@ class AX25Client { */ AX25Client(PhysicalLayer* phy); + #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. */ AX25Client(AFSKClient* audio); + #endif // basic methods @@ -316,7 +318,11 @@ class AX25Client { private: #endif PhysicalLayer* _phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; + #else + void* _audio; + #endif char _srcCallsign[AX25_MAX_CALLSIGN_LEN + 1]; uint8_t _srcSSID; From fc21a1d50192f32fd7d6d9cb05e7d5e333cb3142 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:45:11 +0200 Subject: [PATCH 133/455] [HTTP] Reworked driver exclusion --- src/protocols/HTTP/HTTP.cpp | 3 +++ src/protocols/HTTP/HTTP.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/protocols/HTTP/HTTP.cpp b/src/protocols/HTTP/HTTP.cpp index 00b046d2..6f4cd23d 100644 --- a/src/protocols/HTTP/HTTP.cpp +++ b/src/protocols/HTTP/HTTP.cpp @@ -1,4 +1,5 @@ #include "HTTP.h" +#if !defined(RADIOLIB_EXCLUDE_HTTP) HTTPClient::HTTPClient(TransportLayer* tl, uint16_t port) { _tl = tl; @@ -216,3 +217,5 @@ int16_t HTTPClient::post(const char* url, const char* content, String& response, statusStr[3] = 0x00; return(atoi(statusStr)); } + +#endif diff --git a/src/protocols/HTTP/HTTP.h b/src/protocols/HTTP/HTTP.h index 118df7ec..edc7d6f1 100644 --- a/src/protocols/HTTP/HTTP.h +++ b/src/protocols/HTTP/HTTP.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_HTTP_H +#if !defined(_RADIOLIB_HTTP_H) && !defined(RADIOLIB_EXCLUDE_HTTP) #define _RADIOLIB_HTTP_H #include "../../TypeDef.h" From d032015e318a3b54ea14de41a151f7b2f45b81d2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:45:28 +0200 Subject: [PATCH 134/455] [Hell] Reworked driver exclusion --- src/protocols/Hellschreiber/Hellschreiber.cpp | 5 +++++ src/protocols/Hellschreiber/Hellschreiber.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/protocols/Hellschreiber/Hellschreiber.cpp b/src/protocols/Hellschreiber/Hellschreiber.cpp index 3f769add..5c6483b3 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.cpp +++ b/src/protocols/Hellschreiber/Hellschreiber.cpp @@ -1,14 +1,17 @@ #include "Hellschreiber.h" +#if !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER) HellClient::HellClient(PhysicalLayer* phy) { _phy = phy; _audio = nullptr; } +#if !defined(RADIOLIB_EXCLUDE_AFSK) HellClient::HellClient(AFSKClient* audio) { _phy = audio->_phy; _audio = audio; } +#endif int16_t HellClient::begin(float base, float rate) { // calculate 24-bit frequency @@ -295,3 +298,5 @@ int16_t HellClient::standby() { return(_phy->standby()); } } + +#endif diff --git a/src/protocols/Hellschreiber/Hellschreiber.h b/src/protocols/Hellschreiber/Hellschreiber.h index 8756df5f..a70e74e7 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.h +++ b/src/protocols/Hellschreiber/Hellschreiber.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_HELLSCHREIBER_H +#if !defined(_RADIOLIB_HELLSCHREIBER_H) && !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER) #define _RADIOLIB_HELLSCHREIBER_H #include "../../TypeDef.h" @@ -92,12 +92,14 @@ class HellClient { */ HellClient(PhysicalLayer* phy); + #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. */ HellClient(AFSKClient* audio); + #endif // basic methods @@ -148,7 +150,11 @@ class HellClient { private: #endif PhysicalLayer* _phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; + #else + void* _audio; + #endif uint32_t _base, _baseHz; uint32_t _pixelDuration; From 7a22cbfd4d13cab230d7f8d90547b6db75df837a Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:45:35 +0200 Subject: [PATCH 135/455] [MQTT] Reworked driver exclusion --- src/protocols/MQTT/MQTT.cpp | 3 +++ src/protocols/MQTT/MQTT.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/protocols/MQTT/MQTT.cpp b/src/protocols/MQTT/MQTT.cpp index 92583cbb..cc561157 100644 --- a/src/protocols/MQTT/MQTT.cpp +++ b/src/protocols/MQTT/MQTT.cpp @@ -1,4 +1,5 @@ #include "MQTT.h" +#if !defined(RADIOLIB_EXCLUDE_MQTT) MQTTClient::MQTTClient(TransportLayer* tl, uint16_t port) { _tl = tl; @@ -469,3 +470,5 @@ uint32_t MQTTClient::decodeLength(uint8_t* encoded) { } while((encoded[i] & 128) != 0); return len; } + +#endif diff --git a/src/protocols/MQTT/MQTT.h b/src/protocols/MQTT/MQTT.h index b7a94bdb..efc40d3a 100644 --- a/src/protocols/MQTT/MQTT.h +++ b/src/protocols/MQTT/MQTT.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_MQTT_H +#if !defined(_RADIOLIB_MQTT_H) && !defined(RADIOLIB_EXCLUDE_MQTT) #define _RADIOLIB_MQTT_H #include "../../TypeDef.h" From e5437deae2fc91368d849b76b514e728ac34398f Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:45:45 +0200 Subject: [PATCH 136/455] [Morse] Reworked driver exclusion --- src/protocols/Morse/Morse.cpp | 5 +++++ src/protocols/Morse/Morse.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/protocols/Morse/Morse.cpp b/src/protocols/Morse/Morse.cpp index fe516132..bd336229 100644 --- a/src/protocols/Morse/Morse.cpp +++ b/src/protocols/Morse/Morse.cpp @@ -1,14 +1,17 @@ #include "Morse.h" +#if !defined(RADIOLIB_EXCLUDE_MORSE) MorseClient::MorseClient(PhysicalLayer* phy) { _phy = phy; _audio = nullptr; } +#if !defined(RADIOLIB_EXCLUDE_AFSK) MorseClient::MorseClient(AFSKClient* audio) { _phy = audio->_phy; _audio = audio; } +#endif int16_t MorseClient::begin(float base, uint8_t speed) { // calculate 24-bit frequency @@ -309,3 +312,5 @@ int16_t MorseClient::standby() { return(_phy->standby()); } } + +#endif diff --git a/src/protocols/Morse/Morse.h b/src/protocols/Morse/Morse.h index e09fece0..276a443b 100644 --- a/src/protocols/Morse/Morse.h +++ b/src/protocols/Morse/Morse.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_MORSE_H +#if !defined(_RADIOLIB_MORSE_H) && !defined(RADIOLIB_EXCLUDE_MORSE) #define _RADIOLIB_MORSE_H #include "../../TypeDef.h" @@ -95,12 +95,14 @@ class MorseClient { */ MorseClient(PhysicalLayer* phy); + #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. */ MorseClient(AFSKClient* audio); + #endif // basic methods @@ -153,7 +155,11 @@ class MorseClient { private: #endif PhysicalLayer* _phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; + #else + void* _audio; + #endif uint32_t _base, _baseHz; uint16_t _dotLength; From 80fa8ba99d7a26c1679f03a541a8e02ceda0ad63 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:45:52 +0200 Subject: [PATCH 137/455] [RTTY] Reworked driver exclusion --- src/protocols/RTTY/RTTY.cpp | 5 +++++ src/protocols/RTTY/RTTY.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 1a96d5e2..7b023f8e 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -1,4 +1,5 @@ #include "RTTY.h" +#if !defined(RADIOLIB_EXCLUDE_RTTY) ITA2String::ITA2String(char c) { _len = 1; @@ -109,10 +110,12 @@ RTTYClient::RTTYClient(PhysicalLayer* phy) { _audio = nullptr; } +#if !defined(RADIOLIB_EXCLUDE_AFSK) RTTYClient::RTTYClient(AFSKClient* audio) { _phy = audio->_phy; _audio = audio; } +#endif int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t encoding, uint8_t stopBits) { // save configuration @@ -531,3 +534,5 @@ int16_t RTTYClient::standby() { return(_phy->standby()); } } + +#endif diff --git a/src/protocols/RTTY/RTTY.h b/src/protocols/RTTY/RTTY.h index 1e6120c1..7dc54076 100644 --- a/src/protocols/RTTY/RTTY.h +++ b/src/protocols/RTTY/RTTY.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_RTTY_H +#if !defined(_RADIOLIB_RTTY_H) && !defined(RADIOLIB_EXCLUDE_RTTY) #define _RADIOLIB_RTTY_H #include "../../TypeDef.h" @@ -91,12 +91,14 @@ class RTTYClient { */ RTTYClient(PhysicalLayer* phy); + #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. */ RTTYClient(AFSKClient* audio); + #endif // basic methods @@ -155,7 +157,11 @@ class RTTYClient { private: #endif PhysicalLayer* _phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; + #else + void* _audio; + #endif uint8_t _encoding; uint32_t _base, _baseHz; From 10f11aac885c0ea95c0124ec3ab1e5728a7d73ae Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:46:04 +0200 Subject: [PATCH 138/455] [SSTV] Reworked driver exclusion --- src/protocols/SSTV/SSTV.cpp | 5 +++++ src/protocols/SSTV/SSTV.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index 4bc16902..73b9b1d9 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -1,4 +1,5 @@ #include "SSTV.h" +#if !defined(RADIOLIB_EXCLUDE_SSTV) const SSTVMode_t Scottie1 { .visCode = SSTV_SCOTTIE_1, @@ -158,10 +159,12 @@ SSTVClient::SSTVClient(PhysicalLayer* phy) { _audio = nullptr; } +#if !defined(RADIOLIB_EXCLUDE_AFSK) SSTVClient::SSTVClient(AFSKClient* audio) { _phy = audio->_phy; _audio = audio; } +#endif int16_t SSTVClient::begin(SSTVMode_t mode, float correction) { if(_audio == nullptr) { @@ -290,3 +293,5 @@ void SSTVClient::tone(float freq, uint32_t len) { yield(); } } + +#endif diff --git a/src/protocols/SSTV/SSTV.h b/src/protocols/SSTV/SSTV.h index 4c6777d0..1ab9225b 100644 --- a/src/protocols/SSTV/SSTV.h +++ b/src/protocols/SSTV/SSTV.h @@ -1,4 +1,4 @@ -#ifndef _RADIOLIB_SSTV_H +#if !defined(_RADIOLIB_SSTV_H) && !defined(RADIOLIB_EXCLUDE_SSTV) #define _RADIOLIB_SSTV_H #include "../../TypeDef.h" @@ -123,12 +123,14 @@ class SSTVClient { */ SSTVClient(PhysicalLayer* phy); + #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Constructor for AFSK mode. \param audio Pointer to the AFSK instance providing audio. */ SSTVClient(AFSKClient* phy); + #endif // basic methods @@ -184,7 +186,11 @@ class SSTVClient { private: #endif PhysicalLayer* _phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; + #else + void* _audio; + #endif uint32_t _base; SSTVMode_t _mode; From 8e736217012e988a303e76751ca32c41edbb32e7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 10:53:22 +0200 Subject: [PATCH 139/455] Added support for Arduino Portenta H7 (TRAVIS_FORCE_BUILD) --- .travis.yml | 6 ++++++ README.md | 2 +- src/BuildOpt.h | 26 +++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 889773ac..dd69e1c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ env: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt - BOARD="arduino:avr:uno" + - BOARD="arduino-beta:mbed:envie_m4" - BOARD="arduino:avr:mega:cpu=atmega2560" - BOARD="arduino:avr:leonardo" - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" @@ -111,6 +112,11 @@ before_install: arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; arduino --install-boards adafruit:samd; + elif [[ "$BOARD" =~ "arduino-beta:mbed:" ]]; then + export BUILD_EXAMPLES=false; + arduino --install-boards arduino-beta:mbed; + export SKIP_PAT='(HTTP|MQTT).*ino'; + fi # check if this release commit (or forced build) and if so, build for every board diff --git a/README.md b/README.md index 10da3c3f..e8677ece 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x ### Supported platforms: * __Arduino__ * [__AVR__](https://github.com/arduino/ArduinoCore-avr) - Arduino Uno, Mega, Leonardo, Pro Mini, Nano etc. - * [__mbed__](https://github.com/arduino/ArduinoCore-nRF528x-mbedos) - Arduino Nano 33 BLE + * [__mbed__](https://github.com/arduino/ArduinoCore-mbed) - Arduino Nano 33 BLE and Arduino Portenta H7 * [__megaAVR__](https://github.com/arduino/ArduinoCore-megaavr) - Arduino Uno WiFi Rev.2 and Nano Every * [__SAM__](https://github.com/arduino/ArduinoCore-sam) - Arduino Due * [__SAMD__](https://github.com/arduino/ArduinoCore-samd) - Arduino Zero, MKR boards, M0 Pro etc. diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 84c9b684..490dbf1a 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -33,7 +33,7 @@ #if defined(RADIOLIB_CUSTOM_PLATFORM) // name for your platform - #define RADIOLIB_PLATFORM "Custom" + #define RADIOLIB_PLATFORM "Custom" // the following parameters must always be defined #define RADIOLIB_PIN_TYPE uint8_t @@ -51,6 +51,10 @@ // the following must be defined if the Arduino core does not support tone function //#define RADIOLIB_TONE_UNSUPPORTED + // some of RadioLib drivers may be excluded, to prevent collisions with platform (or to speed up build process) + // for example, to exclude ESP8266 driver: + //RADIOLIB_EXCLUDE_ESP8266 + #else #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. @@ -75,7 +79,7 @@ #define RADIOLIB_DEFAULT_SPI SPI // RadioLib has ESP8266 driver, this must be disabled to use ESP8266 as platform - #define _RADIOLIB_ESP8266_H + #define RADIOLIB_EXCLUDE_ESP8266 #elif defined(ESP32) // ESP32 boards @@ -192,7 +196,23 @@ #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 // Nano 33 BLE uses mbed libraries, which already contain ESP8266 driver - #define _RADIOLIB_ESP8266_H + #define RADIOLIB_EXCLUDE_ESP8266 + + #elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) + // Arduino Portenta H7 + #define RADIOLIB_PLATFORM "Portenta H7" + #define RADIOLIB_PIN_TYPE pin_size_t + #define RADIOLIB_PIN_MODE PinMode + #define RADIOLIB_PIN_STATUS PinStatus + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + + // Arduino Portenta H7 uses mbed libraries, which already contain ESP8266 driver + #define RADIOLIB_EXCLUDE_ESP8266 #elif defined(__STM32F4__) || defined(__STM32F1__) // Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32) From 0831b4a3a143a6de88857d81cffed3f60f8b6d8c Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 11:16:50 +0200 Subject: [PATCH 140/455] [AFSK] Fixed sign --- examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino b/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino index 82052f05..9b80046e 100644 --- a/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino +++ b/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino @@ -28,7 +28,7 @@ SX1278 fsk = new Module(10, 2, 9, 3); // create AFSK client instance using the FSK module -// this requires connection to the module direct +// this requires connection to the module direct // input pin, here connected to Arduino pin 5 // SX127x/RFM9x: DIO2 // RF69: DIO2 @@ -65,12 +65,12 @@ void setup() { void loop() { Serial.print(F("[AFSK] Executing Order 66 ... ")); - + // calculate whole note duration int wholenote = (60000 * 4) / 120; // iterate over the melody - for(int note = 0; note < sizeof(melody) / sizeof(melody[0]); note += 2) { + for(unsigned int note = 0; note < sizeof(melody) / sizeof(melody[0]); note += 2) { // calculate the duration of each note int noteDuration = 0; int divider = melody[note + 1]; @@ -89,7 +89,7 @@ void loop() { audio.noTone(); delay(noteDuration*0.1); } - + Serial.println(F("done!")); // wait for a second From a33a3a5389a41ffbe1c1a71a047e0c7fa3f5a08b Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 11:17:21 +0200 Subject: [PATCH 141/455] [ESP8266] Added missing ESP8266 exclude --- src/modules/ESP8266/ESP8266.cpp | 2 +- src/modules/ESP8266/ESP8266.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index 63f7bca0..7cfef116 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -1,5 +1,5 @@ #include "ESP8266.h" -#if !defined(RADIOLIB_EXCLUDE_ESP8266) +#if !defined(RADIOLIB_EXCLUDE_ESP8266) && !defined(ESP8266) ESP8266::ESP8266(Module* module) { _mod = module; diff --git a/src/modules/ESP8266/ESP8266.h b/src/modules/ESP8266/ESP8266.h index a825b984..4169f12f 100644 --- a/src/modules/ESP8266/ESP8266.h +++ b/src/modules/ESP8266/ESP8266.h @@ -1,6 +1,7 @@ -#if !defined(_RADIOLIB_ESP8266_H) && !defined(RADIOLIB_EXCLUDE_ESP8266) +#if !defined(_RADIOLIB_ESP8266_H) && !defined(RADIOLIB_EXCLUDE_ESP8266) && !defined(ESP8266) #define _RADIOLIB_ESP8266_H +#include "../../TypeDef.h" #include "../../Module.h" #include "../../protocols/TransportLayer/TransportLayer.h" From 9758ad1e444548c2184a94f27b2c382532e8f6f8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 30 Jun 2020 11:17:50 +0200 Subject: [PATCH 142/455] Travis updated build order TRAVIS_FORCE_BUILD --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dd69e1c9..c141bb73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ env: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt - BOARD="arduino:avr:uno" - - BOARD="arduino-beta:mbed:envie_m4" - BOARD="arduino:avr:mega:cpu=atmega2560" - BOARD="arduino:avr:leonardo" - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" @@ -20,6 +19,7 @@ env: - BOARD="arduino:mbed:nano33ble" - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" - BOARD="adafruit:samd:adafruit_feather_m0:usbstack=arduino,debug=off" + - BOARD="arduino-beta:mbed:envie_m4" addons: apt: From 2b61001f40489d6f77af3b39767da02a0b362ed5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:21:21 +0200 Subject: [PATCH 143/455] [CC1101] Added explicit default sync word config --- src/modules/CC1101/CC1101.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 80b0c7db..a2b56ac8 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -89,6 +89,10 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po state = setEncoding(2); RADIOLIB_ASSERT(state); + // set default sync word + state = setSyncWord(0xD3, 0x91, 0, false); + RADIOLIB_ASSERT(state); + // flush FIFOs SPIsendCommand(CC1101_CMD_FLUSH_RX); SPIsendCommand(CC1101_CMD_FLUSH_TX); From 0d5b7cb3e9f255eef4c1188d31bff73311388b3f Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:21:44 +0200 Subject: [PATCH 144/455] [AX.25] Fixed modulation type in comment --- examples/AX25/AX25_Frames/AX25_Frames.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/AX25/AX25_Frames/AX25_Frames.ino b/examples/AX25/AX25_Frames/AX25_Frames.ino index 45cbba32..4289c866 100644 --- a/examples/AX25/AX25_Frames/AX25_Frames.ino +++ b/examples/AX25/AX25_Frames/AX25_Frames.ino @@ -47,8 +47,8 @@ void setup() { // initialize SX1278 Serial.print(F("[SX1278] Initializing ... ")); // carrier frequency: 434.0 MHz - // bit rate: 1.2 kbps (1200 baud AFSK AX.25) - // frequency deviation: 0.5 kHz (1200 baud AFSK AX.25) + // bit rate: 1.2 kbps (1200 baud 2-FSK AX.25) + // frequency deviation: 0.5 kHz (1200 baud 2-FSK AX.25) int state = fsk.beginFSK(434.0, 1.2, 0.5); // when using one of the non-LoRa modules for AX.25 From 4819168d2ea722156fc254d2206fc8808683a650 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:22:47 +0200 Subject: [PATCH 145/455] [CC1101] Added links to default config wiki page --- .../CC1101/CC1101_Receive/CC1101_Receive.ino | 22 +++++----- .../CC1101_Receive_Address.ino | 26 ++++++------ .../CC1101_Receive_Interrupt.ino | 42 +++++++++---------- .../CC1101_Settings/CC1101_Settings.ino | 30 +++++++------ .../CC1101_Transmit/CC1101_Transmit.ino | 20 ++++----- .../CC1101_Transmit_Address.ino | 22 +++++----- .../CC1101_Transmit_Interrupt.ino | 24 +++++------ 7 files changed, 86 insertions(+), 100 deletions(-) diff --git a/examples/CC1101/CC1101_Receive/CC1101_Receive.ino b/examples/CC1101/CC1101_Receive/CC1101_Receive.ino index fa8f3aa8..b51bdf20 100644 --- a/examples/CC1101/CC1101_Receive/CC1101_Receive.ino +++ b/examples/CC1101/CC1101_Receive/CC1101_Receive.ino @@ -9,6 +9,9 @@ - frequency deviation - sync word + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,23 +24,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,12 +50,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = cc.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = cc.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -71,13 +69,13 @@ void loop() { // print RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[CC1101] RSSI:\t\t")); - Serial.print(cc.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print LQI (Link Quality Indicator) // of the last received packet, lower is better Serial.print(F("[CC1101] LQI:\t\t")); - Serial.println(cc.getLQI()); + Serial.println(radio.getLQI()); } else if (state == ERR_CRC_MISMATCH) { // packet was received, but is malformed diff --git a/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino b/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino index 3e12b6d5..81eac67c 100644 --- a/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino +++ b/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino @@ -7,6 +7,9 @@ will automatically filter out any packets that do not contain either node address or broadcast addresses. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -19,23 +22,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,7 +50,7 @@ void setup() { // When setting two broadcast addresses, 0x00 and // 0xFF will be used. Serial.print(F("[CC1101] Setting node address ... ")); - state = cc.setNodeAddress(0x01, 1); + state = radio.setNodeAddress(0x01, 1); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -66,7 +64,7 @@ void setup() { // set node address /* Serial.print(F("[CC1101] Disabling address filtering ... ")); - state == cc.disableAddressFiltering(); + state == radio.disableAddressFiltering(); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -82,12 +80,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = cc.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = cc.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -101,13 +99,13 @@ void loop() { // print RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[CC1101] RSSI:\t\t")); - Serial.print(cc.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print LQI (Link Quality Indicator) // of the last received packet, lower is better Serial.print(F("[CC1101] LQI:\t\t")); - Serial.println(cc.getLQI()); + Serial.println(radio.getLQI()); } else if (state == ERR_CRC_MISMATCH) { // packet was received, but is malformed diff --git a/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino b/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino index e036d71e..a7228de4 100644 --- a/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino +++ b/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino @@ -12,8 +12,11 @@ - frequency deviation - sync word - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -24,23 +27,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -51,11 +49,11 @@ void setup() { // set the function that will be called // when new packet is received - cc.setGdo0Action(setFlag); + radio.setGdo0Action(setFlag); // start listening for packets Serial.print(F("[CC1101] Starting to listen ... ")); - state = cc.startReceive(); + state = radio.startReceive(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -67,11 +65,11 @@ void setup() { // if needed, 'listen' mode can be disabled by calling // any of the following methods: // - // cc.standby() - // cc.sleep() - // cc.transmit(); - // cc.receive(); - // cc.readData(); + // radio.standby() + // radio.sleep() + // radio.transmit(); + // radio.receive(); + // radio.readData(); } // flag to indicate that a packet was received @@ -106,12 +104,12 @@ void loop() { // you can read received data as an Arduino String String str; - int state = cc.readData(str); + int state = radio.readData(str); // you can also read received data as byte array /* byte byteArr[8]; - int state = cc.readData(byteArr, 8); + int state = radio.readData(byteArr, 8); */ if (state == ERR_NONE) { @@ -125,13 +123,13 @@ void loop() { // print RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[CC1101] RSSI:\t\t")); - Serial.print(cc.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print LQI (Link Quality Indicator) // of the last received packet, lower is better Serial.print(F("[CC1101] LQI:\t\t")); - Serial.println(cc.getLQI()); + Serial.println(radio.getLQI()); } else if (state == ERR_CRC_MISMATCH) { // packet was received, but is malformed @@ -145,7 +143,7 @@ void loop() { } // put module back to listen mode - cc.startReceive(); + radio.startReceive(); // we're ready to receive more packets, // enable interrupt service routine diff --git a/examples/CC1101/CC1101_Settings/CC1101_Settings.ino b/examples/CC1101/CC1101_Settings/CC1101_Settings.ino index 02394da1..4e4bcfd3 100644 --- a/examples/CC1101/CC1101_Settings/CC1101_Settings.ino +++ b/examples/CC1101/CC1101_Settings/CC1101_Settings.ino @@ -11,6 +11,9 @@ - output power during transmission - sync word + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -23,30 +26,25 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc1 = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio1 = new Module(10, 2, RADIOLIB_NC, 3); // second CC1101 has different connections: // CS pin: 9 // GDO0 pin: 4 // RST pin: unused // GDO2 pin: 5 (optional) -CC1101 cc2 = new Module(9, 4, RADIOLIB_NC, 53); +CC1101 radio2 = new Module(9, 4, RADIOLIB_NC, 53); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc3 = RadioShield.ModuleB; +//CC1101 radio3 = RadioShield.ModuleB; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc1.begin(); + int state = radio1.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -62,7 +60,7 @@ void setup() { // frequency deviation: 60.0 kHz // Rx bandwidth: 250.0 kHz // sync word: 0xD391 - state = cc2.begin(434.0, 32.0, 60.0, 250.0); + state = radio2.begin(434.0, 32.0, 60.0, 250.0); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -75,13 +73,13 @@ void setup() { // and check if the configuration was changed successfully // set carrier frequency to 433.5 MHz - if (cc1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { + if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { Serial.println(F("[CC1101] Selected frequency is invalid for this module!")); while (true); } // set bit rate to 100.0 kbps - state = cc1.setBitRate(100.0); + state = radio1.setBitRate(100.0); if (state == ERR_INVALID_BIT_RATE) { Serial.println(F("[CC1101] Selected bit rate is invalid for this module!")); while (true); @@ -92,25 +90,25 @@ void setup() { } // set receiver bandwidth to 250.0 kHz - if (cc1.setRxBandwidth(250.0) == ERR_INVALID_RX_BANDWIDTH) { + if (radio1.setRxBandwidth(250.0) == ERR_INVALID_RX_BANDWIDTH) { Serial.println(F("[CC1101] Selected receiver bandwidth is invalid for this module!")); while (true); } // set allowed frequency deviation to 10.0 kHz - if (cc1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) { + if (radio1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) { Serial.println(F("[CC1101] Selected frequency deviation is invalid for this module!")); while (true); } // set output power to 5 dBm - if (cc1.setOutputPower(5) == ERR_INVALID_OUTPUT_POWER) { + if (radio1.setOutputPower(5) == ERR_INVALID_OUTPUT_POWER) { Serial.println(F("[CC1101] Selected output power is invalid for this module!")); while (true); } // 2 bytes can be set as sync word - if (cc1.setSyncWord(0x01, 0x23) == ERR_INVALID_SYNC_WORD) { + if (radio1.setSyncWord(0x01, 0x23) == ERR_INVALID_SYNC_WORD) { Serial.println(F("[CC1101] Selected sync word is invalid for this module!")); while (true); } diff --git a/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino b/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino index be530890..3463c6f1 100644 --- a/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino +++ b/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino @@ -7,6 +7,9 @@ - null-terminated char array (C-string) - arbitrary binary data (byte array) + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -19,23 +22,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); - // initialize CC1101 + // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -49,12 +47,12 @@ void loop() { Serial.print(F("[CC1101] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to 63 characters long - int state = cc.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 63 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = cc.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino b/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino index e584eb7c..430eafd8 100644 --- a/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino +++ b/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino @@ -7,6 +7,9 @@ will automatically filter out any packets that do not contain either node address or broadcast addresses. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -19,23 +22,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,7 +50,7 @@ void setup() { // When setting two broadcast addresses, 0x00 and // 0xFF will be used. Serial.print(F("[CC1101] Setting node address ... ")); - state = cc.setNodeAddress(0x01, 1); + state = radio.setNodeAddress(0x01, 1); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -66,7 +64,7 @@ void setup() { // set node address /* Serial.print(F("[CC1101] Disabling address filtering ... ")); - state == cc.disableAddressFiltering(); + state == radio.disableAddressFiltering(); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -81,12 +79,12 @@ void loop() { Serial.print(F("[CC1101] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to 63 characters long - int state = cc.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 63 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = cc.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino b/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino index 47991677..c15652b6 100644 --- a/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino +++ b/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino @@ -8,6 +8,9 @@ - null-terminated char array (C-string) - arbitrary binary data (byte array) + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,11 +23,11 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; // save transmission state between loops int transmissionState = ERR_NONE; @@ -34,12 +37,7 @@ void setup() { // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,20 +48,20 @@ void setup() { // set the function that will be called // when packet transmission is finished - cc.setGdo0Action(setFlag); + radio.setGdo0Action(setFlag); // start transmitting the first packet Serial.print(F("[CC1101] Sending first packet ... ")); // you can transmit C-string or Arduino string up to // 64 characters long - transmissionState = cc.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; - state = cc.startTransmit(byteArr, 8); + state = radio.startTransmit(byteArr, 8); */ } @@ -119,13 +117,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = cc.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = cc.startTransmit(byteArr, 8); + int state = radio.startTransmit(byteArr, 8); */ // we're ready to send more packets, From bd559b57f19cb92a98095a112139fdbd3be389d8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:24:46 +0200 Subject: [PATCH 146/455] [nRF24] Added explicit default param config --- src/modules/nRF24/nRF24.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 888b959f..e8df4e13 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -33,6 +33,7 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW // set mode to standby state = standby(); RADIOLIB_ASSERT(state); + // set frequency state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -47,6 +48,15 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW // set address width state = setAddressWidth(addrWidth); + RADIOLIB_ASSERT(state); + + // set CRC + state = setCrcFiltering(true); + RADIOLIB_ASSERT(state); + + // set auto-ACK on all pipes + state = setAutoAck(true); + RADIOLIB_ASSERT(state); return(state); } From d867bc043ab98fff1c417a96ad57890ed7ed12a6 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:25:05 +0200 Subject: [PATCH 147/455] [nRF24] Added links to default config wiki page --- .../nRF24/nRF24_Receive/nRF24_Receive.ino | 21 +++++++++---------- .../nRF24/nRF24_Transmit/nRF24_Transmit.ino | 19 ++++++++--------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/examples/nRF24/nRF24_Receive/nRF24_Receive.ino b/examples/nRF24/nRF24_Receive/nRF24_Receive.ino index b5b5571e..2c036fd6 100644 --- a/examples/nRF24/nRF24_Receive/nRF24_Receive.ino +++ b/examples/nRF24/nRF24_Receive/nRF24_Receive.ino @@ -9,6 +9,9 @@ - transmit pipe on transmitter must match receive pipe on receiver + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#nrf24 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,22 +23,18 @@ // CS pin: 10 // IRQ pin: 2 // CE pin: 3 -nRF24 nrf = new Module(10, 2, 3); +nRF24 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//nRF24 nrf = RadioShield.ModuleA; +//nRF24 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); - // initialize nRF24 + // initialize nRF24 with default settings Serial.print(F("[nRF24] Initializing ... ")); - // carrier frequency: 2400 MHz - // data rate: 1000 kbps - // output power: -12 dBm - // address width: 5 bytes - int state = nrf.begin(); + int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,7 +49,7 @@ void setup() { // methods (5 by default) Serial.print(F("[nRF24] Setting address for receive pipe 0 ... ")); byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89}; - state = nrf.setReceivePipe(0, addr); + state = radio.setReceivePipe(0, addr); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -68,12 +67,12 @@ void loop() { // See example ReceiveInterrupt for details // on non-blocking reception method. String str; - int state = nrf.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = nrf.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/nRF24/nRF24_Transmit/nRF24_Transmit.ino b/examples/nRF24/nRF24_Transmit/nRF24_Transmit.ino index 89006b38..c692e8a8 100644 --- a/examples/nRF24/nRF24_Transmit/nRF24_Transmit.ino +++ b/examples/nRF24/nRF24_Transmit/nRF24_Transmit.ino @@ -9,6 +9,9 @@ Packet delivery is automatically acknowledged by the receiver. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#nrf24 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,22 +23,18 @@ // CS pin: 10 // IRQ pin: 2 // CE pin: 3 -nRF24 nrf = new Module(10, 2, 3); +nRF24 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//nRF24 nrf = RadioShield.ModuleA; +//nRF24 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); - // initialize nRF24 + // initialize nRF24 with default settings Serial.print(F("[nRF24] Initializing ... ")); - // carrier frequency: 2400 MHz - // data rate: 1000 kbps - // output power: -12 dBm - // address width: 5 bytes - int state = nrf.begin(); + int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,7 +49,7 @@ void setup() { // methods (5 by default) byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89}; Serial.print(F("[nRF24] Setting transmit pipe ... ")); - state = nrf.setTransmitPipe(addr); + state = radio.setTransmitPipe(addr); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -65,7 +64,7 @@ void loop() { // you can transmit C-string or Arduino string up to // 32 characters long - int state = nrf.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); if (state == ERR_NONE) { // the packet was successfully transmitted From 59c4a71fad8e796da41b3216166c4d713416fe12 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:25:39 +0200 Subject: [PATCH 148/455] [RF69] Added explicit default param config --- src/modules/RF69/RF69.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 7b1cad43..bebaba12 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -96,7 +96,11 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe state = setEncoding(0); RADIOLIB_ASSERT(state); - return(ERR_NONE); + // set CRC on by default + state = setCrcFiltering(true); + RADIOLIB_ASSERT(state); + + return(state); } void RF69::reset() { From 1db4a47181f5148d99a8935429a191c0e7affbed Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:26:01 +0200 Subject: [PATCH 149/455] [RF69] Added links to default config wiki page --- examples/RF69/RF69_Receive/RF69_Receive.ino | 21 +++++------ .../RF69_Receive_AES/RF69_Receive_AES.ino | 25 ++++++------- .../RF69_Receive_Address.ino | 25 ++++++------- .../RF69_Receive_Interrupt.ino | 37 +++++++++---------- examples/RF69/RF69_Settings/RF69_Settings.ino | 36 ++++++++---------- examples/RF69/RF69_Transmit/RF69_Transmit.ino | 21 +++++------ .../RF69_Transmit_AES/RF69_Transmit_AES.ino | 25 ++++++------- .../RF69_Transmit_Address.ino | 21 +++++------ .../RF69_Transmit_Interrupt.ino | 27 ++++++-------- 9 files changed, 105 insertions(+), 133 deletions(-) diff --git a/examples/RF69/RF69_Receive/RF69_Receive.ino b/examples/RF69/RF69_Receive/RF69_Receive.ino index 161173e3..fd924755 100644 --- a/examples/RF69/RF69_Receive/RF69_Receive.ino +++ b/examples/RF69/RF69_Receive/RF69_Receive.ino @@ -9,6 +9,9 @@ - frequency deviation - sync word + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,24 +23,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf = new Module(10, 2, 3); +RF69 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf = RadioShield.ModuleA; +//RF69 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,12 +49,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = rf.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = rf.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -71,7 +68,7 @@ void loop() { // print RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[RF69] RSSI:\t\t")); - Serial.print(rf.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); } else if (state == ERR_RX_TIMEOUT) { diff --git a/examples/RF69/RF69_Receive_AES/RF69_Receive_AES.ino b/examples/RF69/RF69_Receive_AES/RF69_Receive_AES.ino index 7c947cf0..c1fa2816 100644 --- a/examples/RF69/RF69_Receive_AES/RF69_Receive_AES.ino +++ b/examples/RF69/RF69_Receive_AES/RF69_Receive_AES.ino @@ -5,6 +5,9 @@ Packets are decrypted using hardware AES. NOTE: When using address filtering, the address byte is NOT encrypted! + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -16,24 +19,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf = new Module(10, 2, 3); +RF69 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf = RadioShield.ModuleA; +//RF69 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -46,14 +43,14 @@ void setup() { // NOTE: the key must be exactly 16 bytes long! uint8_t key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; - rf.setAESKey(key); + radio.setAESKey(key); // enable AES encryption - rf.enableAES(); + radio.enableAES(); // AES encryption can also be disabled /* - rf.disableAES(); + radio.disableAES(); */ } @@ -62,12 +59,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = rf.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = rf.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/RF69/RF69_Receive_Address/RF69_Receive_Address.ino b/examples/RF69/RF69_Receive_Address/RF69_Receive_Address.ino index 08242ec3..df20200c 100644 --- a/examples/RF69/RF69_Receive_Address/RF69_Receive_Address.ino +++ b/examples/RF69/RF69_Receive_Address/RF69_Receive_Address.ino @@ -7,6 +7,9 @@ automatically filter out any packets that do not contain either node address or broadcast address. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -18,24 +21,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf = new Module(10, 2, 3); +RF69 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf = RadioShield.ModuleA; +//RF69 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -48,7 +45,7 @@ void setup() { // NOTE: calling this method will automatically enable // address filtering (node address only) Serial.print(F("[RF69] Setting node address ... ")); - state = rf.setNodeAddress(0x02); + state = radio.setNodeAddress(0x02); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -61,7 +58,7 @@ void setup() { // NOTE: calling this method will automatically enable // address filtering (node or broadcast address) Serial.print(F("[RF69] Setting broadcast address ... ")); - state = rf.setBroadcastAddress(0xFF); + state = radio.setBroadcastAddress(0xFF); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -75,7 +72,7 @@ void setup() { // node and broadcast address /* Serial.print(F("[RF69] Disabling address filtering ... ")); - state == rf.disableAddressFiltering(); + state == radio.disableAddressFiltering(); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -91,12 +88,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = rf.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = rf.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/RF69/RF69_Receive_Interrupt/RF69_Receive_Interrupt.ino b/examples/RF69/RF69_Receive_Interrupt/RF69_Receive_Interrupt.ino index e028a678..2a512783 100644 --- a/examples/RF69/RF69_Receive_Interrupt/RF69_Receive_Interrupt.ino +++ b/examples/RF69/RF69_Receive_Interrupt/RF69_Receive_Interrupt.ino @@ -5,6 +5,9 @@ receive them. Once a packet is received, an interrupt is triggered. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -16,24 +19,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf = new Module(10, 2, 3); +RF69 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf = RadioShield.ModuleA; +//RF69 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -44,11 +41,11 @@ void setup() { // set the function that will be called // when new packet is received - rf.setDio0Action(setFlag); + radio.setDio0Action(setFlag); // start listening for packets Serial.print(F("[RF69] Starting to listen ... ")); - state = rf.startReceive(); + state = radio.startReceive(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -60,11 +57,11 @@ void setup() { // if needed, 'listen' mode can be disabled by calling // any of the following methods: // - // rf.standby() - // rf.sleep() - // rf.transmit(); - // rf.receive(); - // rf.readData(); + // radio.standby() + // radio.sleep() + // radio.transmit(); + // radio.receive(); + // radio.readData(); } // flag to indicate that a packet was received @@ -99,12 +96,12 @@ void loop() { // you can read received data as an Arduino String String str; - int state = rf.readData(str); + int state = radio.readData(str); // you can also read received data as byte array /* byte byteArr[8]; - int state = rf.readData(byteArr, 8); + int state = radio.readData(byteArr, 8); */ if (state == ERR_NONE) { @@ -118,7 +115,7 @@ void loop() { // print RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[RF69] RSSI:\t\t")); - Serial.print(rf.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); } else if (state == ERR_CRC_MISMATCH) { @@ -133,7 +130,7 @@ void loop() { } // put module back to listen mode - rf.startReceive(); + radio.startReceive(); // we're ready to receive more packets, // enable interrupt service routine diff --git a/examples/RF69/RF69_Settings/RF69_Settings.ino b/examples/RF69/RF69_Settings/RF69_Settings.ino index 2fee90ba..49c23e80 100644 --- a/examples/RF69/RF69_Settings/RF69_Settings.ino +++ b/examples/RF69/RF69_Settings/RF69_Settings.ino @@ -11,6 +11,9 @@ - output power during transmission - sync word + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -22,30 +25,24 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf1 = new Module(10, 2, 3); +RF69 radio1 = new Module(10, 2, 3); // second CC1101 has different connections: // CS pin: 9 // DIO0 pin: 4 // RESET pin: 5 -RF69 rf2 = new Module(9, 4, 5); +RF69 radio2 = new Module(9, 4, 5); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf3 = RadioShield.ModuleB; +//RF69 radio3 = RadioShield.ModuleB; void setup() { Serial.begin(9600); // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf1.begin(); + int state = radio1.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -61,8 +58,7 @@ void setup() { // frequency deviation: 60.0 kHz // Rx bandwidth: 250.0 kHz // output power: 17 dBm - // sync word: 0x2D01 - state = rf2.begin(868.0, 300.0, 60.0, 250.0, 17); + state = radio2.begin(868.0, 300.0, 60.0, 250.0, 17); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -75,13 +71,13 @@ void setup() { // and check if the configuration was changed successfully // set carrier frequency to 433.5 MHz - if (rf1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { + if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { Serial.println(F("[RF69] Selected frequency is invalid for this module!")); while (true); } // set bit rate to 100.0 kbps - state = rf1.setBitRate(100.0); + state = radio1.setBitRate(100.0); if (state == ERR_INVALID_BIT_RATE) { Serial.println(F("[RF69] Selected bit rate is invalid for this module!")); while (true); @@ -92,7 +88,7 @@ void setup() { } // set receiver bandwidth to 250.0 kHz - state = rf1.setRxBandwidth(250.0); + state = radio1.setRxBandwidth(250.0); if (state == ERR_INVALID_RX_BANDWIDTH) { Serial.println(F("[RF69] Selected receiver bandwidth is invalid for this module!")); while (true); @@ -103,13 +99,13 @@ void setup() { } // set allowed frequency deviation to 10.0 kHz - if (rf1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) { + if (radio1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) { Serial.println(F("[RF69] Selected frequency deviation is invalid for this module!")); while (true); } // set output power to 2 dBm - if (rf1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) { + if (radio1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) { Serial.println(F("[RF69] Selected output power is invalid for this module!")); while (true); } @@ -118,7 +114,7 @@ void setup() { // NOTE: sync word must not contain any zero bytes // set sync word to 0x0123456789ABCDEF uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - if (rf1.setSyncWord(syncWord, 8) == ERR_INVALID_SYNC_WORD) { + if (radio1.setSyncWord(syncWord, 8) == ERR_INVALID_SYNC_WORD) { Serial.println(F("[RF69] Selected sync word is invalid for this module!")); while (true); } @@ -128,13 +124,13 @@ void setup() { // RF69 can also measure temperature (roughly) // to get correct temperature measurements, the sensor must be calibrated // at ambient temperature - rf1.setAmbientTemperature(25); // replace 25 with your ambient temperature + radio1.setAmbientTemperature(25); // replace 25 with your ambient temperature } void loop() { // measure temperature Serial.print(F("[RF69] Measured temperature: ")); - Serial.print(rf1.getTemperature()); + Serial.print(radio1.getTemperature()); Serial.println(F(" deg C")); // wait 100 ms before the next measurement diff --git a/examples/RF69/RF69_Transmit/RF69_Transmit.ino b/examples/RF69/RF69_Transmit/RF69_Transmit.ino index 5d39f6f2..c57122b2 100644 --- a/examples/RF69/RF69_Transmit/RF69_Transmit.ino +++ b/examples/RF69/RF69_Transmit/RF69_Transmit.ino @@ -7,6 +7,9 @@ - null-terminated char array (C-string) - arbitrary binary data (byte array) + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -18,24 +21,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf = new Module(10, 2, 3); +RF69 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf = RadioShield.ModuleA; +//RF69 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -51,7 +48,7 @@ void setup() { // second argument set to true. /* Serial.print(F("[RF69] Setting high power module ... ")); - state = rf.setOutputPower(20, true); + state = radio.setOutputPower(20, true); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -66,12 +63,12 @@ void loop() { Serial.print(F("[RF69] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to 64 characters long - int state = rf.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = rf.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/RF69/RF69_Transmit_AES/RF69_Transmit_AES.ino b/examples/RF69/RF69_Transmit_AES/RF69_Transmit_AES.ino index 5df09c65..d5bc2de2 100644 --- a/examples/RF69/RF69_Transmit_AES/RF69_Transmit_AES.ino +++ b/examples/RF69/RF69_Transmit_AES/RF69_Transmit_AES.ino @@ -5,6 +5,9 @@ Packets are encrypted using hardware AES. NOTE: When using address filtering, the address byte is NOT encrypted! + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -16,24 +19,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf = new Module(10, 2, 3); +RF69 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf = RadioShield.ModuleA; +//RF69 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -46,14 +43,14 @@ void setup() { // NOTE: the key must be exactly 16 bytes long! uint8_t key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; - rf.setAESKey(key); + radio.setAESKey(key); // enable AES encryption - rf.enableAES(); + radio.enableAES(); // AES encryption can also be disabled /* - rf.disableAES(); + radio.disableAES(); */ } @@ -61,12 +58,12 @@ void loop() { Serial.print(F("[RF69] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to 64 characters long - int state = rf.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = rf.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino b/examples/RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino index 7413822e..4e8c2667 100644 --- a/examples/RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino +++ b/examples/RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino @@ -7,6 +7,9 @@ automatically filter out any packets that do not contain either node address or broadcast address. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -18,24 +21,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf = new Module(10, 2, 3); +RF69 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf = RadioShield.ModuleA; +//RF69 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -48,7 +45,7 @@ void setup() { // NOTE: calling this method will automatically enable // address filtering (node address only) Serial.print(F("[RF69] Setting node address ... ")); - state = rf.setNodeAddress(0x01); + state = radio.setNodeAddress(0x01); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -61,7 +58,7 @@ void setup() { // NOTE: calling this method will automatically enable // address filtering (node or broadcast address) Serial.print(F("[RF69] Setting broadcast address ... ")); - state = rf.setBroadcastAddress(0xFF); + state = radio.setBroadcastAddress(0xFF); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -75,7 +72,7 @@ void setup() { // node and broadcast address /* Serial.print(F("[RF69] Disabling address filtering ... ")); - state = rf.disableAddressFiltering(); + state = radio.disableAddressFiltering(); if(state == ERR_NONE) { Serial.println(F("success!")); } else { diff --git a/examples/RF69/RF69_Transmit_Interrupt/RF69_Transmit_Interrupt.ino b/examples/RF69/RF69_Transmit_Interrupt/RF69_Transmit_Interrupt.ino index e07b41ec..0f03dad1 100644 --- a/examples/RF69/RF69_Transmit_Interrupt/RF69_Transmit_Interrupt.ino +++ b/examples/RF69/RF69_Transmit_Interrupt/RF69_Transmit_Interrupt.ino @@ -8,6 +8,9 @@ - null-terminated char array (C-string) - arbitrary binary data (byte array) + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -19,11 +22,11 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -RF69 rf = new Module(10, 2, 3); +RF69 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//RF69 rf = RadioShield.ModuleA; +//RF69 radio = RadioShield.ModuleA; // save transmission state between loops int transmissionState = ERR_NONE; @@ -33,13 +36,7 @@ void setup() { // initialize RF69 with default settings Serial.print(F("[RF69] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,7 +47,7 @@ void setup() { // set the function that will be called // when packet transmission is finished - rf.setDio0Action(setFlag); + radio.setDio0Action(setFlag); // NOTE: some RF69 modules use high power output, // those are usually marked RF69H(C/CW). @@ -59,7 +56,7 @@ void setup() { // second argument set to true. /* Serial.print(F("[RF69] Setting high power module ... ")); - state = rf.setOutputPower(20, true); + state = radio.setOutputPower(20, true); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -74,13 +71,13 @@ void setup() { // you can transmit C-string or Arduino string up to // 64 characters long - transmissionState = rf.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = rf.startTransmit(byteArr, 8); + state = radio.startTransmit(byteArr, 8); */ } @@ -136,13 +133,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = rf.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = rf.startTransmit(byteArr, 8); + int state = radio.startTransmit(byteArr, 8); */ // we're ready to send more packets, From d89025d8c789cab4f5dc6c9c1f20829e793228d0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:28:47 +0200 Subject: [PATCH 150/455] [Si443x] Added links to default config wiki page --- .../Si443x/Si443x_Receive/Si443x_Receive.ino | 19 +++++----- .../Si443x_Receive_Interrupt.ino | 35 +++++++++---------- .../Si443x_Settings/Si443x_Settings.ino | 32 ++++++++--------- .../Si443x_Transmit/Si443x_Transmit.ino | 19 +++++----- .../Si443x_Transmit_Interrupt.ino | 26 ++++++-------- 5 files changed, 57 insertions(+), 74 deletions(-) diff --git a/examples/Si443x/Si443x_Receive/Si443x_Receive.ino b/examples/Si443x/Si443x_Receive/Si443x_Receive.ino index 345fb8a6..846e46e3 100644 --- a/examples/Si443x/Si443x_Receive/Si443x_Receive.ino +++ b/examples/Si443x/Si443x_Receive/Si443x_Receive.ino @@ -11,6 +11,9 @@ Other modules from Si443x/RFM2x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -22,24 +25,18 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 fsk = new Module(10, 2, 9); +Si4432 radio = new Module(10, 2, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//Si4432 fsk = RadioShield.ModuleA; +//Si4432 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize Si4432 with default settings Serial.print(F("[Si4432] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 225.1 kHz - // output power: 11 dBm - // sync word: 0x2D 0x01 - int state = fsk.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -54,12 +51,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = fsk.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = rf.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino b/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino index a514980e..e890b08d 100644 --- a/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino +++ b/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino @@ -7,6 +7,9 @@ Other modules from Si443x/RFM2x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -18,24 +21,18 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 fsk = new Module(10, 2, 9); +Si4432 radio = new Module(10, 2, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//Si4432 fsk = RadioShield.ModuleA; +//Si4432 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize Si4432 with default settings Serial.print(F("[Si4432] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 225.1 kHz - // output power: 11 dBm - // sync word: 0x2D 0x01 - int state = fsk.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -46,11 +43,11 @@ void setup() { // set the function that will be called // when new packet is received - fsk.setIrqAction(setFlag); + radio.setIrqAction(setFlag); // start listening for packets Serial.print(F("[Si4432] Starting to listen ... ")); - state = fsk.startReceive(); + state = radio.startReceive(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -62,11 +59,11 @@ void setup() { // if needed, 'listen' mode can be disabled by calling // any of the following methods: // - // fsk.standby() - // fsk.sleep() - // fsk.transmit(); - // fsk.receive(); - // fsk.readData(); + // radio.standby() + // radio.sleep() + // radio.transmit(); + // radio.receive(); + // radio.readData(); } // flag to indicate that a packet was received @@ -101,12 +98,12 @@ void loop() { // you can read received data as an Arduino String String str; - int state = fsk.readData(str); + int state = radio.readData(str); // you can also read received data as byte array /* byte byteArr[8]; - int state = fsk.readData(byteArr, 8); + int state = radio.readData(byteArr, 8); */ if (state == ERR_NONE) { @@ -129,7 +126,7 @@ void loop() { } // put module back to listen mode - fsk.startReceive(); + radio.startReceive(); // we're ready to receive more packets, // enable interrupt service routine diff --git a/examples/Si443x/Si443x_Settings/Si443x_Settings.ino b/examples/Si443x/Si443x_Settings/Si443x_Settings.ino index b3d1ab82..ee5f7e9b 100644 --- a/examples/Si443x/Si443x_Settings/Si443x_Settings.ino +++ b/examples/Si443x/Si443x_Settings/Si443x_Settings.ino @@ -11,6 +11,9 @@ - output power during transmission - sync word + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -22,30 +25,24 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 fsk1 = new Module(10, 2, 9); +Si4432 radio1 = new Module(10, 2, 9); // Si4432 has the following connections: // nSEL pin: 8 // nIRQ pin: 3 // SDN pin: 7 -Si4432 fsk2 = new Module(8, 3, 7); +Si4432 radio2 = new Module(8, 3, 7); // or using RadioShield // https://github.com/jgromes/RadioShield -//Si4432 fsk3 = RadioShield.ModuleB; +//Si4432 radio3 = RadioShield.ModuleB; void setup() { Serial.begin(9600); // initialize Si4432 with default settings Serial.print(F("[Si4432] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 225.1 kHz - // output power: 11 dBm - // sync word: 0x2D 0x01 - int state = fsk1.begin(); + int state = radio1.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -61,8 +58,7 @@ void setup() { // frequency deviation: 60.0 kHz // Rx bandwidth: 335.5 kHz // output power: 17 dBm - // sync word: 0x2D 0x01 - state = fsk2.begin(868.0, 200.0, 60.0, 335.5, 17); + state = radio2.begin(868.0, 200.0, 60.0, 335.5, 17); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -75,13 +71,13 @@ void setup() { // and check if the configuration was changed successfully // set carrier frequency to 433.5 MHz - if (fsk1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { + if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { Serial.println(F("[Si4432] Selected frequency is invalid for this module!")); while (true); } // set bit rate to 100.0 kbps - state = fsk1.setBitRate(100.0); + state = radio1.setBitRate(100.0); if (state == ERR_INVALID_BIT_RATE) { Serial.println(F("[Si4432] Selected bit rate is invalid for this module!")); while (true); @@ -92,20 +88,20 @@ void setup() { } // set receiver bandwidth to 284.8 kHz - state = fsk1.setRxBandwidth(284.8); + state = radio1.setRxBandwidth(284.8); if (state == ERR_INVALID_RX_BANDWIDTH) { Serial.println(F("[Si4432] Selected receiver bandwidth is invalid for this module!")); while (true); } // set frequency deviation to 10.0 kHz - if (fsk1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) { + if (radio1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) { Serial.println(F("[Si4432] Selected frequency deviation is invalid for this module!")); while (true); } // set output power to 2 dBm - if (fsk1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) { + if (radio1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) { Serial.println(F("[Si4432] Selected output power is invalid for this module!")); while (true); } @@ -113,7 +109,7 @@ void setup() { // up to 4 bytes can be set as sync word // set sync word to 0x01234567 uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67}; - if (fsk1.setSyncWord(syncWord, 4) == ERR_INVALID_SYNC_WORD) { + if (radio1.setSyncWord(syncWord, 4) == ERR_INVALID_SYNC_WORD) { Serial.println(F("[Si4432] Selected sync word is invalid for this module!")); while (true); } diff --git a/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino b/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino index 34a278da..ca267624 100644 --- a/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino +++ b/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino @@ -9,6 +9,9 @@ Other modules from Si443x/RFM2x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,24 +23,18 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 fsk = new Module(10, 2, 9); +Si4432 radio = new Module(10, 2, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//Si4432 fsk = RadioShield.ModuleA; +//Si4432 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize Si4432 with default settings Serial.print(F("[Si4432] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 225.1 kHz - // output power: 11 dBm - // sync word: 0x2D 0x01 - int state = fsk.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -55,12 +52,12 @@ void loop() { // NOTE: transmit() is a blocking method! // See example Si443x_Transmit_Interrupt for details // on non-blocking transmission method. - int state = fsk.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; - int state = fsk.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/Si443x/Si443x_Transmit_Interrupt/Si443x_Transmit_Interrupt.ino b/examples/Si443x/Si443x_Transmit_Interrupt/Si443x_Transmit_Interrupt.ino index e4c56c18..82c5364d 100644 --- a/examples/Si443x/Si443x_Transmit_Interrupt/Si443x_Transmit_Interrupt.ino +++ b/examples/Si443x/Si443x_Transmit_Interrupt/Si443x_Transmit_Interrupt.ino @@ -9,6 +9,9 @@ Other modules from Si443x/RFM2x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,11 +23,11 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 fsk = new Module(10, 2, 9); +Si4432 radio = new Module(10, 2, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//Si4432 fsk = RadioShield.ModuleA; +//Si4432 radio = RadioShield.ModuleA; // save transmission state between loops int transmissionState = ERR_NONE; @@ -34,14 +37,7 @@ void setup() { // initialize Si4432 with default settings Serial.print(F("[Si4432] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 225.1 kHz - // output power: 11 dBm - // sync word: 0x2D 0x01 - int state = fsk.begin(); - fsk.setOutputPower(13); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,20 +48,20 @@ void setup() { // set the function that will be called // when packet transmission is finished - fsk.setIrqAction(setFlag); + radio.setIrqAction(setFlag); // start transmitting the first packet Serial.print(F("[Si4432] Sending first packet ... ")); // you can transmit C-string or Arduino string up to // 64 characters long - transmissionState = fsk.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = fsk.startTransmit(byteArr, 8); + state = radio.startTransmit(byteArr, 8); */ } @@ -117,13 +113,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = fsk.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = fsk.startTransmit(byteArr, 8); + int state = radio.startTransmit(byteArr, 8); */ // we're ready to send more packets, From b98f910367d0fefebc019841bcfd02eac1938e9b Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:32:21 +0200 Subject: [PATCH 151/455] [SX126x] Added missing assertions --- src/modules/SX126x/SX1262.cpp | 2 ++ src/modules/SX126x/SX1268.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index 1ce049af..3f086c9a 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -18,6 +18,7 @@ int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = SX126x::fixPaClamping(); + RADIOLIB_ASSERT(state); return(state); } @@ -35,6 +36,7 @@ int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t RADIOLIB_ASSERT(state); state = SX126x::fixPaClamping(); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index 04cd370f..7e6b3443 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -18,9 +18,11 @@ int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = SX126x::fixPaClamping(); + RADIOLIB_ASSERT(state); return(state); } + int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO) { // execute common part int16_t state = SX126x::beginFSK(br, freqDev, rxBw, currentLimit, preambleLength, dataShaping, tcxoVoltage, useRegulatorLDO); @@ -34,6 +36,7 @@ int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t RADIOLIB_ASSERT(state); state = SX126x::fixPaClamping(); + RADIOLIB_ASSERT(state); return(state); } From 4a53a58258320d2935851d093c25e9fd7e29898f Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:32:44 +0200 Subject: [PATCH 152/455] [SX126x] Added links to default config wiki page --- .../SX126x_Channel_Activity_Detection.ino | 22 ++---- .../SX126x_FSK_Modem/SX126x_FSK_Modem.ino | 67 ++++++++----------- .../SX126x/SX126x_Receive/SX126x_Receive.ino | 28 +++----- .../SX126x_Receive_Interrupt.ino | 48 ++++++------- .../SX126x_Settings/SX126x_Settings.ino | 45 +++++-------- .../SX126x_Transmit/SX126x_Transmit.ino | 28 +++----- .../SX126x_Transmit_Interrupt.ino | 32 ++++----- 7 files changed, 108 insertions(+), 162 deletions(-) diff --git a/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino b/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino index 99209b99..b888a95d 100644 --- a/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino +++ b/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino @@ -8,6 +8,9 @@ Other modules from SX126x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,29 +23,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1262 lora = new Module(10, 2, 3, 9); +SX1262 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1262 lora = RadioShield.ModuleA; +//SX1262 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1262 with default settings Serial.print(F("[SX1262] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 (private network) - // output power: 14 dBm - // current limit: 60 mA - // preamble length: 8 symbols - // TCXO voltage: 1.6 V (set to 0 to not use TCXO) - // regulator: DC-DC (set to true to use LDO) - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -56,7 +48,7 @@ void loop() { Serial.print(F("[SX1262] Scanning channel for LoRa transmission ... ")); // start scanning current channel - int state = lora.scanChannel(); + int state = radio.scanChannel(); if (state == LORA_DETECTED) { // LoRa preamble was detected diff --git a/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino b/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino index 90730ed0..13411fdd 100644 --- a/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino +++ b/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino @@ -9,6 +9,9 @@ modem and use the appropriate configuration methods. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---fsk-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,30 +24,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1262 fsk = new Module(10, 2, 3, 9); +SX1262 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1262 fsk = RadioShield.ModuleA; +//SX1262 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1262 FSK modem with default settings Serial.print(F("[SX1262] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 156.2 kHz - // output power: 14 dBm - // current limit: 60.0 mA - // preamble length: 16 bits - // data shaping: Gaussian, BT = 0.5 - // TCXO voltage: 1.6 V (set to 0 to not use TCXO) - // regulator: DC-DC (set to true to use LDO) - // sync word: 0x2D 0x01 - // CRC: enabled, CRC16 (CCIT) - int state = fsk.beginFSK(); + int state = radio.beginFSK(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -55,21 +46,21 @@ void setup() { // if needed, you can switch between LoRa and FSK modes // - // lora.begin() start LoRa mode (and disable FSK) - // lora.beginFSK() start FSK mode (and disable LoRa) + // radio.begin() start LoRa mode (and disable FSK) + // radio.beginFSK() start FSK mode (and disable LoRa) // the following settings can also // be modified at run-time - state = fsk.setFrequency(433.5); - state = fsk.setBitRate(100.0); - state = fsk.setFrequencyDeviation(10.0); - state = fsk.setRxBandwidth(250.0); - state = fsk.setOutputPower(10.0); - state = fsk.setCurrentLimit(100.0); - state = fsk.setDataShaping(1.0); + state = radio.setFrequency(433.5); + state = radio.setBitRate(100.0); + state = radio.setFrequencyDeviation(10.0); + state = radio.setRxBandwidth(250.0); + state = radio.setOutputPower(10.0); + state = radio.setCurrentLimit(100.0); + state = radio.setDataShaping(1.0); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = fsk.setSyncWord(syncWord, 8); + state = radio.setSyncWord(syncWord, 8); if (state != ERR_NONE) { Serial.print(F("Unable to set configuration, code ")); Serial.println(state); @@ -78,15 +69,15 @@ void setup() { // FSK modem on SX126x can handle the sync word setting in bits, not just // whole bytes. The value used is left-justified. - // This makes same result as fsk.setSyncWord(syncWord, 8): - state = fsk.setSyncBits(syncWord, 64); + // This makes same result as radio.setSyncWord(syncWord, 8): + state = radio.setSyncBits(syncWord, 64); // This will use 0x012 as sync word (12 bits only): - state = fsk.setSyncBits(syncWord, 12); + state = radio.setSyncBits(syncWord, 12); // FSK modem allows advanced CRC configuration // Default is CCIT CRC16 (2 bytes, initial 0x1D0F, polynomial 0x1021, inverted) // Set CRC to IBM CRC (2 bytes, initial 0xFFFF, polynomial 0x8005, non-inverted) - state = fsk.setCRC(2, 0xFFFF, 0x8005, false); + state = radio.setCRC(2, 0xFFFF, 0x8005, false); // set CRC length to 0 to disable CRC #warning "This sketch is just an API guide! Read the note at line 6." @@ -97,11 +88,11 @@ void loop() { // as the LoRa modem, even their interrupt-driven versions // transmit FSK packet - int state = fsk.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = lora.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1262] Packet transmitted successfully!")); @@ -116,10 +107,10 @@ void loop() { // receive FSK packet String str; - state = fsk.receive(str); + state = radio.receive(str); /* byte byteArr[8]; - int state = lora.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1262] Received packet!")); @@ -139,13 +130,13 @@ void loop() { // to transmit packet to a particular address, // use the following methods: // - // fsk.transmit("Hello World!", address); - // fsk.startTransmit("Hello World!", address); + // radio.transmit("Hello World!", address); + // radio.startTransmit("Hello World!", address); // set node address to 0x02 - state = fsk.setNodeAddress(0x02); + state = radio.setNodeAddress(0x02); // set broadcast address to 0xFF - state = fsk.setBroadcastAddress(0xFF); + state = radio.setBroadcastAddress(0xFF); if (state != ERR_NONE) { Serial.println(F("[SX1262] Unable to set address filter, code ")); Serial.println(state); @@ -155,7 +146,7 @@ void loop() { // NOTE: calling this method will also erase previously set // node and broadcast address /* - state = fsk.disableAddressFiltering(); + state = radio.disableAddressFiltering(); if (state != ERR_NONE) { Serial.println(F("Unable to remove address filter, code ")); } diff --git a/examples/SX126x/SX126x_Receive/SX126x_Receive.ino b/examples/SX126x/SX126x_Receive/SX126x_Receive.ino index c95592f0..23969cb1 100644 --- a/examples/SX126x/SX126x_Receive/SX126x_Receive.ino +++ b/examples/SX126x/SX126x_Receive/SX126x_Receive.ino @@ -13,6 +13,9 @@ Other modules from SX126x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,29 +28,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1262 lora = new Module(10, 2, 3, 9); +SX1262 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1262 lora = RadioShield.ModuleA; +//SX1262 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1262 with default settings Serial.print(F("[SX1262] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 (private network) - // output power: 14 dBm - // current limit: 60 mA - // preamble length: 8 symbols - // TCXO voltage: 1.6 V (set to 0 to not use TCXO) - // regulator: DC-DC (set to true to use LDO) - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -65,12 +57,12 @@ void loop() { // See example ReceiveInterrupt for details // on non-blocking reception method. String str; - int state = lora.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = lora.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -84,13 +76,13 @@ void loop() { // print the RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[SX1262] RSSI:\t\t")); - Serial.print(lora.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print the SNR (Signal-to-Noise Ratio) // of the last received packet Serial.print(F("[SX1262] SNR:\t\t")); - Serial.print(lora.getSNR()); + Serial.print(radio.getSNR()); Serial.println(F(" dB")); } else if (state == ERR_RX_TIMEOUT) { diff --git a/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino b/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino index 59d49f53..3932f7b0 100644 --- a/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino +++ b/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino @@ -12,7 +12,10 @@ - coding rate - sync word - Other modules from SX126x/RFM9x family can also be used. + Other modules from SX126x family can also be used. + + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ @@ -26,29 +29,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1262 lora = new Module(10, 2, 3, 9); +SX1262 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1262 lora = RadioShield.ModuleA; +//SX1262 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1262 with default settings Serial.print(F("[SX1262] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 (private network) - // output power: 14 dBm - // current limit: 60 mA - // preamble length: 8 symbols - // TCXO voltage: 1.6 V (set to 0 to not use TCXO) - // regulator: DC-DC (set to true to use LDO) - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -59,11 +51,11 @@ void setup() { // set the function that will be called // when new packet is received - lora.setDio1Action(setFlag); + radio.setDio1Action(setFlag); // start listening for LoRa packets Serial.print(F("[SX1262] Starting to listen ... ")); - state = lora.startReceive(); + state = radio.startReceive(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -75,12 +67,12 @@ void setup() { // if needed, 'listen' mode can be disabled by calling // any of the following methods: // - // lora.standby() - // lora.sleep() - // lora.transmit(); - // lora.receive(); - // lora.readData(); - // lora.scanChannel(); + // radio.standby() + // radio.sleep() + // radio.transmit(); + // radio.receive(); + // radio.readData(); + // radio.scanChannel(); } // flag to indicate that a packet was received @@ -115,12 +107,12 @@ void loop() { // you can read received data as an Arduino String String str; - int state = lora.readData(str); + int state = radio.readData(str); // you can also read received data as byte array /* byte byteArr[8]; - int state = lora.readData(byteArr, 8); + int state = radio.readData(byteArr, 8); */ if (state == ERR_NONE) { @@ -133,12 +125,12 @@ void loop() { // print RSSI (Received Signal Strength Indicator) Serial.print(F("[SX1262] RSSI:\t\t")); - Serial.print(lora.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print SNR (Signal-to-Noise Ratio) Serial.print(F("[SX1262] SNR:\t\t")); - Serial.print(lora.getSNR()); + Serial.print(radio.getSNR()); Serial.println(F(" dB")); } else if (state == ERR_CRC_MISMATCH) { @@ -153,7 +145,7 @@ void loop() { } // put module back to listen mode - lora.startReceive(); + radio.startReceive(); // we're ready to receive more packets, // enable interrupt service routine diff --git a/examples/SX126x/SX126x_Settings/SX126x_Settings.ino b/examples/SX126x/SX126x_Settings/SX126x_Settings.ino index 3da7d650..5e34d203 100644 --- a/examples/SX126x/SX126x_Settings/SX126x_Settings.ino +++ b/examples/SX126x/SX126x_Settings/SX126x_Settings.ino @@ -17,6 +17,9 @@ Other modules from SX126x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -29,14 +32,14 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1262 loraSX1262 = new Module(10, 2, 3, 9); +SX1262 radio1 = new Module(10, 2, 3, 9); // SX12628 has different connections: // NSS pin: 8 // DIO1 pin: 4 // NRST pin: 5 // BUSY pin: 6 -SX1268 loraSX1268 = new Module(8, 4, 5, 6); +SX1268 radio2 = new Module(8, 4, 5, 6); // or using RadioShield // https://github.com/jgromes/RadioShield @@ -47,18 +50,7 @@ void setup() { // initialize SX1268 with default settings Serial.print(F("[SX1262] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 (private network) - // output power: 14 dBm - // current limit: 60 mA - // preamble length: 8 symbols - // TCXO voltage: 1.6 V (set to 0 to not use TCXO) - // regulator: DC-DC (set to true to use LDO) - // CRC: enabled - int state = loraSX1262.begin(); + int state = radio1.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -80,8 +72,7 @@ void setup() { // output power: 2 dBm // current limit: 50 mA // preamble length: 20 symbols - // CRC: enabled - state = loraSX1268.begin(915.0, 500.0, 6, 5, 0x34, 50, 20); + state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 50, 20); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -94,56 +85,56 @@ void setup() { // and check if the configuration was changed successfully // set carrier frequency to 433.5 MHz - if (loraSX1262.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { + if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { Serial.println(F("Selected frequency is invalid for this module!")); while (true); } // set bandwidth to 250 kHz - if (loraSX1262.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) { + if (radio1.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) { Serial.println(F("Selected bandwidth is invalid for this module!")); while (true); } // set spreading factor to 10 - if (loraSX1262.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) { + if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) { Serial.println(F("Selected spreading factor is invalid for this module!")); while (true); } // set coding rate to 6 - if (loraSX1262.setCodingRate(6) == ERR_INVALID_CODING_RATE) { + if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) { Serial.println(F("Selected coding rate is invalid for this module!")); while (true); } // set LoRa sync word to 0xAB - if (loraSX1262.setSyncWord(0xAB) != ERR_NONE) { + if (radio1.setSyncWord(0xAB) != ERR_NONE) { Serial.println(F("Unable to set sync word!")); while (true); } // set output power to 10 dBm (accepted range is -17 - 22 dBm) - if (loraSX1262.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) { + if (radio1.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) { Serial.println(F("Selected output power is invalid for this module!")); while (true); } // set over current protection limit to 80 mA (accepted range is 45 - 240 mA) // NOTE: set value to 0 to disable overcurrent protection - if (loraSX1262.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) { + if (radio1.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) { Serial.println(F("Selected current limit is invalid for this module!")); while (true); } // set LoRa preamble length to 15 symbols (accepted range is 0 - 65535) - if (loraSX1262.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) { + if (radio1.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) { Serial.println(F("Selected preamble length is invalid for this module!")); while (true); } // disable CRC - if (loraSX1262.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) { + if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) { Serial.println(F("Selected CRC is invalid for this module!")); while (true); } @@ -151,7 +142,7 @@ void setup() { // Some SX126x modules have TCXO (temperature compensated crystal // oscillator). To configure TCXO reference voltage, // the following method can be used. - if (loraSX1262.setTCXO(2.4) == ERR_INVALID_TCXO_VOLTAGE) { + if (radio1.setTCXO(2.4) == ERR_INVALID_TCXO_VOLTAGE) { Serial.println(F("Selected TCXO voltage is invalid for this module!")); while (true); } @@ -160,7 +151,7 @@ void setup() { // this feature, the following method can be used. // NOTE: As long as DIO2 is configured to control RF switch, // it can't be used as interrupt pin! - if (loraSX1262.setDio2AsRfSwitch() != ERR_NONE) { + if (radio1.setDio2AsRfSwitch() != ERR_NONE) { Serial.println(F("Failed to set DIO2 as RF switch!")); while (true); } diff --git a/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino b/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino index 338bf3f5..541645ee 100644 --- a/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino +++ b/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino @@ -9,6 +9,9 @@ Other modules from SX126x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,29 +24,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1262 lora = new Module(10, 2, 3, 9); +SX1262 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1262 lora = RadioShield.ModuleA; +//SX1262 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1262 with default settings Serial.print(F("[SX1262] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 (private network) - // output power: 14 dBm - // current limit: 60 mA - // preamble length: 8 symbols - // TCXO voltage: 1.6 V (set to 0 to not use TCXO) - // regulator: DC-DC (set to true to use LDO) - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -59,7 +51,7 @@ void setup() { // RX enable: 4 // TX enable: 5 /* - lora.setRfSwitchPins(4, 5); + radio.setRfSwitchPins(4, 5); */ } @@ -71,12 +63,12 @@ void loop() { // NOTE: transmit() is a blocking method! // See example SX126x_Transmit_Interrupt for details // on non-blocking transmission method. - int state = lora.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; - int state = lora.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { @@ -85,7 +77,7 @@ void loop() { // print measured data rate Serial.print(F("[SX1262] Datarate:\t")); - Serial.print(lora.getDataRate()); + Serial.print(radio.getDataRate()); Serial.println(F(" bps")); } else if (state == ERR_PACKET_TOO_LONG) { diff --git a/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino b/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino index 724e05dc..20600a11 100644 --- a/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino +++ b/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino @@ -10,6 +10,9 @@ Other modules from SX126x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -22,7 +25,11 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1262 lora = new Module(10, 2, 3, 9); +SX1262 radio = new Module(10, 2, 3, 9); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1262 radio = RadioShield.ModuleA; // save transmission state between loops int transmissionState = ERR_NONE; @@ -32,18 +39,7 @@ void setup() { // initialize SX1262 with default settings Serial.print(F("[SX1262] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 (private network) - // output power: 14 dBm - // current limit: 60 mA - // preamble length: 8 symbols - // TCXO voltage: 1.6 V (set to 0 to not use TCXO) - // regulator: DC-DC (set to true to use LDO) - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -54,20 +50,20 @@ void setup() { // set the function that will be called // when packet transmission is finished - lora.setDio1Action(setFlag); + radio.setDio1Action(setFlag); // start transmitting the first packet Serial.print(F("[SX1262] Sending first packet ... ")); // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = lora.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = lora.startTransmit(byteArr, 8); + state = radio.startTransmit(byteArr, 8); */ } @@ -123,13 +119,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = lora.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = lora.startTransmit(byteArr, 8); + int state = radio.startTransmit(byteArr, 8); */ // we're ready to send more packets, From 256da12c66aa28d065f9b7b49de7f5ab9d2c4965 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:38:02 +0200 Subject: [PATCH 153/455] [SX127x] Added links to default config wiki page --- .../SX127x_Channel_Activity_Detection.ino | 20 ++---- .../SX127x_FSK_Modem/SX127x_FSK_Modem.ino | 66 +++++++++---------- .../SX127x/SX127x_Receive/SX127x_Receive.ino | 28 ++++---- .../SX127x_Receive_Interrupt.ino | 46 ++++++------- .../SX127x_Settings/SX127x_Settings.ino | 38 +++++------ .../SX127x_Transmit/SX127x_Transmit.ino | 26 +++----- .../SX127x_Transmit_Interrupt.ino | 28 ++++---- 7 files changed, 105 insertions(+), 147 deletions(-) diff --git a/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino b/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino index 4d946254..ececb747 100644 --- a/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino +++ b/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino @@ -9,6 +9,9 @@ Other modules from SX127x/RFM9x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,27 +24,18 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 lora = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 lora = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 - // output power: 17 dBm - // current limit: 100 mA - // preamble length: 8 symbols - // amplifier gain: 0 (automatic gain control) - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -55,7 +49,7 @@ void loop() { Serial.print(F("[SX1278] Scanning channel for LoRa preamble ... ")); // start scanning current channel - int state = lora.scanChannel(); + int state = radio.scanChannel(); if (state == PREAMBLE_DETECTED) { // LoRa preamble was detected diff --git a/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino b/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino index 7727bcfe..184008e8 100644 --- a/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino +++ b/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino @@ -9,6 +9,9 @@ modem and use the appropriate configuration methods. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---fsk-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,7 +24,7 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield @@ -32,16 +35,7 @@ void setup() { // initialize SX1278 FSK modem with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - // data shaping: Gaussian, BT = 0.5 - // sync word: 0x2D 0x01 - // OOK modulation: disabled - int state = fsk.beginFSK(); + int state = radio.beginFSK(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,21 +46,21 @@ void setup() { // if needed, you can switch between LoRa and FSK modes // - // lora.begin() start LoRa mode (and disable FSK) - // lora.beginFSK() start FSK mode (and disable LoRa) + // radio.begin() start LoRa mode (and disable FSK) + // radio.beginFSK() start FSK mode (and disable LoRa) // the following settings can also // be modified at run-time - state = fsk.setFrequency(433.5); - state = fsk.setBitRate(100.0); - state = fsk.setFrequencyDeviation(10.0); - state = fsk.setRxBandwidth(250.0); - state = fsk.setOutputPower(10.0); - state = fsk.setCurrentLimit(100); - state = fsk.setDataShaping(0.5); + state = radio.setFrequency(433.5); + state = radio.setBitRate(100.0); + state = radio.setFrequencyDeviation(10.0); + state = radio.setRxBandwidth(250.0); + state = radio.setOutputPower(10.0); + state = radio.setCurrentLimit(100); + state = radio.setDataShaping(0.5); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = fsk.setSyncWord(syncWord, 8); + state = radio.setSyncWord(syncWord, 8); if (state != ERR_NONE) { Serial.print(F("Unable to set configuration, code ")); Serial.println(state); @@ -78,8 +72,8 @@ void setup() { // Also, data shaping changes from Gaussian filter to // simple filter with cutoff frequency. Make sure to call // setDataShapingOOK() to set the correct shaping! - state = fsk.setOOK(true); - state = fsk.setDataShapingOOK(1); + state = radio.setOOK(true); + state = radio.setDataShapingOOK(1); if (state != ERR_NONE) { Serial.print(F("Unable to change modulation, code ")); Serial.println(state); @@ -95,11 +89,11 @@ void loop() { // NOTE: FSK modem maximum packet length is 63 bytes! // transmit FSK packet - int state = fsk.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = lora.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1278] Packet transmitted successfully!")); @@ -114,10 +108,10 @@ void loop() { // receive FSK packet String str; - state = fsk.receive(str); + state = radio.receive(str); /* byte byteArr[8]; - int state = lora.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1278] Received packet!")); @@ -137,13 +131,13 @@ void loop() { // to transmit packet to a particular address, // use the following methods: // - // fsk.transmit("Hello World!", address); - // fsk.startTransmit("Hello World!", address); + // radio.transmit("Hello World!", address); + // radio.startTransmit("Hello World!", address); // set node address to 0x02 - state = fsk.setNodeAddress(0x02); + state = radio.setNodeAddress(0x02); // set broadcast address to 0xFF - state = fsk.setBroadcastAddress(0xFF); + state = radio.setBroadcastAddress(0xFF); if (state != ERR_NONE) { Serial.println(F("[SX1278] Unable to set address filter, code ")); Serial.println(state); @@ -153,7 +147,7 @@ void loop() { // NOTE: calling this method will also erase previously set // node and broadcast address /* - state = fsk.disableAddressFiltering(); + state = radio.disableAddressFiltering(); if (state != ERR_NONE) { Serial.println(F("Unable to remove address filter, code ")); } @@ -164,7 +158,7 @@ void loop() { // sent to DIO1 (data) and DIO2 (clock) // activate direct mode transmitter - state = fsk.transmitDirect(); + state = radio.transmitDirect(); if (state != ERR_NONE) { Serial.println(F("[SX1278] Unable to start direct transmission mode, code ")); Serial.println(state); @@ -175,7 +169,7 @@ void loop() { // it is recommended to set data shaping to 0 // (no shaping) when transmitting audio - state = fsk.setDataShaping(0.0); + state = radio.setDataShaping(0.0); if (state != ERR_NONE) { Serial.println(F("[SX1278] Unable to set data shaping, code ")); Serial.println(state); @@ -199,7 +193,7 @@ void loop() { // direct mode transmissions can also be received // as bit stream on DIO1 (data) and DIO2 (clock) - state = fsk.receiveDirect(); + state = radio.receiveDirect(); if (state != ERR_NONE) { Serial.println(F("[SX1278] Unable to start direct reception mode, code ")); Serial.println(state); @@ -207,5 +201,5 @@ void loop() { // NOTE: you will not be able to send or receive packets // while direct mode is active! to deactivate it, call method - // fsk.packetMode() + // radio.packetMode() } diff --git a/examples/SX127x/SX127x_Receive/SX127x_Receive.ino b/examples/SX127x/SX127x_Receive/SX127x_Receive.ino index 5627bdc3..0f839eec 100644 --- a/examples/SX127x/SX127x_Receive/SX127x_Receive.ino +++ b/examples/SX127x/SX127x_Receive/SX127x_Receive.ino @@ -13,6 +13,9 @@ Other modules from SX127x/RFM9x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,27 +28,18 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 lora = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 lora = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 - // output power: 17 dBm - // current limit: 100 mA - // preamble length: 8 symbols - // amplifier gain: 0 (automatic gain control) - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -63,12 +57,12 @@ void loop() { // See example ReceiveInterrupt for details // on non-blocking reception method. String str; - int state = lora.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = lora.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -82,19 +76,19 @@ void loop() { // print the RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[SX1278] RSSI:\t\t\t")); - Serial.print(lora.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print the SNR (Signal-to-Noise Ratio) // of the last received packet Serial.print(F("[SX1278] SNR:\t\t\t")); - Serial.print(lora.getSNR()); + Serial.print(radio.getSNR()); Serial.println(F(" dB")); // print frequency error // of the last received packet Serial.print(F("[SX1278] Frequency error:\t")); - Serial.print(lora.getFrequencyError()); + Serial.print(radio.getFrequencyError()); Serial.println(F(" Hz")); } else if (state == ERR_RX_TIMEOUT) { diff --git a/examples/SX127x/SX127x_Receive_Interrupt/SX127x_Receive_Interrupt.ino b/examples/SX127x/SX127x_Receive_Interrupt/SX127x_Receive_Interrupt.ino index 7f192757..8a755bb8 100644 --- a/examples/SX127x/SX127x_Receive_Interrupt/SX127x_Receive_Interrupt.ino +++ b/examples/SX127x/SX127x_Receive_Interrupt/SX127x_Receive_Interrupt.ino @@ -14,6 +14,9 @@ Other modules from SX127x/RFM9x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,27 +29,18 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 lora = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 lora = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 - // output power: 17 dBm - // current limit: 100 mA - // preamble length: 8 symbols - // amplifier gain: 0 (automatic gain control) - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -57,11 +51,11 @@ void setup() { // set the function that will be called // when new packet is received - lora.setDio0Action(setFlag); + radio.setDio0Action(setFlag); // start listening for LoRa packets Serial.print(F("[SX1278] Starting to listen ... ")); - state = lora.startReceive(); + state = radio.startReceive(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -73,12 +67,12 @@ void setup() { // if needed, 'listen' mode can be disabled by calling // any of the following methods: // - // lora.standby() - // lora.sleep() - // lora.transmit(); - // lora.receive(); - // lora.readData(); - // lora.scanChannel(); + // radio.standby() + // radio.sleep() + // radio.transmit(); + // radio.receive(); + // radio.readData(); + // radio.scanChannel(); } // flag to indicate that a packet was received @@ -113,12 +107,12 @@ void loop() { // you can read received data as an Arduino String String str; - int state = lora.readData(str); + int state = radio.readData(str); // you can also read received data as byte array /* byte byteArr[8]; - int state = lora.readData(byteArr, 8); + int state = radio.readData(byteArr, 8); */ if (state == ERR_NONE) { @@ -131,17 +125,17 @@ void loop() { // print RSSI (Received Signal Strength Indicator) Serial.print(F("[SX1278] RSSI:\t\t")); - Serial.print(lora.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print SNR (Signal-to-Noise Ratio) Serial.print(F("[SX1278] SNR:\t\t")); - Serial.print(lora.getSNR()); + Serial.print(radio.getSNR()); Serial.println(F(" dB")); // print frequency error Serial.print(F("[SX1278] Frequency error:\t")); - Serial.print(lora.getFrequencyError()); + Serial.print(radio.getFrequencyError()); Serial.println(F(" Hz")); } else if (state == ERR_CRC_MISMATCH) { @@ -156,7 +150,7 @@ void loop() { } // put module back to listen mode - lora.startReceive(); + radio.startReceive(); // we're ready to receive more packets, // enable interrupt service routine diff --git a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino index 76b26b10..45f637a4 100644 --- a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino +++ b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino @@ -13,6 +13,9 @@ Other modules from SX127x/RFM9x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,14 +28,14 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 loraSX1278 = new Module(10, 2, 9, 3); +SX1278 radio1 = new Module(10, 2, 9, 3); // SX1272 has different connections: // NSS pin: 9 // DIO0 pin: 4 // RESET pin: 5 // DIO1 pin: 6 -SX1272 loraSX1272 = new Module(9, 4, 5, 6); +SX1272 radio2 = new Module(9, 4, 5, 6); // or using RadioShield // https://github.com/jgromes/RadioShield @@ -43,16 +46,7 @@ void setup() { // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 - // output power: 17 dBm - // current limit: 100 mA - // preamble length: 8 symbols - // amplifier gain: 0 (automatic gain control) - int state = loraSX1278.begin(); + int state = radio1.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -79,7 +73,7 @@ void setup() { // current limit: 50 mA // preamble length: 20 symbols // amplifier gain: 1 (maximum gain) - state = loraSX1272.begin(915.0, 500.0, 6, 5, 0x14, 2); + state = radio2.begin(915.0, 500.0, 6, 5, 0x14, 2); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -92,32 +86,32 @@ void setup() { // and check if the configuration was changed successfully // set carrier frequency to 433.5 MHz - if (loraSX1278.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { + if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { Serial.println(F("Selected frequency is invalid for this module!")); while (true); } // set bandwidth to 250 kHz - if (loraSX1278.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) { + if (radio1.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) { Serial.println(F("Selected bandwidth is invalid for this module!")); while (true); } // set spreading factor to 10 - if (loraSX1278.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) { + if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) { Serial.println(F("Selected spreading factor is invalid for this module!")); while (true); } // set coding rate to 6 - if (loraSX1278.setCodingRate(6) == ERR_INVALID_CODING_RATE) { + if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) { Serial.println(F("Selected coding rate is invalid for this module!")); while (true); } // set LoRa sync word to 0x14 // NOTE: value 0x34 is reserved for LoRaWAN networks and should not be used - if (loraSX1278.setSyncWord(0x14) != ERR_NONE) { + if (radio1.setSyncWord(0x14) != ERR_NONE) { Serial.println(F("Unable to set sync word!")); while (true); } @@ -125,20 +119,20 @@ void setup() { // set output power to 10 dBm (accepted range is -3 - 17 dBm) // NOTE: 20 dBm value allows high power operation, but transmission // duty cycle MUST NOT exceed 1% - if (loraSX1278.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) { + if (radio1.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) { Serial.println(F("Selected output power is invalid for this module!")); while (true); } // set over current protection limit to 80 mA (accepted range is 45 - 240 mA) // NOTE: set value to 0 to disable overcurrent protection - if (loraSX1278.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) { + if (radio1.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) { Serial.println(F("Selected current limit is invalid for this module!")); while (true); } // set LoRa preamble length to 15 symbols (accepted range is 6 - 65535) - if (loraSX1278.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) { + if (radio1.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) { Serial.println(F("Selected preamble length is invalid for this module!")); while (true); } @@ -146,7 +140,7 @@ void setup() { // set amplifier gain to 1 (accepted range is 1 - 6, where 1 is maximum gain) // NOTE: set value to 0 to enable automatic gain control // leave at 0 unless you know what you're doing - if (loraSX1278.setGain(1) == ERR_INVALID_GAIN) { + if (radio1.setGain(1) == ERR_INVALID_GAIN) { Serial.println(F("Selected gain is invalid for this module!")); while (true); } diff --git a/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino b/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino index 265ee32f..6113046b 100644 --- a/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino +++ b/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino @@ -9,6 +9,9 @@ Other modules from SX127x/RFM9x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,27 +24,18 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 lora = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 lora = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 - // output power: 17 dBm - // current limit: 100 mA - // preamble length: 8 symbols - // amplifier gain: 0 (automatic gain control) - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -57,7 +51,7 @@ void setup() { // RX enable: 4 // TX enable: 5 /* - lora.setRfSwitchPins(4, 5); + radio.setRfSwitchPins(4, 5); */ } @@ -69,12 +63,12 @@ void loop() { // NOTE: transmit() is a blocking method! // See example SX127x_Transmit_Interrupt for details // on non-blocking transmission method. - int state = lora.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = lora.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { @@ -83,7 +77,7 @@ void loop() { // print measured data rate Serial.print(F("[SX1278] Datarate:\t")); - Serial.print(lora.getDataRate()); + Serial.print(radio.getDataRate()); Serial.println(F(" bps")); } else if (state == ERR_PACKET_TOO_LONG) { diff --git a/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino b/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino index 0290e54b..7f4b33be 100644 --- a/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino +++ b/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino @@ -10,6 +10,9 @@ Other modules from SX127x/RFM9x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -22,11 +25,11 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 lora = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 lora = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // save transmission state between loops int transmissionState = ERR_NONE; @@ -36,16 +39,7 @@ void setup() { // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bandwidth: 125.0 kHz - // spreading factor: 9 - // coding rate: 7 - // sync word: 0x12 - // output power: 17 dBm - // current limit: 100 mA - // preamble length: 8 symbols - // amplifier gain: 0 (automatic gain control) - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -56,20 +50,20 @@ void setup() { // set the function that will be called // when packet transmission is finished - lora.setDio0Action(setFlag); + radio.setDio0Action(setFlag); // start transmitting the first packet Serial.print(F("[SX1278] Sending first packet ... ")); // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = lora.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = lora.startTransmit(byteArr, 8); + state = radio.startTransmit(byteArr, 8); */ } @@ -125,13 +119,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = lora.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = lora.startTransmit(byteArr, 8); + int state = radio.startTransmit(byteArr, 8); */ // we're ready to send more packets, From 0bf3406d45cdae6326326f8384a53d06227f60e0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:45:56 +0200 Subject: [PATCH 154/455] [SX127x] Fixed typo --- examples/SX127x/SX127x_Settings/SX127x_Settings.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino index 45f637a4..08d1c967 100644 --- a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino +++ b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino @@ -39,7 +39,7 @@ SX1272 radio2 = new Module(9, 4, 5, 6); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1276 loraSX1276 = RadioShield.ModuleB; +//SX1276 radio3 = RadioShield.ModuleB; void setup() { Serial.begin(9600); From 4a4f3256e99ff784b8be7967408025ebf0873078 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:46:20 +0200 Subject: [PATCH 155/455] [SX126x] Fixed typo --- examples/SX126x/SX126x_Settings/SX126x_Settings.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/SX126x/SX126x_Settings/SX126x_Settings.ino b/examples/SX126x/SX126x_Settings/SX126x_Settings.ino index 5e34d203..2e500dee 100644 --- a/examples/SX126x/SX126x_Settings/SX126x_Settings.ino +++ b/examples/SX126x/SX126x_Settings/SX126x_Settings.ino @@ -43,7 +43,7 @@ SX1268 radio2 = new Module(8, 4, 5, 6); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1261 loraSX1261 = RadioShield.ModuleB; +//SX1261 radio3 = RadioShield.ModuleB; void setup() { Serial.begin(9600); From 12770ddfdb913ea18abcc17cf6ea609325cdc6a0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:47:24 +0200 Subject: [PATCH 156/455] [SX128x] Added links to default config wiki page --- .../SX128x_BLE_Modem/SX128x_BLE_Modem.ino | 42 ++++++++--------- .../SX128x_Channel_Activity_Detection.ino | 18 +++----- .../SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino | 45 +++++++++---------- .../SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino | 43 ++++++++---------- .../SX128x/SX128x_Ranging/SX128x_Ranging.ino | 22 ++++----- .../SX128x/SX128x_Receive/SX128x_Receive.ino | 24 +++++----- .../SX128x_Receive_Interrupt.ino | 42 ++++++++--------- .../SX128x_Settings/SX128x_Settings.ino | 35 +++++++-------- .../SX128x_Transmit/SX128x_Transmit.ino | 15 ++++--- .../SX128x_Transmit_Interrupt.ino | 26 +++++------ 10 files changed, 138 insertions(+), 174 deletions(-) diff --git a/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino b/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino index abf6a582..96a96ffa 100644 --- a/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino +++ b/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino @@ -11,6 +11,9 @@ modem and use the appropriate configuration methods. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---ble-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -23,25 +26,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 ble = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 ble = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bit rate: 800 kbps - // frequency deviation: 400.0 kHz - // output power: 10 dBm - // preamble length: 16 bits - // data shaping: Gaussian, BT = 0.5 - // CRC: enabled, CRC16 (CCIT) - int state = ble.beginBLE(); + int state = radio.beginBLE(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,19 +46,19 @@ void setup() { while (true); } - // if needed, you can switch between LoRa and FSK modes + // if needed, you can switch between any of the modems // - // ble.begin() start LoRa mode (and disable BLE) - // lora.beginBLE() start BLE mode (and disable LoRa) + // radio.begin() start LoRa modem (and disable BLE) + // radio.beginBLE() start BLE modem (and disable LoRa) // the following settings can also // be modified at run-time - state = ble.setFrequency(2410.5); - state = ble.setBitRate(250); - state = ble.setFrequencyDeviation(100.0); - state = ble.setOutputPower(5); - state = ble.setDataShaping(1.0); - state = ble.setAccessAddress(0x12345678); + state = radio.setFrequency(2410.5); + state = radio.setBitRate(250); + state = radio.setFrequencyDeviation(100.0); + state = radio.setOutputPower(5); + state = radio.setDataShaping(1.0); + state = radio.setAccessAddress(0x12345678); if (state != ERR_NONE) { Serial.print(F("Unable to set configuration, code ")); Serial.println(state); @@ -77,11 +73,11 @@ void loop() { // as the LoRa modem, even their interrupt-driven versions // transmit BLE packet - int state = ble.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = ble.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Packet transmitted successfully!")); @@ -96,10 +92,10 @@ void loop() { // receive BLE packet String str; - state = ble.receive(str); + state = radio.receive(str); /* byte byteArr[8]; - int state = ble.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Received packet!")); diff --git a/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino b/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino index 6ec30377..cec1560a 100644 --- a/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino +++ b/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino @@ -6,6 +6,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -18,25 +21,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,7 +46,7 @@ void loop() { Serial.print(F("[SX1280] Scanning channel for LoRa transmission ... ")); // start scanning current channel - int state = lora.scanChannel(); + int state = radio.scanChannel(); if (state == LORA_DETECTED) { // LoRa preamble was detected diff --git a/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino b/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino index af680b50..cf2d0e7c 100644 --- a/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino +++ b/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino @@ -9,6 +9,9 @@ modem and use the appropriate configuration methods. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---flrc-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,26 +24,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 flrc = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 flrc = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bit rate: 650 kbps - // coding rate: 3 - // output power: 10 dBm - // preamble length: 16 bits - // data shaping: Gaussian, BT = 0.5 - // sync word: 0x2D 0x01 0x4B 0x1D - // CRC: enabled - int state = flrc.beginFLRC(); + int state = radio.beginFLRC(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -49,20 +44,20 @@ void setup() { while (true); } - // if needed, you can switch between LoRa and FLRC modes + // if needed, you can switch between any of the modems // - // flrc.begin() start LoRa mode (and disable FLRC) - // lora.beginFLRC() start FLRC mode (and disable LoRa) + // radio.begin() start LoRa modem (and disable FLRC) + // radio.beginFLRC() start FLRC modem (and disable LoRa) // the following settings can also // be modified at run-time - state = flrc.setFrequency(2410.5); - state = flrc.setBitRate(520); - state = flrc.setCodingRate(2); - state = flrc.setOutputPower(5); - state = flrc.setDataShaping(1.0); + state = radio.setFrequency(2410.5); + state = radio.setBitRate(520); + state = radio.setCodingRate(2); + state = radio.setOutputPower(5); + state = radio.setDataShaping(1.0); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67}; - state = flrc.setSyncWord(syncWord, 4); + state = radio.setSyncWord(syncWord, 4); if (state != ERR_NONE) { Serial.print(F("Unable to set configuration, code ")); Serial.println(state); @@ -77,11 +72,11 @@ void loop() { // as the LoRa modem, even their interrupt-driven versions // transmit FLRC packet - int state = flrc.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = flrc.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Packet transmitted successfully!")); @@ -94,12 +89,12 @@ void loop() { Serial.println(state); } - // receive GFSK packet + // receive FLRC packet String str; - state = flrc.receive(str); + state = radio.receive(str); /* byte byteArr[8]; - int state = flrc.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Received packet!")); diff --git a/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino b/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino index adfc5320..4ef75900 100644 --- a/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino +++ b/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino @@ -9,6 +9,9 @@ modem and use the appropriate configuration methods. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---gfsk-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,26 +24,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 gfsk = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bit rate: 800 kbps - // frequency deviation: 400.0 kHz - // output power: 10 dBm - // preamble length: 16 bits - // data shaping: Gaussian, BT = 0.5 - // sync word: 0x2D 0x01 - // CRC: enabled, CRC16 (CCIT) - int state = gfsk.beginGFSK(); + int state = radio.beginGFSK(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -49,20 +44,20 @@ void setup() { while (true); } - // if needed, you can switch between LoRa and FSK modes + // if needed, you can switch between any of the modems // - // gfsk.begin() start LoRa mode (and disable GFSK) - // lora.beginGFSK() start GFSK mode (and disable LoRa) + // radio.begin() start LoRa modem (and disable GFSK) + // radio.beginGFSK() start GFSK modem (and disable LoRa) // the following settings can also // be modified at run-time - state = gfsk.setFrequency(2410.5); - state = gfsk.setBitRate(200); - state = gfsk.setFrequencyDeviation(100.0); - state = gfsk.setOutputPower(5); - state = gfsk.setDataShaping(1.0); + state = radio.setFrequency(2410.5); + state = radio.setBitRate(200); + state = radio.setFrequencyDeviation(100.0); + state = radio.setOutputPower(5); + state = radio.setDataShaping(1.0); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89}; - state = gfsk.setSyncWord(syncWord, 5); + state = radio.setSyncWord(syncWord, 5); if (state != ERR_NONE) { Serial.print(F("Unable to set configuration, code ")); Serial.println(state); @@ -77,11 +72,11 @@ void loop() { // as the LoRa modem, even their interrupt-driven versions // transmit GFSK packet - int state = gfsk.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = gfsk.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Packet transmitted successfully!")); @@ -96,10 +91,10 @@ void loop() { // receive GFSK packet String str; - state = gfsk.receive(str); + state = radio.receive(str); /* byte byteArr[8]; - int state = gfsk.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Received packet!")); diff --git a/examples/SX128x/SX128x_Ranging/SX128x_Ranging.ino b/examples/SX128x/SX128x_Ranging/SX128x_Ranging.ino index 585f948b..f53b1a2d 100644 --- a/examples/SX128x/SX128x_Ranging/SX128x_Ranging.ino +++ b/examples/SX128x/SX128x_Ranging/SX128x_Ranging.ino @@ -8,6 +8,9 @@ Only SX1280 and SX1282 support ranging! + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,25 +23,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -54,18 +50,18 @@ void loop() { // start ranging exchange // range as master: true // slave address: 0x12345678 - int state = lora.range(true, 0x12345678); + int state = radio.range(true, 0x12345678); // the other module must be configured as slave with the same address /* - int state = lora.range(false, 0x12345678); + int state = radio.range(false, 0x12345678); */ if (state == ERR_NONE) { // ranging finished successfully Serial.println(F("success!")); Serial.print(F("[SX1280] Distance:\t\t\t")); - Serial.print(lora.getRangingResult()); + Serial.print(radio.getRangingResult()); Serial.println(F(" meters")); } else if (state == ERR_RANGING_TIMEOUT) { diff --git a/examples/SX128x/SX128x_Receive/SX128x_Receive.ino b/examples/SX128x/SX128x_Receive/SX128x_Receive.ino index 0427cf41..ff5adc41 100644 --- a/examples/SX128x/SX128x_Receive/SX128x_Receive.ino +++ b/examples/SX128x/SX128x_Receive/SX128x_Receive.ino @@ -13,6 +13,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,25 +28,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -61,12 +57,12 @@ void loop() { // See example ReceiveInterrupt for details // on non-blocking reception method. String str; - int state = lora.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = lora.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -80,13 +76,13 @@ void loop() { // print the RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[SX1280] RSSI:\t\t")); - Serial.print(lora.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print the SNR (Signal-to-Noise Ratio) // of the last received packet Serial.print(F("[SX1280] SNR:\t\t")); - Serial.print(lora.getSNR()); + Serial.print(radio.getSNR()); Serial.println(F(" dB")); } else if (state == ERR_RX_TIMEOUT) { diff --git a/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino b/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino index 2d6f1664..65e03f7d 100644 --- a/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino +++ b/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino @@ -14,6 +14,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,25 +29,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -55,11 +51,11 @@ void setup() { // set the function that will be called // when new packet is received - lora.setDio1Action(setFlag); + radio.setDio1Action(setFlag); // start listening for LoRa packets Serial.print(F("[SX1280] Starting to listen ... ")); - state = lora.startReceive(); + state = radio.startReceive(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -71,12 +67,12 @@ void setup() { // if needed, 'listen' mode can be disabled by calling // any of the following methods: // - // lora.standby() - // lora.sleep() - // lora.transmit(); - // lora.receive(); - // lora.readData(); - // lora.scanChannel(); + // radio.standby() + // radio.sleep() + // radio.transmit(); + // radio.receive(); + // radio.readData(); + // radio.scanChannel(); } // flag to indicate that a packet was received @@ -111,12 +107,12 @@ void loop() { // you can read received data as an Arduino String String str; - int state = lora.readData(str); + int state = radio.readData(str); // you can also read received data as byte array /* byte byteArr[8]; - int state = lora.readData(byteArr, 8); + int state = radio.readData(byteArr, 8); */ if (state == ERR_NONE) { @@ -129,12 +125,12 @@ void loop() { // print RSSI (Received Signal Strength Indicator) Serial.print(F("[SX1280] RSSI:\t\t")); - Serial.print(lora.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print SNR (Signal-to-Noise Ratio) Serial.print(F("[SX1280] SNR:\t\t")); - Serial.print(lora.getSNR()); + Serial.print(radio.getSNR()); Serial.println(F(" dB")); } else if (state == ERR_CRC_MISMATCH) { @@ -149,7 +145,7 @@ void loop() { } // put module back to listen mode - lora.startReceive(); + radio.startReceive(); // we're ready to receive more packets, // enable interrupt service routine diff --git a/examples/SX128x/SX128x_Settings/SX128x_Settings.ino b/examples/SX128x/SX128x_Settings/SX128x_Settings.ino index 49d218d6..0963d85a 100644 --- a/examples/SX128x/SX128x_Settings/SX128x_Settings.ino +++ b/examples/SX128x/SX128x_Settings/SX128x_Settings.ino @@ -14,6 +14,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,32 +29,25 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 loraSX1280 = new Module(10, 2, 3, 9); +SX1280 radio1 = new Module(10, 2, 3, 9); // SX1280 has the following connections: // NSS pin: 8 // DIO1 pin: 4 // NRST pin: 5 // BUSY pin: 6 -SX1281 loraSX1281 = new Module(8, 4, 5, 6); +SX1281 radio2 = new Module(8, 4, 5, 6); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1282 loraSX1282 = RadioShield.ModuleB; +//SX1282 radio3 = RadioShield.ModuleB; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = loraSX1280.begin(); + int state = radio1.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -71,8 +67,7 @@ void setup() { // coding rate: 5 // output power: 2 dBm // preamble length: 20 symbols - // CRC: enabled - state = loraSX1281.begin(2450.0, 1625.0, 7, 5, 2, 20); + state = radio2.begin(2450.0, 1625.0, 7, 5, 2, 20); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -85,43 +80,43 @@ void setup() { // and check if the configuration was changed successfully // set carrier frequency to 2410.5 MHz - if (loraSX1280.setFrequency(2410.5) == ERR_INVALID_FREQUENCY) { + if (radio1.setFrequency(2410.5) == ERR_INVALID_FREQUENCY) { Serial.println(F("Selected frequency is invalid for this module!")); while (true); } // set bandwidth to 203.125 kHz - if (loraSX1280.setBandwidth(203.125) == ERR_INVALID_BANDWIDTH) { + if (radio1.setBandwidth(203.125) == ERR_INVALID_BANDWIDTH) { Serial.println(F("Selected bandwidth is invalid for this module!")); while (true); } // set spreading factor to 10 - if (loraSX1280.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) { + if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) { Serial.println(F("Selected spreading factor is invalid for this module!")); while (true); } // set coding rate to 6 - if (loraSX1280.setCodingRate(6) == ERR_INVALID_CODING_RATE) { + if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) { Serial.println(F("Selected coding rate is invalid for this module!")); while (true); } // set output power to -2 dBm - if (loraSX1280.setOutputPower(-2) == ERR_INVALID_OUTPUT_POWER) { + if (radio1.setOutputPower(-2) == ERR_INVALID_OUTPUT_POWER) { Serial.println(F("Selected output power is invalid for this module!")); while (true); } // set LoRa preamble length to 16 symbols (accepted range is 2 - 65535) - if (loraSX1280.setPreambleLength(16) == ERR_INVALID_PREAMBLE_LENGTH) { + if (radio1.setPreambleLength(16) == ERR_INVALID_PREAMBLE_LENGTH) { Serial.println(F("Selected preamble length is invalid for this module!")); while (true); } // disable CRC - if (loraSX1280.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) { + if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) { Serial.println(F("Selected CRC is invalid for this module!")); while (true); } diff --git a/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino b/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino index b86259cf..a4037def 100644 --- a/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino +++ b/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino @@ -9,6 +9,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,11 +24,11 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -39,7 +42,7 @@ void setup() { // output power: 10 dBm // preamble length: 12 symbols // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -55,7 +58,7 @@ void setup() { // RX enable: 4 // TX enable: 5 /* - lora.setRfSwitchPins(4, 5); + radio.setRfSwitchPins(4, 5); */ } @@ -67,12 +70,12 @@ void loop() { // NOTE: transmit() is a blocking method! // See example SX128x_Transmit_Interrupt for details // on non-blocking transmission method. - int state = lora.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; - int state = lora.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino index 284244e8..ecdd9312 100644 --- a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino +++ b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino @@ -10,6 +10,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -22,11 +25,11 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; // save transmission state between loops int transmissionState = ERR_NONE; @@ -36,14 +39,7 @@ void setup() { // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -54,20 +50,20 @@ void setup() { // set the function that will be called // when packet transmission is finished - lora.setDio1Action(setFlag); + radio.setDio1Action(setFlag); // start transmitting the first packet Serial.print(F("[SX1280] Sending first packet ... ")); // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = lora.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = lora.startTransmit(byteArr, 8); + state = radio.startTransmit(byteArr, 8); */ } @@ -119,13 +115,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = lora.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = lora.startTransmit(byteArr, 8); + int state = radio.startTransmit(byteArr, 8); */ // we're ready to send more packets, From a31a028e4e84e678725fec3a32143232d36b0b35 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:02:35 +0200 Subject: [PATCH 157/455] [AFSK] Added links to default config wiki page --- .../AFSK_Imperial_March.ino | 19 +++++++-------- examples/AFSK/AFSK_Tone/AFSK_Tone.ino | 23 ++++++++----------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino b/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino index 9b80046e..29469f48 100644 --- a/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino +++ b/examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino @@ -10,6 +10,9 @@ - CC1101 - Si443x/RFM2x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,7 +28,7 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // create AFSK client instance using the FSK module // this requires connection to the module direct @@ -35,24 +38,18 @@ SX1278 fsk = new Module(10, 2, 9, 3); // SX1231: DIO2 // CC1101: GDO2 // Si443x/RFM2x: GPIO -AFSKClient audio(&fsk, 5); +AFSKClient audio(&radio, 5); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - int state = fsk.beginFSK(); + int state = radio.beginFSK(); // when using one of the non-LoRa modules for AFSK // (RF69, CC1101,, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); diff --git a/examples/AFSK/AFSK_Tone/AFSK_Tone.ino b/examples/AFSK/AFSK_Tone/AFSK_Tone.ino index 09e66c28..43286f84 100644 --- a/examples/AFSK/AFSK_Tone/AFSK_Tone.ino +++ b/examples/AFSK/AFSK_Tone/AFSK_Tone.ino @@ -11,6 +11,9 @@ - CC1101 - Si443x/RFM2x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -23,34 +26,28 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // create AFSK client instance using the FSK module -// this requires connection to the module direct +// this requires connection to the module direct // input pin, here connected to Arduino pin 5 // SX127x/RFM9x: DIO2 // RF69: DIO2 // SX1231: DIO2 // CC1101: GDO2 // Si443x/RFM2x: GPIO -AFSKClient audio(&fsk, 5); +AFSKClient audio(&radio, 5); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - int state = fsk.beginFSK(); + int state = radio.beginFSK(); // when using one of the non-LoRa modules for AFSK // (RF69, CC1101,, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); @@ -62,7 +59,7 @@ void setup() { } void loop() { - // AFSKClient can be used to transmit tones, + // AFSKClient can be used to transmit tones, // same as Arduino tone() function // 400 Hz tone From 41db6b18bfbe20f84e4ef20af389f2f6b4730bd5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:02:47 +0200 Subject: [PATCH 158/455] [AX25] Added links to default config wiki page --- examples/AX25/AX25_Frames/AX25_Frames.ino | 13 +++++++----- examples/AX25/AX25_Transmit/AX25_Transmit.ino | 13 +++++++----- .../AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino | 21 ++++++++----------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/examples/AX25/AX25_Frames/AX25_Frames.ino b/examples/AX25/AX25_Frames/AX25_Frames.ino index 4289c866..0167214c 100644 --- a/examples/AX25/AX25_Frames/AX25_Frames.ino +++ b/examples/AX25/AX25_Frames/AX25_Frames.ino @@ -20,6 +20,9 @@ exhaustive; all possible AX.25 frames should be supported. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -32,14 +35,14 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create AX.25 client instance using the FSK module -AX25Client ax25(&fsk); +AX25Client ax25(&radio); void setup() { Serial.begin(9600); @@ -49,11 +52,11 @@ void setup() { // carrier frequency: 434.0 MHz // bit rate: 1.2 kbps (1200 baud 2-FSK AX.25) // frequency deviation: 0.5 kHz (1200 baud 2-FSK AX.25) - int state = fsk.beginFSK(434.0, 1.2, 0.5); + int state = radio.beginFSK(434.0, 1.2, 0.5); // when using one of the non-LoRa modules for AX.25 // (RF69, CC1101, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); diff --git a/examples/AX25/AX25_Transmit/AX25_Transmit.ino b/examples/AX25/AX25_Transmit/AX25_Transmit.ino index 6ab9c59e..2ed78875 100644 --- a/examples/AX25/AX25_Transmit/AX25_Transmit.ino +++ b/examples/AX25/AX25_Transmit/AX25_Transmit.ino @@ -13,6 +13,9 @@ - nRF24 - Si443x/RFM2x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,14 +28,14 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create AX.25 client instance using the FSK module -AX25Client ax25(&fsk); +AX25Client ax25(&radio); void setup() { Serial.begin(9600); @@ -42,11 +45,11 @@ void setup() { // carrier frequency: 434.0 MHz // bit rate: 1.2 kbps (1200 baud 2-FSK AX.25) // frequency deviation: 0.5 kHz (1200 baud 2-FSK AX.25) - int state = fsk.beginFSK(434.0, 1.2, 0.5); + int state = radio.beginFSK(434.0, 1.2, 0.5); // when using one of the non-LoRa modules for AX.25 // (RF69, CC1101,, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); diff --git a/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino b/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino index d55e14aa..703847af 100644 --- a/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino +++ b/examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino @@ -14,6 +14,9 @@ - nRF24 - Si443x/RFM2x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,15 +29,15 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create AFSK client instance using the FSK module // pin 5 is connected to SX1278 DIO2 -AFSKClient audio(&fsk, 5); +AFSKClient audio(&radio, 5); // create AX.25 client instance using the AFSK instance AX25Client ax25(&audio); @@ -42,19 +45,13 @@ AX25Client ax25(&audio); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - int state = fsk.beginFSK(); + int state = radio.beginFSK(); // when using one of the non-LoRa modules for AX.25 // (RF69, CC1101,, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); From fd69e8a29459f4286ae8526189f093b0657d9154 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:02:57 +0200 Subject: [PATCH 159/455] [Hell] Added links to default config wiki page --- .../Hellschreiber_Transmit.ino | 24 ++++++++----------- .../Hellschreiber_Transmit_AFSK.ino | 23 ++++++++---------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/examples/Hellschreiber/Hellschreiber_Transmit/Hellschreiber_Transmit.ino b/examples/Hellschreiber/Hellschreiber_Transmit/Hellschreiber_Transmit.ino index a8dda9f0..edadc5d6 100644 --- a/examples/Hellschreiber/Hellschreiber_Transmit/Hellschreiber_Transmit.ino +++ b/examples/Hellschreiber/Hellschreiber_Transmit/Hellschreiber_Transmit.ino @@ -14,6 +14,9 @@ - Si443x/RFM2x - SX128x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,32 +29,25 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create Hellschreiber client instance using the FSK module -HellClient hell(&fsk); +HellClient hell(&radio); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - // sync word: 0x2D 0x01 - int state = fsk.beginFSK(); + int state = radio.beginFSK(); // when using one of the non-LoRa modules for Morse code // (RF69, CC1101, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); @@ -109,7 +105,7 @@ void loop() { float f = -3.1415; hell.println(f, 3); - // custom glyph - must be a 7 byte array of rows 7 pixels long + // custom glyph - must be a 7 byte array of rows 7 pixels long uint8_t customGlyph[] = { 0b0000000, 0b0010100, 0b0010100, 0b0000000, 0b0100010, 0b0011100, 0b0000000 }; hell.printGlyph(customGlyph); diff --git a/examples/Hellschreiber/Hellschreiber_Transmit_AFSK/Hellschreiber_Transmit_AFSK.ino b/examples/Hellschreiber/Hellschreiber_Transmit_AFSK/Hellschreiber_Transmit_AFSK.ino index ec2aa4e7..1938f34c 100644 --- a/examples/Hellschreiber/Hellschreiber_Transmit_AFSK/Hellschreiber_Transmit_AFSK.ino +++ b/examples/Hellschreiber/Hellschreiber_Transmit_AFSK/Hellschreiber_Transmit_AFSK.ino @@ -13,6 +13,9 @@ - CC1101 - Si443x/RFM2x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,15 +28,15 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create AFSK client instance using the FSK module // pin 5 is connected to SX1278 DIO2 -AFSKClient audio(&fsk, 5); +AFSKClient audio(&radio, 5); // create Hellschreiber client instance using the AFSK instance HellClient hell(&audio); @@ -41,19 +44,13 @@ HellClient hell(&audio); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - int state = fsk.beginFSK(); + int state = radio.beginFSK(); // when using one of the non-LoRa modules for Morse code // (RF69, CC1101, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); @@ -111,7 +108,7 @@ void loop() { float f = -3.1415; hell.println(f, 3); - // custom glyph - must be a 7 byte array of rows 7 pixels long + // custom glyph - must be a 7 byte array of rows 7 pixels long uint8_t customGlyph[] = { 0b0000000, 0b0010100, 0b0010100, 0b0000000, 0b0100010, 0b0011100, 0b0000000 }; hell.printGlyph(customGlyph); From 96f7a51ec9416b4409ab54aa3e9b72a778ee2a37 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:03:04 +0200 Subject: [PATCH 160/455] [Morse] Added links to default config wiki page --- .../Morse/Morse_Transmit/Morse_Transmit.ino | 24 ++++++++----------- .../Morse_Transmit_AFSK.ino | 23 ++++++++---------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/examples/Morse/Morse_Transmit/Morse_Transmit.ino b/examples/Morse/Morse_Transmit/Morse_Transmit.ino index 4f3c07e4..9c39a3b7 100644 --- a/examples/Morse/Morse_Transmit/Morse_Transmit.ino +++ b/examples/Morse/Morse_Transmit/Morse_Transmit.ino @@ -14,6 +14,9 @@ - Si443x/RFM2x - SX128x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,32 +29,25 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create Morse client instance using the FSK module -MorseClient morse(&fsk); +MorseClient morse(&radio); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - // sync word: 0x2D 0x01 - int state = fsk.beginFSK(); - + int state = radio.beginFSK(); + // when using one of the non-LoRa modules for Morse code // (RF69, CC1101, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); diff --git a/examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino b/examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino index 3dbb5d6f..ad89cb49 100644 --- a/examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino +++ b/examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino @@ -13,6 +13,9 @@ - CC1101 - Si443x/RFM2x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,15 +28,15 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create AFSK client instance using the FSK module // pin 5 is connected to SX1278 DIO2 -AFSKClient audio(&fsk, 5); +AFSKClient audio(&radio, 5); // create Morse client instance using the AFSK instance MorseClient morse(&audio); @@ -41,19 +44,13 @@ MorseClient morse(&audio); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - int state = fsk.beginFSK(); - + int state = radio.beginFSK(); + // when using one of the non-LoRa modules for Morse code // (RF69, CC1101, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); From 92ded012349d211427d36ee9e66d1291c52e86cc Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:03:11 +0200 Subject: [PATCH 161/455] [RTTY] Added links to default config wiki page --- examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino | 22 ++++++++----------- .../RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino | 21 ++++++++---------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino b/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino index f565c6f0..80c3c67f 100644 --- a/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino +++ b/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino @@ -14,6 +14,9 @@ - Si443x/RFM2x - SX128x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,32 +29,25 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create RTTY client instance using the FSK module -RTTYClient rtty(&fsk); +RTTYClient rtty(&radio); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - // sync word: 0x2D 0x01 - int state = fsk.beginFSK(); + int state = radio.beginFSK(); // when using one of the non-LoRa modules for RTTY // (RF69, CC1101, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); diff --git a/examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino b/examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino index d836821e..23a66598 100644 --- a/examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino +++ b/examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino @@ -11,6 +11,9 @@ - CC1101 - Si443x/RFM2x + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -23,15 +26,15 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create AFSK client instance using the FSK module // pin 5 is connected to SX1278 DIO2 -AFSKClient audio(&fsk, 5); +AFSKClient audio(&radio, 5); // create RTTY client instance using the AFSK instance RTTYClient rtty(&audio); @@ -39,19 +42,13 @@ RTTYClient rtty(&audio); void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - int state = fsk.beginFSK(); + int state = radio.beginFSK(); // when using one of the non-LoRa modules for RTTY // (RF69, CC1101, Si4432 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); if(state == ERR_NONE) { Serial.println(F("success!")); From ffe535c873489c490dadd09b524382bd2b47e532 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:03:17 +0200 Subject: [PATCH 162/455] [SSTV] Added links to default config wiki page --- examples/SSTV/SSTV_Transmit/SSTV_Transmit.ino | 24 ++++++++----------- .../SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino | 23 ++++++++---------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/examples/SSTV/SSTV_Transmit/SSTV_Transmit.ino b/examples/SSTV/SSTV_Transmit/SSTV_Transmit.ino index 92bdde6f..6b06bae3 100644 --- a/examples/SSTV/SSTV_Transmit/SSTV_Transmit.ino +++ b/examples/SSTV/SSTV_Transmit/SSTV_Transmit.ino @@ -25,6 +25,9 @@ lower speed modes such as Wrasse, Scottie1 or Martin1 are recommended. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -37,14 +40,14 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create SSTV client instance using the FSK module -SSTVClient sstv(&fsk); +SSTVClient sstv(&radio); // test "image" - actually just a single 320px line // will be sent over and over again, to create vertical color stripes at the receiver @@ -85,16 +88,9 @@ uint32_t line[320] = { void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - // sync word: 0x2D 0x01 - int state = fsk.beginFSK(); + int state = radio.beginFSK(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -105,7 +101,7 @@ void setup() { // when using one of the non-LoRa modules for SSTV // (RF69, SX1231 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); // initialize SSTV client Serial.print(F("[SSTV] Initializing ... ")); @@ -152,7 +148,7 @@ void loop() { } // turn off transmitter - fsk.standby(); + radio.standby(); Serial.println(F("done!")); diff --git a/examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino b/examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino index b43c3743..e27bf67e 100644 --- a/examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino +++ b/examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino @@ -20,6 +20,9 @@ lower speed modes such as Wrasse, Scottie1 or Martin1 are recommended. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -32,15 +35,15 @@ // DIO0 pin: 2 // RESET pin: 9 // DIO1 pin: 3 -SX1278 fsk = new Module(10, 2, 9, 3); +SX1278 radio = new Module(10, 2, 9, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1278 fsk = RadioShield.ModuleA; +//SX1278 radio = RadioShield.ModuleA; // create AFSK client instance using the FSK module // pin 5 is connected to SX1278 DIO2 -AFSKClient audio(&fsk, 5); +AFSKClient audio(&radio, 5); // create SSTV client instance using the AFSK instance SSTVClient sstv(&audio); @@ -84,15 +87,9 @@ uint32_t line[320] = { void setup() { Serial.begin(9600); - // initialize SX1278 + // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // frequency deviation: 50.0 kHz - // Rx bandwidth: 125.0 kHz - // output power: 13 dBm - // current limit: 100 mA - int state = fsk.beginFSK(); + int state = radio.beginFSK(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -103,7 +100,7 @@ void setup() { // when using one of the non-LoRa modules for SSTV // (RF69, SX1231 etc.), use the basic begin() method - // int state = fsk.begin(); + // int state = radio.begin(); // initialize SSTV client Serial.print(F("[SSTV] Initializing ... ")); @@ -147,7 +144,7 @@ void loop() { } // turn off transmitter - fsk.standby(); + radio.standby(); Serial.println(F("done!")); From 305e187bfe73695755887f38c97810d23b220e1a Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:03:26 +0200 Subject: [PATCH 163/455] [SX1231] Added links to default config wiki page --- .../SX1231/SX1231_Receive/SX1231_Receive.ino | 19 ++++++++----------- .../SX1231_Transmit/SX1231_Transmit.ino | 19 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/examples/SX1231/SX1231_Receive/SX1231_Receive.ino b/examples/SX1231/SX1231_Receive/SX1231_Receive.ino index 727de1e5..18d0354c 100644 --- a/examples/SX1231/SX1231_Receive/SX1231_Receive.ino +++ b/examples/SX1231/SX1231_Receive/SX1231_Receive.ino @@ -7,6 +7,9 @@ interface. Please see RF69 examples for examples on AES, address filtering, interrupts and settings. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -18,24 +21,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -SX1231 rf = new Module(10, 2, 3); +SX1231 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1231 rf = RadioShield.ModuleA; +//SX1231 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1231 with default settings Serial.print(F("[SX1231] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // Rx bandwidth: 125.0 kHz - // frequency deviation: 50.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,12 +47,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = rf.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = rf.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/SX1231/SX1231_Transmit/SX1231_Transmit.ino b/examples/SX1231/SX1231_Transmit/SX1231_Transmit.ino index e651202a..0f8cd14b 100644 --- a/examples/SX1231/SX1231_Transmit/SX1231_Transmit.ino +++ b/examples/SX1231/SX1231_Transmit/SX1231_Transmit.ino @@ -7,6 +7,9 @@ interface. Please see RF69 examples for examples on AES, address filtering, interrupts and settings. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -18,24 +21,18 @@ // CS pin: 10 // DIO0 pin: 2 // RESET pin: 3 -SX1231 rf = new Module(10, 2, 3); +SX1231 radio = new Module(10, 2, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1231 rf = RadioShield.ModuleA; +//SX1231 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1231 with default settings Serial.print(F("[SX1231] Initializing ... ")); - // carrier frequency: 434.0 MHz - // bit rate: 48.0 kbps - // Rx bandwidth: 125.0 kHz - // frequency deviation: 50.0 kHz - // output power: 13 dBm - // sync word: 0x2D01 - int state = rf.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -49,12 +46,12 @@ void loop() { Serial.print(F("[SX1231] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to 256 characters long - int state = rf.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = rf.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { From 4d87146123dc6979d39692b67cf1e75222bc039c Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:08:43 +0200 Subject: [PATCH 164/455] [RF69] Fixed old variable name --- .../RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino b/examples/RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino index 4e8c2667..5f91e1f6 100644 --- a/examples/RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino +++ b/examples/RF69/RF69_Transmit_Address/RF69_Transmit_Address.ino @@ -87,23 +87,23 @@ void loop() { Serial.print(F("[RF69] Transmitting packet ... ")); // transmit C-string or Arduino string to node with address 0x02 - int state = rf.transmit("Hello World!", 0x02); + int state = radio.transmit("Hello World!", 0x02); // transmit byte array to node with address 0x02 /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = rf.transmit(byteArr, 8, 0x02); + int state = radio.transmit(byteArr, 8, 0x02); */ // transmit C-string or Arduino string in broadcast mode /* - int state = rf.transmit("Hello World!", 0xFF); + int state = radio.transmit("Hello World!", 0xFF); */ // transmit byte array in broadcast mode /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = rf.transmit(byteArr, 8, 0xFF); + int state = radio.transmit(byteArr, 8, 0xFF); */ if (state == ERR_NONE) { From b67060e424b25c90469240950bbf41cdff10bd73 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 12:18:02 +0200 Subject: [PATCH 165/455] [AX25] Fixed uninitialized array --- src/protocols/AX25/AX25.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index 579ed8f1..e73021a6 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -266,6 +266,9 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { uint8_t stuffedFrameBuff[RADIOLIB_STATIC_ARRAY_SIZE]; #endif + // initialize buffer to all zeros + memset(stuffedFrameBuff, 0x00, _preambleLen + 1 + (6*frameBuffLen)/5 + 2); + // stuff bits (skip preamble and both flags) uint16_t stuffedFrameBuffLenBits = 8*(_preambleLen + 1); uint8_t count = 0; From be585bbf78ca8ba89b243524852c00a0085fc533 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 13:18:24 +0200 Subject: [PATCH 166/455] [SSTV] Fixes from cppcheck scan --- src/protocols/SSTV/SSTV.cpp | 8 ++------ src/protocols/SSTV/SSTV.h | 16 ++++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index 73b9b1d9..7988fc64 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -166,7 +166,7 @@ SSTVClient::SSTVClient(AFSKClient* audio) { } #endif -int16_t SSTVClient::begin(SSTVMode_t mode, float correction) { +int16_t SSTVClient::begin(const SSTVMode_t& mode, float correction) { if(_audio == nullptr) { // this initialization method can only be used in AFSK mode return(ERR_WRONG_MODEM); @@ -175,7 +175,7 @@ int16_t SSTVClient::begin(SSTVMode_t mode, float correction) { return(begin(0, mode, correction)); } -int16_t SSTVClient::begin(float base, SSTVMode_t mode, float correction) { +int16_t SSTVClient::begin(float base, const SSTVMode_t& mode, float correction) { // save mode _mode = mode; @@ -278,10 +278,6 @@ void SSTVClient::sendLine(uint32_t* imgLine) { } } -uint16_t SSTVClient::getPictureHeight() { - return(_mode.height); -} - void SSTVClient::tone(float freq, uint32_t len) { uint32_t start = micros(); if(_audio != nullptr) { diff --git a/src/protocols/SSTV/SSTV.h b/src/protocols/SSTV/SSTV.h index 1ab9225b..ea64ceca 100644 --- a/src/protocols/SSTV/SSTV.h +++ b/src/protocols/SSTV/SSTV.h @@ -121,7 +121,7 @@ class SSTVClient { \param phy Pointer to the wireless module providing PhysicalLayer communication. */ - SSTVClient(PhysicalLayer* phy); + explicit SSTVClient(PhysicalLayer* phy); #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! @@ -129,7 +129,7 @@ class SSTVClient { \param audio Pointer to the AFSK instance providing audio. */ - SSTVClient(AFSKClient* phy); + explicit SSTVClient(AFSKClient* audio); #endif // basic methods @@ -145,7 +145,7 @@ class SSTVClient { \returns \ref status_codes */ - int16_t begin(float base, SSTVMode_t mode, float correction = 1.0); + int16_t begin(float base, const SSTVMode_t& mode, float correction = 1.0); /*! \brief Initialization method for AFSK. @@ -156,7 +156,7 @@ class SSTVClient { \returns \ref status_codes */ - int16_t begin(SSTVMode_t mode, float correction = 1.0); + int16_t begin(const SSTVMode_t& mode, float correction = 1.0); /*! \brief Sends out tone at 1900 Hz. @@ -180,7 +180,7 @@ class SSTVClient { \returns Picture height of the currently configured SSTV mode in pixels. */ - uint16_t getPictureHeight(); + uint16_t getPictureHeight() const { return(_mode.height); }; #ifndef RADIOLIB_GODMODE private: @@ -192,9 +192,9 @@ class SSTVClient { void* _audio; #endif - uint32_t _base; - SSTVMode_t _mode; - bool _firstLine; + uint32_t _base = 0; + SSTVMode_t _mode = Scottie1; + bool _firstLine = true; void tone(float freq, uint32_t len = 0); }; From d066f616b152bb242a7e94146ba68d4496018f26 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 13:18:48 +0200 Subject: [PATCH 167/455] [RTTY] Fixes from cppcheck scan --- src/protocols/RTTY/RTTY.cpp | 18 +++++++++--------- src/protocols/RTTY/RTTY.h | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 7b023f8e..ccd166cf 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -235,7 +235,7 @@ size_t RTTYClient::print(__FlashStringHelper* fstr) { size_t n = 0; if(_encoding == ITA2) { - ITA2String ita2 = str; + ITA2String ita2 = ITA2String(str); n = RTTYClient::print(ita2); } else if((_encoding == ASCII) || (_encoding == ASCII_EXTENDED)) { n = RTTYClient::write((uint8_t*)str, len); @@ -256,7 +256,7 @@ size_t RTTYClient::print(ITA2String& ita2) { size_t RTTYClient::print(const String& str) { size_t n = 0; if(_encoding == ITA2) { - ITA2String ita2 = str.c_str(); + ITA2String ita2 = ITA2String(str.c_str()); n = RTTYClient::print(ita2); } else if((_encoding == ASCII) || (_encoding == ASCII_EXTENDED)) { n = RTTYClient::write((uint8_t*)str.c_str(), str.length()); @@ -267,7 +267,7 @@ size_t RTTYClient::print(const String& str) { size_t RTTYClient::print(const char str[]) { size_t n = 0; if(_encoding == ITA2) { - ITA2String ita2 = str; + ITA2String ita2 = ITA2String(str); n = RTTYClient::print(ita2); } else if((_encoding == ASCII) || (_encoding == ASCII_EXTENDED)) { n = RTTYClient::write((uint8_t*)str, strlen(str)); @@ -278,7 +278,7 @@ size_t RTTYClient::print(const char str[]) { size_t RTTYClient::print(char c) { size_t n = 0; if(_encoding == ITA2) { - ITA2String ita2 = c; + ITA2String ita2 = ITA2String(c); n = RTTYClient::print(ita2); } else if((_encoding == ASCII) || (_encoding == ASCII_EXTENDED)) { n = RTTYClient::write(c); @@ -328,7 +328,7 @@ size_t RTTYClient::print(double n, int digits) { size_t RTTYClient::println(void) { size_t n = 0; if(_encoding == ITA2) { - ITA2String lf = "\r\n"; + ITA2String lf = ITA2String("\r\n"); n = RTTYClient::print(lf); } else if((_encoding == ASCII) || (_encoding == ASCII_EXTENDED)) { n = RTTYClient::write("\r\n"); @@ -437,7 +437,7 @@ size_t RTTYClient::printNumber(unsigned long n, uint8_t base) { size_t l = 0; if(_encoding == ITA2) { - ITA2String ita2 = str; + ITA2String ita2 = ITA2String(str); uint8_t* arr = ita2.byteArr(); l = RTTYClient::write(arr, ita2.length()); delete[] arr; @@ -461,7 +461,7 @@ size_t RTTYClient::printFloat(double number, uint8_t digits) { if(code[0] != 0x00) { if(_encoding == ITA2) { - ITA2String ita2 = code; + ITA2String ita2 = ITA2String(code); uint8_t* arr = ita2.byteArr(); n = RTTYClient::write(arr, ita2.length()); delete[] arr; @@ -474,7 +474,7 @@ size_t RTTYClient::printFloat(double number, uint8_t digits) { // Handle negative numbers if (number < 0.0) { if(_encoding == ITA2) { - ITA2String ita2 = "-"; + ITA2String ita2 = ITA2String("-"); uint8_t* arr = ita2.byteArr(); n += RTTYClient::write(arr, ita2.length()); delete[] arr; @@ -499,7 +499,7 @@ size_t RTTYClient::printFloat(double number, uint8_t digits) { // Print the decimal point, but only if there are digits beyond if(digits > 0) { if(_encoding == ITA2) { - ITA2String ita2 = "."; + ITA2String ita2 = ITA2String("."); uint8_t* arr = ita2.byteArr(); n += RTTYClient::write(arr, ita2.length()); delete[] arr; diff --git a/src/protocols/RTTY/RTTY.h b/src/protocols/RTTY/RTTY.h index 7dc54076..a7bfbf73 100644 --- a/src/protocols/RTTY/RTTY.h +++ b/src/protocols/RTTY/RTTY.h @@ -29,14 +29,14 @@ class ITA2String { \param c ASCII-encoded character to encode as ITA2. */ - ITA2String(char c); + explicit ITA2String(char c); /*! \brief Default string constructor. \param str ASCII-encoded string to encode as ITA2. */ - ITA2String(const char* str); + explicit ITA2String(const char* str); /*! \brief Default destructor. @@ -69,7 +69,7 @@ class ITA2String { size_t _len; size_t _ita2Len; - uint16_t getBits(char c); + static uint16_t getBits(char c); }; // supported encoding schemes @@ -89,7 +89,7 @@ class RTTYClient { \param phy Pointer to the wireless module providing PhysicalLayer communication. */ - RTTYClient(PhysicalLayer* phy); + explicit RTTYClient(PhysicalLayer* phy); #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! @@ -97,7 +97,7 @@ class RTTYClient { \param audio Pointer to the AFSK instance providing audio. */ - RTTYClient(AFSKClient* audio); + explicit RTTYClient(AFSKClient* audio); #endif // basic methods @@ -143,7 +143,7 @@ class RTTYClient { size_t println(void); size_t println(__FlashStringHelper*); size_t println(ITA2String &); - size_t println(const String &s); + size_t println(const String &); size_t println(const char[]); size_t println(char); size_t println(unsigned char, int = DEC); @@ -163,12 +163,12 @@ class RTTYClient { void* _audio; #endif - uint8_t _encoding; - uint32_t _base, _baseHz; - uint32_t _shift, _shiftHz; - uint32_t _bitDuration; - uint8_t _dataBits; - uint8_t _stopBits; + uint8_t _encoding = ASCII; + uint32_t _base = 0, _baseHz = 0; + uint32_t _shift = 0, _shiftHz = 0; + uint32_t _bitDuration = 0; + uint8_t _dataBits = 0; + uint8_t _stopBits = 0; void mark(); void space(); From 7e62dbd1d87b7c4a6b31a7da7a7c1616fc091a05 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 13:43:39 +0200 Subject: [PATCH 168/455] Fixes from cppcheck scan --- src/ISerial.h | 2 +- src/Module.cpp | 36 ++++++++++++++++++++++-------------- src/Module.h | 24 ++++++++++++------------ 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/ISerial.h b/src/ISerial.h index d086beaf..c8ecacbe 100644 --- a/src/ISerial.h +++ b/src/ISerial.h @@ -15,7 +15,7 @@ */ class ISerial { public: - ISerial(Module* mod); + explicit ISerial(Module* mod); void begin(long); bool listen(); diff --git a/src/Module.cpp b/src/Module.cpp index e24e6424..218be4fa 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -9,6 +9,7 @@ Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rs _spi = &RADIOLIB_DEFAULT_SPI; _spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0); _initInterface = true; + ModuleSerial = NULL; } Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio) { @@ -20,9 +21,10 @@ Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rs _spi = &RADIOLIB_DEFAULT_SPI; _spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0); _initInterface = true; + ModuleSerial = NULL; } -Module::Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* useSer, RADIOLIB_PIN_TYPE rst) { +Module::Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* serial, RADIOLIB_PIN_TYPE rst) { _cs = RADIOLIB_NC; _rx = rx; _tx = tx; @@ -31,10 +33,10 @@ Module::Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* useSe _initInterface = true; #ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - ModuleSerial = useSer; + ModuleSerial = serial; #else ModuleSerial = new SoftwareSerial(_rx, _tx); - (void)useSer; + (void)serial; #endif } @@ -47,6 +49,7 @@ Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rs _spi = &spi; _spiSettings = spiSettings; _initInterface = false; + ModuleSerial = NULL; } Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings) { @@ -58,9 +61,10 @@ Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rs _spi = &spi; _spiSettings = spiSettings; _initInterface = false; + ModuleSerial = NULL; } -Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi, SPISettings spiSettings, HardwareSerial* useSer) { +Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi, SPISettings spiSettings, HardwareSerial* serial) { _cs = cs; _rx = rx; _tx = tx; @@ -71,10 +75,10 @@ Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rs _initInterface = false; #ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - ModuleSerial = useSer; + ModuleSerial = serial; #else ModuleSerial = new SoftwareSerial(_rx, _tx); - (void)useSer; + (void)serial; #endif } @@ -259,16 +263,20 @@ void Module::SPItransfer(uint8_t cmd, uint8_t reg, uint8_t* dataOut, uint8_t* da // send data or get response if(cmd == SPIwriteCommand) { - for(size_t n = 0; n < numBytes; n++) { - _spi->transfer(dataOut[n]); - RADIOLIB_VERBOSE_PRINT(dataOut[n], HEX); - RADIOLIB_VERBOSE_PRINT('\t'); + if(dataOut != NULL) { + for(size_t n = 0; n < numBytes; n++) { + _spi->transfer(dataOut[n]); + RADIOLIB_VERBOSE_PRINT(dataOut[n], HEX); + RADIOLIB_VERBOSE_PRINT('\t'); + } } } else if (cmd == SPIreadCommand) { - for(size_t n = 0; n < numBytes; n++) { - dataIn[n] = _spi->transfer(0x00); - RADIOLIB_VERBOSE_PRINT(dataIn[n], HEX); - RADIOLIB_VERBOSE_PRINT('\t'); + if(dataIn != NULL) { + for(size_t n = 0; n < numBytes; n++) { + dataIn[n] = _spi->transfer(0x00); + RADIOLIB_VERBOSE_PRINT(dataIn[n], HEX); + RADIOLIB_VERBOSE_PRINT('\t'); + } } } RADIOLIB_VERBOSE_PRINTLN(); diff --git a/src/Module.h b/src/Module.h index 2a20b926..ccc571c0 100644 --- a/src/Module.h +++ b/src/Module.h @@ -21,18 +21,18 @@ class Module { /*! \brief UART-based module constructor. - \param tx Arduino pin to be used as Tx pin for SoftwareSerial communication. - \param rx Arduino pin to be used as Rx pin for SoftwareSerial communication. + \param tx Arduino pin to be used as Tx pin for SoftwareSerial communication. + \param serial HardwareSerial to be used on platforms that do not support SoftwareSerial. Defaults to Serial1. \param rst Arduino pin to be used as hardware reset for the module. Defaults to NC (unused). */ #ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - Module(RADIOLIB_PIN_TYPE tx, RADIOLIB_PIN_TYPE rx, HardwareSerial* serial = &RADIOLIB_HARDWARE_SERIAL_PORT, RADIOLIB_PIN_TYPE rst = RADIOLIB_NC); + Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* serial = &RADIOLIB_HARDWARE_SERIAL_PORT, RADIOLIB_PIN_TYPE rst = RADIOLIB_NC); #else - Module(RADIOLIB_PIN_TYPE tx, RADIOLIB_PIN_TYPE rx, HardwareSerial* serial = nullptr, RADIOLIB_PIN_TYPE rst = RADIOLIB_NC); + Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* serial = nullptr, RADIOLIB_PIN_TYPE rst = RADIOLIB_NC); #endif /*! @@ -408,18 +408,18 @@ class Module { #ifndef RADIOLIB_GODMODE private: #endif - RADIOLIB_PIN_TYPE _cs; - RADIOLIB_PIN_TYPE _tx; - RADIOLIB_PIN_TYPE _rx; - RADIOLIB_PIN_TYPE _irq; - RADIOLIB_PIN_TYPE _rst; + RADIOLIB_PIN_TYPE _cs = RADIOLIB_NC; + RADIOLIB_PIN_TYPE _tx = RADIOLIB_NC; + RADIOLIB_PIN_TYPE _rx = RADIOLIB_NC; + RADIOLIB_PIN_TYPE _irq = RADIOLIB_NC; + RADIOLIB_PIN_TYPE _rst = RADIOLIB_NC; - bool _initInterface; - SPIClass* _spi; + bool _initInterface = false; + SPIClass* _spi = NULL; SPISettings _spiSettings; bool _useRfSwitch = false; - RADIOLIB_PIN_TYPE _rxEn, _txEn; + RADIOLIB_PIN_TYPE _rxEn = RADIOLIB_NC, _txEn = RADIOLIB_NC; uint32_t _ATtimeout = 15000; }; From e3fb8959698d5989ff2dc2574a364c31cdf349ed Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:10:09 +0200 Subject: [PATCH 169/455] [CC1101] Fixes from cppcheck scan --- src/modules/CC1101/CC1101.cpp | 9 ++----- src/modules/CC1101/CC1101.h | 48 +++++++++++++++++------------------ 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index a2b56ac8..3d1f50dd 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -3,11 +3,6 @@ CC1101::CC1101(Module* module) : PhysicalLayer(CC1101_FREQUENCY_STEP_SIZE, CC1101_MAX_PACKET_LENGTH) { _mod = module; - _packetLengthQueried = false; - _packetLengthConfig = CC1101_LENGTH_CONFIG_VARIABLE; - _modulation = CC1101_MOD_FORMAT_2_FSK; - - _syncWordLength = 2; } int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLength) { @@ -598,7 +593,7 @@ int16_t CC1101::setOOK(bool enableOOK) { } -float CC1101::getRSSI() { +float CC1101::getRSSI() const { float rssi; if(_rawRSSI >= 128) { rssi = (((float)_rawRSSI - 256.0)/2.0) - 74.0; @@ -608,7 +603,7 @@ float CC1101::getRSSI() { return(rssi); } -uint8_t CC1101::getLQI() { +uint8_t CC1101::getLQI() const { return(_rawLQI); } diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 2ba3089e..f38b57c6 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -549,7 +549,7 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Blocking binary receive method. @@ -561,14 +561,14 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t receive(uint8_t* data, size_t len); + int16_t receive(uint8_t* data, size_t len) override; /*! \brief Sets the module to standby mode. \returns \ref status_codes */ - int16_t standby(); + int16_t standby() override; /*! \brief Starts direct mode transmission. @@ -577,14 +577,14 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmitDirect(uint32_t frf = 0); + int16_t transmitDirect(uint32_t frf = 0) override; /*! \brief Starts direct mode reception. \returns \ref status_codes */ - int16_t receiveDirect(); + int16_t receiveDirect() override; /*! \brief Stops direct mode. It is required to call this method to switch from direct transmissions to packet-based transmissions. @@ -633,7 +633,7 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Interrupt-driven receive method. GDO0 will be activated when full packet is received. @@ -651,7 +651,7 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t readData(uint8_t* data, size_t len); + int16_t readData(uint8_t* data, size_t len) override; // configuration methods @@ -689,7 +689,7 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t setFrequencyDeviation(float freqDev); + int16_t setFrequencyDeviation(float freqDev) override; /*! \brief Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm. @@ -771,14 +771,14 @@ class CC1101: public PhysicalLayer { \returns Last packet RSSI in dBm. */ - float getRSSI(); + float getRSSI() const; /*! \brief Gets LQI (Link Quality Indicator) of the last received packet. \returns Last packet LQI (lower is better). */ - uint8_t getLQI(); + uint8_t getLQI() const; /*! \brief Query modem for the packet length of received payload. @@ -787,7 +787,7 @@ class CC1101: public PhysicalLayer { \returns Length of last received packet in bytes. */ - size_t getPacketLength(bool update = true); + size_t getPacketLength(bool update = true) override; /*! \brief Set modem in fixed packet length mode. @@ -853,7 +853,7 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t setDataShaping(float sh); + int16_t setDataShaping(float sh) override; /*! \brief Sets transmission encoding. @@ -862,7 +862,7 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t setEncoding(uint8_t encoding); + int16_t setEncoding(uint8_t encoding) override; /*! \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. @@ -879,24 +879,24 @@ class CC1101: public PhysicalLayer { #endif Module* _mod; - float _freq; - uint8_t _rawRSSI; - uint8_t _rawLQI; - uint8_t _modulation; + float _freq = 0; + uint8_t _rawRSSI = 0; + uint8_t _rawLQI = 0; + uint8_t _modulation = CC1101_MOD_FORMAT_2_FSK; - size_t _packetLength; - bool _packetLengthQueried; - uint8_t _packetLengthConfig; + size_t _packetLength = 0; + bool _packetLengthQueried = false; + uint8_t _packetLengthConfig = CC1101_LENGTH_CONFIG_VARIABLE; - bool _promiscuous; + bool _promiscuous = false; bool _crcOn = true; - uint8_t _syncWordLength; - int8_t _power; + uint8_t _syncWordLength = 2; + int8_t _power = 0; int16_t config(); int16_t directMode(); - void getExpMant(float target, uint16_t mantOffset, uint8_t divExp, uint8_t expMax, uint8_t& exp, uint8_t& mant); + static void getExpMant(float target, uint16_t mantOffset, uint8_t divExp, uint8_t expMax, uint8_t& exp, uint8_t& mant); int16_t setPacketMode(uint8_t mode, uint8_t len); // SPI read overrides to set bit for burst write and status registers access From 7a8cde1d38366b57300b9e1501d7d61ce7cc7386 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:15:23 +0200 Subject: [PATCH 170/455] [ESP8266] Fixes from cppchekc scan --- src/modules/ESP8266/ESP8266.cpp | 6 +++--- src/modules/ESP8266/ESP8266.h | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index 7cfef116..c7e23b00 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -83,9 +83,9 @@ int16_t ESP8266::join(const char* ssid, const char* password) { int16_t ESP8266::openTransportConnection(const char* host, const char* protocol, uint16_t port, uint16_t tcpKeepAlive) { char portStr[6]; - sprintf(portStr, "%d", port); + sprintf(portStr, "%u", port); char tcpKeepAliveStr[6]; - sprintf(tcpKeepAliveStr, "%d", tcpKeepAlive); + sprintf(tcpKeepAliveStr, "%u", tcpKeepAlive); // build AT command const char* atStr = "AT+CIPSTART=\""; @@ -132,7 +132,7 @@ int16_t ESP8266::closeTransportConnection() { int16_t ESP8266::send(const char* data) { // build AT command char lenStr[12]; - sprintf(lenStr, "%d", strlen(data)); + sprintf(lenStr, "%u", (uint16_t)strlen(data)); const char* atStr = "AT+CIPSEND="; #ifdef RADIOLIB_STATIC_ONLY char cmd[RADIOLIB_STATIC_ARRAY_SIZE]; diff --git a/src/modules/ESP8266/ESP8266.h b/src/modules/ESP8266/ESP8266.h index 4169f12f..eff7b8b0 100644 --- a/src/modules/ESP8266/ESP8266.h +++ b/src/modules/ESP8266/ESP8266.h @@ -48,12 +48,12 @@ class ESP8266: public TransportLayer { int16_t join(const char* ssid, const char* password); // transport layer methods (implementations of purely virtual methods in TransportLayer class) - int16_t openTransportConnection(const char* host, const char* protocol, uint16_t port, uint16_t tcpKeepAlive = 0); - int16_t closeTransportConnection(); - int16_t send(const char* data); - int16_t send(uint8_t* data, uint32_t len); - size_t receive(uint8_t* data, size_t len, uint32_t timeout = 10000); - size_t getNumBytes(uint32_t timeout = 10000, size_t minBytes = 10); + int16_t openTransportConnection(const char* host, const char* protocol, uint16_t port, uint16_t tcpKeepAlive = 0) override; + int16_t closeTransportConnection() override; + int16_t send(const char* data) override; + int16_t send(uint8_t* data, uint32_t len) override; + size_t receive(uint8_t* data, size_t len, uint32_t timeout = 10000) override; + size_t getNumBytes(uint32_t timeout = 10000, size_t minBytes = 10) override; #ifndef RADIOLIB_GODMODE private: From 0a53900b5172772e23627f5ada51114ab6d615e0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:22:36 +0200 Subject: [PATCH 171/455] [RF69] Fixes from cppcheck scan --- src/modules/RF69/RF69.cpp | 13 +++---------- src/modules/RF69/RF69.h | 40 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index bebaba12..ba1548b8 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -3,14 +3,6 @@ RF69::RF69(Module* module) : PhysicalLayer(RF69_FREQUENCY_STEP_SIZE, RF69_MAX_PACKET_LENGTH) { _mod = module; - _tempOffset = 0; - - _packetLengthQueried = false; - _packetLengthConfig = RF69_PACKET_FORMAT_VARIABLE; - - _promiscuous = false; - - _syncWordLength = 2; } int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t power) { @@ -245,6 +237,7 @@ int16_t RF69::disableAES() { int16_t RF69::startReceive() { // set mode to standby int16_t state = setMode(RF69_STANDBY); + RADIOLIB_ASSERT(state); // set RX timeouts and DIO pin mapping state = _mod->SPIsetRegValue(RF69_REG_DIO_MAPPING_1, RF69_DIO0_PACK_PAYLOAD_READY, 7, 4); @@ -805,13 +798,13 @@ int16_t RF69::config() { // set Rx timeouts state = _mod->SPIsetRegValue(RF69_REG_RX_TIMEOUT_1, RF69_TIMEOUT_RX_START, 7, 0); - state = _mod->SPIsetRegValue(RF69_REG_RX_TIMEOUT_2, RF69_TIMEOUT_RSSI_THRESH, 7, 0); + state |= _mod->SPIsetRegValue(RF69_REG_RX_TIMEOUT_2, RF69_TIMEOUT_RSSI_THRESH, 7, 0); RADIOLIB_ASSERT(state); // enable improved fading margin state = _mod->SPIsetRegValue(RF69_REG_TEST_DAGC, RF69_CONTINUOUS_DAGC_LOW_BETA_OFF, 7, 0); - return(ERR_NONE); + return(state); } int16_t RF69::setPacketMode(uint8_t mode, uint8_t len) { diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index b82f607d..70815395 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -477,7 +477,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Blocking binary receive method. @@ -489,7 +489,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t receive(uint8_t* data, size_t len); + int16_t receive(uint8_t* data, size_t len) override; /*! \brief Sets the module to sleep mode. @@ -503,7 +503,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t standby(); + int16_t standby() override; /*! \brief Starts direct mode transmission. @@ -512,14 +512,14 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmitDirect(uint32_t frf = 0); + int16_t transmitDirect(uint32_t frf = 0) override; /*! \brief Starts direct mode reception. \returns \ref status_codes */ - int16_t receiveDirect(); + int16_t receiveDirect() override; /*! \brief Stops direct mode. It is required to call this method to switch from direct transmissions to packet-based transmissions. @@ -587,7 +587,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Interrupt-driven receive method. GDO0 will be activated when full packet is received. @@ -605,7 +605,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t readData(uint8_t* data, size_t len); + int16_t readData(uint8_t* data, size_t len) override; // configuration methods @@ -643,7 +643,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t setFrequencyDeviation(float freqDev); + int16_t setFrequencyDeviation(float freqDev) override; /*! \brief Sets output power. Allowed values range from -18 to 13 dBm for low power modules (RF69C/CW) or -2 to 20 dBm (RF69H/HC/HCW). @@ -715,7 +715,7 @@ class RF69: public PhysicalLayer { \returns Length of last received packet in bytes. */ - size_t getPacketLength(bool update = true); + size_t getPacketLength(bool update = true) override; /*! \brief Set modem in fixed packet length mode. @@ -777,7 +777,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t setDataShaping(float sh); + int16_t setDataShaping(float sh) override; /*! \brief Sets transmission encoding. @@ -786,7 +786,7 @@ class RF69: public PhysicalLayer { \returns \ref status_codes */ - int16_t setEncoding(uint8_t encoding); + int16_t setEncoding(uint8_t encoding) override; /*! \brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. @@ -810,18 +810,18 @@ class RF69: public PhysicalLayer { #endif Module* _mod; - float _br; - float _rxBw; - int16_t _tempOffset; - int8_t _power; + float _br = 0; + float _rxBw = 0; + int16_t _tempOffset = 0; + int8_t _power = 0; - size_t _packetLength; - bool _packetLengthQueried; - uint8_t _packetLengthConfig; + size_t _packetLength = 0; + bool _packetLengthQueried = false; + uint8_t _packetLengthConfig = RF69_PACKET_FORMAT_VARIABLE; - bool _promiscuous; + bool _promiscuous = false; - uint8_t _syncWordLength; + uint8_t _syncWordLength = 2; int16_t config(); int16_t directMode(); From 638bcfd32be0e49c021ca77a85bdb3887ca8a5a0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:24:14 +0200 Subject: [PATCH 172/455] [SX1231] Fixes from cppcheck scan --- src/modules/SX1231/SX1231.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX1231/SX1231.h b/src/modules/SX1231/SX1231.h index 0761fa8e..4597efa8 100644 --- a/src/modules/SX1231/SX1231.h +++ b/src/modules/SX1231/SX1231.h @@ -49,7 +49,7 @@ class SX1231: public RF69 { #ifndef RADIOLIB_GODMODE private: #endif - uint8_t _chipRevision; + uint8_t _chipRevision = 0; }; #endif From fed86b0742cef33db83ed6a0295cce8c1d2f9967 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:32:29 +0200 Subject: [PATCH 173/455] [SX126x] Fixes from cppcheck scan --- src/modules/SX126x/SX1262.cpp | 4 +--- src/modules/SX126x/SX1268.cpp | 4 +--- src/modules/SX126x/SX126x.cpp | 2 +- src/modules/SX126x/SX126x.h | 42 +++++++++++++++++------------------ 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index 3f086c9a..804c88a3 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -44,8 +44,6 @@ int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t SX1262::setFrequency(float freq, bool calibrate) { RADIOLIB_CHECK_RANGE(freq, 150.0, 960.0, ERR_INVALID_FREQUENCY); - int16_t state = ERR_NONE; - // calibrate image if(calibrate) { uint8_t data[2]; @@ -65,7 +63,7 @@ int16_t SX1262::setFrequency(float freq, bool calibrate) { data[0] = SX126X_CAL_IMG_430_MHZ_1; data[1] = SX126X_CAL_IMG_430_MHZ_2; } - state = SX126x::calibrateImage(data); + int16_t state = SX126x::calibrateImage(data); RADIOLIB_ASSERT(state); } diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index 7e6b3443..a6ec18ed 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -44,8 +44,6 @@ int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t SX1268::setFrequency(float freq, bool calibrate) { RADIOLIB_CHECK_RANGE(freq, 410.0, 810.0, ERR_INVALID_FREQUENCY); - int16_t state = ERR_NONE; - // calibrate image if(calibrate) { uint8_t data[2]; @@ -59,7 +57,7 @@ int16_t SX1268::setFrequency(float freq, bool calibrate) { data[0] = SX126X_CAL_IMG_430_MHZ_1; data[1] = SX126X_CAL_IMG_430_MHZ_2; } - state = SX126x::calibrateImage(data); + int16_t state = SX126x::calibrateImage(data); RADIOLIB_ASSERT(state); } diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 900a835c..f459e975 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1042,7 +1042,7 @@ int16_t SX126x::setWhitening(bool enabled, uint16_t initial) { return(state); } -float SX126x::getDataRate() { +float SX126x::getDataRate() const { return(_dataRate); } diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 26881c8c..09c22639 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -421,7 +421,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Blocking binary receive method. @@ -433,7 +433,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t receive(uint8_t* data, size_t len); + int16_t receive(uint8_t* data, size_t len) override; /*! \brief Starts direct mode transmission. @@ -450,7 +450,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t receiveDirect(); + int16_t receiveDirect() override; /*! \brief Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. @@ -473,7 +473,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t standby(); + int16_t standby() override; /*! \brief Sets the module to standby mode. @@ -510,7 +510,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Interrupt-driven receive method. DIO1 will be activated when full packet is received. @@ -555,7 +555,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t readData(uint8_t* data, size_t len); + int16_t readData(uint8_t* data, size_t len) override; // configuration methods @@ -629,7 +629,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setFrequencyDeviation(float freqDev); + int16_t setFrequencyDeviation(float freqDev) override; /*! \brief Sets FSK bit rate. Allowed values range from 0.6 to 300.0 kbps. @@ -656,7 +656,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setDataShaping(float sh); + int16_t setDataShaping(float sh) override; /*! \brief Sets FSK sync word in the form of array of up to 8 bytes. @@ -752,7 +752,7 @@ class SX126x: public PhysicalLayer { \returns Effective data rate in bps. */ - float getDataRate(); + float getDataRate() const; /*! \brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. @@ -775,7 +775,7 @@ class SX126x: public PhysicalLayer { \returns Length of last received packet in bytes. */ - size_t getPacketLength(bool update = true); + size_t getPacketLength(bool update = true) override; /*! \brief Set modem in fixed packet length mode. Available in FSK mode only. @@ -841,7 +841,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setEncoding(uint8_t encoding); + int16_t setEncoding(uint8_t encoding) override; /*! \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. @@ -899,20 +899,20 @@ class SX126x: public PhysicalLayer { #endif Module* _mod; - uint8_t _bw, _sf, _cr, _ldro, _crcType, _headerType; - uint16_t _preambleLength; - float _bwKhz; + uint8_t _bw = 0, _sf = 0, _cr = 0, _ldro = 0, _crcType = 0, _headerType = 0; + uint16_t _preambleLength = 0; + float _bwKhz = 0; - uint32_t _br, _freqDev; - uint8_t _rxBw, _pulseShape, _crcTypeFSK, _syncWordLength, _addrComp, _whitening, _packetType; - uint16_t _preambleLengthFSK; - float _rxBwKhz; + uint32_t _br = 0, _freqDev = 0; + uint8_t _rxBw = 0, _pulseShape = 0, _crcTypeFSK = 0, _syncWordLength = 0, _addrComp = 0, _whitening = 0, _packetType = 0; + uint16_t _preambleLengthFSK = 0; + float _rxBwKhz = 0; - float _dataRate; + float _dataRate = 0; - uint32_t _tcxoDelay; + uint32_t _tcxoDelay = 0; - size_t _implicitLen; + size_t _implicitLen = 0; int16_t config(uint8_t modem); From 95e7bdb7c67a0e6a24f55998ca5930b0872ac19a Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:48:51 +0200 Subject: [PATCH 174/455] [SX126x] Added missing override --- src/modules/SX126x/SX126x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 09c22639..ae92e253 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -442,7 +442,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmitDirect(uint32_t frf = 0); + int16_t transmitDirect(uint32_t frf = 0) override; /*! \brief Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as %SX126x series does not support direct mode reception. From a367a3fe699c64ca90f38950fe4c6f1c1eecf6ff Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:49:05 +0200 Subject: [PATCH 175/455] [SX127x] Fixes from cppcheck scan --- src/modules/SX127x/SX1272.cpp | 2 +- src/modules/SX127x/SX1272.h | 4 +-- src/modules/SX127x/SX1278.cpp | 2 +- src/modules/SX127x/SX1278.h | 4 +-- src/modules/SX127x/SX127x.cpp | 21 +++++++++------- src/modules/SX127x/SX127x.h | 46 +++++++++++++++++------------------ 6 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index b37cf75e..4384fd54 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -218,7 +218,7 @@ int16_t SX1272::setOutputPower(int8_t power) { state |= _mod->SPIsetRegValue(SX127X_REG_PA_CONFIG, SX127X_PA_SELECT_RFO, 7, 7); state |= _mod->SPIsetRegValue(SX127X_REG_PA_CONFIG, (power + 1), 3, 0); state |= _mod->SPIsetRegValue(SX1272_REG_PA_DAC, SX127X_PA_BOOST_OFF, 2, 0); - } else if((power >= 2) && (power <= 17)) { + } else if(power <= 17) { // power is 2 - 17 dBm, enable PA1 + PA2 on PA_BOOST state |= _mod->SPIsetRegValue(SX127X_REG_PA_CONFIG, SX127X_PA_SELECT_BOOST, 7, 7); state |= _mod->SPIsetRegValue(SX127X_REG_PA_CONFIG, (power - 2), 3, 0); diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index 547f2905..7538c845 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -159,7 +159,7 @@ class SX1272: public SX127x { /*! \brief Reset method. Will reset the chip to the default state using RST pin. */ - void reset(); + void reset() override; // configuration methods @@ -226,7 +226,7 @@ class SX1272: public SX127x { \returns \ref status_codes */ - int16_t setDataShaping(float sh); + int16_t setDataShaping(float sh) override; /*! \brief Sets filter cutoff frequency that will be used for data shaping. diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 698634f8..8e70be39 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -290,7 +290,7 @@ int16_t SX1278::setOutputPower(int8_t power) { state |= _mod->SPIsetRegValue(SX127X_REG_PA_CONFIG, SX127X_PA_SELECT_RFO, 7, 7); state |= _mod->SPIsetRegValue(SX127X_REG_PA_CONFIG, SX1278_LOW_POWER | (power + 3), 6, 0); state |= _mod->SPIsetRegValue(SX1278_REG_PA_DAC, SX127X_PA_BOOST_OFF, 2, 0); - } else if((power >= 2) && (power <= 17)) { + } else if(power <= 17) { // power is 2 - 17 dBm, enable PA1 + PA2 on PA_BOOST state |= _mod->SPIsetRegValue(SX127X_REG_PA_CONFIG, SX127X_PA_SELECT_BOOST, 7, 7); state |= _mod->SPIsetRegValue(SX127X_REG_PA_CONFIG, SX1278_MAX_POWER | (power - 2), 6, 0); diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index e2c5220a..ccd47da8 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -168,7 +168,7 @@ class SX1278: public SX127x { /*! \brief Reset method. Will reset the chip to the default state using RST pin. */ - void reset(); + void reset() override; // configuration methods @@ -235,7 +235,7 @@ class SX1278: public SX127x { \returns \ref status_codes */ - int16_t setDataShaping(float sh); + int16_t setDataShaping(float sh) override; /*! \brief Sets filter cutoff frequency that will be used for data shaping. diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index c3d2dd7e..79c2ab65 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -3,7 +3,6 @@ SX127x::SX127x(Module* mod) : PhysicalLayer(SX127X_FREQUENCY_STEP_SIZE, SX127X_MAX_PACKET_LENGTH) { _mod = mod; - _packetLengthQueried = false; } int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimit, uint16_t preambleLength) { @@ -122,6 +121,7 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) { // set mode to standby int16_t state = setMode(SX127X_STANDBY); + RADIOLIB_ASSERT(state); int16_t modem = getActiveModem(); uint32_t start = 0; @@ -188,6 +188,7 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) { int16_t SX127x::receive(uint8_t* data, size_t len) { // set mode to standby int16_t state = setMode(SX127X_STANDBY); + RADIOLIB_ASSERT(state); int16_t modem = getActiveModem(); if(modem == SX127X_LORA) { @@ -284,7 +285,7 @@ int16_t SX127x::standby() { return(setMode(SX127X_STANDBY)); } -int16_t SX127x::transmitDirect(uint32_t FRF) { +int16_t SX127x::transmitDirect(uint32_t frf) { // check modem if(getActiveModem() != SX127X_FSK_OOK) { return(ERR_WRONG_MODEM); @@ -294,10 +295,10 @@ int16_t SX127x::transmitDirect(uint32_t FRF) { _mod->setRfSwitchState(LOW, HIGH); // user requested to start transmitting immediately (required for RTTY) - if(FRF != 0) { - _mod->SPIwriteRegister(SX127X_REG_FRF_MSB, (FRF & 0xFF0000) >> 16); - _mod->SPIwriteRegister(SX127X_REG_FRF_MID, (FRF & 0x00FF00) >> 8); - _mod->SPIwriteRegister(SX127X_REG_FRF_LSB, FRF & 0x0000FF); + if(frf != 0) { + _mod->SPIwriteRegister(SX127X_REG_FRF_MSB, (frf & 0xFF0000) >> 16); + _mod->SPIwriteRegister(SX127X_REG_FRF_MID, (frf & 0x00FF00) >> 8); + _mod->SPIwriteRegister(SX127X_REG_FRF_LSB, frf & 0x0000FF); return(setMode(SX127X_TX)); } @@ -352,11 +353,12 @@ int16_t SX127x::packetMode() { int16_t SX127x::startReceive(uint8_t len, uint8_t mode) { // set mode to standby int16_t state = setMode(SX127X_STANDBY); + RADIOLIB_ASSERT(state); int16_t modem = getActiveModem(); if(modem == SX127X_LORA) { // set DIO pin mapping - state |= _mod->SPIsetRegValue(SX127X_REG_DIO_MAPPING_1, SX127X_DIO0_RX_DONE | SX127X_DIO1_RX_TIMEOUT, 7, 4); + state = _mod->SPIsetRegValue(SX127X_REG_DIO_MAPPING_1, SX127X_DIO0_RX_DONE | SX127X_DIO1_RX_TIMEOUT, 7, 4); // set expected packet length for SF6 if(_sf == 6) { @@ -373,7 +375,8 @@ int16_t SX127x::startReceive(uint8_t len, uint8_t mode) { } else if(modem == SX127X_FSK_OOK) { // set DIO pin mapping - state |= _mod->SPIsetRegValue(SX127X_REG_DIO_MAPPING_1, SX127X_DIO0_PACK_PAYLOAD_READY, 7, 6); + state = _mod->SPIsetRegValue(SX127X_REG_DIO_MAPPING_1, SX127X_DIO0_PACK_PAYLOAD_READY, 7, 6); + RADIOLIB_ASSERT(state); // clear interrupt flags clearIRQFlags(); @@ -651,7 +654,7 @@ float SX127x::getSNR() { return(rawSNR / 4.0); } -float SX127x::getDataRate() { +float SX127x::getDataRate() const { return(_dataRate); } diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 0023e4d8..ac22a49b 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -602,7 +602,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Binary receive method. Will attempt to receive arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem. @@ -614,7 +614,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t receive(uint8_t* data, size_t len); + int16_t receive(uint8_t* data, size_t len) override; /*! \brief Performs scan for valid %LoRa preamble in the current channel. @@ -636,17 +636,17 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t standby(); + int16_t standby() override; /*! \brief Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data). While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode. - \param FRF 24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY. + \param frf 24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY. \returns \ref status_codes */ - int16_t transmitDirect(uint32_t FRF = 0); + int16_t transmitDirect(uint32_t frf = 0) override; /*! \brief Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). @@ -654,7 +654,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t receiveDirect(); + int16_t receiveDirect() override; /*! \brief Disables direct mode and enables packet mode, allowing the module to receive packets. Can only be activated in FSK mode. @@ -700,7 +700,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Interrupt-driven receive method. DIO0 will be activated when full valid packet is received. @@ -722,7 +722,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t readData(uint8_t* data, size_t len); + int16_t readData(uint8_t* data, size_t len) override; // configuration methods @@ -775,7 +775,7 @@ class SX127x: public PhysicalLayer { \returns Last packet data rate in bps (bits per second). */ - float getDataRate(); + float getDataRate() const; /*! \brief Sets FSK bit rate. Allowed values range from 1.2 to 300 kbps. Only available in FSK mode. @@ -793,7 +793,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setFrequencyDeviation(float freqDev); + int16_t setFrequencyDeviation(float freqDev) override; /*! \brief Sets FSK receiver bandwidth. Allowed values range from 2.6 to 250 kHz. Only available in FSK mode. @@ -856,7 +856,7 @@ class SX127x: public PhysicalLayer { \returns Length of last received packet in bytes. */ - size_t getPacketLength(bool update = true); + size_t getPacketLength(bool update = true) override; /*! \brief Set modem in fixed packet length mode. Available in FSK mode only. @@ -895,7 +895,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setEncoding(uint8_t encoding); + int16_t setEncoding(uint8_t encoding) override; /*! \brief Reads currently active IRQ flags, can be used to check which event caused an interrupt. @@ -936,13 +936,13 @@ class SX127x: public PhysicalLayer { #endif Module* _mod; - float _freq; - float _bw; - uint8_t _sf; - uint8_t _cr; - float _br; - float _rxBw; - bool _ook; + float _freq = 0; + float _bw = 0; + uint8_t _sf = 0; + uint8_t _cr = 0; + float _br = 0; + float _rxBw = 0; + bool _ook = false; int16_t setFrequencyRaw(float newFreq); int16_t config(); @@ -954,10 +954,10 @@ class SX127x: public PhysicalLayer { #ifndef RADIOLIB_GODMODE private: #endif - float _dataRate; - size_t _packetLength; - bool _packetLengthQueried; // FSK packet length is the first byte in FIFO, length can only be queried once - uint8_t _packetLengthConfig; + float _dataRate = 0; + size_t _packetLength = 0; + bool _packetLengthQueried = false; // FSK packet length is the first byte in FIFO, length can only be queried once + uint8_t _packetLengthConfig = SX127X_PACKET_VARIABLE; bool findChip(uint8_t ver); int16_t setMode(uint8_t mode); From b642fd1a8de9aa87e08f4fb25cf9b3936bc5fa47 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:54:01 +0200 Subject: [PATCH 176/455] [SX128x] Fixes from cppcheck scan --- src/modules/SX128x/SX128x.cpp | 2 +- src/modules/SX128x/SX128x.h | 42 +++++++++++++++++------------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 1dda7d8c..a5fec200 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -894,7 +894,7 @@ int16_t SX128x::setCRC(uint8_t len, uint32_t initial, uint16_t polynomial) { // check active modem uint8_t modem = getPacketType(); - int16_t state = ERR_NONE; + int16_t state; if((modem == SX128X_PACKET_TYPE_GFSK) || (modem == SX128X_PACKET_TYPE_FLRC)) { // update packet parameters if(modem == SX128X_PACKET_TYPE_GFSK) { diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index bd403a29..873525fa 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -446,7 +446,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Blocking binary receive method. @@ -458,7 +458,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t receive(uint8_t* data, size_t len); + int16_t receive(uint8_t* data, size_t len) override; /*! \brief Starts direct mode transmission. @@ -467,7 +467,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmitDirect(uint32_t frf = 0); + int16_t transmitDirect(uint32_t frf = 0) override; /*! \brief Starts direct mode reception. Only implemented for PhysicalLayer compatibility, as %SX128x series does not support direct mode reception. @@ -475,7 +475,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t receiveDirect(); + int16_t receiveDirect() override; /*! \brief Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. @@ -498,7 +498,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t standby(); + int16_t standby() override; /*! \brief Sets the module to standby mode. @@ -535,7 +535,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Interrupt-driven receive method. DIO1 will be activated when full packet is received. @@ -555,7 +555,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t readData(uint8_t* data, size_t len); + int16_t readData(uint8_t* data, size_t len) override; // configuration methods @@ -631,7 +631,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setFrequencyDeviation(float freqDev); + int16_t setFrequencyDeviation(float freqDev) override; /*! \brief Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are 0.5 and 1.0. Set to 0 to disable shaping. @@ -640,7 +640,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setDataShaping(float dataShaping); + int16_t setDataShaping(float dataShaping) override; /*! \brief Sets FSK/FLRC sync word in the form of array of up to 5 bytes (FSK). For FLRC modem, the sync word must be exactly 4 bytes long @@ -705,7 +705,7 @@ class SX128x: public PhysicalLayer { \returns Length of last received packet in bytes. */ - size_t getPacketLength(bool update = true); + size_t getPacketLength(bool update = true) override; /*! \brief Get expected time-on-air for a given size of payload. @@ -739,7 +739,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setEncoding(uint8_t encoding); + int16_t setEncoding(uint8_t encoding) override; /*! \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. @@ -757,9 +757,9 @@ class SX128x: public PhysicalLayer { Module* _mod; // cached LoRa parameters - float _bwKhz; - uint8_t _bw, _sf, _cr; - uint8_t _preambleLengthLoRa, _headerType, _payloadLen, _crcLoRa; + float _bwKhz = 0; + uint8_t _bw = 0, _sf = 0, _cr = 0; + uint8_t _preambleLengthLoRa = 0, _headerType = 0, _payloadLen = 0, _crcLoRa = 0; // SX128x SPI command implementations uint8_t getStatus(); @@ -790,19 +790,19 @@ class SX128x: public PhysicalLayer { private: #endif // common parameters - uint8_t _pwr; + uint8_t _pwr = 0; // cached GFSK parameters - float _modIndexReal; - uint16_t _brKbps; - uint8_t _br, _modIndex, _shaping; - uint8_t _preambleLengthGFSK, _syncWordLen, _syncWordMatch, _crcGFSK, _whitening; + float _modIndexReal = 0; + uint16_t _brKbps = 0; + uint8_t _br = 0, _modIndex = 0, _shaping = 0; + uint8_t _preambleLengthGFSK = 0, _syncWordLen = 0, _syncWordMatch = 0, _crcGFSK = 0, _whitening = 0; // cached FLRC parameters - uint8_t _crFLRC; + uint8_t _crFLRC = 0; // cached BLE parameters - uint8_t _connectionState, _crcBLE, _bleTestPayload; + uint8_t _connectionState = 0, _crcBLE = 0, _bleTestPayload = 0; int16_t config(uint8_t modem); From 7e9686fcaa457cf2ca54de729b65adab666ccc5c Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 14:59:37 +0200 Subject: [PATCH 177/455] [Si443x] Fixes from cppcheck scan --- src/modules/Si443x/Si443x.cpp | 8 +++----- src/modules/Si443x/Si443x.h | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 45734b3a..94ca8446 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -3,8 +3,6 @@ Si443x::Si443x(Module* mod) : PhysicalLayer(SI443X_FREQUENCY_STEP_SIZE, SI443X_MAX_PACKET_LENGTH) { _mod = mod; - - _packetLengthQueried = false; } int16_t Si443x::begin(float br, float freqDev, float rxBw) { @@ -622,15 +620,15 @@ int16_t Si443x::updateClockRecovery() { uint8_t rxOsr_int = (uint8_t)rxOsr; uint8_t rxOsr_dec = 0; float rxOsr_temp = rxOsr; - if(rxOsr_temp - rxOsr_int >= 0.5) { + if((rxOsr_temp - rxOsr_int) >= 0.5) { rxOsr_dec |= 0x04; rxOsr_temp -= 0.5; } - if(rxOsr_temp - rxOsr_int >= 0.25) { + if((rxOsr_temp - rxOsr_int) >= 0.25) { rxOsr_dec |= 0x02; rxOsr_temp -= 0.25; } - if(rxOsr_temp - rxOsr_int >= 0.125) { + if((rxOsr_temp - rxOsr_int) >= 0.125) { rxOsr_dec |= 0x01; rxOsr_temp -= 0.125; } diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 7fbe26b6..29417363 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -597,7 +597,7 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Binary receive method. Will attempt to receive arbitrary binary data up to 64 bytes long. @@ -609,7 +609,7 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t receive(uint8_t* data, size_t len); + int16_t receive(uint8_t* data, size_t len) override; /*! \brief Sets the module to sleep to save power. %Module will not be able to transmit or receive any data while in sleep mode. @@ -624,7 +624,7 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t standby(); + int16_t standby() override; /*! \brief Enables direct transmission mode. While in direct mode, the module will not be able to transmit or receive packets. @@ -633,14 +633,14 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmitDirect(uint32_t frf = 0); + int16_t transmitDirect(uint32_t frf = 0) override; /*! \brief Enables direct reception mode. While in direct mode, the module will not be able to transmit or receive packets. \returns \ref status_codes */ - int16_t receiveDirect(); + int16_t receiveDirect() override; /*! \brief Disables direct mode and enables packet mode, allowing the module to receive packets. @@ -674,7 +674,7 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0); + int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override; /*! \brief Interrupt-driven receive method. IRQ will be activated when full valid packet is received. @@ -692,7 +692,7 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t readData(uint8_t* data, size_t len); + int16_t readData(uint8_t* data, size_t len) override; // configuration methods @@ -712,7 +712,7 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setFrequencyDeviation(float freqDev); + int16_t setFrequencyDeviation(float freqDev) override; /*! \brief Sets receiver bandwidth. Allowed values range from 2.6 to 620.7 kHz. @@ -739,7 +739,7 @@ class Si443x: public PhysicalLayer { \returns Length of last received packet in bytes. */ - size_t getPacketLength(bool update = true); + size_t getPacketLength(bool update = true) override; /*! \brief Sets transmission encoding. Only available in FSK mode. @@ -748,7 +748,7 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setEncoding(uint8_t encoding); + int16_t setEncoding(uint8_t encoding) override; /*! \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. @@ -758,7 +758,7 @@ class Si443x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setDataShaping(float sh); + int16_t setDataShaping(float sh) override; /*! \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. @@ -775,11 +775,11 @@ class Si443x: public PhysicalLayer { #endif Module* _mod; - float _br; - float _freqDev; + float _br = 0; + float _freqDev = 0; - size_t _packetLength; - bool _packetLengthQueried; + size_t _packetLength = 0; + bool _packetLengthQueried = false; int16_t setFrequencyRaw(float newFreq); From 57b46386e8644b2b1256a789df8f4d10eea3fbcd Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:03:26 +0200 Subject: [PATCH 178/455] [XBee] Fixes from cppcheck scan --- src/modules/XBee/XBee.cpp | 5 +---- src/modules/XBee/XBee.h | 12 ++++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/modules/XBee/XBee.cpp b/src/modules/XBee/XBee.cpp index 919de28e..d5d4b20c 100644 --- a/src/modules/XBee/XBee.cpp +++ b/src/modules/XBee/XBee.cpp @@ -3,9 +3,6 @@ XBee::XBee(Module* mod) { _mod = mod; - _frameID = 0x01; - _frameLength = 0; - _frameHeaderProcessed = false; } int16_t XBee::begin(long speed) { @@ -97,9 +94,9 @@ size_t XBee::available() { return(0); } - uint8_t header[3]; if(!_frameHeaderProcessed) { // read frame header + uint8_t header[3]; for(uint8_t i = 0; i < 3; i++) { header[i] = _mod->ModuleSerial->read(); } diff --git a/src/modules/XBee/XBee.h b/src/modules/XBee/XBee.h index e9c970b2..15d7cb92 100644 --- a/src/modules/XBee/XBee.h +++ b/src/modules/XBee/XBee.h @@ -79,7 +79,7 @@ class XBeeSerial: public ISerial { \param panId 8-byte PAN ID to be used, in the form of uppercase hexadecimal string (i.e. 16 characters). */ - int16_t setPanId(const char* panID); + int16_t setPanId(const char* panId); #ifndef RADIOLIB_GODMODE private: @@ -170,22 +170,22 @@ class XBee { \param panId 8-byte PAN ID to be used, in the form of uppercase hexadecimal string (i.e. 16 characters). */ - int16_t setPanId(uint8_t* panID); + int16_t setPanId(uint8_t* panId); #ifndef RADIOLIB_GODMODE private: #endif Module* _mod; - uint8_t _frameID; - size_t _frameLength; - bool _frameHeaderProcessed; + uint8_t _frameID = 0x01; + size_t _frameLength = 0; + bool _frameHeaderProcessed = false; #ifdef RADIOLIB_STATIC_ONLY char _packetData[RADIOLIB_STATIC_ARRAY_SIZE]; #else char* _packetData = new char[0]; #endif - uint8_t _packetSource[8]; + uint8_t _packetSource[8] = {0, 0, 0, 0, 0, 0, 0, 0}; int16_t confirmChanges(); From e60435d57c2130892e31bebc0440e77c6cd75031 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:09:14 +0200 Subject: [PATCH 179/455] Updated module template --- extras/ModuleTemplate.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/extras/ModuleTemplate.h b/extras/ModuleTemplate.h index dcb7b0f9..4d957cb0 100644 --- a/extras/ModuleTemplate.h +++ b/extras/ModuleTemplate.h @@ -12,14 +12,16 @@ If at any point you are unsure about the required style, please refer to the rest of the modules. */ +#if !defined(_RADIOLIB__H) && !defined(RADIOLIB_EXCLUDE_) #ifndef _RADIOLIB__H #define _RADIOLIB__H /* - Header file for each module MUST include Module.h. + Header file for each module MUST include Module.h and TypeDef.h in the src folder. The header file MAY include additional header files. */ -#include "Module.h" +#include "../../Module.h" +#include "../../TypeDef.h" /* Only use the following include if the module implements methods for OSI transport layer control. @@ -29,7 +31,7 @@ You also MUST provide crystal oscillator frequency and frequency configuration divisor step resolution to the TransportLayer constructor. */ -//#include "../protocols/TransportLayer.h" +//#include "../../protocols/PhysicalLayer/TransportLayer.h" /* Only use the following include if the module implements methods for OSI physical layer control. @@ -37,7 +39,7 @@ In this case, your class MUST implement all virtual methods of PhysicalLayer class. */ -//#include "../protocols/PhysicalLayer.h" +//#include "../../protocols/PhysicalLayer/PhysicalLayer.h" /* Register map @@ -74,7 +76,7 @@ class { The class MAY implement additional overloaded constructors. */ // constructor - (Module* module); + (Module* mod); /* The class MUST implement at least one basic method called "begin". @@ -105,3 +107,5 @@ class { }; #endif + +#endif From 75f2db65099b7db03aa2e1d44a9d10107282fac8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:10:02 +0200 Subject: [PATCH 180/455] [nRF24] Fixes from cppcheck scan --- src/modules/nRF24/nRF24.h | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index 55802bbe..d41e683f 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -189,7 +189,7 @@ class nRF24: public PhysicalLayer { \param mod Instance of Module that will be used to communicate with the radio. */ - nRF24(Module* module); + nRF24(Module* mod); // basic methods @@ -220,7 +220,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t standby(); + int16_t standby() override; /*! \brief Blocking binary transmit method. @@ -234,7 +234,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmit(uint8_t* data, size_t len, uint8_t addr); + int16_t transmit(uint8_t* data, size_t len, uint8_t addr) override; /*! \brief Blocking binary receive method. @@ -246,7 +246,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t receive(uint8_t* data, size_t len); + int16_t receive(uint8_t* data, size_t len) override; /*! \brief Starts direct mode transmission. @@ -255,14 +255,14 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t transmitDirect(uint32_t frf = 0); + int16_t transmitDirect(uint32_t frf = 0) override; /*! \brief Dummy direct mode reception method, to ensure PhysicalLayer compatibility. \returns \ref status_codes */ - int16_t receiveDirect(); + int16_t receiveDirect() override; // interrupt methods @@ -285,7 +285,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr); + int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr) override; /*! \brief Interrupt-driven receive method. IRQ will be activated when full packet is received. @@ -303,7 +303,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t readData(uint8_t* data, size_t len); + int16_t readData(uint8_t* data, size_t len) override; // configuration methods @@ -406,7 +406,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t setFrequencyDeviation(float freqDev); + int16_t setFrequencyDeviation(float freqDev) override; /*! \brief Query modem for the packet length of received payload. @@ -415,8 +415,7 @@ class nRF24: public PhysicalLayer { \returns Length of last received packet in bytes. */ - size_t getPacketLength(bool update = true); - + size_t getPacketLength(bool update = true) override; /*! \brief Enable CRC filtering and generation. @@ -454,7 +453,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t setDataShaping(float sh); + int16_t setDataShaping(float sh) override; /*! \brief Dummy encoding configuration method, to ensure PhysicalLayer compatibility. @@ -463,14 +462,14 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t setEncoding(uint8_t encoding); + int16_t setEncoding(uint8_t encoding) override; #ifndef RADIOLIB_GODMODE private: #endif Module* _mod; - uint8_t _addrWidth; + uint8_t _addrWidth = 0; int16_t config(); void clearIRQ(); From 36d41671613330fa0312bc281e07eaac23539bca Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:23:57 +0200 Subject: [PATCH 181/455] [AX25] Fixes from cppcheck scan --- src/protocols/AX25/AX25.cpp | 7 +++---- src/protocols/AX25/AX25.h | 16 ++++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index e73021a6..edde12c4 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -74,8 +74,7 @@ int16_t AX25Frame::setRepeaters(char** repeaterCallsigns, uint8_t* repeaterSSIDs } // check repeater configuration - if(!(((repeaterCallsigns == NULL) && (repeaterSSIDs == NULL) && (numRepeaters == 0)) || - ((repeaterCallsigns != NULL) && (repeaterSSIDs != NULL) && (numRepeaters != 0)))) { + if((repeaterCallsigns == NULL) || (repeaterSSIDs == NULL)) { return(ERR_INVALID_NUM_REPEATERS); } for(uint16_t i = 0; i < numRepeaters; i++) { @@ -390,8 +389,8 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { https://creativecommons.org/licenses/by-sa/4.0/ */ uint16_t AX25Client::getFrameCheckSequence(uint8_t* buff, size_t len) { - uint8_t outBit = 0; - uint16_t mask = 0x0000; + uint8_t outBit; + uint16_t mask; uint16_t shiftReg = CRC_CCITT_INIT; for(size_t i = 0; i < len; i++) { diff --git a/src/protocols/AX25/AX25.h b/src/protocols/AX25/AX25.h index c751a7c1..7f7ed959 100644 --- a/src/protocols/AX25/AX25.h +++ b/src/protocols/AX25/AX25.h @@ -266,7 +266,7 @@ class AX25Client { \param phy Pointer to the wireless module providing PhysicalLayer communication. */ - AX25Client(PhysicalLayer* phy); + explicit AX25Client(PhysicalLayer* phy); #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! @@ -274,7 +274,7 @@ class AX25Client { \param audio Pointer to the AFSK instance providing audio. */ - AX25Client(AFSKClient* audio); + explicit AX25Client(AFSKClient* audio); #endif // basic methods @@ -324,13 +324,13 @@ class AX25Client { void* _audio; #endif - char _srcCallsign[AX25_MAX_CALLSIGN_LEN + 1]; - uint8_t _srcSSID; - uint16_t _preambleLen; + char _srcCallsign[AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0}; + uint8_t _srcSSID = 0; + uint16_t _preambleLen = 0; - uint16_t getFrameCheckSequence(uint8_t* buff, size_t len); - uint8_t flipBits(uint8_t b); - uint16_t flipBits16(uint16_t i); + static uint16_t getFrameCheckSequence(uint8_t* buff, size_t len); + static uint8_t flipBits(uint8_t b); + static uint16_t flipBits16(uint16_t i); }; #endif From 02bb36e1afdbb9b837b99ded8ecf5877ddc84648 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:26:55 +0200 Subject: [PATCH 182/455] [Hell] Fixes from cppcheck scan --- src/protocols/Hellschreiber/Hellschreiber.cpp | 3 ++- src/protocols/Hellschreiber/Hellschreiber.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/protocols/Hellschreiber/Hellschreiber.cpp b/src/protocols/Hellschreiber/Hellschreiber.cpp index 5c6483b3..d2355480 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.cpp +++ b/src/protocols/Hellschreiber/Hellschreiber.cpp @@ -153,7 +153,8 @@ size_t HellClient::print(double n, int digits) { } size_t HellClient::println(void) { - return(0); + // Hellschreiber has no concept of "line ending", print one space instead + return(HellClient::print(' ')); } size_t HellClient::println(__FlashStringHelper* fstr) { diff --git a/src/protocols/Hellschreiber/Hellschreiber.h b/src/protocols/Hellschreiber/Hellschreiber.h index a70e74e7..74eacb33 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.h +++ b/src/protocols/Hellschreiber/Hellschreiber.h @@ -136,7 +136,7 @@ class HellClient { size_t println(void); size_t println(__FlashStringHelper*); - size_t println(const String &s); + size_t println(const String &); size_t println(const char[]); size_t println(char); size_t println(unsigned char, int = DEC); @@ -156,8 +156,8 @@ class HellClient { void* _audio; #endif - uint32_t _base, _baseHz; - uint32_t _pixelDuration; + uint32_t _base = 0, _baseHz = 0; + uint32_t _pixelDuration = 0; size_t printNumber(unsigned long, uint8_t); size_t printFloat(double, uint8_t); From 0c7f597b7f7af9dff5f4b9461eb3672d0311f9d1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:28:02 +0200 Subject: [PATCH 183/455] [Hell] Made ctors explicit --- src/protocols/Hellschreiber/Hellschreiber.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocols/Hellschreiber/Hellschreiber.h b/src/protocols/Hellschreiber/Hellschreiber.h index 74eacb33..1f8087e1 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.h +++ b/src/protocols/Hellschreiber/Hellschreiber.h @@ -90,7 +90,7 @@ class HellClient { \param phy Pointer to the wireless module providing PhysicalLayer communication. */ - HellClient(PhysicalLayer* phy); + explicit HellClient(PhysicalLayer* phy); #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! @@ -98,7 +98,7 @@ class HellClient { \param audio Pointer to the AFSK instance providing audio. */ - HellClient(AFSKClient* audio); + explicit HellClient(AFSKClient* audio); #endif // basic methods From f394912c920f819bde3f10f4ecf5fb71ba72fc29 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:29:37 +0200 Subject: [PATCH 184/455] [HTTP] Fixes from cppcheck scan --- src/protocols/HTTP/HTTP.cpp | 2 +- src/protocols/HTTP/HTTP.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocols/HTTP/HTTP.cpp b/src/protocols/HTTP/HTTP.cpp index 6f4cd23d..63b2fe95 100644 --- a/src/protocols/HTTP/HTTP.cpp +++ b/src/protocols/HTTP/HTTP.cpp @@ -142,7 +142,7 @@ int16_t HTTPClient::post(const char* url, const char* content, String& response, // build the POST request char contentLengthStr[12]; - sprintf(contentLengthStr, "%d", strlen(content)); + sprintf(contentLengthStr, "%u", (uint16_t)strlen(content)); char* request = new char[strlen(endpoint) + strlen(host) + strlen(contentType) + strlen(contentLengthStr) + strlen(content) + 64 + 1]; strcpy(request, "POST "); strcat(request, endpoint); diff --git a/src/protocols/HTTP/HTTP.h b/src/protocols/HTTP/HTTP.h index edc7d6f1..ae9a3888 100644 --- a/src/protocols/HTTP/HTTP.h +++ b/src/protocols/HTTP/HTTP.h @@ -19,7 +19,7 @@ class HTTPClient { \param port Port to be used for HTTP. Defaults to 80. */ - HTTPClient(TransportLayer* tl, uint16_t port = 80); + explicit HTTPClient(TransportLayer* tl, uint16_t port = 80); /*! \brief Sends HTTP GET request. From cb0cf75c9958f37378e730eaf923b82ba5d193a8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:32:32 +0200 Subject: [PATCH 185/455] [MQTT] Fixes from cppcheck scan --- src/protocols/MQTT/MQTT.cpp | 3 --- src/protocols/MQTT/MQTT.h | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/protocols/MQTT/MQTT.cpp b/src/protocols/MQTT/MQTT.cpp index cc561157..cb62321c 100644 --- a/src/protocols/MQTT/MQTT.cpp +++ b/src/protocols/MQTT/MQTT.cpp @@ -96,7 +96,6 @@ int16_t MQTTClient::connect(const char* host, const char* clientId, const char* packet[pos++] = (passwordLen & 0xFF00) >> 8;; packet[pos++] = passwordLen & 0x00FF; memcpy(packet + pos, password, passwordLen); - pos += passwordLen; } // create TCP connection @@ -198,7 +197,6 @@ int16_t MQTTClient::publish(const char* topic, const char* message) { // payload // message memcpy(packet + pos, message, messageLen); - pos += messageLen; // send MQTT packet int16_t state = _tl->send(packet, 1 + encodedBytes + remainingLength); @@ -314,7 +312,6 @@ int16_t MQTTClient::unsubscribe(const char* topicFilter) { packet[pos++] = (topicFilterLen & 0xFF00) >> 8;; packet[pos++] = topicFilterLen & 0x00FF; memcpy(packet + pos, topicFilter, topicFilterLen); - pos += topicFilterLen; // send MQTT packet int16_t state = _tl->send(packet, 1 + encodedBytes + remainingLength); diff --git a/src/protocols/MQTT/MQTT.h b/src/protocols/MQTT/MQTT.h index efc40d3a..e6b0adbe 100644 --- a/src/protocols/MQTT/MQTT.h +++ b/src/protocols/MQTT/MQTT.h @@ -39,7 +39,7 @@ class MQTTClient { \param tl Pointer to the wireless module providing TransportLayer communication. */ - MQTTClient(TransportLayer* tl, uint16_t port = 1883); + explicit MQTTClient(TransportLayer* tl, uint16_t port = 1883); // basic methods @@ -135,8 +135,8 @@ class MQTTClient { uint16_t _port; uint16_t _packetId; - size_t encodeLength(uint32_t len, uint8_t* encoded); - uint32_t decodeLength(uint8_t* encoded); + static size_t encodeLength(uint32_t len, uint8_t* encoded); + static uint32_t decodeLength(uint8_t* encoded); }; #endif From b611cf3a9c988011cd0bbc90bacf5e1e99aae317 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:34:06 +0200 Subject: [PATCH 186/455] [Morse] Fixes from cppcheck scan --- src/protocols/Morse/Morse.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/protocols/Morse/Morse.h b/src/protocols/Morse/Morse.h index 276a443b..c7bcce52 100644 --- a/src/protocols/Morse/Morse.h +++ b/src/protocols/Morse/Morse.h @@ -93,7 +93,7 @@ class MorseClient { \param phy Pointer to the wireless module providing PhysicalLayer communication. */ - MorseClient(PhysicalLayer* phy); + explicit MorseClient(PhysicalLayer* phy); #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! @@ -101,7 +101,7 @@ class MorseClient { \param audio Pointer to the AFSK instance providing audio. */ - MorseClient(AFSKClient* audio); + explicit MorseClient(AFSKClient* audio); #endif // basic methods @@ -141,7 +141,7 @@ class MorseClient { size_t println(void); size_t println(__FlashStringHelper*); - size_t println(const String &s); + size_t println(const String &); size_t println(const char[]); size_t println(char); size_t println(unsigned char, int = DEC); @@ -161,8 +161,8 @@ class MorseClient { void* _audio; #endif - uint32_t _base, _baseHz; - uint16_t _dotLength; + uint32_t _base = 0, _baseHz = 0; + uint16_t _dotLength = 0; size_t printNumber(unsigned long, uint8_t); size_t printFloat(double, uint8_t); From c429563deb82180cdc497cb2a81c9f8814423775 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:42:41 +0200 Subject: [PATCH 187/455] [PHY] Fixes from cppcheck scan --- src/protocols/PhysicalLayer/PhysicalLayer.cpp | 2 +- src/protocols/PhysicalLayer/PhysicalLayer.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index 0fc34b5b..9bb8e322 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -140,6 +140,6 @@ int16_t PhysicalLayer::receive(String& str, size_t len) { return(state); } -float PhysicalLayer::getFreqStep() { +float PhysicalLayer::getFreqStep() const { return(_freqStep); } diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.h b/src/protocols/PhysicalLayer/PhysicalLayer.h index a434bcb3..601c39c6 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.h +++ b/src/protocols/PhysicalLayer/PhysicalLayer.h @@ -164,11 +164,11 @@ class PhysicalLayer { \brief Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class. While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode. - \param FRF 24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY. + \param frf 24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY. \returns \ref status_codes */ - virtual int16_t transmitDirect(uint32_t FRF = 0) = 0; + virtual int16_t transmitDirect(uint32_t frf = 0) = 0; /*! \brief Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class. @@ -213,7 +213,7 @@ class PhysicalLayer { \returns Synthesizer frequency step size in Hz. */ - float getFreqStep(); + float getFreqStep() const; /*! \brief Query modem for the packet length of received payload. From 91de2e1eeb520117692543f48a851b0ac3331bed Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 15:43:06 +0200 Subject: [PATCH 188/455] [SSTV] Moved method back to .cpp file --- src/protocols/SSTV/SSTV.cpp | 4 ++++ src/protocols/SSTV/SSTV.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index 7988fc64..6e658a25 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -278,6 +278,10 @@ void SSTVClient::sendLine(uint32_t* imgLine) { } } +uint16_t SSTVClient::getPictureHeight() const { + return(_mode.height); +} + void SSTVClient::tone(float freq, uint32_t len) { uint32_t start = micros(); if(_audio != nullptr) { diff --git a/src/protocols/SSTV/SSTV.h b/src/protocols/SSTV/SSTV.h index ea64ceca..fd827b6a 100644 --- a/src/protocols/SSTV/SSTV.h +++ b/src/protocols/SSTV/SSTV.h @@ -180,7 +180,7 @@ class SSTVClient { \returns Picture height of the currently configured SSTV mode in pixels. */ - uint16_t getPictureHeight() const { return(_mode.height); }; + uint16_t getPictureHeight() const; #ifndef RADIOLIB_GODMODE private: From c439b097d85e01e07650e752f46dee035612dc70 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 16:05:56 +0200 Subject: [PATCH 189/455] Switched to initializer lists --- src/Module.cpp | 89 +++++++++++++++++++++++++++----------------------- src/Module.h | 7 ++-- 2 files changed, 52 insertions(+), 44 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index 218be4fa..ee9d00e3 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -1,35 +1,39 @@ #include "Module.h" -Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst) { - _cs = cs; - _rx = RADIOLIB_NC; - _tx = RADIOLIB_NC; - _irq = irq; - _rst = rst; +Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst): + _cs(cs), + _irq(irq), + _rst(rst), + _rx(RADIOLIB_NC), + _tx(RADIOLIB_NC), + _spiSettings(SPISettings(2000000, MSBFIRST, SPI_MODE0)) +{ _spi = &RADIOLIB_DEFAULT_SPI; - _spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0); _initInterface = true; ModuleSerial = NULL; } -Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio) { - _cs = cs; - _rx = gpio; - _tx = RADIOLIB_NC; - _irq = irq; - _rst = rst; +Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio): + _cs(cs), + _irq(irq), + _rst(rst), + _rx(gpio), + _tx(RADIOLIB_NC), + _spiSettings(SPISettings(2000000, MSBFIRST, SPI_MODE0)) +{ _spi = &RADIOLIB_DEFAULT_SPI; - _spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0); _initInterface = true; ModuleSerial = NULL; } -Module::Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* serial, RADIOLIB_PIN_TYPE rst) { - _cs = RADIOLIB_NC; - _rx = rx; - _tx = tx; - _irq = RADIOLIB_NC; - _rst = rst; +Module::Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* serial, RADIOLIB_PIN_TYPE rst): + _cs(RADIOLIB_NC), + _irq(RADIOLIB_NC), + _rst(rst), + _rx(rx), + _tx(tx), + _spiSettings(SPISettings(2000000, MSBFIRST, SPI_MODE0)) +{ _initInterface = true; #ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED @@ -40,38 +44,41 @@ Module::Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* seria #endif } -Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass& spi, SPISettings spiSettings) { - _cs = cs; - _rx = RADIOLIB_NC; - _tx = RADIOLIB_NC; - _irq = irq; - _rst = rst; +Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass& spi, SPISettings spiSettings): + _cs(cs), + _irq(irq), + _rst(rst), + _rx(RADIOLIB_NC), + _tx(RADIOLIB_NC), + _spiSettings(spiSettings) +{ _spi = &spi; - _spiSettings = spiSettings; _initInterface = false; ModuleSerial = NULL; } -Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings) { - _cs = cs; - _rx = gpio; - _tx = RADIOLIB_NC; - _irq = irq; - _rst = rst; +Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings): + _cs(cs), + _irq(irq), + _rst(rst), + _rx(gpio), + _tx(RADIOLIB_NC), + _spiSettings(spiSettings) +{ _spi = &spi; - _spiSettings = spiSettings; _initInterface = false; ModuleSerial = NULL; } -Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi, SPISettings spiSettings, HardwareSerial* serial) { - _cs = cs; - _rx = rx; - _tx = tx; - _irq = irq; - _rst = rst; +Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi, SPISettings spiSettings, HardwareSerial* serial): + _cs(cs), + _irq(irq), + _rst(rst), + _rx(rx), + _tx(tx), + _spiSettings(spiSettings) +{ _spi = &spi; - _spiSettings = spiSettings; _initInterface = false; #ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED diff --git a/src/Module.h b/src/Module.h index ccc571c0..71b372eb 100644 --- a/src/Module.h +++ b/src/Module.h @@ -409,14 +409,15 @@ class Module { private: #endif RADIOLIB_PIN_TYPE _cs = RADIOLIB_NC; - RADIOLIB_PIN_TYPE _tx = RADIOLIB_NC; - RADIOLIB_PIN_TYPE _rx = RADIOLIB_NC; RADIOLIB_PIN_TYPE _irq = RADIOLIB_NC; RADIOLIB_PIN_TYPE _rst = RADIOLIB_NC; + RADIOLIB_PIN_TYPE _rx = RADIOLIB_NC; + RADIOLIB_PIN_TYPE _tx = RADIOLIB_NC; + + SPISettings _spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0); bool _initInterface = false; SPIClass* _spi = NULL; - SPISettings _spiSettings; bool _useRfSwitch = false; RADIOLIB_PIN_TYPE _rxEn = RADIOLIB_NC, _txEn = RADIOLIB_NC; From 31c37536b9c87bd00e805fc5fdeb8c02f05e40ed Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 16:16:31 +0200 Subject: [PATCH 190/455] Fixed definition --- src/BuildOpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 490dbf1a..0366a125 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -53,7 +53,7 @@ // some of RadioLib drivers may be excluded, to prevent collisions with platform (or to speed up build process) // for example, to exclude ESP8266 driver: - //RADIOLIB_EXCLUDE_ESP8266 + //#define RADIOLIB_EXCLUDE_ESP8266 #else #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) From 93f1bd51d36098bbeff4e95487f57aca568c8653 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:13:16 +0200 Subject: [PATCH 191/455] Updated template implementation file --- extras/ModuleTemplate.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extras/ModuleTemplate.cpp b/extras/ModuleTemplate.cpp index 0ee26318..07267305 100644 --- a/extras/ModuleTemplate.cpp +++ b/extras/ModuleTemplate.cpp @@ -1,4 +1,5 @@ #include ".h" +#if !defined(RADIOLIB_EXCLUDE_) ::(Module* mod) { /* @@ -12,10 +13,10 @@ int16_t ::begin() { "begin" method implementation MUST call the "init" method with appropriate settings. */ _mod->init(); - + /* "begin" method SHOULD implement some sort of mechanism to verify the connection between Arduino and the module. - + For example, sending AT command for UART modules, or reading a version register for SPI/I2C modules */ } From ccb363548599252c8db5246a3de8d36d3b3a3680 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:17:14 +0200 Subject: [PATCH 192/455] [RF69] Fixed exclusion macros --- src/modules/RF69/RF69.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 70815395..1994980b 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_RF69_H) && !defined(RADIOLIB_EXCLUDE_RF69) +#if !defined(_RADIOLIB_RF69_H) #define _RADIOLIB_RF69_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_RF69) + #include "../../Module.h" #include "../../protocols/PhysicalLayer/PhysicalLayer.h" @@ -835,3 +838,5 @@ class RF69: public PhysicalLayer { }; #endif + +#endif From 763fed74ffd8a5163046ed016317ce54c643fe03 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:17:29 +0200 Subject: [PATCH 193/455] [RFM2x] Fixed exclusion macros --- src/modules/RFM2x/RFM22.h | 7 ++++++- src/modules/RFM2x/RFM23.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/RFM2x/RFM22.h b/src/modules/RFM2x/RFM22.h index bfad6cd7..3204c7ca 100644 --- a/src/modules/RFM2x/RFM22.h +++ b/src/modules/RFM2x/RFM22.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_RFM22_H) && !defined(RADIOLIB_EXCLUDE_SI443X) +#if !defined(_RADIOLIB_RFM22_H) #define _RADIOLIB_RFM22_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_RFM2X) + #include "../../Module.h" #include "../Si443x/Si443x.h" #include "../Si443x/Si4432.h" @@ -14,3 +17,5 @@ using RFM22 = Si4432; #endif + +#endif diff --git a/src/modules/RFM2x/RFM23.h b/src/modules/RFM2x/RFM23.h index 506c3482..45a708a2 100644 --- a/src/modules/RFM2x/RFM23.h +++ b/src/modules/RFM2x/RFM23.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_RFM23_H) && !defined(RADIOLIB_EXCLUDE_SI443X) +#if !defined(_RADIOLIB_RFM23_H) #define _RADIOLIB_RFM23_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_RFM2X) + #include "../../Module.h" #include "../Si443x/Si443x.h" #include "../Si443x/Si4431.h" @@ -14,3 +17,5 @@ using RFM23 = Si4431; #endif + +#endif From a218cc04f2d8b712b2e021b00b8229dccdbe5f11 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:17:37 +0200 Subject: [PATCH 194/455] [RFM9x] Fixed exclusion macros --- src/modules/RFM9x/RFM95.h | 7 ++++++- src/modules/RFM9x/RFM96.h | 7 ++++++- src/modules/RFM9x/RFM97.h | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/modules/RFM9x/RFM95.h b/src/modules/RFM9x/RFM95.h index 914ccad9..8c760630 100644 --- a/src/modules/RFM9x/RFM95.h +++ b/src/modules/RFM9x/RFM95.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_RFM95_H) && !defined(RADIOLIB_EXCLUDE_RFM9X) +#if !defined(_RADIOLIB_RFM95_H) #define _RADIOLIB_RFM95_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_RFM9X) + #include "../../Module.h" #include "../SX127x/SX127x.h" #include "../SX127x/SX1278.h" @@ -75,3 +78,5 @@ class RFM95: public SX1278 { }; #endif + +#endif diff --git a/src/modules/RFM9x/RFM96.h b/src/modules/RFM9x/RFM96.h index 985fcf74..9bafe6ea 100644 --- a/src/modules/RFM9x/RFM96.h +++ b/src/modules/RFM9x/RFM96.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_RFM96_H) && !defined(RADIOLIB_EXCLUDE_RFM9X) +#if !defined(_RADIOLIB_RFM96_H) #define _RADIOLIB_RFM96_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_RFM9X) + #include "../../Module.h" #include "../SX127x/SX127x.h" #include "../SX127x/SX1278.h" @@ -82,3 +85,5 @@ class RFM96: public SX1278 { using RFM98 = RFM96; #endif + +#endif diff --git a/src/modules/RFM9x/RFM97.h b/src/modules/RFM9x/RFM97.h index 90e59e42..30454f91 100644 --- a/src/modules/RFM9x/RFM97.h +++ b/src/modules/RFM9x/RFM97.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_RFM97_H) && !defined(RADIOLIB_EXCLUDE_RFM9X) +#if !defined(_RADIOLIB_RFM97_H) #define _RADIOLIB_RFM97_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_RFM9X) + #include "../../Module.h" #include "../SX127x/SX127x.h" #include "../SX127x/SX1278.h" @@ -42,3 +45,5 @@ class RFM97: public RFM95 { }; #endif + +#endif From 3aa5adf91665435d36294a1aa60beb51ab68a4b9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:17:46 +0200 Subject: [PATCH 195/455] [SX1231] Fixed exclusion macros --- src/modules/SX1231/SX1231.cpp | 2 +- src/modules/SX1231/SX1231.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index 53981685..6122a452 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -1,5 +1,5 @@ #include "SX1231.h" -#if !defined(RADIOLIB_EXCLUDE_RF69) +#if !defined(RADIOLIB_EXCLUDE_SX1231) SX1231::SX1231(Module* mod) : RF69(mod) { diff --git a/src/modules/SX1231/SX1231.h b/src/modules/SX1231/SX1231.h index 4597efa8..9ec08f4c 100644 --- a/src/modules/SX1231/SX1231.h +++ b/src/modules/SX1231/SX1231.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1231_H) && !defined(RADIOLIB_EXCLUDE_RF69) +#if !defined(_RADIOLIB_SX1231_H) #define _RADIOLIB_SX1231_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX1231) + #include "../../Module.h" #include "../RF69/RF69.h" @@ -53,3 +56,5 @@ class SX1231: public RF69 { }; #endif + +#endif From b1fa564cd35cd40e860aa874473591a663688aa0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:17:54 +0200 Subject: [PATCH 196/455] [SX126x] Fixed exclusion macros --- src/modules/SX126x/SX1261.h | 6 +++++- src/modules/SX126x/SX1262.h | 7 ++++++- src/modules/SX126x/SX1268.h | 7 ++++++- src/modules/SX126x/SX126x.h | 7 ++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/modules/SX126x/SX1261.h b/src/modules/SX126x/SX1261.h index 5b6f9ef6..a52d4235 100644 --- a/src/modules/SX126x/SX1261.h +++ b/src/modules/SX126x/SX1261.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1261_H) && !defined(RADIOLIB_EXCLUDE_SX126X) +#if !defined(_RADIOLIB_SX1261_H) #define _RADIOLIB_SX1261_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX126X) + #include "../../Module.h" #include "SX126x.h" #include "SX1262.h" @@ -38,5 +41,6 @@ class SX1261 : public SX1262 { }; +#endif #endif diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index b268759b..1aa0529f 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1262_H) && !defined(RADIOLIB_EXCLUDE_SX126X) +#if !defined(_RADIOLIB_SX1262_H) #define _RADIOLIB_SX1262_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX126X) + #include "../../Module.h" #include "SX126x.h" @@ -103,3 +106,5 @@ class SX1262: public SX126x { }; #endif + +#endif diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h index 76f01c1e..d7acd5f0 100644 --- a/src/modules/SX126x/SX1268.h +++ b/src/modules/SX126x/SX1268.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1268_H) && !defined(RADIOLIB_EXCLUDE_SX126X) +#if !defined(_RADIOLIB_SX1268_H) #define _RADIOLIB_SX1268_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX126X) + #include "../../Module.h" #include "SX126x.h" @@ -103,3 +106,5 @@ class SX1268: public SX126x { }; #endif + +#endif diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index ae92e253..849d8757 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX126X_H) && !defined(RADIOLIB_EXCLUDE_SX126X) +#if !defined(_RADIOLIB_SX126X_H) #define _RADIOLIB_SX126X_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX126X) + #include "../../Module.h" #include "../../protocols/PhysicalLayer/PhysicalLayer.h" @@ -925,3 +928,5 @@ class SX126x: public PhysicalLayer { }; #endif + +#endif From 368c646ad56f928a4fe3b85f556d25348fc897c4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:18:04 +0200 Subject: [PATCH 197/455] [SX127x] Fixed exclusion macros --- src/modules/SX127x/SX1272.h | 7 ++++++- src/modules/SX127x/SX1273.h | 7 ++++++- src/modules/SX127x/SX1276.h | 7 ++++++- src/modules/SX127x/SX1277.h | 7 ++++++- src/modules/SX127x/SX1278.h | 7 ++++++- src/modules/SX127x/SX1279.h | 7 ++++++- src/modules/SX127x/SX127x.h | 7 ++++++- 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index 7538c845..e47e7fed 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1272_H) && !defined(RADIOLIB_EXCLUDE_SX127X) +#if !defined(_RADIOLIB_SX1272_H) #define _RADIOLIB_SX1272_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX127X) + #include "../../Module.h" #include "SX127x.h" @@ -271,3 +274,5 @@ class SX1272: public SX127x { }; #endif + +#endif diff --git a/src/modules/SX127x/SX1273.h b/src/modules/SX127x/SX1273.h index ac7fcd98..e8b3902b 100644 --- a/src/modules/SX127x/SX1273.h +++ b/src/modules/SX127x/SX1273.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1273_H) && !defined(RADIOLIB_EXCLUDE_SX127X) +#if !defined(_RADIOLIB_SX1273_H) #define _RADIOLIB_SX1273_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX127X) + #include "SX1272.h" /*! @@ -69,3 +72,5 @@ class SX1273: public SX1272 { }; #endif + +#endif diff --git a/src/modules/SX127x/SX1276.h b/src/modules/SX127x/SX1276.h index 55861cc3..cc4ce493 100644 --- a/src/modules/SX127x/SX1276.h +++ b/src/modules/SX127x/SX1276.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1276_H) && !defined(RADIOLIB_EXCLUDE_SX127X) +#if !defined(_RADIOLIB_SX1276_H) #define _RADIOLIB_SX1276_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX127X) + #include "SX1278.h" /*! @@ -69,3 +72,5 @@ class SX1276: public SX1278 { }; #endif + +#endif diff --git a/src/modules/SX127x/SX1277.h b/src/modules/SX127x/SX1277.h index afbfdc1f..804ee6f9 100644 --- a/src/modules/SX127x/SX1277.h +++ b/src/modules/SX127x/SX1277.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1277_H) && !defined(RADIOLIB_EXCLUDE_SX127X) +#if !defined(_RADIOLIB_SX1277_H) #define _RADIOLIB_SX1277_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX127X) + #include "SX1278.h" /*! @@ -78,3 +81,5 @@ class SX1277: public SX1278 { }; #endif + +#endif diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index ccd47da8..c7e5d5b5 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1278_H) && !defined(RADIOLIB_EXCLUDE_SX127X) +#if !defined(_RADIOLIB_SX1278_H) #define _RADIOLIB_SX1278_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX127X) + #include "../../Module.h" #include "SX127x.h" @@ -280,3 +283,5 @@ class SX1278: public SX127x { }; #endif + +#endif diff --git a/src/modules/SX127x/SX1279.h b/src/modules/SX127x/SX1279.h index 9908b3eb..c466b64a 100644 --- a/src/modules/SX127x/SX1279.h +++ b/src/modules/SX127x/SX1279.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1279_H) && !defined(RADIOLIB_EXCLUDE_SX127X) +#if !defined(_RADIOLIB_SX1279_H) #define _RADIOLIB_SX1279_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX127X) + #include "SX1278.h" /*! @@ -69,3 +72,5 @@ class SX1279: public SX1278 { }; #endif + +#endif diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index ac22a49b..1a318c33 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX127X_H) && !defined(RADIOLIB_EXCLUDE_SX127X) +#if !defined(_RADIOLIB_SX127X_H) #define _RADIOLIB_SX127X_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX127X) + #include "../../Module.h" #include "../../protocols/PhysicalLayer/PhysicalLayer.h" @@ -967,3 +970,5 @@ class SX127x: public PhysicalLayer { }; #endif + +#endif From 96f4bd667e6aca0430b20db7f099b5490114a36a Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:18:13 +0200 Subject: [PATCH 198/455] [SX128x] Fixed exclusion macros --- src/modules/SX128x/SX1280.h | 7 ++++++- src/modules/SX128x/SX1281.h | 7 ++++++- src/modules/SX128x/SX1282.h | 7 ++++++- src/modules/SX128x/SX128x.h | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/modules/SX128x/SX1280.h b/src/modules/SX128x/SX1280.h index 4c079ac4..3cd3184a 100644 --- a/src/modules/SX128x/SX1280.h +++ b/src/modules/SX128x/SX1280.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1280_H) && !defined(RADIOLIB_EXCLUDE_SX128X) +#if !defined(_RADIOLIB_SX1280_H) #define _RADIOLIB_SX1280_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX128X) + #include "../../Module.h" #include "SX128x.h" #include "SX1281.h" @@ -56,3 +59,5 @@ class SX1280: public SX1281 { }; #endif + +#endif diff --git a/src/modules/SX128x/SX1281.h b/src/modules/SX128x/SX1281.h index 6cb85192..67a0a323 100644 --- a/src/modules/SX128x/SX1281.h +++ b/src/modules/SX128x/SX1281.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1281_H) && !defined(RADIOLIB_EXCLUDE_SX128X) +#if !defined(_RADIOLIB_SX1281_H) #define _RADIOLIB_SX1281_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX128X) + #include "../../Module.h" #include "SX128x.h" @@ -26,3 +29,5 @@ class SX1281: public SX128x { }; #endif + +#endif diff --git a/src/modules/SX128x/SX1282.h b/src/modules/SX128x/SX1282.h index 8b677d95..1e3b9be7 100644 --- a/src/modules/SX128x/SX1282.h +++ b/src/modules/SX128x/SX1282.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX1282_H) && !defined(RADIOLIB_EXCLUDE_SX128X) +#if !defined(_RADIOLIB_SX1282_H) #define _RADIOLIB_SX1282_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX128X) + #include "../../Module.h" #include "SX128x.h" #include "SX1280.h" @@ -29,3 +32,5 @@ class SX1282: public SX1280 { }; #endif + +#endif diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index 873525fa..131e7baf 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SX128X_H) && !defined(RADIOLIB_EXCLUDE_SX128X) +#if !defined(_RADIOLIB_SX128X_H) #define _RADIOLIB_SX128X_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SX128X) + #include "../../Module.h" #include "../../protocols/PhysicalLayer/PhysicalLayer.h" @@ -815,3 +818,5 @@ class SX128x: public PhysicalLayer { }; #endif + +#endif From 906b0857bd0d3d7fd4cd1c146a464333caf108e5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:18:24 +0200 Subject: [PATCH 199/455] [Si443x] Fixed exclusion macros --- src/modules/Si443x/Si4430.h | 7 ++++++- src/modules/Si443x/Si4431.h | 7 ++++++- src/modules/Si443x/Si4432.h | 7 ++++++- src/modules/Si443x/Si443x.h | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/modules/Si443x/Si4430.h b/src/modules/Si443x/Si4430.h index 815ec7ad..ff3b06f6 100644 --- a/src/modules/Si443x/Si4430.h +++ b/src/modules/Si443x/Si4430.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SI4430_H) && !defined(RADIOLIB_EXCLUDE_SI443X) +#if !defined(_RADIOLIB_SI4430_H) #define _RADIOLIB_SI4430_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SI443X) + #include "../../Module.h" #include "Si4432.h" @@ -72,3 +75,5 @@ class Si4430: public Si4432 { }; #endif + +#endif diff --git a/src/modules/Si443x/Si4431.h b/src/modules/Si443x/Si4431.h index 5f8b3821..00167a7d 100644 --- a/src/modules/Si443x/Si4431.h +++ b/src/modules/Si443x/Si4431.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SI4431_H) && !defined(RADIOLIB_EXCLUDE_SI443X) +#if !defined(_RADIOLIB_SI4431_H) #define _RADIOLIB_SI4431_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SI443X) + #include "../../Module.h" #include "Si4432.h" @@ -63,3 +66,5 @@ class Si4431: public Si4432 { }; #endif + +#endif diff --git a/src/modules/Si443x/Si4432.h b/src/modules/Si443x/Si4432.h index 4b1d0af6..7537e689 100644 --- a/src/modules/Si443x/Si4432.h +++ b/src/modules/Si443x/Si4432.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SI4432_H) && !defined(RADIOLIB_EXCLUDE_SI443X) +#if !defined(_RADIOLIB_SI4432_H) #define _RADIOLIB_SI4432_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SI443X) + #include "../../Module.h" #include "Si443x.h" @@ -72,3 +75,5 @@ class Si4432: public Si443x { }; #endif + +#endif diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 29417363..8e2907a5 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SI443X_H) && !defined(RADIOLIB_EXCLUDE_SI443X) +#if !defined(_RADIOLIB_SI443X_H) #define _RADIOLIB_SI443X_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SI443X) + #include "../../Module.h" #include "../../protocols/PhysicalLayer/PhysicalLayer.h" @@ -794,3 +797,5 @@ class Si443x: public PhysicalLayer { }; #endif + +#endif From 4ca26f6e477efa77b06e7b9d9d78bccd30b1e391 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:18:31 +0200 Subject: [PATCH 200/455] [AFSK] Fixed exclusion macros --- src/protocols/AFSK/AFSK.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/protocols/AFSK/AFSK.h b/src/protocols/AFSK/AFSK.h index c487dd17..d92ffe65 100644 --- a/src/protocols/AFSK/AFSK.h +++ b/src/protocols/AFSK/AFSK.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_AFSK_H) && !defined(RADIOLIB_EXCLUDE_AFSK) +#if !defined(_RADIOLIB_AFSK_H) #define _RADIOLIB_AFSK_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_AFSK) + #include "../../Module.h" #include "../PhysicalLayer/PhysicalLayer.h" @@ -55,3 +58,5 @@ class AFSKClient { }; #endif + +#endif From 152d3d3da38b629809eaea95acd488d794b99af4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:18:40 +0200 Subject: [PATCH 201/455] [AX25] Fixed exclusion macros --- src/protocols/AX25/AX25.cpp | 15 ++++++++++++--- src/protocols/AX25/AX25.h | 9 ++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index edde12c4..d5bedc48 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -112,7 +112,9 @@ void AX25Frame::setSendSequence(uint8_t seqNumber) { AX25Client::AX25Client(PhysicalLayer* phy) { _phy = phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) _audio = nullptr; + #endif } #if !defined(RADIOLIB_EXCLUDE_AFSK) @@ -140,12 +142,14 @@ int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t prea // set module frequency deviation to 0 if using FSK int16_t state = ERR_NONE; + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio == nullptr) { state = _phy->setFrequencyDeviation(0); RADIOLIB_ASSERT(state); state = _phy->setEncoding(0); } + #endif return(state); } @@ -348,9 +352,8 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { // transmit int16_t state = ERR_NONE; - if(_audio == nullptr) { - state = _phy->transmit(stuffedFrameBuff, stuffedFrameBuffLen); - } else { + #if !defined(RADIOLIB_EXCLUDE_AFSK) + if(_audio != nullptr) { _phy->transmitDirect(); // iterate over all bytes in the buffer @@ -372,7 +375,13 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { } _audio->noTone(); + + } else { + #endif + state = _phy->transmit(stuffedFrameBuff, stuffedFrameBuffLen); + #if !defined(RADIOLIB_EXCLUDE_AFSK) } + #endif // deallocate memory #ifndef RADIOLIB_STATIC_ONLY diff --git a/src/protocols/AX25/AX25.h b/src/protocols/AX25/AX25.h index 7f7ed959..20df8d53 100644 --- a/src/protocols/AX25/AX25.h +++ b/src/protocols/AX25/AX25.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_AX25_H) && !defined(RADIOLIB_EXCLUDE_AX25) +#if !defined(_RADIOLIB_AX25_H) #define _RADIOLIB_AX25_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_AX25) + #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -320,8 +323,6 @@ class AX25Client { PhysicalLayer* _phy; #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; - #else - void* _audio; #endif char _srcCallsign[AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0}; @@ -334,3 +335,5 @@ class AX25Client { }; #endif + +#endif From dc4c588bae2bffddd4efeea171901a865f8009e8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:18:49 +0200 Subject: [PATCH 202/455] [HTTP] Fixed exclusion macros --- src/protocols/HTTP/HTTP.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/protocols/HTTP/HTTP.h b/src/protocols/HTTP/HTTP.h index ae9a3888..0f30a43e 100644 --- a/src/protocols/HTTP/HTTP.h +++ b/src/protocols/HTTP/HTTP.h @@ -1,9 +1,11 @@ -#if !defined(_RADIOLIB_HTTP_H) && !defined(RADIOLIB_EXCLUDE_HTTP) +#if !defined(_RADIOLIB_HTTP_H) #define _RADIOLIB_HTTP_H #include "../../TypeDef.h" -#include "../TransportLayer/TransportLayer.h" +#if !defined(RADIOLIB_EXCLUDE_HTTP) + +#include "../TransportLayer/TransportLayer.h" /*! \class HTTPClient @@ -67,3 +69,5 @@ class HTTPClient { }; #endif + +#endif From e23f095585b4cac746f15d515f93ee36ac1b92ca Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:19:00 +0200 Subject: [PATCH 203/455] [Hell] Fixed exclusion macros --- src/protocols/Hellschreiber/Hellschreiber.cpp | 15 +++++++++++---- src/protocols/Hellschreiber/Hellschreiber.h | 9 ++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/protocols/Hellschreiber/Hellschreiber.cpp b/src/protocols/Hellschreiber/Hellschreiber.cpp index d2355480..3a7bb6fc 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.cpp +++ b/src/protocols/Hellschreiber/Hellschreiber.cpp @@ -3,7 +3,10 @@ HellClient::HellClient(PhysicalLayer* phy) { _phy = phy; + + #if !defined(RADIOLIB_EXCLUDE_AFSK) _audio = nullptr; + #endif } #if !defined(RADIOLIB_EXCLUDE_AFSK) @@ -23,9 +26,11 @@ int16_t HellClient::begin(float base, float rate) { // set module frequency deviation to 0 if using FSK int16_t state = ERR_NONE; + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio == nullptr) { state = _phy->setFrequencyDeviation(0); } + #endif return(state); } @@ -285,19 +290,21 @@ size_t HellClient::printFloat(double number, uint8_t digits) { } int16_t HellClient::transmitDirect(uint32_t freq, uint32_t freqHz) { + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio != nullptr) { return(_audio->tone(freqHz)); - } else { - return(_phy->transmitDirect(freq)); } + #endif + return(_phy->transmitDirect(freq)); } int16_t HellClient::standby() { + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio != nullptr) { return(_audio->noTone()); - } else { - return(_phy->standby()); } + #endif + return(_phy->standby()); } #endif diff --git a/src/protocols/Hellschreiber/Hellschreiber.h b/src/protocols/Hellschreiber/Hellschreiber.h index 1f8087e1..bfe20473 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.h +++ b/src/protocols/Hellschreiber/Hellschreiber.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_HELLSCHREIBER_H) && !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER) +#if !defined(_RADIOLIB_HELLSCHREIBER_H) #define _RADIOLIB_HELLSCHREIBER_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER) + #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -152,8 +155,6 @@ class HellClient { PhysicalLayer* _phy; #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; - #else - void* _audio; #endif uint32_t _base = 0, _baseHz = 0; @@ -167,3 +168,5 @@ class HellClient { }; #endif + +#endif From 55845fe3d7f68e302758a451615fee79a88b560a Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:19:10 +0200 Subject: [PATCH 204/455] [MQTT] Fixed exclusion macros --- src/protocols/MQTT/MQTT.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/protocols/MQTT/MQTT.h b/src/protocols/MQTT/MQTT.h index e6b0adbe..87b8444d 100644 --- a/src/protocols/MQTT/MQTT.h +++ b/src/protocols/MQTT/MQTT.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_MQTT_H) && !defined(RADIOLIB_EXCLUDE_MQTT) +#if !defined(_RADIOLIB_MQTT_H) #define _RADIOLIB_MQTT_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_MQTT) + #include "../TransportLayer/TransportLayer.h" // MQTT packet types @@ -140,3 +143,5 @@ class MQTTClient { }; #endif + +#endif From 27471fd788d41499dbd636985095802601ce2d57 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:19:16 +0200 Subject: [PATCH 205/455] [Morse] Fixed exclusion macros --- src/protocols/Morse/Morse.cpp | 14 ++++++++++---- src/protocols/Morse/Morse.h | 2 -- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/protocols/Morse/Morse.cpp b/src/protocols/Morse/Morse.cpp index bd336229..80a44d46 100644 --- a/src/protocols/Morse/Morse.cpp +++ b/src/protocols/Morse/Morse.cpp @@ -3,7 +3,9 @@ MorseClient::MorseClient(PhysicalLayer* phy) { _phy = phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) _audio = nullptr; + #endif } #if !defined(RADIOLIB_EXCLUDE_AFSK) @@ -23,9 +25,11 @@ int16_t MorseClient::begin(float base, uint8_t speed) { // set module frequency deviation to 0 if using FSK int16_t state = ERR_NONE; + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio == nullptr) { state = _phy->setFrequencyDeviation(0); } + #endif return(state); } @@ -298,19 +302,21 @@ size_t MorseClient::printFloat(double number, uint8_t digits) { } int16_t MorseClient::transmitDirect(uint32_t freq, uint32_t freqHz) { + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio != nullptr) { return(_audio->tone(freqHz)); - } else { - return(_phy->transmitDirect(freq)); } + #endif + return(_phy->transmitDirect(freq)); } int16_t MorseClient::standby() { + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio != nullptr) { return(_audio->noTone()); - } else { - return(_phy->standby()); } + #endif + return(_phy->standby()); } #endif diff --git a/src/protocols/Morse/Morse.h b/src/protocols/Morse/Morse.h index c7bcce52..d94fad0d 100644 --- a/src/protocols/Morse/Morse.h +++ b/src/protocols/Morse/Morse.h @@ -157,8 +157,6 @@ class MorseClient { PhysicalLayer* _phy; #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; - #else - void* _audio; #endif uint32_t _base = 0, _baseHz = 0; From dabac56cc45c5a7e3727bcc4b7a4db29b1a4cb31 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:19:23 +0200 Subject: [PATCH 206/455] [RTTY] Fixed exclusion macros --- src/protocols/RTTY/RTTY.cpp | 14 ++++++++++---- src/protocols/RTTY/RTTY.h | 9 ++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index ccd166cf..657f55f1 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -107,7 +107,9 @@ uint16_t ITA2String::getBits(char c) { RTTYClient::RTTYClient(PhysicalLayer* phy) { _phy = phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) _audio = nullptr; + #endif } #if !defined(RADIOLIB_EXCLUDE_AFSK) @@ -161,9 +163,11 @@ int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t enc // set module frequency deviation to 0 if using FSK int16_t state = ERR_NONE; + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio == nullptr) { state = _phy->setFrequencyDeviation(0); } + #endif return(state); } @@ -520,19 +524,21 @@ size_t RTTYClient::printFloat(double number, uint8_t digits) { } int16_t RTTYClient::transmitDirect(uint32_t freq, uint32_t freqHz) { + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio != nullptr) { return(_audio->tone(freqHz)); - } else { - return(_phy->transmitDirect(freq)); } + #endif + return(_phy->transmitDirect(freq)); } int16_t RTTYClient::standby() { + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio != nullptr) { return(_audio->noTone()); - } else { - return(_phy->standby()); } + #endif + return(_phy->standby()); } #endif diff --git a/src/protocols/RTTY/RTTY.h b/src/protocols/RTTY/RTTY.h index a7bfbf73..baf89fe1 100644 --- a/src/protocols/RTTY/RTTY.h +++ b/src/protocols/RTTY/RTTY.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_RTTY_H) && !defined(RADIOLIB_EXCLUDE_RTTY) +#if !defined(_RADIOLIB_RTTY_H) #define _RADIOLIB_RTTY_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_RTTY) + #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -159,8 +162,6 @@ class RTTYClient { PhysicalLayer* _phy; #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; - #else - void* _audio; #endif uint8_t _encoding = ASCII; @@ -181,3 +182,5 @@ class RTTYClient { }; #endif + +#endif From a5db0c02bf2d3c9d4bde534a17b877b805f46a67 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:19:30 +0200 Subject: [PATCH 207/455] [SSTV] Fixed exclusion macros --- src/protocols/SSTV/SSTV.cpp | 10 ++++++++++ src/protocols/SSTV/SSTV.h | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index 6e658a25..9fc9fd3e 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -156,7 +156,9 @@ const SSTVMode_t PasokonP7 { SSTVClient::SSTVClient(PhysicalLayer* phy) { _phy = phy; + #if !defined(RADIOLIB_EXCLUDE_AFSK) _audio = nullptr; + #endif } #if !defined(RADIOLIB_EXCLUDE_AFSK) @@ -166,6 +168,7 @@ SSTVClient::SSTVClient(AFSKClient* audio) { } #endif +#if !defined(RADIOLIB_EXCLUDE_AFSK) int16_t SSTVClient::begin(const SSTVMode_t& mode, float correction) { if(_audio == nullptr) { // this initialization method can only be used in AFSK mode @@ -174,6 +177,7 @@ int16_t SSTVClient::begin(const SSTVMode_t& mode, float correction) { return(begin(0, mode, correction)); } +#endif int16_t SSTVClient::begin(float base, const SSTVMode_t& mode, float correction) { // save mode @@ -190,9 +194,11 @@ int16_t SSTVClient::begin(float base, const SSTVMode_t& mode, float correction) // set module frequency deviation to 0 if using FSK int16_t state = ERR_NONE; + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio == nullptr) { state = _phy->setFrequencyDeviation(0); } + #endif return(state); } @@ -284,11 +290,15 @@ uint16_t SSTVClient::getPictureHeight() const { void SSTVClient::tone(float freq, uint32_t len) { uint32_t start = micros(); + #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio != nullptr) { _audio->tone(freq, false); } else { _phy->transmitDirect(_base + (freq / _phy->getFreqStep())); } + #else + _phy->transmitDirect(_base + (freq / _phy->getFreqStep())); + #endif while(micros() - start < len) { yield(); } diff --git a/src/protocols/SSTV/SSTV.h b/src/protocols/SSTV/SSTV.h index fd827b6a..fb8fc27a 100644 --- a/src/protocols/SSTV/SSTV.h +++ b/src/protocols/SSTV/SSTV.h @@ -1,7 +1,10 @@ -#if !defined(_RADIOLIB_SSTV_H) && !defined(RADIOLIB_EXCLUDE_SSTV) +#if !defined(_RADIOLIB_SSTV_H) #define _RADIOLIB_SSTV_H #include "../../TypeDef.h" + +#if !defined(RADIOLIB_EXCLUDE_SSTV) + #include "../PhysicalLayer/PhysicalLayer.h" #include "../AFSK/AFSK.h" @@ -147,6 +150,7 @@ class SSTVClient { */ int16_t begin(float base, const SSTVMode_t& mode, float correction = 1.0); + #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Initialization method for AFSK. @@ -157,6 +161,7 @@ class SSTVClient { \returns \ref status_codes */ int16_t begin(const SSTVMode_t& mode, float correction = 1.0); + #endif /*! \brief Sends out tone at 1900 Hz. @@ -188,8 +193,6 @@ class SSTVClient { PhysicalLayer* _phy; #if !defined(RADIOLIB_EXCLUDE_AFSK) AFSKClient* _audio; - #else - void* _audio; #endif uint32_t _base = 0; @@ -200,3 +203,5 @@ class SSTVClient { }; #endif + +#endif From f896765405abe5946ba073b58fef568ae84f0782 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:20:33 +0200 Subject: [PATCH 208/455] Added complete list of supported exclusion macros (TRAVIS_FORCE_BUILD) --- src/BuildOpt.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 0366a125..6c35a902 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -51,9 +51,33 @@ // the following must be defined if the Arduino core does not support tone function //#define RADIOLIB_TONE_UNSUPPORTED - // some of RadioLib drivers may be excluded, to prevent collisions with platform (or to speed up build process) - // for example, to exclude ESP8266 driver: + // some of RadioLib drivers may be excluded, to prevent collisions with platforms (or to speed up build process) + // the following is a complete list of all possible exclusion macros, uncomment any of them to disable that driver + // 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 dependeny is always uni-directional, + // so excluding SX1231 and keeping RF69 is valid. + //#define RADIOLIB_EXCLUDE_CC1101 //#define RADIOLIB_EXCLUDE_ESP8266 + //#define RADIOLIB_EXCLUDE_HC05 + //#define RADIOLIB_EXCLUDE_JDY08 + //#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_RFM9X // dependent on RADIOLIB_EXCLUDE_SX127X + //#define RADIOLIB_EXCLUDE_SX126X + //#define RADIOLIB_EXCLUDE_SX128X + //#define RADIOLIB_EXCLUDE_XBEE + #define RADIOLIB_EXCLUDE_AFSK + //#define RADIOLIB_EXCLUDE_AX25 + //#define RADIOLIB_EXCLUDE_HELLSCHREIBER + //#define RADIOLIB_EXCLUDE_HTTP + //#define RADIOLIB_EXCLUDE_MORSE + //#define RADIOLIB_EXCLUDE_MQTT + //#define RADIOLIB_EXCLUDE_RTTY + //#define RADIOLIB_EXCLUDE_SSTV #else #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) From f3fd516a85ac80cf08e2a86b1f4a7b46cf9bba5e Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:24:43 +0200 Subject: [PATCH 209/455] Fixed AFSK excluded by default --- src/BuildOpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 6c35a902..128450e6 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -70,7 +70,7 @@ //#define RADIOLIB_EXCLUDE_SX126X //#define RADIOLIB_EXCLUDE_SX128X //#define RADIOLIB_EXCLUDE_XBEE - #define RADIOLIB_EXCLUDE_AFSK + //#define RADIOLIB_EXCLUDE_AFSK //#define RADIOLIB_EXCLUDE_AX25 //#define RADIOLIB_EXCLUDE_HELLSCHREIBER //#define RADIOLIB_EXCLUDE_HTTP From eeb70e24bd594f1878a0e7daac3c84827c7968c1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 21:26:23 +0200 Subject: [PATCH 210/455] Fixed typo (TRAVIS_FORCE_BUILD) --- src/BuildOpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 128450e6..dfbaf26d 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -54,7 +54,7 @@ // some of RadioLib drivers may be excluded, to prevent collisions with platforms (or to speed up build process) // the following is a complete list of all possible exclusion macros, uncomment any of them to disable that driver // 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 dependeny is always uni-directional, + // 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_ESP8266 From 0dd3e347a0e19a25a215f26eae0b597bc574f7f8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 09:59:40 +0200 Subject: [PATCH 211/455] [MQTT] Implemented remaining length decoding --- src/protocols/MQTT/MQTT.cpp | 12 +++++++----- src/protocols/MQTT/MQTT.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/protocols/MQTT/MQTT.cpp b/src/protocols/MQTT/MQTT.cpp index cb62321c..fb4791f7 100644 --- a/src/protocols/MQTT/MQTT.cpp +++ b/src/protocols/MQTT/MQTT.cpp @@ -411,10 +411,11 @@ int16_t MQTTClient::check(void (*func)(const char*, const char*)) { _tl->receive(dataIn, numBytes); if(dataIn[0] == MQTT_PUBLISH << 4) { // TODO: properly decode remaining length - uint8_t remainingLength = dataIn[1]; + uint8_t remLenFieldLen = 0; + uint32_t remainingLength = decodeLength(dataIn + 1, remLenFieldLen); // get the topic - size_t topicLength = dataIn[3] | dataIn[2] << 8; + size_t topicLength = dataIn[remLenFieldLen + 2] | dataIn[remLenFieldLen + 1] << 8; char* topic = new char[topicLength + 1]; memcpy(topic, dataIn + 4, topicLength); topic[topicLength] = 0x00; @@ -422,7 +423,7 @@ int16_t MQTTClient::check(void (*func)(const char*, const char*)) { // get the message size_t messageLength = remainingLength - topicLength - 2; char* message = new char[messageLength + 1]; - memcpy(message, dataIn + 4 + topicLength, messageLength); + memcpy(message, dataIn + remLenFieldLen + 3 + topicLength, messageLength); message[messageLength] = 0x00; // execute the callback function provided by user @@ -452,7 +453,7 @@ size_t MQTTClient::encodeLength(uint32_t len, uint8_t* encoded) { return(i); } -uint32_t MQTTClient::decodeLength(uint8_t* encoded) { +uint32_t MQTTClient::decodeLength(uint8_t* encoded, uint8_t& numBytes) { // algorithm to decode packet length as per MQTT specification 3.1.1 uint32_t mult = 1; uint32_t len = 0; @@ -464,7 +465,8 @@ uint32_t MQTTClient::decodeLength(uint8_t* encoded) { // malformed remaining length return(0); } - } while((encoded[i] & 128) != 0); + } while((encoded[i++] & 128) != 0); + numBytes = i; return len; } diff --git a/src/protocols/MQTT/MQTT.h b/src/protocols/MQTT/MQTT.h index 87b8444d..6f21f585 100644 --- a/src/protocols/MQTT/MQTT.h +++ b/src/protocols/MQTT/MQTT.h @@ -139,7 +139,7 @@ class MQTTClient { uint16_t _packetId; static size_t encodeLength(uint32_t len, uint8_t* encoded); - static uint32_t decodeLength(uint8_t* encoded); + static uint32_t decodeLength(uint8_t* encoded, uint8_t& numBytes); }; #endif From fa8d00a7362dc75dd1ea25d66d70d07f20d56431 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:00:04 +0200 Subject: [PATCH 212/455] [ESP8266] Fixed variable scope --- src/modules/ESP8266/ESP8266.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index c7e23b00..c07a96e8 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -7,7 +7,8 @@ ESP8266::ESP8266(Module* module) { int16_t ESP8266::begin(long speed) { // set module properties - _mod->AtLineFeed = "\r\n"; + char lf[3] = "\r\n"; + memcpy(_mod->AtLineFeed, lf, strlen(lf)); _mod->baudrate = speed; _mod->init(RADIOLIB_USE_UART); @@ -89,13 +90,13 @@ int16_t ESP8266::openTransportConnection(const char* host, const char* protocol, // build AT command const char* atStr = "AT+CIPSTART=\""; - uint8_t cmdLen = strlen(atStr) + strlen(protocol) + strlen(host) + strlen(portStr) + 5; - if((strcmp(protocol, "TCP") == 0) && (tcpKeepAlive > 0)) { - cmdLen += strlen(tcpKeepAliveStr) + 1; - } #ifdef RADIOLIB_STATIC_ONLY char cmd[RADIOLIB_STATIC_ARRAY_SIZE]; #else + uint8_t cmdLen = strlen(atStr) + strlen(protocol) + strlen(host) + strlen(portStr) + 5; + if((strcmp(protocol, "TCP") == 0) && (tcpKeepAlive > 0)) { + cmdLen += strlen(tcpKeepAliveStr) + 1; + } char* cmd = new char[cmdLen + 1]; #endif strcpy(cmd, atStr); From 12b4fc9e02c7fd9cd815f6a99177b6a471ceec99 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:00:38 +0200 Subject: [PATCH 213/455] Changed line feed data type --- src/Module.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module.h b/src/Module.h index 71b372eb..84b398c4 100644 --- a/src/Module.h +++ b/src/Module.h @@ -136,7 +136,7 @@ class Module { /*! \brief Line feed to be used when sending AT commands. Defaults to CR+LF. */ - const char* AtLineFeed = "\r\n"; + char AtLineFeed[3] = "\r\n"; /*! \brief Basic SPI read command. Defaults to 0x00. From 2c6d42f64854600a6f96eb72c47e8e6466bd6b83 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:01:52 +0200 Subject: [PATCH 214/455] [JDY08] Updated line feed assignment --- src/modules/JDY08/JDY08.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/JDY08/JDY08.cpp b/src/modules/JDY08/JDY08.cpp index a94cb37d..0179a142 100644 --- a/src/modules/JDY08/JDY08.cpp +++ b/src/modules/JDY08/JDY08.cpp @@ -7,7 +7,8 @@ JDY08::JDY08(Module* mod) : ISerial(mod) { void JDY08::begin(long speed) { // set module properties - _mod->AtLineFeed = ""; + char lf[3] = ""; + memcpy(_mod->AtLineFeed, lf, strlen(lf)); _mod->baudrate = speed; _mod->init(RADIOLIB_USE_UART); } From 0ee58ff770c15c6108d201d4ec7e8851b050f5d9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:02:11 +0200 Subject: [PATCH 215/455] [XBee] Updated line feed assignment --- src/modules/XBee/XBee.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/XBee/XBee.cpp b/src/modules/XBee/XBee.cpp index d5d4b20c..894c32b3 100644 --- a/src/modules/XBee/XBee.cpp +++ b/src/modules/XBee/XBee.cpp @@ -3,6 +3,7 @@ XBee::XBee(Module* mod) { _mod = mod; + _packetData[0] = '\0'; } int16_t XBee::begin(long speed) { @@ -182,7 +183,8 @@ XBeeSerial::XBeeSerial(Module* mod) : ISerial(mod) { int16_t XBeeSerial::begin(long speed) { // set module properties - _mod->AtLineFeed = "\r"; + char lf[3] = "\r"; + memcpy(_mod->AtLineFeed, lf, strlen(lf)); _mod->baudrate = speed; _mod->init(RADIOLIB_USE_UART); From 047dee5244ae5dd2e45141a75023622b1ac5a8bb Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:02:38 +0200 Subject: [PATCH 216/455] Moved SoftwareSerial only methods to macro guards --- src/ISerial.cpp | 50 +++++++++++++++++++------------------------------ src/ISerial.h | 12 ++++++++---- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/ISerial.cpp b/src/ISerial.cpp index 8cd4c65a..dbfa6a30 100644 --- a/src/ISerial.cpp +++ b/src/ISerial.cpp @@ -8,41 +8,10 @@ void ISerial::begin(long speed) { _mod->ModuleSerial->begin(speed); } -bool ISerial::listen() { -#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - return true; -#else - return(_mod->ModuleSerial->listen()); -#endif -} - void ISerial::end() { _mod->ModuleSerial->end(); } -bool ISerial::isListening() { -#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - return true; -#else - return(_mod->ModuleSerial->isListening()); -#endif -} - -bool ISerial::stopListening() { -#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - return true; -#else - return(_mod->ModuleSerial->stopListening()); -#endif -} - -bool ISerial::overflow() { -#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - return false; -#else - return(_mod->ModuleSerial->overflow()); -#endif -} int ISerial::peek() { return(_mod->ModuleSerial->peek()); @@ -64,6 +33,25 @@ void ISerial::flush() { _mod->ModuleSerial->flush(); } +// SoftwareSerial-only methods +#if !defined(RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED) +bool ISerial::listen() { + return(_mod->ModuleSerial->listen()); +} + +bool ISerial::isListening() { + return(_mod->ModuleSerial->isListening()); +} + +bool ISerial::stopListening() { + return(_mod->ModuleSerial->stopListening()); +} + +bool ISerial::overflow() { + return(_mod->ModuleSerial->overflow()); +} +#endif + size_t ISerial::print(const __FlashStringHelper *ifsh) { return(_mod->ModuleSerial->print(ifsh)); } diff --git a/src/ISerial.h b/src/ISerial.h index c8ecacbe..34064934 100644 --- a/src/ISerial.h +++ b/src/ISerial.h @@ -18,17 +18,21 @@ class ISerial { explicit ISerial(Module* mod); void begin(long); - bool listen(); void end(); - bool isListening(); - bool stopListening(); - bool overflow(); int peek(); size_t write(uint8_t); int read(); int available(); void flush(); + // SoftwareSerial-only methods + #if !defined(RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED) + bool listen(); + bool isListening(); + bool stopListening(); + bool overflow(); + #endif + size_t print(const __FlashStringHelper *); size_t print(const String &); size_t print(const char[]); From 1534aab9105185cf751b065f31b97d500746261f Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:03:43 +0200 Subject: [PATCH 217/455] [Si443x] Removed redundant variable assingment --- src/modules/Si443x/Si443x.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 94ca8446..301ea4ac 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -630,7 +630,6 @@ int16_t Si443x::updateClockRecovery() { } if((rxOsr_temp - rxOsr_int) >= 0.125) { rxOsr_dec |= 0x01; - rxOsr_temp -= 0.125; } uint16_t rxOsr_fixed = ((uint16_t)rxOsr_int << 3) | ((uint16_t)rxOsr_dec); From e89e8a053a31924d237b90bf79302a22be1fad20 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:03:57 +0200 Subject: [PATCH 218/455] [AFSK] Using init list --- src/protocols/AFSK/AFSK.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/protocols/AFSK/AFSK.cpp b/src/protocols/AFSK/AFSK.cpp index 6cf64ac9..831a278d 100644 --- a/src/protocols/AFSK/AFSK.cpp +++ b/src/protocols/AFSK/AFSK.cpp @@ -1,9 +1,8 @@ #include "AFSK.h" #if !defined(RADIOLIB_EXCLUDE_AFSK) -AFSKClient::AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin) { +AFSKClient::AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin): _pin(pin) { _phy = phy; - _pin = pin; } int16_t AFSKClient::tone(uint16_t freq, bool autoStart) { From e1990e460dad528b8b617cccebe2fdefcdb39cba Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:05:46 +0200 Subject: [PATCH 219/455] [AX25] Added copy ctor and assignment operator --- src/protocols/AX25/AX25.cpp | 39 +++++++++++++++++++++++++++++++++++++ src/protocols/AX25/AX25.h | 14 +++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index d5bedc48..7f5c0ef6 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -49,6 +49,10 @@ AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* src } } +AX25Frame::AX25Frame(const AX25Frame& frame) { + *this = frame; +} + AX25Frame::~AX25Frame() { #ifndef RADIOLIB_STATIC_ONLY // deallocate info field @@ -67,6 +71,41 @@ AX25Frame::~AX25Frame() { #endif } +AX25Frame& AX25Frame::operator=(const AX25Frame& frame) { + // destination callsign/SSID + memcpy(this->destCallsign, frame.destCallsign, strlen(frame.destCallsign)); + this->destCallsign[strlen(frame.destCallsign)] = '\0'; + this->destSSID = frame.destSSID; + + // source callsign/SSID + memcpy(this->srcCallsign, frame.srcCallsign, strlen(frame.srcCallsign)); + this->srcCallsign[strlen(frame.srcCallsign)] = '\0'; + this->srcSSID = frame.srcSSID; + + // repeaters + this->numRepeaters = frame.numRepeaters; + for(uint8_t i = 0; i < this->numRepeaters; i++) { + memcpy(this->repeaterCallsigns[i], frame.repeaterCallsigns[i], strlen(frame.repeaterCallsigns[i])); + } + memcpy(this->repeaterSSIDs, frame.repeaterSSIDs, this->numRepeaters); + + // control field + this->control = frame.control; + + // sequence numbers + this->rcvSeqNumber = frame.rcvSeqNumber; + this->sendSeqNumber = frame.sendSeqNumber; + + // PID field + this->protocolID = frame.protocolID; + + // info field + this->infoLen = frame.infoLen; + memcpy(this->info, frame.info, this->infoLen); + + return(*this); +} + int16_t AX25Frame::setRepeaters(char** repeaterCallsigns, uint8_t* repeaterSSIDs, uint8_t numRepeaters) { // check number of repeaters if((numRepeaters < 1) || (numRepeaters > 8)) { diff --git a/src/protocols/AX25/AX25.h b/src/protocols/AX25/AX25.h index 20df8d53..8f005b3f 100644 --- a/src/protocols/AX25/AX25.h +++ b/src/protocols/AX25/AX25.h @@ -224,11 +224,25 @@ class AX25Frame { */ AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control, uint8_t protocolID, uint8_t* info, uint16_t infoLen); + /*! + \brief Copy constructor. + + \param frame AX25Frame instance to copy. + */ + AX25Frame(const AX25Frame& frame); + /*! \brief Default destructor. */ ~AX25Frame(); + /*! + \brief Overload for assignment operator. + + \param frame rvalue AX25Frame. + */ + AX25Frame& operator=(const AX25Frame& frame); + /*! \brief Method to set the repeater callsigns and SSIDs. From b8de06288c0847ce076179235cb3ba5a28ff8baf Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:05:54 +0200 Subject: [PATCH 220/455] Added copy ctor and assignment operator --- src/Module.cpp | 23 ++++++++++++++++++++++- src/Module.h | 13 +++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Module.cpp b/src/Module.cpp index ee9d00e3..9e690883 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -89,6 +89,27 @@ Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rs #endif } +Module::Module(const Module& mod) { + *this = mod; +} + +Module& Module::operator=(const Module& mod) { + this->ModuleSerial = mod.ModuleSerial; + this->baudrate = mod.baudrate; + memcpy(this->AtLineFeed, mod.AtLineFeed, strlen(mod.AtLineFeed)); + this->SPIreadCommand = mod.SPIreadCommand; + this->SPIwriteCommand = mod.SPIwriteCommand; + this->_cs = mod.getCs(); + this->_irq = mod.getIrq(); + this->_rst = mod.getRst(); + this->_rx = mod.getRx(); + this->_tx = mod.getTx(); + this->_spiSettings = mod.getSpiSettings(); + this->_spi = mod.getSpi(); + + return(*this); +} + void Module::init(uint8_t interface) { // select interface switch(interface) { @@ -198,7 +219,7 @@ int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t // 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 = micros(); - uint8_t readValue = 0; + uint8_t readValue; while(micros() - start < (checkInterval * 1000)) { readValue = SPIreadRegister(reg); if(readValue == newValue) { diff --git a/src/Module.h b/src/Module.h index 84b398c4..cdf9109f 100644 --- a/src/Module.h +++ b/src/Module.h @@ -116,6 +116,19 @@ class Module { Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = RADIOLIB_DEFAULT_SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = nullptr); #endif + /*! + \brief Copy constructor. + + \param mod Module instance to copy. + */ + Module(const Module& mod); + + /*! + \brief Overload for assignment operator. + + \param frame rvalue Module. + */ + Module& operator=(const Module& mod); // public member variables From cb191e79732b7cd4cfc8c54d8c863b8ffadba140 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:51:24 +0200 Subject: [PATCH 221/455] Added encoding and data shaping aliases --- src/TypeDef.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/TypeDef.h b/src/TypeDef.h index f8254d3d..aa4c41af 100644 --- a/src/TypeDef.h +++ b/src/TypeDef.h @@ -88,6 +88,66 @@ \} */ +/*! + \defgroup config_shaping Data shaping filter values aliases. + + \{ +*/ + +/*! + \brief No shaping. +*/ +#define RADIOLIB_SHAPING_NONE 0x00 + +/*! + \brief Gaussin shaping filter, BT = 0.3 +*/ +#define RADIOLIB_SHAPING_0_3 0x01 + +/*! + \brief Gaussin shaping filter, BT = 0.5 +*/ +#define RADIOLIB_SHAPING_0_5 0x02 + +/*! + \brief Gaussin shaping filter, BT = 0.7 +*/ +#define RADIOLIB_SHAPING_0_7 0x03 + +/*! + \brief Gaussin shaping filter, BT = 1.0 +*/ +#define RADIOLIB_SHAPING_1_0 0x04 + +/*! + \} +*/ + +/*! + \defgroup config_encoding Encoding type aliases. + + \{ +*/ + +/*! + \brief Non-return to zero - no encoding. +*/ +#define RADIOLIB_ENCODING_NRZ 0x00 + +/*! + \brief Manchester encoding. +*/ +#define RADIOLIB_ENCODING_MANCHESTER 0x01 + +/*! + \brief Whitening. +*/ +#define RADIOLIB_ENCODING_WHITENING 0x02 + +/*! + \} +*/ + /*! \defgroup status_codes Status Codes From acdd70693daf86a8f2a99cfec1e7c22ecd604d6e Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:52:11 +0200 Subject: [PATCH 222/455] [CC1101] Changed shaping datatype to uint8_t --- src/modules/CC1101/CC1101.cpp | 24 +++++++++++++----------- src/modules/CC1101/CC1101.h | 10 +++++----- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 3d1f50dd..3f186000 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -685,19 +685,21 @@ int16_t CC1101::setPromiscuousMode(bool promiscuous) { return(state); } -int16_t CC1101::setDataShaping(float sh) { +int16_t CC1101::setDataShaping(uint8_t sh) { // set mode to standby int16_t state = standby(); RADIOLIB_ASSERT(state); // set data shaping - sh *= 10.0; - if(abs(sh - 0.0) <= 0.001) { - state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_2_FSK, 6, 4); - } else if(abs(sh - 5.0) <= 0.001) { - state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_GFSK, 6, 4); - } else { - return(ERR_INVALID_DATA_SHAPING); + switch(sh) { + case RADIOLIB_SHAPING_NONE: + state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_2_FSK, 6, 4); + break; + case RADIOLIB_SHAPING_0_5: + state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_GFSK, 6, 4); + break; + default: + return(ERR_INVALID_DATA_SHAPING); } return(state); } @@ -709,15 +711,15 @@ int16_t CC1101::setEncoding(uint8_t encoding) { // set encoding switch(encoding) { - case 0: + case RADIOLIB_ENCODING_NRZ: state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3); RADIOLIB_ASSERT(state); return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6)); - case 1: + case RADIOLIB_ENCODING_MANCHESTER: state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_ON, 3, 3); RADIOLIB_ASSERT(state); return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6)); - case 2: + case RADIOLIB_ENCODING_WHITENING: state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3); RADIOLIB_ASSERT(state); return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_ON, 6, 6)); diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index f38b57c6..a442a068 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -847,18 +847,18 @@ class CC1101: public PhysicalLayer { /*! \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. - Allowed value is 0.5. Set to 0 to disable data shaping. + Allowed value is RADIOLIB_SHAPING_0_5. Set to RADIOLIB_SHAPING_NONE to disable data shaping. - \param sh Gaussian shaping bandwidth-time product that will be used for data shaping + \param sh Gaussian shaping bandwidth-time product that will be used for data shaping. \returns \ref status_codes */ - int16_t setDataShaping(float sh) override; + int16_t setDataShaping(uint8_t sh) override; /*! - \brief Sets transmission encoding. + \brief Sets transmission encoding. Allowed values are RADIOLIB_ENCODING_NRZ and RADIOLIB_ENCODING_WHITENING. - \param encoding Encoding to be used. Set to 0 for NRZ, 1 for Manchester and 2 for whitening. + \param encoding Encoding to be used. \returns \ref status_codes */ From 263410ffb1523b3e1e3bb0511bccf48caa80eb5c Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:52:30 +0200 Subject: [PATCH 223/455] [RF69] Changed shaping datatype to uint8_t --- src/modules/RF69/RF69.cpp | 31 +++++++++++++++---------------- src/modules/RF69/RF69.h | 7 ++++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index ba1548b8..263541a3 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -704,25 +704,24 @@ int16_t RF69::setPromiscuousMode(bool promiscuous) { return(state); } -int16_t RF69::setDataShaping(float sh) { +int16_t RF69::setDataShaping(uint8_t sh) { // set mode to standby int16_t state = standby(); RADIOLIB_ASSERT(state); // set data shaping - sh *= 10.0; - if(abs(sh - 0.0) <= 0.001) { - state = _mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_NO_SHAPING, 1, 0); - } else if(abs(sh - 3.0) <= 0.001) { - state = _mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_0_3, 1, 0); - } else if(abs(sh - 5.0) <= 0.001) { - state = _mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_0_5, 1, 0); - } else if(abs(sh - 10.0) <= 0.001) { - state = _mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_1_0, 1, 0); - } else { - return(ERR_INVALID_DATA_SHAPING); + switch(sh) { + case RADIOLIB_SHAPING_NONE: + return(_mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_NO_SHAPING, 1, 0)); + case RADIOLIB_SHAPING_0_3: + return(_mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_0_3, 1, 0)); + case RADIOLIB_SHAPING_0_5: + return(_mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_0_5, 1, 0)); + case RADIOLIB_SHAPING_1_0: + return(_mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_1_0, 1, 0)); + default: + return(ERR_INVALID_DATA_SHAPING); } - return(state); } int16_t RF69::setEncoding(uint8_t encoding) { @@ -732,11 +731,11 @@ int16_t RF69::setEncoding(uint8_t encoding) { // set encoding switch(encoding) { - case 0: + case RADIOLIB_ENCODING_NRZ: return(_mod->SPIsetRegValue(RF69_REG_PACKET_CONFIG_1, RF69_DC_FREE_NONE, 6, 5)); - case 1: + case RADIOLIB_ENCODING_MANCHESTER: return(_mod->SPIsetRegValue(RF69_REG_PACKET_CONFIG_1, RF69_DC_FREE_MANCHESTER, 6, 5)); - case 2: + case RADIOLIB_ENCODING_WHITENING: return(_mod->SPIsetRegValue(RF69_REG_PACKET_CONFIG_1, RF69_DC_FREE_WHITENING, 6, 5)); default: return(ERR_INVALID_ENCODING); diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 1994980b..a87752f0 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -774,18 +774,19 @@ class RF69: public PhysicalLayer { /*! \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. - Allowed values are 0.3, 0.5 or 1.0. Set to 0 to disable data shaping. + Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. \param sh Gaussian shaping bandwidth-time product that will be used for data shaping \returns \ref status_codes */ - int16_t setDataShaping(float sh) override; + int16_t setDataShaping(uint8_t sh) override; /*! \brief Sets transmission encoding. + Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER and RADIOLIB_ENCODING_WHITENING. - \param encoding Encoding to be used. Set to 0 for NRZ, 1 for Manchester and 2 for whitening. + \param encoding Encoding to be used. \returns \ref status_codes */ From 5aff492323444f65eac4fd6ddf2c1fecfc4712f6 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:52:48 +0200 Subject: [PATCH 224/455] [SX126x] Changed shaping datatype to uint8_t --- src/modules/SX126x/SX1262.cpp | 2 +- src/modules/SX126x/SX1262.h | 2 +- src/modules/SX126x/SX1268.cpp | 2 +- src/modules/SX126x/SX1268.h | 4 ++-- src/modules/SX126x/SX126x.cpp | 37 ++++++++++++++++++++--------------- src/modules/SX126x/SX126x.h | 8 +++++--- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index 804c88a3..02363bf8 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -23,7 +23,7 @@ int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } -int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) { // execute common part int16_t state = SX126x::beginFSK(br, freqDev, rxBw, currentLimit, preambleLength, dataShaping, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index 1aa0529f..adb11a93 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -75,7 +75,7 @@ class SX1262: public SX126x { \returns \ref status_codes */ - int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, float dataShaping = 0.5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); // configuration methods diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index a6ec18ed..bf0b15b0 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -23,7 +23,7 @@ int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } -int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) { // execute common part int16_t state = SX126x::beginFSK(br, freqDev, rxBw, currentLimit, preambleLength, dataShaping, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h index d7acd5f0..004d74b5 100644 --- a/src/modules/SX126x/SX1268.h +++ b/src/modules/SX126x/SX1268.h @@ -69,13 +69,13 @@ class SX1268: public SX126x { \parma preambleLength FSK preamble length in bits. Defaults to 16 bits. - \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5. + \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to RADIOLIB_SHAPING_0_5. \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip. \returns \ref status_codes */ - int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, float dataShaping = 0.5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); // configuration methods diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index f459e975..e48828b1 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -75,7 +75,7 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float return(state); } -int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -826,26 +826,31 @@ int16_t SX126x::setRxBandwidth(float rxBw) { return(setModulationParamsFSK(_br, _pulseShape, _rxBw, _freqDev)); } -int16_t SX126x::setDataShaping(float sh) { +int16_t SX126x::setDataShaping(uint8_t sh) { // check active modem if(getPacketType() != SX126X_PACKET_TYPE_GFSK) { return(ERR_WRONG_MODEM); } - // check allowed values - sh *= 10.0; - if(abs(sh - 0.0) <= 0.001) { - _pulseShape = SX126X_GFSK_FILTER_NONE; - } else if(abs(sh - 3.0) <= 0.001) { - _pulseShape = SX126X_GFSK_FILTER_GAUSS_0_3; - } else if(abs(sh - 5.0) <= 0.001) { - _pulseShape = SX126X_GFSK_FILTER_GAUSS_0_5; - } else if(abs(sh - 7.0) <= 0.001) { - _pulseShape = SX126X_GFSK_FILTER_GAUSS_0_7; - } else if(abs(sh - 10.0) <= 0.001) { - _pulseShape = SX126X_GFSK_FILTER_GAUSS_1; - } else { - return(ERR_INVALID_DATA_SHAPING); + // set data shaping + switch(sh) { + case RADIOLIB_SHAPING_NONE: + _pulseShape = SX126X_GFSK_FILTER_NONE; + break; + case RADIOLIB_SHAPING_0_3: + _pulseShape = SX126X_GFSK_FILTER_GAUSS_0_3; + break; + case RADIOLIB_SHAPING_0_5: + _pulseShape = SX126X_GFSK_FILTER_GAUSS_0_5; + break; + case RADIOLIB_SHAPING_0_7: + _pulseShape = SX126X_GFSK_FILTER_GAUSS_0_7; + break; + case RADIOLIB_SHAPING_1_0: + _pulseShape = SX126X_GFSK_FILTER_GAUSS_1; + break; + default: + return(ERR_INVALID_DATA_SHAPING); } // update modulation parameters diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 849d8757..c2224e92 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -400,7 +400,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, float dataShaping, float tcxoVoltage, bool useRegulatorLDO = false); + int16_t beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO = false); /*! \brief Reset method. Will reset the chip to the default state using RST pin. @@ -653,13 +653,15 @@ class SX126x: public PhysicalLayer { int16_t setRxBandwidth(float rxBw); /*! - \brief Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are 0.3, 0.5, 0.7 and 1.0. Set to 0 to disable shaping. + \brief Sets time-bandwidth product of Gaussian filter applied for shaping. + Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5, RADIOLIB_SHAPING_0_7 or RADIOLIB_SHAPING_1_0. + Set to RADIOLIB_SHAPING_NONE to disable data shaping. \param sh Time-bandwidth product of Gaussian filter to be set. \returns \ref status_codes */ - int16_t setDataShaping(float sh) override; + int16_t setDataShaping(uint8_t sh) override; /*! \brief Sets FSK sync word in the form of array of up to 8 bytes. From 7dc7f4d76c01358ed02197b597dbd13175bd6a02 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:53:05 +0200 Subject: [PATCH 225/455] [SX127x] Changed shaping datatype to uint8_t --- src/modules/SX127x/SX1272.cpp | 26 +++++++++++++------------- src/modules/SX127x/SX1272.h | 6 +++--- src/modules/SX127x/SX1278.cpp | 26 +++++++++++++------------- src/modules/SX127x/SX1278.h | 6 +++--- src/modules/SX127x/SX127x.cpp | 6 +++--- src/modules/SX127x/SX127x.h | 3 ++- 6 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 4384fd54..411c3ab3 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -257,7 +257,7 @@ int16_t SX1272::setGain(uint8_t gain) { return(state); } -int16_t SX1272::setDataShaping(float sh) { +int16_t SX1272::setDataShaping(uint8_t sh) { // check active modem if(getActiveModem() != SX127X_FSK_OOK) { return(ERR_WRONG_MODEM); @@ -270,21 +270,21 @@ int16_t SX1272::setDataShaping(float sh) { // set mode to standby int16_t state = SX127x::standby(); + RADIOLIB_ASSERT(state); // set data shaping - sh *= 10.0; - if(abs(sh - 0.0) <= 0.001) { - state |= _mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1272_NO_SHAPING, 4, 3); - } else if(abs(sh - 3.0) <= 0.001) { - state |= _mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1272_FSK_GAUSSIAN_0_3, 4, 3); - } else if(abs(sh - 5.0) <= 0.001) { - state |= _mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1272_FSK_GAUSSIAN_0_5, 4, 3); - } else if(abs(sh - 10.0) <= 0.001) { - state |= _mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1272_FSK_GAUSSIAN_1_0, 4, 3); - } else { - return(ERR_INVALID_DATA_SHAPING); + switch(sh) { + case RADIOLIB_SHAPING_NONE: + return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1272_NO_SHAPING, 4, 3)); + case RADIOLIB_SHAPING_0_3: + return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1272_FSK_GAUSSIAN_0_3, 4, 3)); + case RADIOLIB_SHAPING_0_5: + return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1272_FSK_GAUSSIAN_0_5, 4, 3)); + case RADIOLIB_SHAPING_1_0: + return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1272_FSK_GAUSSIAN_1_0, 4, 3)); + default: + return(ERR_INVALID_DATA_SHAPING); } - return(state); } int16_t SX1272::setDataShapingOOK(uint8_t sh) { diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index e47e7fed..6aba8259 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -222,14 +222,14 @@ class SX1272: public SX127x { int16_t setGain(uint8_t gain); /*! - \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. - Allowed values are 0.3, 0.5 or 1.0. Set to 0 to disable data shaping. Only available in FSK mode with FSK modulation. + \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. Only available in FSK mode with FSK modulation. + Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. \param sh Gaussian shaping bandwidth-time product that will be used for data shaping \returns \ref status_codes */ - int16_t setDataShaping(float sh) override; + int16_t setDataShaping(uint8_t sh) override; /*! \brief Sets filter cutoff frequency that will be used for data shaping. diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 8e70be39..ae2933a5 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -329,7 +329,7 @@ int16_t SX1278::setGain(uint8_t gain) { return(state); } -int16_t SX1278::setDataShaping(float sh) { +int16_t SX1278::setDataShaping(uint8_t sh) { // check active modem if(getActiveModem() != SX127X_FSK_OOK) { return(ERR_WRONG_MODEM); @@ -342,21 +342,21 @@ int16_t SX1278::setDataShaping(float sh) { // set mode to standby int16_t state = SX127x::standby(); + RADIOLIB_ASSERT(state); // set data shaping - sh *= 10.0; - if(abs(sh - 0.0) <= 0.001) { - state |= _mod->SPIsetRegValue(SX127X_REG_PA_RAMP, SX1278_NO_SHAPING, 6, 5); - } else if(abs(sh - 3.0) <= 0.001) { - state |= _mod->SPIsetRegValue(SX127X_REG_PA_RAMP, SX1278_FSK_GAUSSIAN_0_3, 6, 5); - } else if(abs(sh - 5.0) <= 0.001) { - state |= _mod->SPIsetRegValue(SX127X_REG_PA_RAMP, SX1278_FSK_GAUSSIAN_0_5, 6, 5); - } else if(abs(sh - 10.0) <= 0.001) { - state |= _mod->SPIsetRegValue(SX127X_REG_PA_RAMP, SX1278_FSK_GAUSSIAN_1_0, 6, 5); - } else { - return(ERR_INVALID_DATA_SHAPING); + switch(sh) { + case RADIOLIB_SHAPING_NONE: + return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1278_NO_SHAPING, 6, 5)); + case RADIOLIB_SHAPING_0_3: + return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1278_FSK_GAUSSIAN_0_3, 6, 5)); + case RADIOLIB_SHAPING_0_5: + return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1278_FSK_GAUSSIAN_0_5, 6, 5)); + case RADIOLIB_SHAPING_1_0: + return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1278_FSK_GAUSSIAN_1_0, 6, 5)); + default: + return(ERR_INVALID_DATA_SHAPING); } - return(state); } int16_t SX1278::setDataShapingOOK(uint8_t sh) { diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index c7e5d5b5..5ee20cc8 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -231,14 +231,14 @@ class SX1278: public SX127x { int16_t setGain(uint8_t gain); /*! - \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. - Allowed values are 0.3, 0.5 or 1.0. Set to 0 to disable data shaping. Only available in FSK mode with FSK modulation. + \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. Only available in FSK mode with FSK modulation. + Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. \param sh Gaussian shaping bandwidth-time product that will be used for data shaping \returns \ref status_codes */ - int16_t setDataShaping(float sh) override; + int16_t setDataShaping(uint8_t sh) override; /*! \brief Sets filter cutoff frequency that will be used for data shaping. diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 79c2ab65..9f1f4ad0 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -912,11 +912,11 @@ int16_t SX127x::setEncoding(uint8_t encoding) { // set encoding switch(encoding) { - case 0: + case RADIOLIB_ENCODING_NRZ: return(_mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_1, SX127X_DC_FREE_NONE, 6, 5)); - case 1: + case RADIOLIB_ENCODING_MANCHESTER: return(_mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_1, SX127X_DC_FREE_MANCHESTER, 6, 5)); - case 2: + case RADIOLIB_ENCODING_WHITENING: return(_mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_1, SX127X_DC_FREE_WHITENING, 6, 5)); default: return(ERR_INVALID_ENCODING); diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 1a318c33..efc5eb50 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -893,8 +893,9 @@ class SX127x: public PhysicalLayer { /*! \brief Sets transmission encoding. Only available in FSK mode. + Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER and RADIOLIB_ENCODING_WHITENING. - \param encoding Encoding to be used. Set to 0 for NRZ, 1 for Manchester and 2 for whitening. + \param encoding Encoding to be used. \returns \ref status_codes */ From be346eb6aa2e02afed8e97f9a15ec381828cdcd9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:53:12 +0200 Subject: [PATCH 226/455] [SX128x] Changed shaping datatype to uint8_t --- src/modules/SX128x/SX128x.cpp | 31 +++++++++++++++++-------------- src/modules/SX128x/SX128x.h | 13 +++++++------ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index a5fec200..2bd2c456 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -56,7 +56,7 @@ int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, int8_t power return(state); } -int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, uint16_t preambleLength, float dataShaping) { +int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, uint16_t preambleLength, uint8_t dataShaping) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -115,7 +115,7 @@ int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, return(state); } -int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, float dataShaping) { +int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, uint8_t dataShaping) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -163,7 +163,7 @@ int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, f return(state); } -int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uint16_t preambleLength, float dataShaping) { +int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uint16_t preambleLength, uint8_t dataShaping) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -815,23 +815,26 @@ int16_t SX128x::setFrequencyDeviation(float freqDev) { return(setModulationParams(_br, _modIndex, _shaping)); } -int16_t SX128x::setDataShaping(float dataShaping) { +int16_t SX128x::setDataShaping(uint8_t sh) { // check active modem uint8_t modem = getPacketType(); if(!((modem == SX128X_PACKET_TYPE_GFSK) || (modem == SX128X_PACKET_TYPE_BLE) || (modem == SX128X_PACKET_TYPE_FLRC))) { return(ERR_WRONG_MODEM); } - // check allowed values - dataShaping *= 10.0; - if(abs(dataShaping - 0.0) <= 0.001) { - _shaping = SX128X_BLE_GFSK_BT_OFF; - } else if(abs(dataShaping - 5.0) <= 0.001) { - _shaping = SX128X_BLE_GFSK_BT_0_5; - } else if(abs(dataShaping - 10.0) <= 0.001) { - _shaping = SX128X_BLE_GFSK_BT_1_0; - } else { - return(ERR_INVALID_DATA_SHAPING); + // set data shaping + switch(sh) { + case RADIOLIB_SHAPING_NONE: + _shaping = SX128X_BLE_GFSK_BT_OFF; + break; + case RADIOLIB_SHAPING_0_5: + _shaping = SX128X_BLE_GFSK_BT_0_5; + break; + case RADIOLIB_SHAPING_1_0: + _shaping = SX128X_BLE_GFSK_BT_1_0; + break; + default: + return(ERR_INVALID_DATA_SHAPING); } // update modulation parameters diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index 131e7baf..5c4f3978 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -385,11 +385,11 @@ class SX128x: public PhysicalLayer { \parma preambleLength FSK preamble length in bits. Defaults to 16 bits. - \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5. + \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to RADIOLIB_SHAPING_0_5. \returns \ref status_codes */ - int16_t beginGFSK(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t power = 10, uint16_t preambleLength = 16, float dataShaping = 0.5); + int16_t beginGFSK(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t power = 10, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5); /*! \brief Initialization method for BLE modem. @@ -406,7 +406,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t beginBLE(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t power = 10, float dataShaping = 0.5); + int16_t beginBLE(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t power = 10, uint8_t dataShaping = RADIOLIB_SHAPING_0_5); /*! \brief Initialization method for FLRC modem. @@ -425,7 +425,7 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ - int16_t beginFLRC(float freq = 2400.0, uint16_t br = 650, uint8_t cr = 3, int8_t power = 10, uint16_t preambleLength = 16, float dataShaping = 0.5); + int16_t beginFLRC(float freq = 2400.0, uint16_t br = 650, uint8_t cr = 3, int8_t power = 10, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5); /*! \brief Reset method. Will reset the chip to the default state using RST pin. @@ -637,13 +637,14 @@ class SX128x: public PhysicalLayer { int16_t setFrequencyDeviation(float freqDev) override; /*! - \brief Sets time-bandwidth product of Gaussian filter applied for shaping. Allowed values are 0.5 and 1.0. Set to 0 to disable shaping. + \brief Sets time-bandwidth product of Gaussian filter applied for shaping. + Allowed values are RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. \param sh Time-bandwidth product of Gaussian filter to be set. \returns \ref status_codes */ - int16_t setDataShaping(float dataShaping) override; + int16_t setDataShaping(uint8_t sh) override; /*! \brief Sets FSK/FLRC sync word in the form of array of up to 5 bytes (FSK). For FLRC modem, the sync word must be exactly 4 bytes long From 3312645d90d4a2f7b1fd761c0814a9e6ee972151 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:53:20 +0200 Subject: [PATCH 227/455] [Si443x] Changed shaping datatype to uint8_t --- src/modules/Si443x/Si443x.cpp | 26 +++++++++++++++----------- src/modules/Si443x/Si443x.h | 9 +++++---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 301ea4ac..78c95b74 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -495,29 +495,33 @@ int16_t Si443x::setEncoding(uint8_t encoding) { // set encoding // TODO - add inverted Manchester? switch(encoding) { - case 0: + case RADIOLIB_ENCODING_NRZ: return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_1, SI443X_MANCHESTER_INVERTED_OFF | SI443X_MANCHESTER_OFF | SI443X_WHITENING_OFF, 2, 0)); - case 1: + case RADIOLIB_ENCODING_MANCHESTER: return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_1, SI443X_MANCHESTER_INVERTED_OFF | SI443X_MANCHESTER_ON | SI443X_WHITENING_OFF, 2, 0)); - case 2: + case RADIOLIB_ENCODING_WHITENING: return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_1, SI443X_MANCHESTER_INVERTED_OFF | SI443X_MANCHESTER_OFF | SI443X_WHITENING_ON, 2, 0)); default: return(ERR_INVALID_ENCODING); } } -int16_t Si443x::setDataShaping(float sh) { +int16_t Si443x::setDataShaping(uint8_t sh) { // set mode to standby int16_t state = standby(); RADIOLIB_ASSERT(state); - if(sh == 0.0) { - // set modulation to FSK - return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_2, SI443X_MODULATION_FSK, 1, 0)); - } else { - // set modulation to GFSK - // TODO implement fiter configuration - docs claim this should be possible, but seems undocumented - return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_2, SI443X_MODULATION_GFSK, 1, 0)); + // set data shaping + switch(sh) { + case RADIOLIB_SHAPING_NONE: + return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_1, SI443X_MANCHESTER_INVERTED_OFF | SI443X_MANCHESTER_OFF | SI443X_WHITENING_OFF, 2, 0)); + case RADIOLIB_SHAPING_0_3: + case RADIOLIB_SHAPING_0_5: + case RADIOLIB_SHAPING_1_0: + // TODO implement fiter configuration - docs claim this should be possible, but seems undocumented + return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_1, SI443X_MANCHESTER_INVERTED_OFF | SI443X_MANCHESTER_OFF | SI443X_WHITENING_ON, 2, 0)); + default: + return(ERR_INVALID_ENCODING); } } diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 8e2907a5..6cabb7d4 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -746,22 +746,23 @@ class Si443x: public PhysicalLayer { /*! \brief Sets transmission encoding. Only available in FSK mode. + Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER and RADIOLIB_ENCODING_WHITENING. - \param encoding Encoding to be used. Set to 0 for NRZ, 1 for Manchester and 2 for whitening. + \param encoding Encoding to be used. \returns \ref status_codes */ int16_t setEncoding(uint8_t encoding) override; /*! - \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. - Allowed values are 0.3, 0.5 or 1.0. Set to 0 to disable data shaping. Only available in FSK mode with FSK modulation. + \brief Sets Gaussian filter bandwidth-time product that will be used for data shaping. Only available in FSK mode with FSK modulation. + Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping. \param sh Gaussian shaping bandwidth-time product that will be used for data shaping \returns \ref status_codes */ - int16_t setDataShaping(float sh) override; + int16_t setDataShaping(uint8_t sh) override; /*! \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. From 92c19da05891853ab9bae70968575585339de944 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:53:29 +0200 Subject: [PATCH 228/455] [nRF24] Changed shaping datatype to uint8_t --- src/modules/nRF24/nRF24.cpp | 2 +- src/modules/nRF24/nRF24.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index e8df4e13..135e75af 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -489,7 +489,7 @@ int16_t nRF24::setAutoAck(uint8_t pipeNum, bool autoAckOn){ } } -int16_t nRF24::setDataShaping(float sh) { +int16_t nRF24::setDataShaping(uint8_t sh) { // nRF24 is unable to set data shaping // this method is implemented only for PhysicalLayer compatibility (void)sh; diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index d41e683f..d1e7a8b3 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -453,7 +453,7 @@ class nRF24: public PhysicalLayer { \returns \ref status_codes */ - int16_t setDataShaping(float sh) override; + int16_t setDataShaping(uint8_t sh) override; /*! \brief Dummy encoding configuration method, to ensure PhysicalLayer compatibility. From a437e25968aa05db551ade2166d2419746538e65 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 08:53:40 +0200 Subject: [PATCH 229/455] [PHY] Changed shaping datatype to uint8_t --- src/protocols/PhysicalLayer/PhysicalLayer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.h b/src/protocols/PhysicalLayer/PhysicalLayer.h index 601c39c6..11bfb490 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.h +++ b/src/protocols/PhysicalLayer/PhysicalLayer.h @@ -193,16 +193,16 @@ class PhysicalLayer { /*! \brief Sets GFSK data shaping. Only available in FSK mode. Must be implemented in module class. - \param sh Shaping to be set. Set to zero to disable data shaping. + \param sh Shaping to be set. See \ref config_shaping for possible values. \returns \ref status_codes */ - virtual int16_t setDataShaping(float sh) = 0; + virtual int16_t setDataShaping(uint8_t sh) = 0; /*! \brief Sets FSK data encoding. Only available in FSK mode. Must be implemented in module class. - \param enc Encoding to be used. Set to zero to for no encoding (NRZ). + \param enc Encoding to be used. See \ref config_encoding for possible values. \returns \ref status_codes */ From 58db5d1661c6c7885fbd0ce24816a56a381a2a11 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:13:01 +0200 Subject: [PATCH 230/455] [CC1101] Synced parameters of all FSK modules --- .../CC1101_Settings/CC1101_Settings.ino | 5 +++-- src/modules/CC1101/CC1101.cpp | 22 +++++++++---------- src/modules/CC1101/CC1101.h | 14 ++++++------ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/examples/CC1101/CC1101_Settings/CC1101_Settings.ino b/examples/CC1101/CC1101_Settings/CC1101_Settings.ino index 4e4bcfd3..e724f7b6 100644 --- a/examples/CC1101/CC1101_Settings/CC1101_Settings.ino +++ b/examples/CC1101/CC1101_Settings/CC1101_Settings.ino @@ -59,8 +59,9 @@ void setup() { // bit rate: 32.0 kbps // frequency deviation: 60.0 kHz // Rx bandwidth: 250.0 kHz - // sync word: 0xD391 - state = radio2.begin(434.0, 32.0, 60.0, 250.0); + // output power: 7 dBm + // preamble length: 32 bits + state = radio2.begin(434.0, 32.0, 60.0, 250.0, 7, 32); if (state == ERR_NONE) { Serial.println(F("success!")); } else { diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 3f186000..9fd98d99 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -77,15 +77,15 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po RADIOLIB_ASSERT(state); // set default data shaping - state = setDataShaping(0); + state = setDataShaping(RADIOLIB_ENCODING_NRZ); RADIOLIB_ASSERT(state); // set default encoding - state = setEncoding(2); + state = setEncoding(RADIOLIB_SHAPING_NONE); RADIOLIB_ASSERT(state); // set default sync word - state = setSyncWord(0xD3, 0x91, 0, false); + state = setSyncWord(0x12, 0xAD, 0, false); RADIOLIB_ASSERT(state); // flush FIFOs @@ -508,28 +508,28 @@ int16_t CC1101::setPreambleLength(uint8_t preambleLength) { // check allowed values uint8_t value; switch(preambleLength){ - case 2: + case 16: value = CC1101_NUM_PREAMBLE_2; break; - case 3: + case 24: value = CC1101_NUM_PREAMBLE_3; break; - case 4: + case 32: value = CC1101_NUM_PREAMBLE_4; break; - case 6: + case 48: value = CC1101_NUM_PREAMBLE_6; break; - case 8: + case 64: value = CC1101_NUM_PREAMBLE_8; break; - case 12: + case 96: value = CC1101_NUM_PREAMBLE_12; break; - case 16: + case 128: value = CC1101_NUM_PREAMBLE_16; break; - case 24: + case 192: value = CC1101_NUM_PREAMBLE_24; break; default: diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index a442a068..70256b63 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -521,21 +521,21 @@ class CC1101: public PhysicalLayer { /*! \brief Initialization method. - \param freq Carrier frequency in MHz. Defaults to 868.0 MHz. + \param freq Carrier frequency in MHz. Defaults to 434.0 MHz. - \param br Bit rate to be used in kbps. Defaults to 4.8 kbps. + \param br Bit rate to be used in kbps. Defaults to 48.0 kbps. \param freqDev Frequency deviation from carrier frequency in kHz Defaults to 48.0 kHz. - \param rxBw Receiver bandwidth in kHz. Defaults to 325.0 kHz. + \param rxBw Receiver bandwidth in kHz. Defaults to 125.0 kHz. - \param power Output power in dBm. Defaults to 0 dBm. + \param power Output power in dBm. Defaults to 10 dBm. - \param preambleLength Preamble Length in bytes. Defaults to 4 bytes. + \param preambleLength Preamble Length in bits. Defaults to 16 bits. \returns \ref status_codes */ - int16_t begin(float freq = 868.0, float br = 4.8, float freqDev = 48.0, float rxBw = 325.0, int8_t power = 0, uint8_t preambleLength = 4); + int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 48.0, float rxBw = 125.0, int8_t power = 10, uint8_t preambleLength = 16); /*! \brief Blocking binary transmit method. @@ -733,7 +733,7 @@ class CC1101: public PhysicalLayer { /*! \brief Sets preamble length. - \param preambleLength Preamble length to be set (in bytes), allowed values: 2, 3, 4, 6, 8, 12, 16, 24 + \param preambleLength Preamble length to be set (in bits), allowed values: 16, 24, 32, 48, 64, 96, 128 and 192. \returns \ref status_codes */ From 59434cb0251b2cdf3c6fb44ff0cacd4acfebac25 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:13:24 +0200 Subject: [PATCH 231/455] [RF69] Synced parameters of all FSK modules --- examples/RF69/RF69_Settings/RF69_Settings.ino | 3 ++- src/modules/RF69/RF69.cpp | 25 +++++++++++++++---- src/modules/RF69/RF69.h | 15 +++++++++-- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/examples/RF69/RF69_Settings/RF69_Settings.ino b/examples/RF69/RF69_Settings/RF69_Settings.ino index 49c23e80..f936ee2e 100644 --- a/examples/RF69/RF69_Settings/RF69_Settings.ino +++ b/examples/RF69/RF69_Settings/RF69_Settings.ino @@ -58,7 +58,8 @@ void setup() { // frequency deviation: 60.0 kHz // Rx bandwidth: 250.0 kHz // output power: 17 dBm - state = radio2.begin(868.0, 300.0, 60.0, 250.0, 17); + // preamble length: 32 bits + state = radio2.begin(868.0, 300.0, 60.0, 250.0, 17, 32); if (state == ERR_NONE) { Serial.println(F("success!")); } else { diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 263541a3..ddffc532 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -5,7 +5,7 @@ RF69::RF69(Module* module) : PhysicalLayer(RF69_FREQUENCY_STEP_SIZE, RF69_MAX_PA _mod = module; } -int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t power) { +int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -71,21 +71,25 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe state = setOutputPower(power); RADIOLIB_ASSERT(state); + // configure default preamble length + state = setPreambleLength(preambleLen); + RADIOLIB_ASSERT(state); + // set default packet length mode state = variablePacketLengthMode(); RADIOLIB_ASSERT(state); - // default sync word values 0x2D01 is the same as the default in LowPowerLab RFM69 library - uint8_t syncWord[] = {0x2D, 0x01}; + // set default sync word + uint8_t syncWord[] = {0x12, 0xAD}; state = setSyncWord(syncWord, sizeof(syncWord)); RADIOLIB_ASSERT(state); // set default data shaping - state = setDataShaping(0); + state = setDataShaping(RADIOLIB_SHAPING_NONE); RADIOLIB_ASSERT(state); // set default encoding - state = setEncoding(0); + state = setEncoding(RADIOLIB_ENCODING_NRZ); RADIOLIB_ASSERT(state); // set CRC on by default @@ -580,6 +584,17 @@ int16_t RF69::setSyncWord(uint8_t* syncWord, size_t len, uint8_t maxErrBits) { return(ERR_NONE); } +int16_t RF69::setPreambleLength(uint8_t preambleLen) { + // RF69 configures preamble length in bytes + if(preambleLen % 8 != 0) { + return(ERR_INVALID_PREAMBLE_LENGTH); + } + + uint8_t preLenBytes = preambleLen / 8; + _mod->SPIwriteRegister(RF69_REG_PREAMBLE_MSB, 0x00); + return(_mod->SPIsetRegValue(RF69_REG_PREAMBLE_LSB, preLenBytes)); +} + int16_t RF69::setNodeAddress(uint8_t nodeAddr) { // enable address filtering (node only) int16_t state = _mod->SPIsetRegValue(RF69_REG_PACKET_CONFIG_1, RF69_ADDRESS_FILTERING_NODE, 2, 1); diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index a87752f0..63b63513 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -457,11 +457,13 @@ class RF69: public PhysicalLayer { \param rxBw Receiver bandwidth in kHz. Defaults to 125.0 kHz. - \param power Output power in dBm. Defaults to 13 dBm. + \param power Output power in dBm. Defaults to 10 dBm. + + \param preambleLen Preamble Length in bits. Defaults to 16 bits. \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 13); + int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 10, uint8_t preambleLen = 16); /*! \brief Reset method. Will reset the chip to the default state using RST pin. @@ -670,6 +672,15 @@ class RF69: public PhysicalLayer { */ int16_t setSyncWord(uint8_t* syncWord, size_t len, uint8_t maxErrBits = 0); + /*! + \brief Sets preamble length. + + \param preambleLen Preamble length to be set (in bits), allowed values: 16, 24, 32, 48, 64, 96, 128 and 192. + + \returns \ref status_codes + */ + int16_t setPreambleLength(uint8_t preambleLen); + /*! \brief Sets node address. Calling this method will also enable address filtering for node address only. From c8f4698a26abafbfe8953ad6ae97a3a40cc310e6 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:13:37 +0200 Subject: [PATCH 232/455] [SX126x] Synced parameters of all FSK modules --- .../SX126x_FSK_Modem/SX126x_FSK_Modem.ino | 2 +- src/modules/SX126x/SX1262.cpp | 4 +- src/modules/SX126x/SX1262.h | 14 +++---- src/modules/SX126x/SX1268.cpp | 4 +- src/modules/SX126x/SX1268.h | 16 ++++--- src/modules/SX126x/SX126x.cpp | 42 ++++++++++--------- src/modules/SX126x/SX126x.h | 6 +-- 7 files changed, 42 insertions(+), 46 deletions(-) diff --git a/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino b/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino index 13411fdd..d450f9c6 100644 --- a/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino +++ b/examples/SX126x/SX126x_FSK_Modem/SX126x_FSK_Modem.ino @@ -57,7 +57,7 @@ void setup() { state = radio.setRxBandwidth(250.0); state = radio.setOutputPower(10.0); state = radio.setCurrentLimit(100.0); - state = radio.setDataShaping(1.0); + state = radio.setDataShaping(RADIOLIB_SHAPING_1_0); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; state = radio.setSyncWord(syncWord, 8); diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index 02363bf8..70bb7c44 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -23,9 +23,9 @@ int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } -int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // execute common part - int16_t state = SX126x::beginFSK(br, freqDev, rxBw, currentLimit, preambleLength, dataShaping, tcxoVoltage, useRegulatorLDO); + int16_t state = SX126x::beginFSK(br, freqDev, rxBw, preambleLength, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); // configure publicly accessible settings diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index adb11a93..110b4611 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -40,9 +40,7 @@ class SX1262: public SX126x { \param syncWord 2-byte LoRa sync word. Defaults to SX126X_SYNC_WORD_PRIVATE (0x12). - \param power Output power in dBm. Defaults to 14 dBm. - - \param currentLimit Current protection limit in mA. Defaults to 60.0 mA. + \param power Output power in dBm. Defaults to 10 dBm. \param preambleLength LoRa preamble length in symbols.Defaults to 8 symbols. @@ -50,7 +48,7 @@ class SX1262: public SX126x { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, float currentLimit = 60.0, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); /*! \brief Initialization method for FSK modem. @@ -63,19 +61,19 @@ class SX1262: public SX126x { \param rxBw Receiver bandwidth in kHz. Defaults to 156.2 kHz. - \param power Output power in dBm. Defaults to 14 dBm. + \param power Output power in dBm. Defaults to 10 dBm. \param currentLimit Current protection limit in mA. Defaults to 60.0 mA. \parma preambleLength FSK preamble length in bits. Defaults to 16 bits. - \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5. - \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip. + \param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false. + \returns \ref status_codes */ - int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); // configuration methods diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index bf0b15b0..44923333 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -23,9 +23,9 @@ int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } -int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength,float tcxoVoltage, bool useRegulatorLDO) { // execute common part - int16_t state = SX126x::beginFSK(br, freqDev, rxBw, currentLimit, preambleLength, dataShaping, tcxoVoltage, useRegulatorLDO); + int16_t state = SX126x::beginFSK(br, freqDev, rxBw, preambleLength, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); // configure publicly accessible settings diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h index 004d74b5..8d289c72 100644 --- a/src/modules/SX126x/SX1268.h +++ b/src/modules/SX126x/SX1268.h @@ -40,7 +40,7 @@ class SX1268: public SX126x { \param syncWord 2-byte LoRa sync word. Defaults to SX126X_SYNC_WORD_PRIVATE (0x12). - \param power Output power in dBm. Defaults to 14 dBm. + \param power Output power in dBm. Defaults to 10 dBm. \param currentLimit Current protection limit in mA. Defaults to 60.0 mA. @@ -50,7 +50,7 @@ class SX1268: public SX126x { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, float currentLimit = 60.0, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); /*! \brief Initialization method for FSK modem. @@ -59,23 +59,21 @@ class SX1268: public SX126x { \param br FSK bit rate in kbps. Defaults to 48.0 kbps. - \param freqDev Frequency deviation from carrier frequency in kHz. Defaults to 50.0 kHz. + \param freqDev Frequency deviation from carrier frequency in kHz. Defaults to 50.0 kHz. \param rxBw Receiver bandwidth in kHz. Defaults to 156.2 kHz. - \param power Output power in dBm. Defaults to 14 dBm. - - \param currentLimit Current protection limit in mA. Defaults to 60.0 mA. + \param power Output power in dBm. Defaults to 10 dBm. \parma preambleLength FSK preamble length in bits. Defaults to 16 bits. - \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to RADIOLIB_SHAPING_0_5. - \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip. + \param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false. + \returns \ref status_codes */ - int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 14, float currentLimit = 60.0, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); // configuration methods diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index e48828b1..3b89bdd7 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -75,7 +75,7 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float return(state); } -int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -119,34 +119,38 @@ int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, float currentLimit state = setRxBandwidth(rxBw); RADIOLIB_ASSERT(state); - state = setCurrentLimit(currentLimit); - RADIOLIB_ASSERT(state); - - state = setDataShaping(dataShaping); + state = setCurrentLimit(60.0); RADIOLIB_ASSERT(state); state = setPreambleLength(preambleLength); RADIOLIB_ASSERT(state); - // set publicly accessible settings that are not a part of begin method - uint8_t sync[] = {0x2D, 0x01}; - state = setSyncWord(sync, 2); - RADIOLIB_ASSERT(state); - - state = setWhitening(true, 0x01FF); - RADIOLIB_ASSERT(state); - - state = variablePacketLengthMode(SX126X_MAX_PACKET_LENGTH); - RADIOLIB_ASSERT(state); - - state = setDio2AsRfSwitch(false); - RADIOLIB_ASSERT(state); - if(useRegulatorLDO) { state = setRegulatorLDO(); } else { state = setRegulatorDCDC(); } + RADIOLIB_ASSERT(state); + + // set publicly accessible settings that are not a part of begin method + uint8_t sync[] = {0x12, 0xAD}; + state = setSyncWord(sync, 2); + RADIOLIB_ASSERT(state); + + state = setDataShaping(RADIOLIB_SHAPING_NONE); + RADIOLIB_ASSERT(state); + + state = setEncoding(RADIOLIB_ENCODING_NRZ); + RADIOLIB_ASSERT(state); + + state = variablePacketLengthMode(SX126X_MAX_PACKET_LENGTH); + RADIOLIB_ASSERT(state); + + state = setCRC(2); + RADIOLIB_ASSERT(state); + + state = setDio2AsRfSwitch(false); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index c2224e92..faf3ae8b 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -388,19 +388,15 @@ class SX126x: public PhysicalLayer { \param rxBw Receiver bandwidth in kHz. Allowed values are 4.8, 5.8, 7.3, 9.7, 11.7, 14.6, 19.5, 23.4, 29.3, 39.0, 46.9, 58.6, 78.2, 93.8, 117.3, 156.2, 187.2, 234.3, 312.0, 373.6 and 467.0 kHz. - \param currentLimit Current protection limit in mA. - \param preambleLength FSK preamble length in bits. Allowed values range from 0 to 65535. - \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Allowed values are 0.3, 0.5, 0.7 and 1.0. Set to 0 to disable shaping. - \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip. \param useRegulatorLDO use the LDO instead of DC-DC converter (default false). This is necessary for some modules such as the LAMBDA from RF solutions. \returns \ref status_codes */ - int16_t beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, uint8_t dataShaping, float tcxoVoltage, bool useRegulatorLDO = false); + int16_t beginFSK(float br, float freqDev, float rxBw, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO = false); /*! \brief Reset method. Will reset the chip to the default state using RST pin. From 82e4cb7f97d575ff23d4b04007e46d4b6d8dd4cd Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:13:53 +0200 Subject: [PATCH 233/455] [SX127x] Synced parameters of all FSK modules --- examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino | 2 +- src/modules/SX127x/SX1272.cpp | 9 +++++++-- src/modules/SX127x/SX1272.h | 5 +---- src/modules/SX127x/SX1278.cpp | 9 +++++++-- src/modules/SX127x/SX1278.h | 5 +---- src/modules/SX127x/SX127x.cpp | 10 +++++----- src/modules/SX127x/SX127x.h | 4 +--- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino b/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino index 184008e8..d6294889 100644 --- a/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino +++ b/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino @@ -57,7 +57,7 @@ void setup() { state = radio.setRxBandwidth(250.0); state = radio.setOutputPower(10.0); state = radio.setCurrentLimit(100); - state = radio.setDataShaping(0.5); + state = radio.setDataShaping(RADIOLIB_SHAPING_0_5); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; state = radio.setSyncWord(syncWord, 8); diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 411c3ab3..503923e9 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -36,13 +36,14 @@ int16_t SX1272::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } -int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t power, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK) { +int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t power, uint16_t preambleLength, bool enableOOK) { // execute common part - int16_t state = SX127x::beginFSK(SX1272_CHIP_VERSION, br, rxBw, freqDev, currentLimit, preambleLength, enableOOK); + int16_t state = SX127x::beginFSK(SX1272_CHIP_VERSION, br, rxBw, freqDev, preambleLength, enableOOK); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -53,7 +54,11 @@ int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t state = setFrequency(freq); RADIOLIB_ASSERT(state); + state = setDataShaping(RADIOLIB_SHAPING_NONE); + RADIOLIB_ASSERT(state); + state = setOutputPower(power); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index 6aba8259..f65539f2 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -148,16 +148,13 @@ class SX1272: public SX127x { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of FSK preamble in bits. \param enableOOK Use OOK modulation instead of FSK. \returns \ref status_codes */ - int16_t beginFSK(float freq = 915.0, float br = 48.0, float rxBw = 125.0, float freqDev = 50.0, int8_t power = 13, uint8_t currentLimit = 100, uint16_t preambleLength = 16, bool enableOOK = false); + int16_t beginFSK(float freq = 915.0, float br = 48.0, float rxBw = 125.0, float freqDev = 50.0, int8_t power = 10, uint16_t preambleLength = 16, bool enableOOK = false); /*! \brief Reset method. Will reset the chip to the default state using RST pin. diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index ae2933a5..b4c37576 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -31,13 +31,14 @@ int16_t SX1278::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } -int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK) { +int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, bool enableOOK) { // execute common part - int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, currentLimit, preambleLength, enableOOK); + int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -49,6 +50,10 @@ int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t RADIOLIB_ASSERT(state); state = setOutputPower(power); + RADIOLIB_ASSERT(state); + + state = setDataShaping(RADIOLIB_SHAPING_NONE); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index 5ee20cc8..fe136361 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -157,16 +157,13 @@ class SX1278: public SX127x { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of FSK preamble in bits. \param enableOOK Use OOK modulation instead of FSK. \returns \ref status_codes */ - int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 13, uint8_t currentLimit = 100, uint16_t preambleLength = 16, bool enableOOK = false); + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 10, uint16_t preambleLength = 16, bool enableOOK = false); /*! \brief Reset method. Will reset the chip to the default state using RST pin. diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 9f1f4ad0..557035d8 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -49,7 +49,7 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimi return(state); } -int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK) { +int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint16_t preambleLength, bool enableOOK) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -88,15 +88,15 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB RADIOLIB_ASSERT(state); // set over current protection - state = SX127x::setCurrentLimit(currentLimit); + state = SX127x::setCurrentLimit(60); RADIOLIB_ASSERT(state); // set preamble length state = SX127x::setPreambleLength(preambleLength); RADIOLIB_ASSERT(state); - // default sync word value 0x2D01 is the same as the default in LowPowerLab RFM69 library - uint8_t syncWord[] = {0x2D, 0x01}; + // set default sync word + uint8_t syncWord[] = {0x12, 0xAD}; state = setSyncWord(syncWord, 2); RADIOLIB_ASSERT(state); @@ -109,7 +109,7 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB RADIOLIB_ASSERT(state); // set default encoding - state = setEncoding(0); + state = setEncoding(RADIOLIB_ENCODING_NRZ); RADIOLIB_ASSERT(state); // set default packet length mode diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index efc5eb50..04a28bc5 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -583,15 +583,13 @@ class SX127x: public PhysicalLayer { \param rxBw Receiver bandwidth in kHz. - \param currentLimit Trim value for OCP (over current protection) in mA. - \param preambleLength Length of FSK preamble in bits. \param enableOOK Flag to specify OOK mode. This modulation is similar to FSK. \returns \ref status_codes */ - int16_t beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK); + int16_t beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint16_t preambleLength, bool enableOOK); /*! \brief Binary transmit method. Will transmit arbitrary binary data up to 255 bytes long using %LoRa or up to 63 bytes using FSK modem. From ec225236d08fc49c797c095c9ccb79ea0ab6c5d3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:14:08 +0200 Subject: [PATCH 234/455] [SX1231] Synced parameters of all FSK modules --- src/modules/SX1231/SX1231.cpp | 6 +++++- src/modules/SX1231/SX1231.h | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index 6122a452..3b4668e9 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -5,7 +5,7 @@ SX1231::SX1231(Module* mod) : RF69(mod) { } -int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t power) { +int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t power, uint8_t preambleLen) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -69,6 +69,10 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po state = setOutputPower(power); RADIOLIB_ASSERT(state); + // configure default preamble length + state = setPreambleLength(preambleLen); + RADIOLIB_ASSERT(state); + // default sync word values 0x2D01 is the same as the default in LowPowerLab RFM69 library uint8_t syncWord[] = {0x2D, 0x01}; state = setSyncWord(syncWord, 2); diff --git a/src/modules/SX1231/SX1231.h b/src/modules/SX1231/SX1231.h index 9ec08f4c..08cea4d4 100644 --- a/src/modules/SX1231/SX1231.h +++ b/src/modules/SX1231/SX1231.h @@ -43,11 +43,13 @@ class SX1231: public RF69 { \param freqDev Frequency deviation from carrier frequency in kHz Defaults to 50.0 kHz. - \param power Output power in dBm. Defaults to 13 dBm. + \param power Output power in dBm. Defaults to 10 dBm. + + \param preambleLen Preamble Length in bits. Defaults to 16 bits. \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float br = 48.0, float rxBw = 125.0, float freqDev = 50.0, int8_t power = 13); + int16_t begin(float freq = 434.0, float br = 48.0, float rxBw = 125.0, float freqDev = 50.0, int8_t power = 10, uint8_t preambleLen = 16); #ifndef RADIOLIB_GODMODE private: From 4d00170612a7100303eeca46c3832616271339a7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:14:21 +0200 Subject: [PATCH 235/455] [SX128x] Synced parameters of all FSK modules --- examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino | 2 +- src/modules/SX128x/SX128x.cpp | 9 ++++++--- src/modules/SX128x/SX128x.h | 4 +--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino b/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino index 4ef75900..2df0d6ac 100644 --- a/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino +++ b/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino @@ -55,7 +55,7 @@ void setup() { state = radio.setBitRate(200); state = radio.setFrequencyDeviation(100.0); state = radio.setOutputPower(5); - state = radio.setDataShaping(1.0); + state = radio.setDataShaping(RADIOLIB_SHAPING_1_0); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89}; state = radio.setSyncWord(syncWord, 5); if (state != ERR_NONE) { diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 2bd2c456..48d3b69f 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -56,7 +56,7 @@ int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, int8_t power return(state); } -int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, uint16_t preambleLength, uint8_t dataShaping) { +int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, uint16_t preambleLength) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -104,14 +104,17 @@ int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, state = setPreambleLength(preambleLength); RADIOLIB_ASSERT(state); - state = setDataShaping(dataShaping); + state = setDataShaping(RADIOLIB_SHAPING_0_5); RADIOLIB_ASSERT(state); // set publicly accessible settings that are not a part of begin method - uint8_t sync[] = { 0x2D, 0x01 }; + uint8_t sync[] = { 0x12, 0xAD }; state = setSyncWord(sync, 2); RADIOLIB_ASSERT(state); + state = setEncoding(RADIOLIB_ENCODING_NRZ); + RADIOLIB_ASSERT(state); + return(state); } diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index 5c4f3978..bf82c0cc 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -385,11 +385,9 @@ class SX128x: public PhysicalLayer { \parma preambleLength FSK preamble length in bits. Defaults to 16 bits. - \param dataShaping Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to RADIOLIB_SHAPING_0_5. - \returns \ref status_codes */ - int16_t beginGFSK(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t power = 10, uint16_t preambleLength = 16, uint8_t dataShaping = RADIOLIB_SHAPING_0_5); + int16_t beginGFSK(float freq = 2400.0, uint16_t br = 800, float freqDev = 400.0, int8_t power = 10, uint16_t preambleLength = 16); /*! \brief Initialization method for BLE modem. From 868235788197aa81bcfafb019c3581417556d55a Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:14:33 +0200 Subject: [PATCH 236/455] [Si443x] Synced parameters of all FSK modules --- .../Si443x_Settings/Si443x_Settings.ino | 3 ++- src/modules/Si443x/Si4430.cpp | 4 ++-- src/modules/Si443x/Si4430.h | 4 +++- src/modules/Si443x/Si4431.cpp | 4 ++-- src/modules/Si443x/Si4431.h | 4 +++- src/modules/Si443x/Si4432.cpp | 4 ++-- src/modules/Si443x/Si4432.h | 4 +++- src/modules/Si443x/Si443x.cpp | 23 +++++++++++++++++-- src/modules/Si443x/Si443x.h | 13 ++++++++++- 9 files changed, 50 insertions(+), 13 deletions(-) diff --git a/examples/Si443x/Si443x_Settings/Si443x_Settings.ino b/examples/Si443x/Si443x_Settings/Si443x_Settings.ino index ee5f7e9b..cd420505 100644 --- a/examples/Si443x/Si443x_Settings/Si443x_Settings.ino +++ b/examples/Si443x/Si443x_Settings/Si443x_Settings.ino @@ -58,7 +58,8 @@ void setup() { // frequency deviation: 60.0 kHz // Rx bandwidth: 335.5 kHz // output power: 17 dBm - state = radio2.begin(868.0, 200.0, 60.0, 335.5, 17); + // preamble length: 32 bits + state = radio2.begin(868.0, 200.0, 60.0, 335.5, 17, 32); if (state == ERR_NONE) { Serial.println(F("success!")); } else { diff --git a/src/modules/Si443x/Si4430.cpp b/src/modules/Si443x/Si4430.cpp index 3f31370c..778ee9dd 100644 --- a/src/modules/Si443x/Si4430.cpp +++ b/src/modules/Si443x/Si4430.cpp @@ -5,9 +5,9 @@ Si4430::Si4430(Module* mod) : Si4432(mod) { } -int16_t Si4430::begin(float freq, float br, float freqDev, float rxBw, int8_t power) { +int16_t Si4430::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) { // execute common part - int16_t state = Si443x::begin(br, freqDev, rxBw); + int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen); RADIOLIB_ASSERT(state); // configure publicly accessible settings diff --git a/src/modules/Si443x/Si4430.h b/src/modules/Si443x/Si4430.h index ff3b06f6..ca8a1b8f 100644 --- a/src/modules/Si443x/Si4430.h +++ b/src/modules/Si443x/Si4430.h @@ -40,9 +40,11 @@ class Si4430: public Si4432 { \param power Transmission output power in dBm. Allowed values range from -8 to 13 dBm in 3 dBm steps. + \param preambleLen Preamble Length in bits. Defaults to 16 bits. + \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10); + int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10, uint8_t preambleLen = 16); // configuration methods diff --git a/src/modules/Si443x/Si4431.cpp b/src/modules/Si443x/Si4431.cpp index 54371858..88e43396 100644 --- a/src/modules/Si443x/Si4431.cpp +++ b/src/modules/Si443x/Si4431.cpp @@ -5,9 +5,9 @@ Si4431::Si4431(Module* mod) : Si4432(mod) { } -int16_t Si4431::begin(float freq, float br, float freqDev, float rxBw, int8_t power) { +int16_t Si4431::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) { // execute common part - int16_t state = Si443x::begin(br, freqDev, rxBw); + int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen); RADIOLIB_ASSERT(state); // configure publicly accessible settings diff --git a/src/modules/Si443x/Si4431.h b/src/modules/Si443x/Si4431.h index 00167a7d..0143d41b 100644 --- a/src/modules/Si443x/Si4431.h +++ b/src/modules/Si443x/Si4431.h @@ -40,9 +40,11 @@ class Si4431: public Si4432 { \param power Transmission output power in dBm. Allowed values range from -8 to 13 dBm in 3 dBm steps. + \param preambleLen Preamble Length in bits. Defaults to 16 bits. + \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10); + int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10, uint8_t preambleLen = 16); // configuration methods diff --git a/src/modules/Si443x/Si4432.cpp b/src/modules/Si443x/Si4432.cpp index 0c9dee43..8037edcf 100644 --- a/src/modules/Si443x/Si4432.cpp +++ b/src/modules/Si443x/Si4432.cpp @@ -5,9 +5,9 @@ Si4432::Si4432(Module* mod) : Si443x(mod) { } -int16_t Si4432::begin(float freq, float br, float freqDev, float rxBw, int8_t power) { +int16_t Si4432::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) { // execute common part - int16_t state = Si443x::begin(br, freqDev, rxBw); + int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen); RADIOLIB_ASSERT(state); // configure publicly accessible settings diff --git a/src/modules/Si443x/Si4432.h b/src/modules/Si443x/Si4432.h index 7537e689..2f785634 100644 --- a/src/modules/Si443x/Si4432.h +++ b/src/modules/Si443x/Si4432.h @@ -40,9 +40,11 @@ class Si4432: public Si443x { \param power Transmission output power in dBm. Allowed values range from -1 to 20 dBm in 3 dBm steps. + \param preambleLen Preamble Length in bits. Defaults to 16 bits. + \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 11); + int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 181.1, int8_t power = 10, uint8_t preambleLen = 16); // configuration methods diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 78c95b74..84534e09 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -5,7 +5,7 @@ Si443x::Si443x(Module* mod) : PhysicalLayer(SI443X_FREQUENCY_STEP_SIZE, SI443X_M _mod = mod; } -int16_t Si443x::begin(float br, float freqDev, float rxBw) { +int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -38,7 +38,10 @@ int16_t Si443x::begin(float br, float freqDev, float rxBw) { state = setRxBandwidth(rxBw); RADIOLIB_ASSERT(state); - uint8_t syncWord[] = {0x2D, 0x01}; + state = setPreambleLength(preambleLen); + RADIOLIB_ASSERT(state); + + uint8_t syncWord[] = {0x12, 0xAD}; state = setSyncWord(syncWord, sizeof(syncWord)); RADIOLIB_ASSERT(state); @@ -477,6 +480,22 @@ int16_t Si443x::setSyncWord(uint8_t* syncWord, size_t len) { return(state); } +int16_t Si443x::setPreambleLength(uint8_t preambleLen) { + // Si443x configures preamble length in bytes + if(preambleLen % 8 != 0) { + return(ERR_INVALID_PREAMBLE_LENGTH); + } + + // set default preamble length + uint8_t preLenBytes = preambleLen / 8; + int16_t state = _mod->SPIsetRegValue(SI443X_REG_PREAMBLE_LENGTH, preLenBytes); + RADIOLIB_ASSERT(state); + + // set default preamble detection threshold to 50% of preamble length (in units of 4 bits) + uint8_t preThreshold = preambleLen / 4; + return(_mod->SPIsetRegValue(SI443X_REG_PREAMBLE_DET_CONTROL, preThreshold << 4, 3, 7)); +} + size_t Si443x::getPacketLength(bool update) { // TODO variable length mode if(!_packetLengthQueried && update) { diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 6cabb7d4..b5ffeb54 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -579,9 +579,11 @@ class Si443x: public PhysicalLayer { \param rxBw Receiver bandwidth in kHz. + \param preambleLen Preamble Length in bits. + \returns \ref status_codes */ - int16_t begin(float br, float freqDev, float rxBw); + int16_t begin(float br, float freqDev, float rxBw, uint8_t preambleLen); /*! \brief Reset method. Will reset the chip to the default state using SDN pin. @@ -735,6 +737,15 @@ class Si443x: public PhysicalLayer { */ int16_t setSyncWord(uint8_t* syncWord, size_t len); + /*! + \brief Sets preamble length. + + \param preambleLen Preamble length to be set (in bits). + + \returns \ref status_codes + */ + int16_t setPreambleLength(uint8_t preambleLen); + /*! \brief Query modem for the packet length of received payload. From 59c4fe638fa93c87311d0be26463664cf6aa0e26 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:48:02 +0200 Subject: [PATCH 237/455] [RFM9x] Synced parameters of all LoRa modules --- src/modules/RFM9x/RFM95.cpp | 6 +++--- src/modules/RFM9x/RFM95.h | 5 +---- src/modules/RFM9x/RFM96.cpp | 7 ++++--- src/modules/RFM9x/RFM96.h | 5 +---- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/modules/RFM9x/RFM95.cpp b/src/modules/RFM9x/RFM95.cpp index 80db42a6..f2b4a302 100644 --- a/src/modules/RFM9x/RFM95.cpp +++ b/src/modules/RFM9x/RFM95.cpp @@ -5,12 +5,12 @@ RFM95::RFM95(Module* mod) : SX1278(mod) { } -int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, preambleLength); if(state == ERR_CHIP_NOT_FOUND) { // SX127X_REG_VERSION might be set 0x12 - state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, currentLimit, preambleLength); + state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, preambleLength); RADIOLIB_ASSERT(state); } else if(state != ERR_NONE) { // some other error diff --git a/src/modules/RFM9x/RFM95.h b/src/modules/RFM9x/RFM95.h index 8c760630..f6c02840 100644 --- a/src/modules/RFM9x/RFM95.h +++ b/src/modules/RFM9x/RFM95.h @@ -47,9 +47,6 @@ class RFM95: public SX1278 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -58,7 +55,7 @@ class RFM95: public SX1278 { \returns \ref status_codes */ - int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/RFM9x/RFM96.cpp b/src/modules/RFM9x/RFM96.cpp index 5ca6f594..c2f43f0e 100644 --- a/src/modules/RFM9x/RFM96.cpp +++ b/src/modules/RFM9x/RFM96.cpp @@ -5,12 +5,12 @@ RFM96::RFM96(Module* mod) : SX1278(mod) { } -int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, preambleLength); if(state == ERR_CHIP_NOT_FOUND) { // SX127X_REG_VERSION might be set 0x12 - state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, currentLimit, preambleLength); + state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, preambleLength); RADIOLIB_ASSERT(state); } else if(state != ERR_NONE) { // some other error @@ -38,6 +38,7 @@ int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/RFM9x/RFM96.h b/src/modules/RFM9x/RFM96.h index 9bafe6ea..c18019b2 100644 --- a/src/modules/RFM9x/RFM96.h +++ b/src/modules/RFM9x/RFM96.h @@ -47,9 +47,6 @@ class RFM96: public SX1278 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -58,7 +55,7 @@ class RFM96: public SX1278 { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods From e1141ca64c2f19110eac84f123d89861e98c4650 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:48:14 +0200 Subject: [PATCH 238/455] [SX127x] Synced parameters of all LoRa modules --- examples/SX127x/SX127x_Settings/SX127x_Settings.ino | 3 +-- src/modules/SX127x/SX1272.cpp | 4 ++-- src/modules/SX127x/SX1272.h | 4 +--- src/modules/SX127x/SX1273.cpp | 5 +++-- src/modules/SX127x/SX1273.h | 5 +---- src/modules/SX127x/SX1276.cpp | 5 +++-- src/modules/SX127x/SX1276.h | 5 +---- src/modules/SX127x/SX1277.cpp | 5 +++-- src/modules/SX127x/SX1277.h | 5 +---- src/modules/SX127x/SX1278.cpp | 4 ++-- src/modules/SX127x/SX1278.h | 5 +---- src/modules/SX127x/SX1279.cpp | 5 +++-- src/modules/SX127x/SX1279.h | 5 +---- src/modules/SX127x/SX127x.cpp | 4 ++-- src/modules/SX127x/SX127x.h | 4 +--- 15 files changed, 26 insertions(+), 42 deletions(-) diff --git a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino index 08d1c967..84f31fac 100644 --- a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino +++ b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino @@ -70,10 +70,9 @@ void setup() { // coding rate: 5 // sync word: 0x14 // output power: 2 dBm - // current limit: 50 mA // preamble length: 20 symbols // amplifier gain: 1 (maximum gain) - state = radio2.begin(915.0, 500.0, 6, 5, 0x14, 2); + state = radio2.begin(915.0, 500.0, 6, 5, 0x14, 2, 20, 1); if (state == ERR_NONE) { Serial.println(F("success!")); } else { diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 503923e9..e6219fc2 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -5,9 +5,9 @@ SX1272::SX1272(Module* mod) : SX127x(mod) { } -int16_t SX1272::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1272::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index f65539f2..26a5b84a 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -119,8 +119,6 @@ class SX1272: public SX127x { \param syncWord %LoRa sync word. Can be used to distinguish different networks. Note that value 0x34 is reserved for LoRaWAN networks. - \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. Set to 0 to disable OCP (not recommended). @@ -132,7 +130,7 @@ class SX1272: public SX127x { \returns \ref status_codes */ - int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); /*! \brief FSK modem initialization method. Must be called at least once from Arduino sketch to initialize the module. diff --git a/src/modules/SX127x/SX1273.cpp b/src/modules/SX127x/SX1273.cpp index b45ca0e5..97178f81 100644 --- a/src/modules/SX127x/SX1273.cpp +++ b/src/modules/SX127x/SX1273.cpp @@ -5,9 +5,9 @@ SX1273::SX1273(Module* mod) : SX1272(mod) { } -int16_t SX1273::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1273::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -36,6 +36,7 @@ int16_t SX1273::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1273.h b/src/modules/SX127x/SX1273.h index e8b3902b..83b43dd4 100644 --- a/src/modules/SX127x/SX1273.h +++ b/src/modules/SX127x/SX1273.h @@ -41,9 +41,6 @@ class SX1273: public SX1272 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -52,7 +49,7 @@ class SX1273: public SX1272 { \returns \ref status_codes */ - int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/SX127x/SX1276.cpp b/src/modules/SX127x/SX1276.cpp index 66510443..b331fe95 100644 --- a/src/modules/SX127x/SX1276.cpp +++ b/src/modules/SX127x/SX1276.cpp @@ -5,9 +5,9 @@ SX1276::SX1276(Module* mod) : SX1278(mod) { } -int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -31,6 +31,7 @@ int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1276.h b/src/modules/SX127x/SX1276.h index cc4ce493..ec6e33d6 100644 --- a/src/modules/SX127x/SX1276.h +++ b/src/modules/SX127x/SX1276.h @@ -41,9 +41,6 @@ class SX1276: public SX1278 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -52,7 +49,7 @@ class SX1276: public SX1278 { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/SX127x/SX1277.cpp b/src/modules/SX127x/SX1277.cpp index fe187055..371c125e 100644 --- a/src/modules/SX127x/SX1277.cpp +++ b/src/modules/SX127x/SX1277.cpp @@ -5,9 +5,9 @@ SX1277::SX1277(Module* mod) : SX1278(mod) { } -int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -31,6 +31,7 @@ int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1277.h b/src/modules/SX127x/SX1277.h index 804ee6f9..6598f066 100644 --- a/src/modules/SX127x/SX1277.h +++ b/src/modules/SX127x/SX1277.h @@ -41,9 +41,6 @@ class SX1277: public SX1278 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -52,7 +49,7 @@ class SX1277: public SX1278 { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index b4c37576..2e0566a0 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -5,9 +5,9 @@ SX1278::SX1278(Module* mod) : SX127x(mod) { } -int16_t SX1278::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1278::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index fe136361..b25d7be8 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -130,9 +130,6 @@ class SX1278: public SX127x { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -141,7 +138,7 @@ class SX1278: public SX127x { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); /*! \brief FSK modem initialization method. Must be called at least once from Arduino sketch to initialize the module. diff --git a/src/modules/SX127x/SX1279.cpp b/src/modules/SX127x/SX1279.cpp index 9d5562e5..21d1f598 100644 --- a/src/modules/SX127x/SX1279.cpp +++ b/src/modules/SX127x/SX1279.cpp @@ -5,9 +5,9 @@ SX1279::SX1279(Module* mod) : SX1278(mod) { } -int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) { +int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { // execute common part - int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, currentLimit, preambleLength); + int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); // configure settings not accessible by API @@ -31,6 +31,7 @@ int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync RADIOLIB_ASSERT(state); state = setGain(gain); + RADIOLIB_ASSERT(state); return(state); } diff --git a/src/modules/SX127x/SX1279.h b/src/modules/SX127x/SX1279.h index c466b64a..27220119 100644 --- a/src/modules/SX127x/SX1279.h +++ b/src/modules/SX127x/SX1279.h @@ -41,9 +41,6 @@ class SX1279: public SX1278 { \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. - \param currentLimit Trim value for OCP (over current protection) in mA. Can be set to multiplies of 5 in range 45 to 120 mA and to multiples of 10 in range 120 to 240 mA. - Set to 0 to disable OCP (not recommended). - \param preambleLength Length of %LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. @@ -52,7 +49,7 @@ class SX1279: public SX1278 { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint8_t currentLimit = 100, uint16_t preambleLength = 8, uint8_t gain = 0); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); // configuration methods diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 557035d8..3e464260 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -5,7 +5,7 @@ SX127x::SX127x(Module* mod) : PhysicalLayer(SX127X_FREQUENCY_STEP_SIZE, SX127X_M _mod = mod; } -int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimit, uint16_t preambleLength) { +int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLength) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -36,7 +36,7 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimi RADIOLIB_ASSERT(state); // set over current protection - state = SX127x::setCurrentLimit(currentLimit); + state = SX127x::setCurrentLimit(60); RADIOLIB_ASSERT(state); // set preamble length diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 04a28bc5..61953144 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -559,13 +559,11 @@ class SX127x: public PhysicalLayer { \param syncWord %LoRa sync word. - \param currentLimit Trim value for OCP (over current protection) in mA. - \param preambleLength Length of %LoRa transmission preamble in symbols. \returns \ref status_codes */ - int16_t begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimit, uint16_t preambleLength); + int16_t begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLength); /*! \brief Reset method. Will reset the chip to the default state using RST pin. Declared pure virtual since SX1272 and SX1278 implementations differ. From b21f93342ed1f5c9eef346a48252415c1b4c147b Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:48:25 +0200 Subject: [PATCH 239/455] [SX126x] Synced parameters of all LoRa modules --- examples/SX126x/SX126x_Settings/SX126x_Settings.ino | 3 +-- src/modules/SX126x/SX1262.cpp | 4 ++-- src/modules/SX126x/SX1262.h | 6 ++---- src/modules/SX126x/SX1268.cpp | 4 ++-- src/modules/SX126x/SX1268.h | 4 +--- src/modules/SX126x/SX126x.cpp | 8 ++++---- src/modules/SX126x/SX126x.h | 4 +--- 7 files changed, 13 insertions(+), 20 deletions(-) diff --git a/examples/SX126x/SX126x_Settings/SX126x_Settings.ino b/examples/SX126x/SX126x_Settings/SX126x_Settings.ino index 2e500dee..f485284f 100644 --- a/examples/SX126x/SX126x_Settings/SX126x_Settings.ino +++ b/examples/SX126x/SX126x_Settings/SX126x_Settings.ino @@ -70,9 +70,8 @@ void setup() { // coding rate: 5 // sync word: 0x34 (public network/LoRaWAN) // output power: 2 dBm - // current limit: 50 mA // preamble length: 20 symbols - state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 50, 20); + state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 20); if (state == ERR_NONE) { Serial.println(F("success!")); } else { diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index 70bb7c44..b67cf949 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -5,9 +5,9 @@ SX1262::SX1262(Module* mod) : SX126x(mod) { } -int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, float currentLimit, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // execute common part - int16_t state = SX126x::begin(bw, sf, cr, syncWord, currentLimit, preambleLength, tcxoVoltage, useRegulatorLDO); + int16_t state = SX126x::begin(bw, sf, cr, syncWord, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); // configure publicly accessible settings diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index 110b4611..616cd407 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -42,13 +42,13 @@ class SX1262: public SX126x { \param power Output power in dBm. Defaults to 10 dBm. - \param preambleLength LoRa preamble length in symbols.Defaults to 8 symbols. + \param preambleLength LoRa preamble length in symbols. Defaults to 8 symbols. \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip. \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, float currentLimit = 60.0, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); /*! \brief Initialization method for FSK modem. @@ -63,8 +63,6 @@ class SX1262: public SX126x { \param power Output power in dBm. Defaults to 10 dBm. - \param currentLimit Current protection limit in mA. Defaults to 60.0 mA. - \parma preambleLength FSK preamble length in bits. Defaults to 16 bits. \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip. diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index 44923333..673f5853 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -5,9 +5,9 @@ SX1268::SX1268(Module* mod) : SX126x(mod) { } -int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, float currentLimit, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // execute common part - int16_t state = SX126x::begin(bw, sf, cr, syncWord, currentLimit, preambleLength, tcxoVoltage, useRegulatorLDO); + int16_t state = SX126x::begin(bw, sf, cr, syncWord, preambleLength, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); // configure publicly accessible settings diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h index 8d289c72..909dd334 100644 --- a/src/modules/SX126x/SX1268.h +++ b/src/modules/SX126x/SX1268.h @@ -42,15 +42,13 @@ class SX1268: public SX126x { \param power Output power in dBm. Defaults to 10 dBm. - \param currentLimit Current protection limit in mA. Defaults to 60.0 mA. - \param preambleLength LoRa preamble length in symbols. Defaults to 8 symbols. \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip. \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, float currentLimit = 60.0, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false); /*! \brief Initialization method for FSK modem. diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 3b89bdd7..b5b0d8b9 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -5,7 +5,7 @@ SX126x::SX126x(Module* mod) : PhysicalLayer(SX126X_FREQUENCY_STEP_SIZE, SX126X_M _mod = mod; } -int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float currentLimit, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // set module properties _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); @@ -56,13 +56,13 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float state = setSyncWord(syncWord); RADIOLIB_ASSERT(state); - state = setCurrentLimit(currentLimit); - RADIOLIB_ASSERT(state); - state = setPreambleLength(preambleLength); RADIOLIB_ASSERT(state); // set publicly accessible settings that are not a part of begin method + state = setCurrentLimit(60.0); + RADIOLIB_ASSERT(state); + state = setDio2AsRfSwitch(true); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index faf3ae8b..0461e10b 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -367,8 +367,6 @@ class SX126x: public PhysicalLayer { \param syncWord 1-byte LoRa sync word. - \param currentLimit Current protection limit in mA. - \param preambleLength LoRa preamble length in symbols. Allowed values range from 1 to 65535. \param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip. @@ -377,7 +375,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, float currentLimit, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO = false); + int16_t begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO = false); /*! \brief Initialization method for FSK modem. From 2a2efb5413b77c2ae16fa776de6f16967ad83cf0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 11:57:09 +0200 Subject: [PATCH 240/455] Bump version to 4.0.0 --- library.properties | 2 +- src/BuildOpt.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.properties b/library.properties index f2c3def6..b7a8ddfa 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=3.7.0 +version=4.0.0 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index dfbaf26d..66697fac 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -333,8 +333,8 @@ // version definitions -#define RADIOLIB_VERSION_MAJOR (0x03) -#define RADIOLIB_VERSION_MINOR (0x07) +#define RADIOLIB_VERSION_MAJOR (0x04) +#define RADIOLIB_VERSION_MINOR (0x00) #define RADIOLIB_VERSION_PATCH (0x00) #define RADIOLIB_VERSION_EXTRA (0x00) From c9add26cfe998c0dc1a2d6312441e59d92e3d0b0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 12:36:19 +0200 Subject: [PATCH 241/455] Fixed array as initializer (illegal pre-C++11) --- src/Module.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module.h b/src/Module.h index cdf9109f..aa12389f 100644 --- a/src/Module.h +++ b/src/Module.h @@ -149,7 +149,7 @@ class Module { /*! \brief Line feed to be used when sending AT commands. Defaults to CR+LF. */ - char AtLineFeed[3] = "\r\n"; + char AtLineFeed[3] = {'\r', '\n'}; /*! \brief Basic SPI read command. Defaults to 0x00. From cdbabdb30db9fd611fdcd6779f0915d48bd781f5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 12:37:29 +0200 Subject: [PATCH 242/455] [SX126x] Fixed unused parameter (TRAVIS_FORCE_BUILD) --- src/modules/SX126x/SX1262.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index b67cf949..a73cebe6 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -7,7 +7,7 @@ SX1262::SX1262(Module* mod) : SX126x(mod) { int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // execute common part - int16_t state = SX126x::begin(bw, sf, cr, syncWord, tcxoVoltage, useRegulatorLDO); + int16_t state = SX126x::begin(bw, sf, cr, syncWord, preambleLength, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); // configure publicly accessible settings From 9152c5d91d1c915bfb28ef8a2e45ac4fe678b21f Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 15:48:23 +0200 Subject: [PATCH 243/455] Travis set Arduino to 1.8.13 and enabled warnings TRAVIS_FORCE_BUILD --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c141bb73..1da28814 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ env: global: - - ARDUINO_IDE_VERSION="1.8.9" + - ARDUINO_IDE_VERSION="1.8.13" matrix: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt @@ -146,7 +146,7 @@ script: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino --verify --board $BOARD $example; + arduino --verify --warnings=all --board $BOARD $example; if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From 4e79d7d26af5d3acf7e3ed8c2ed9dab71192bd83 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 16:28:38 +0200 Subject: [PATCH 244/455] Travis switched to Arduino CLI --- .travis.yml | 99 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1da28814..eb85bd00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ env: global: - - ARDUINO_IDE_VERSION="1.8.13" + # - ARDUINO_IDE_VERSION="1.8.13" matrix: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt @@ -30,91 +30,121 @@ addons: - python3-setuptools before_install: - # install Arduino IDE - - wget https://downloads.arduino.cc/arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz - - tar xf arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz - - mv arduino-$ARDUINO_IDE_VERSION $HOME/arduino-ide - - export PATH=$PATH:$HOME/arduino-ide - + # install Arduino + # - wget https://downloads.arduino.cc/arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz + # - tar xf arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz + # - mv arduino-$ARDUINO_IDE_VERSION $HOME/arduino-ide + # - export PATH=$PATH:$HOME/arduino-ide # firewall Arduino IDE noise (https://github.com/per1234/arduino-ci-script/issues/1#issuecomment-504158113) - - sudo iptables -P INPUT DROP - - sudo iptables -P FORWARD DROP - - sudo iptables -P OUTPUT ACCEPT - - sudo iptables -A INPUT -i lo -j ACCEPT - - sudo iptables -A OUTPUT -o lo -j ACCEPT - - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT + # - sudo iptables -P INPUT DROP + # - sudo iptables -P FORWARD DROP + # - sudo iptables -P OUTPUT ACCEPT + # - sudo iptables -A INPUT -i lo -j ACCEPT + # - sudo iptables -A OUTPUT -o lo -j ACCEPT + # - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT + + - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh # check every board in matrix and install 3rd party definitions - if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then export BUILD_EXAMPLES=true; + arduino-cli core update-index; elif [[ "$BOARD" =~ "arduino:avr:mega" ]]; then export BUILD_EXAMPLES=false; + arduino-cli core update-index; elif [[ "$BOARD" =~ "arduino:avr:leonardo" ]]; then export BUILD_EXAMPLES=false; + arduino-cli core update-index; elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs 2>&1; - arduino --install-boards esp8266:esp8266; + # arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs 2>&1; + # arduino --install-boards esp8266:esp8266; + arduino-cli core update-index --additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json; + arduino-cli core install esp8266:esp8266; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; - arduino --install-boards esp32:esp32; + # arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; + # arduino --install-boards esp32:esp32; + arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json; + arduino-cli core install esp32:esp32; elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; - arduino --install-boards STM32:stm32; + # arduino --pref "boardsmanager.additional.urls=https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; + # arduino --install-boards STM32:stm32; + arduino-cli core update-index --additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json; + arduino-cli core install STM32:stm32; elif [[ "$BOARD" =~ "arduino:samd:" ]]; then export BUILD_EXAMPLES=false; - arduino --install-boards arduino:samd; + arduino-cli core update-index; + # arduino --install-boards arduino:samd; + arduino-cli core install arduino:samd; elif [[ "$BOARD" =~ "arduino:sam:" ]]; then export BUILD_EXAMPLES=false; - arduino --install-boards arduino:sam; + arduino-cli core update-index; + # arduino --install-boards arduino:sam; + arduino-cli core install arduino:sam; elif [[ "$BOARD" =~ "adafruit:nrf52:" ]]; then pip3 install --user adafruit-nrfutil; export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; - arduino --install-boards adafruit:nrf52; + # arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; + # arduino --install-boards adafruit:nrf52; + arduino-cli core update-index --additional-urls https://www.adafruit.com/package_adafruit_index.json; + arduino-cli core install adafruit:nrf52; elif [[ "$BOARD" =~ "Intel:arc32:" ]]; then export BUILD_EXAMPLES=false; - arduino --install-boards Intel:arc32; + arduino-cli core update-index; + # arduino --install-boards Intel:arc32; + arduino-cli core install Intel:arc32; elif [[ "$BOARD" =~ "arduino:megaavr:" ]]; then export BUILD_EXAMPLES=false; - arduino --install-boards arduino:megaavr; + arduino-cli core update-index; + # arduino --install-boards arduino:megaavr; + arduino-cli core install arduino:megaavr; elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1; - arduino --install-boards SparkFun:apollo3; + # arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1; + # arduino --install-boards SparkFun:apollo3; + arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json; + arduino-cli core install SparkFun:apollo3; elif [[ "$BOARD" =~ "arduino:mbed:" ]]; then export BUILD_EXAMPLES=false; - arduino --install-boards arduino:mbed; + arduino-cli core update-index; + # arduino --install-boards arduino:mbed; + arduino-cli core install arduino:mbed; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "stm32duino:STM32F1:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; - arduino --install-boards stm32duino:STM32F1; + # arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; + # arduino --install-boards stm32duino:STM32F1; + arduino-cli core update-index --additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json; + arduino-cli core install stm32duino:STM32F1; elif [[ "$BOARD" =~ "adafruit:samd:" ]]; then export BUILD_EXAMPLES=false; - arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; - arduino --install-boards adafruit:samd; + # arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; + # arduino --install-boards adafruit:samd; + arduino-cli core update-index --additional-urls https://www.adafruit.com/package_adafruit_index.json + arduino-cli core install adafruit:samd; elif [[ "$BOARD" =~ "arduino-beta:mbed:" ]]; then export BUILD_EXAMPLES=false; - arduino --install-boards arduino-beta:mbed; + arduino-cli core update-index; + # arduino --install-boards arduino-beta:mbed; + arduino-cli core install arduino-beta:mbed; export SKIP_PAT='(HTTP|MQTT).*ino'; fi @@ -146,7 +176,8 @@ script: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino --verify --warnings=all --board $BOARD $example; + # arduino --verify --warnings=all --board $BOARD $example; + arduino-cli compile --fqbn $BOARD $example --warnings=all if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From e0d7398fe924f341978d6653a8bc27ed5db66e2d Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 16:45:18 +0200 Subject: [PATCH 245/455] Travis fix indentation --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb85bd00..ad9e03cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,7 +46,8 @@ before_install: - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh # check every board in matrix and install 3rd party definitions - - if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then + - | + if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then export BUILD_EXAMPLES=true; arduino-cli core update-index; @@ -142,8 +143,8 @@ before_install: elif [[ "$BOARD" =~ "arduino-beta:mbed:" ]]; then export BUILD_EXAMPLES=false; - arduino-cli core update-index; # arduino --install-boards arduino-beta:mbed; + arduino-cli core update-index; arduino-cli core install arduino-beta:mbed; export SKIP_PAT='(HTTP|MQTT).*ino'; From f70c403d3f15b00f0e01992bf6efe217f00ec77d Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 16:48:07 +0200 Subject: [PATCH 246/455] Travis fix missing path --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ad9e03cd..65567af4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,7 @@ before_install: # - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh + - export PATH=$PATH:$PWD/bin # check every board in matrix and install 3rd party definitions - | From 362c8a064e848221969c34f07ea325efe185049e Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 16:51:37 +0200 Subject: [PATCH 247/455] Travis added missing platforms --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 65567af4..b630a5e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,14 +51,17 @@ before_install: if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then export BUILD_EXAMPLES=true; arduino-cli core update-index; + arduino-cli core install arduino:avr; elif [[ "$BOARD" =~ "arduino:avr:mega" ]]; then export BUILD_EXAMPLES=false; arduino-cli core update-index; + arduino-cli core install arduino:avr; elif [[ "$BOARD" =~ "arduino:avr:leonardo" ]]; then export BUILD_EXAMPLES=false; arduino-cli core update-index; + arduino-cli core install arduino:avr; elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then export BUILD_EXAMPLES=false; From 422e4ee7b15d9daaa4faca3fb351fb2311ce1e66 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 16:56:21 +0200 Subject: [PATCH 248/455] Travis added missing platform links TRAVIS_FORCE_BUILD --- .travis.yml | 48 ++++++++---------------------------------------- 1 file changed, 8 insertions(+), 40 deletions(-) diff --git a/.travis.yml b/.travis.yml index b630a5e5..79b24873 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ env: global: - # - ARDUINO_IDE_VERSION="1.8.13" matrix: # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt @@ -30,19 +29,7 @@ addons: - python3-setuptools before_install: - # install Arduino - # - wget https://downloads.arduino.cc/arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz - # - tar xf arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz - # - mv arduino-$ARDUINO_IDE_VERSION $HOME/arduino-ide - # - export PATH=$PATH:$HOME/arduino-ide - # firewall Arduino IDE noise (https://github.com/per1234/arduino-ci-script/issues/1#issuecomment-504158113) - # - sudo iptables -P INPUT DROP - # - sudo iptables -P FORWARD DROP - # - sudo iptables -P OUTPUT ACCEPT - # - sudo iptables -A INPUT -i lo -j ACCEPT - # - sudo iptables -A OUTPUT -o lo -j ACCEPT - # - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT - + # install Arduino CLI - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh - export PATH=$PATH:$PWD/bin @@ -65,85 +52,66 @@ before_install: elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then export BUILD_EXAMPLES=false; - # arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs 2>&1; - # arduino --install-boards esp8266:esp8266; arduino-cli core update-index --additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json; - arduino-cli core install esp8266:esp8266; + arduino-cli core install esp8266:esp8266 --additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then export BUILD_EXAMPLES=false; - # arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs 2>&1; - # arduino --install-boards esp32:esp32; arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json; - arduino-cli core install esp32:esp32; + arduino-cli core install esp32:esp32 --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json; elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then export BUILD_EXAMPLES=false; - # arduino --pref "boardsmanager.additional.urls=https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" --save-prefs 2>&1; - # arduino --install-boards STM32:stm32; arduino-cli core update-index --additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json; - arduino-cli core install STM32:stm32; + arduino-cli core install STM32:stm32 --additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json; elif [[ "$BOARD" =~ "arduino:samd:" ]]; then export BUILD_EXAMPLES=false; arduino-cli core update-index; - # arduino --install-boards arduino:samd; arduino-cli core install arduino:samd; elif [[ "$BOARD" =~ "arduino:sam:" ]]; then export BUILD_EXAMPLES=false; arduino-cli core update-index; - # arduino --install-boards arduino:sam; arduino-cli core install arduino:sam; elif [[ "$BOARD" =~ "adafruit:nrf52:" ]]; then pip3 install --user adafruit-nrfutil; export BUILD_EXAMPLES=false; - # arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; - # arduino --install-boards adafruit:nrf52; arduino-cli core update-index --additional-urls https://www.adafruit.com/package_adafruit_index.json; - arduino-cli core install adafruit:nrf52; + arduino-cli core install adafruit:nrf52 --additional-urls https://www.adafruit.com/package_adafruit_index.json; elif [[ "$BOARD" =~ "Intel:arc32:" ]]; then export BUILD_EXAMPLES=false; arduino-cli core update-index; - # arduino --install-boards Intel:arc32; arduino-cli core install Intel:arc32; elif [[ "$BOARD" =~ "arduino:megaavr:" ]]; then export BUILD_EXAMPLES=false; arduino-cli core update-index; - # arduino --install-boards arduino:megaavr; arduino-cli core install arduino:megaavr; elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then export BUILD_EXAMPLES=false; - # arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1; - # arduino --install-boards SparkFun:apollo3; arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json; - arduino-cli core install SparkFun:apollo3; + arduino-cli core install SparkFun:apollo3 --additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json; elif [[ "$BOARD" =~ "arduino:mbed:" ]]; then export BUILD_EXAMPLES=false; arduino-cli core update-index; - # arduino --install-boards arduino:mbed; arduino-cli core install arduino:mbed; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "stm32duino:STM32F1:" ]]; then export BUILD_EXAMPLES=false; - # arduino --pref "boardsmanager.additional.urls=http://dan.drown.org/stm32duino/package_STM32duino_index.json" --save-prefs 2>&1; - # arduino --install-boards stm32duino:STM32F1; arduino-cli core update-index --additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json; - arduino-cli core install stm32duino:STM32F1; + arduino-cli core install stm32duino:STM32F1 --additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json; elif [[ "$BOARD" =~ "adafruit:samd:" ]]; then export BUILD_EXAMPLES=false; - # arduino --pref "boardsmanager.additional.urls=https://www.adafruit.com/package_adafruit_index.json" --save-prefs 2>&1; - # arduino --install-boards adafruit:samd; arduino-cli core update-index --additional-urls https://www.adafruit.com/package_adafruit_index.json - arduino-cli core install adafruit:samd; + arduino-cli core install adafruit:samd --additional-urls https://www.adafruit.com/package_adafruit_index.json elif [[ "$BOARD" =~ "arduino-beta:mbed:" ]]; then export BUILD_EXAMPLES=false; From eabbf9e5afa90be72df239db4ec923b4912d36ee Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 17:16:53 +0200 Subject: [PATCH 249/455] [TL] Changed type to size_t --- src/protocols/TransportLayer/TransportLayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protocols/TransportLayer/TransportLayer.h b/src/protocols/TransportLayer/TransportLayer.h index ecf3ad5b..eb23bd8e 100644 --- a/src/protocols/TransportLayer/TransportLayer.h +++ b/src/protocols/TransportLayer/TransportLayer.h @@ -56,7 +56,7 @@ class TransportLayer { \returns \ref status_codes */ - virtual int16_t send(uint8_t* data, uint32_t len) = 0; + virtual int16_t send(uint8_t* data, size_t len) = 0; /*! \brief Receive data. From 8cbbf3d668ab31c306bb65dd6cb37f58a98abc39 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 17:28:17 +0200 Subject: [PATCH 250/455] [ESP8266] Changed length type to size_t TRAVIS_FORCE_BUILD --- src/modules/ESP8266/ESP8266.cpp | 4 ++-- src/modules/ESP8266/ESP8266.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index c07a96e8..98d8c8d5 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -160,10 +160,10 @@ int16_t ESP8266::send(const char* data) { return(ERR_NONE); } -int16_t ESP8266::send(uint8_t* data, uint32_t len) { +int16_t ESP8266::send(uint8_t* data, size_t len) { // build AT command char lenStr[8]; - sprintf(lenStr, "%lu", len); + sprintf(lenStr, "%u", (uint16_t)len); const char atStr[] = "AT+CIPSEND="; #ifdef RADIOLIB_STATIC_ONLY char cmd[RADIOLIB_STATIC_ARRAY_SIZE]; diff --git a/src/modules/ESP8266/ESP8266.h b/src/modules/ESP8266/ESP8266.h index eff7b8b0..cc999500 100644 --- a/src/modules/ESP8266/ESP8266.h +++ b/src/modules/ESP8266/ESP8266.h @@ -51,7 +51,7 @@ class ESP8266: public TransportLayer { int16_t openTransportConnection(const char* host, const char* protocol, uint16_t port, uint16_t tcpKeepAlive = 0) override; int16_t closeTransportConnection() override; int16_t send(const char* data) override; - int16_t send(uint8_t* data, uint32_t len) override; + int16_t send(uint8_t* data, size_t len) override; size_t receive(uint8_t* data, size_t len, uint32_t timeout = 10000) override; size_t getNumBytes(uint32_t timeout = 10000, size_t minBytes = 10) override; From 37a94494b4c5ab6a7cde0c85824943618b0011e2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 18:30:36 +0200 Subject: [PATCH 251/455] Added TODOs --- src/Module.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Module.cpp b/src/Module.cpp index 9e690883..6ce55043 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -336,6 +336,7 @@ RADIOLIB_PIN_STATUS Module::digitalRead(RADIOLIB_PIN_TYPE pin) { } void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { + // TODO add tone support for platforms without tone() #ifndef RADIOLIB_TONE_UNSUPPORTED if(pin != RADIOLIB_NC) { ::tone(pin, value); @@ -344,6 +345,7 @@ void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { } void Module::noTone(RADIOLIB_PIN_TYPE pin) { + // TODO add tone support for platforms without noTone() #ifndef RADIOLIB_TONE_UNSUPPORTED if(pin != RADIOLIB_NC) { ::noTone(pin); From a827f91bca156b1196e920fed24304d42cd9e2c3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 18:31:05 +0200 Subject: [PATCH 252/455] Skipped warnings for SparlFun Apollo --- .travis.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 79b24873..39ede145 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,85 +37,100 @@ before_install: - | if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then export BUILD_EXAMPLES=true; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install arduino:avr; elif [[ "$BOARD" =~ "arduino:avr:mega" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install arduino:avr; elif [[ "$BOARD" =~ "arduino:avr:leonardo" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install arduino:avr; elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index --additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json; arduino-cli core install esp8266:esp8266 --additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json; arduino-cli core install esp32:esp32 --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json; elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index --additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json; arduino-cli core install STM32:stm32 --additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json; elif [[ "$BOARD" =~ "arduino:samd:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install arduino:samd; elif [[ "$BOARD" =~ "arduino:sam:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install arduino:sam; elif [[ "$BOARD" =~ "adafruit:nrf52:" ]]; then pip3 install --user adafruit-nrfutil; export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index --additional-urls https://www.adafruit.com/package_adafruit_index.json; arduino-cli core install adafruit:nrf52 --additional-urls https://www.adafruit.com/package_adafruit_index.json; elif [[ "$BOARD" =~ "Intel:arc32:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install Intel:arc32; elif [[ "$BOARD" =~ "arduino:megaavr:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install arduino:megaavr; elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=none; arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json; arduino-cli core install SparkFun:apollo3 --additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json; elif [[ "$BOARD" =~ "arduino:mbed:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install arduino:mbed; export SKIP_PAT='(HTTP|MQTT).*ino'; elif [[ "$BOARD" =~ "stm32duino:STM32F1:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index --additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json; arduino-cli core install stm32duino:STM32F1 --additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json; elif [[ "$BOARD" =~ "adafruit:samd:" ]]; then export BUILD_EXAMPLES=false; + export WARNINGS=all; arduino-cli core update-index --additional-urls https://www.adafruit.com/package_adafruit_index.json arduino-cli core install adafruit:samd --additional-urls https://www.adafruit.com/package_adafruit_index.json elif [[ "$BOARD" =~ "arduino-beta:mbed:" ]]; then export BUILD_EXAMPLES=false; - # arduino --install-boards arduino-beta:mbed; + export WARNINGS=all; arduino-cli core update-index; arduino-cli core install arduino-beta:mbed; export SKIP_PAT='(HTTP|MQTT).*ino'; @@ -149,7 +164,7 @@ script: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - # arduino --verify --warnings=all --board $BOARD $example; + # arduino --verify --warnings=$WARNINGS --board $BOARD $example; arduino-cli compile --fqbn $BOARD $example --warnings=all if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; From 93080845d213a17eaa25e48d45cb641b93e672f4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 6 Jul 2020 19:39:16 +0200 Subject: [PATCH 253/455] Added missing keywords --- keywords.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/keywords.txt b/keywords.txt index f55c7fbf..846709b1 100644 --- a/keywords.txt +++ b/keywords.txt @@ -241,6 +241,16 @@ noTone KEYWORD2 RADIOLIB_NC LITERAL1 RADIOLIB_VERSION LITERAL1 +RADIOLIB_SHAPING_NONE LITERAL1 +RADIOLIB_SHAPING_0_3 LITERAL1 +RADIOLIB_SHAPING_0_5 LITERAL1 +RADIOLIB_SHAPING_0_7 LITERAL1 +RADIOLIB_SHAPING_1_0 LITERAL1 + +RADIOLIB_ENCODING_NRZ LITERAL1 +RADIOLIB_ENCODING_MANCHESTER LITERAL1 +RADIOLIB_ENCODING_WHITENING LITERAL1 + ERR_NONE LITERAL1 ERR_UNKNOWN LITERAL1 From 760fefaad8794ef893aa1aa9bdd33d68f940ad37 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 8 Jul 2020 18:00:09 +0200 Subject: [PATCH 254/455] [CC1101] Fixed invalid default Rx bandwidth --- src/modules/CC1101/CC1101.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 70256b63..d2284aa2 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -535,7 +535,7 @@ class CC1101: public PhysicalLayer { \returns \ref status_codes */ - int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 48.0, float rxBw = 125.0, int8_t power = 10, uint8_t preambleLength = 16); + int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 48.0, float rxBw = 135.0, int8_t power = 10, uint8_t preambleLength = 16); /*! \brief Blocking binary transmit method. From a91c8252d62101ef0f12f67d6be89909409ce9c8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 8 Jul 2020 18:51:01 +0200 Subject: [PATCH 255/455] Added new keywords --- keywords.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/keywords.txt b/keywords.txt index 846709b1..a564bcf6 100644 --- a/keywords.txt +++ b/keywords.txt @@ -128,6 +128,8 @@ getIRQFlags KEYWORD2 getModemStatus KEYWORD2 getTempRaw KEYWORD2 setRfSwitchPins KEYWORD2 +forceLDRO KEYWORD2 +autoLDRO KEYWORD2 # RF69-specific setAESKey KEYWORD2 From 96405b938da6a7f93a1b1220901d58d4b773982f Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 8 Jul 2020 18:52:08 +0200 Subject: [PATCH 256/455] [SX126x] Added methods to manually set LoRa LDRO --- src/modules/SX126x/SX126x.cpp | 31 ++++++++++++++++++++++++++----- src/modules/SX126x/SX126x.h | 21 ++++++++++++++++++++- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index b5b0d8b9..fbd0edf4 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -650,7 +650,7 @@ int16_t SX126x::setBandwidth(float bw) { // update modulation parameters _bwKhz = bw; - return(setModulationParams(_sf, _bw, _cr)); + return(setModulationParams(_sf, _bw, _cr, _ldro)); } int16_t SX126x::setSpreadingFactor(uint8_t sf) { @@ -663,7 +663,7 @@ int16_t SX126x::setSpreadingFactor(uint8_t sf) { // update modulation parameters _sf = sf; - return(setModulationParams(_sf, _bw, _cr)); + return(setModulationParams(_sf, _bw, _cr, _ldro)); } int16_t SX126x::setCodingRate(uint8_t cr) { @@ -676,7 +676,7 @@ int16_t SX126x::setCodingRate(uint8_t cr) { // update modulation parameters _cr = cr - 4; - return(setModulationParams(_sf, _bw, _cr)); + return(setModulationParams(_sf, _bw, _cr, _ldro)); } int16_t SX126x::setSyncWord(uint8_t syncWord, uint8_t controlBits) { @@ -1152,6 +1152,27 @@ void SX126x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { _mod->setRfSwitchPins(rxEn, txEn); } +int16_t SX126x::forceLDRO(bool enable) { + // check active modem + if(getPacketType() != SX126X_PACKET_TYPE_LORA) { + return(ERR_WRONG_MODEM); + } + + // update modulation parameters + _ldroAuto = false; + _ldro = (uint8_t)enable; + return(setModulationParams(_sf, _bw, _cr, _ldro)); +} + +int16_t SX126x::autoLDRO() { + if(getPacketType() != SX126X_PACKET_TYPE_LORA) { + return(ERR_WRONG_MODEM); + } + + _ldroAuto = true; + return(ERR_NONE); +} + int16_t SX126x::setTCXO(float voltage, uint32_t delay) { // set mode to standby standby(); @@ -1316,8 +1337,8 @@ int16_t SX126x::setHeaderType(uint8_t headerType, size_t len) { } int16_t SX126x::setModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro) { - // calculate symbol length and enable low data rate optimization, if needed - if(ldro == 0xFF) { + // calculate symbol length and enable low data rate optimization, if auto-configuration is enabled + if(_ldroAuto) { float symbolLength = (float)(uint32_t(1) << _sf) / (float)_bwKhz; RADIOLIB_DEBUG_PRINT("Symbol length: "); RADIOLIB_DEBUG_PRINT(symbolLength); diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 0461e10b..3d45266a 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -852,6 +852,24 @@ class SX126x: public PhysicalLayer { */ void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + /*! + \brief Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to + the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX1278::autoLDRO() + + \param enable Force LDRO to be always enabled (true) or disabled (false). + + \returns \ref status_codes + */ + int16_t forceLDRO(bool enable); + + /*! + \brief Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method, LDRO will be enabled automatically + when symbol length exceeds 16 ms. + + \returns \ref status_codes + */ + int16_t autoLDRO(); + #ifndef RADIOLIB_GODMODE protected: #endif @@ -871,7 +889,7 @@ class SX126x: public PhysicalLayer { int16_t calibrateImage(uint8_t* data); uint8_t getPacketType(); int16_t setTxParams(uint8_t power, uint8_t rampTime = SX126X_PA_RAMP_200U); - int16_t setModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro = 0xFF); + int16_t setModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t ldro); int16_t setModulationParamsFSK(uint32_t br, uint8_t pulseShape, uint8_t rxBw, uint32_t freqDev); int16_t setPacketParams(uint16_t preambleLength, uint8_t crcType, uint8_t payloadLength, uint8_t headerType, uint8_t invertIQ = SX126X_LORA_IQ_STANDARD); int16_t setPacketParamsFSK(uint16_t preambleLength, uint8_t crcType, uint8_t syncWordLength, uint8_t addrComp, uint8_t whitening, uint8_t packetType = SX126X_GFSK_PACKET_VARIABLE, uint8_t payloadLength = 0xFF, uint8_t preambleDetectorLength = SX126X_GFSK_PREAMBLE_DETECT_16); @@ -901,6 +919,7 @@ class SX126x: public PhysicalLayer { uint8_t _bw = 0, _sf = 0, _cr = 0, _ldro = 0, _crcType = 0, _headerType = 0; uint16_t _preambleLength = 0; float _bwKhz = 0; + bool _ldroAuto = true; uint32_t _br = 0, _freqDev = 0; uint8_t _rxBw = 0, _pulseShape = 0, _crcTypeFSK = 0, _syncWordLength = 0, _addrComp = 0, _whitening = 0, _packetType = 0; From 58194483b1fe24fbc6718f513055ac99b156e2c9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 8 Jul 2020 18:52:34 +0200 Subject: [PATCH 257/455] [SX127x] Added methods to manually set LoRa LDRO (#162) --- src/modules/SX127x/SX1272.cpp | 61 ++++++++++++++++++++++++---------- src/modules/SX127x/SX1272.h | 20 +++++++++++ src/modules/SX127x/SX1278.cpp | 62 +++++++++++++++++++++++++---------- src/modules/SX127x/SX1278.h | 20 +++++++++++ 4 files changed, 128 insertions(+), 35 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index e6219fc2..cc3e8133 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -106,15 +106,17 @@ int16_t SX1272::setBandwidth(float bw) { if(state == ERR_NONE) { SX127x::_bw = bw; - // calculate symbol length and set low data rate optimization, if needed - float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw; - RADIOLIB_DEBUG_PRINT("Symbol length: "); - RADIOLIB_DEBUG_PRINT(symbolLength); - RADIOLIB_DEBUG_PRINTLN(" ms"); - if(symbolLength >= 16.0) { - state = _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_ON, 0, 0); - } else { - state = _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_OFF, 0, 0); + // calculate symbol length and set low data rate optimization, if auto-configuration is enabled + if(_ldroAuto) { + float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw; + RADIOLIB_DEBUG_PRINT("Symbol length: "); + RADIOLIB_DEBUG_PRINT(symbolLength); + RADIOLIB_DEBUG_PRINTLN(" ms"); + if(symbolLength >= 16.0) { + state = _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_ON, 0, 0); + } else { + state = _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_OFF, 0, 0); + } } } return(state); @@ -160,15 +162,17 @@ int16_t SX1272::setSpreadingFactor(uint8_t sf) { if(state == ERR_NONE) { SX127x::_sf = sf; - // calculate symbol length and set low data rate optimization, if needed + // calculate symbol length and set low data rate optimization, if auto-configuration is enabled + if(_ldroAuto) { float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw; - RADIOLIB_DEBUG_PRINT("Symbol length: "); - RADIOLIB_DEBUG_PRINT(symbolLength); - RADIOLIB_DEBUG_PRINTLN(" ms"); - if(symbolLength >= 16.0) { - state = _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_ON, 0, 0); - } else { - state = _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_OFF, 0, 0); + RADIOLIB_DEBUG_PRINT("Symbol length: "); + RADIOLIB_DEBUG_PRINT(symbolLength); + RADIOLIB_DEBUG_PRINTLN(" ms"); + if(symbolLength >= 16.0) { + state = _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_ON, 0, 0); + } else { + state = _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_OFF, 0, 0); + } } } return(state); @@ -372,6 +376,29 @@ int16_t SX1272::setCRC(bool enableCRC) { } } +int16_t SX1272::forceLDRO(bool enable) { + if(getActiveModem() != SX127X_LORA) { + return(ERR_WRONG_MODEM); + } + + _ldroAuto = false; + if(enable) { + return(_mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_ON, 0, 0)); + } else { + return(_mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_LOW_DATA_RATE_OPT_OFF, 0, 0)); + } +} + +int16_t SX1272::autoLDRO() { + if(getActiveModem() != SX127X_LORA) { + return(ERR_WRONG_MODEM); + } + + _ldroAuto = true; + return(ERR_NONE); +} + + int16_t SX1272::setBandwidthRaw(uint8_t newBandwidth) { // set mode to standby int16_t state = SX127x::standby(); diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index 26a5b84a..78e009d3 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -253,6 +253,24 @@ class SX1272: public SX127x { */ int16_t setCRC(bool enableCRC); + /*! + \brief Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to + the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX1278::autoLDRO() + + \param enable Force LDRO to be always enabled (true) or disabled (false). + + \returns \ref status_codes + */ + int16_t forceLDRO(bool enable); + + /*! + \brief Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method, LDRO will be enabled automatically + when symbol length exceeds 16 ms. + + \returns \ref status_codes + */ + int16_t autoLDRO(); + #ifndef RADIOLIB_GODMODE protected: #endif @@ -265,6 +283,8 @@ class SX1272: public SX127x { #ifndef RADIOLIB_GODMODE private: #endif + bool _ldroAuto = true; + bool _ldroEnabled = false; }; diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 2e0566a0..c4f6ff40 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -178,15 +178,17 @@ int16_t SX1278::setBandwidth(float bw) { if(state == ERR_NONE) { SX127x::_bw = bw; - // calculate symbol length and set low data rate optimization, if needed - float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw; - RADIOLIB_DEBUG_PRINT("Symbol length: "); - RADIOLIB_DEBUG_PRINT(symbolLength); - RADIOLIB_DEBUG_PRINTLN(" ms"); - if(symbolLength >= 16.0) { - state = _mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_ON, 3, 3); - } else { - state = _mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_OFF, 3, 3); + // calculate symbol length and set low data rate optimization, if auto-configuration is enabled + if(_ldroAuto) { + float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw; + RADIOLIB_DEBUG_PRINT("Symbol length: "); + RADIOLIB_DEBUG_PRINT(symbolLength); + RADIOLIB_DEBUG_PRINTLN(" ms"); + if(symbolLength >= 16.0) { + state = _mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_ON, 3, 3); + } else { + state = _mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_OFF, 3, 3); + } } } return(state); @@ -232,15 +234,17 @@ int16_t SX1278::setSpreadingFactor(uint8_t sf) { if(state == ERR_NONE) { SX127x::_sf = sf; - // calculate symbol length and set low data rate optimization, if needed - float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw; - RADIOLIB_DEBUG_PRINT("Symbol length: "); - RADIOLIB_DEBUG_PRINT(symbolLength); - RADIOLIB_DEBUG_PRINTLN(" ms"); - if(symbolLength >= 16.0) { - state = _mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_ON, 3, 3); - } else { - state = _mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_OFF, 3, 3); + // calculate symbol length and set low data rate optimization, if auto-configuration is enabled + if(_ldroAuto) { + float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw; + RADIOLIB_DEBUG_PRINT("Symbol length: "); + RADIOLIB_DEBUG_PRINT(symbolLength); + RADIOLIB_DEBUG_PRINTLN(" ms"); + if(symbolLength >= 16.0) { + state = _mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_ON, 3, 3); + } else { + state = _mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_OFF, 3, 3); + } } } return(state); @@ -450,6 +454,28 @@ int16_t SX1278::setCRC(bool enableCRC) { } } +int16_t SX1278::forceLDRO(bool enable) { + if(getActiveModem() != SX127X_LORA) { + return(ERR_WRONG_MODEM); + } + + _ldroAuto = false; + if(enable) { + return(_mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_ON, 3, 3)); + } else { + return(_mod->SPIsetRegValue(SX1278_REG_MODEM_CONFIG_3, SX1278_LOW_DATA_RATE_OPT_OFF, 3, 3)); + } +} + +int16_t SX1278::autoLDRO() { + if(getActiveModem() != SX127X_LORA) { + return(ERR_WRONG_MODEM); + } + + _ldroAuto = true; + return(ERR_NONE); +} + int16_t SX1278::setBandwidthRaw(uint8_t newBandwidth) { // set mode to standby int16_t state = SX127x::standby(); diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index b25d7be8..cba8c635 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -261,6 +261,24 @@ class SX1278: public SX127x { */ int16_t setCRC(bool enableCRC); + /*! + \brief Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to + the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX1278::autoLDRO() + + \param enable Force LDRO to be always enabled (true) or disabled (false). + + \returns \ref status_codes + */ + int16_t forceLDRO(bool enable); + + /*! + \brief Re-enables automatic LDRO configuration. Only available in LoRa mode. After calling this method, LDRO will be enabled automatically + when symbol length exceeds 16 ms. + + \returns \ref status_codes + */ + int16_t autoLDRO(); + #ifndef RADIOLIB_GODMODE protected: #endif @@ -273,6 +291,8 @@ class SX1278: public SX127x { #ifndef RADIOLIB_GODMODE private: #endif + bool _ldroAuto = true; + bool _ldroEnabled = false; }; From 7397a1a9578c3017c8e048e09b64debc9bdbe04c Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 8 Jul 2020 19:06:38 +0200 Subject: [PATCH 258/455] Bump version to 4.0.1 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index b7a8ddfa..14217d0d 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=4.0.0 +version=4.0.1 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 66697fac..07a21840 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -335,7 +335,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) #define RADIOLIB_VERSION_MINOR (0x00) -#define RADIOLIB_VERSION_PATCH (0x00) +#define RADIOLIB_VERSION_PATCH (0x01) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From e5d23ba23836d2d274d3825de3320a95379d1512 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 8 Jul 2020 20:50:23 +0200 Subject: [PATCH 259/455] Travis fixed warnings configuration TRAVIS_FORCE_BUILD --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 39ede145..46945334 100644 --- a/.travis.yml +++ b/.travis.yml @@ -164,8 +164,7 @@ script: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - # arduino --verify --warnings=$WARNINGS --board $BOARD $example; - arduino-cli compile --fqbn $BOARD $example --warnings=all + arduino-cli compile --fqbn $BOARD $example --warnings=$WARNINGS if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From d3233ff585eb9ca106586fe1094fa2ccfd65a2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Fri, 10 Jul 2020 06:57:46 +0200 Subject: [PATCH 260/455] Added module not working issue template --- .github/ISSUE_TEMPLATE/module-not-working.md | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/module-not-working.md diff --git a/.github/ISSUE_TEMPLATE/module-not-working.md b/.github/ISSUE_TEMPLATE/module-not-working.md new file mode 100644 index 00000000..1b67e8d6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/module-not-working.md @@ -0,0 +1,34 @@ +--- +name: Module not working +about: Template to use when your module isn't working +title: '' +labels: '' +assignees: '' + +--- + +**IMPORTANT: Before submitting an issue, please check the following:** +1. **Read [CONTRIBUTING.md](https://github.com/jgromes/RadioLib/blob/master/CONTRIBUTING.md)!** Issues that do not follow this document will be closed/locked/deleted/ignored. +2. RadioLib has a [Wiki](https://github.com/jgromes/RadioLib/wiki) and an extensive [API documentation](https://jgromes.github.io/RadioLib/). You might find a solution to your issue there. +3. Make sure you're using the latest release of the library! Releases can be found [here](https://github.com/jgromes/RadioLib/releases). +4. Use [Arduino forums](https://forum.arduino.cc/) to ask generic questions about wireless modules, wiring, usage, etc. Only create issues for problems specific to RadioLib! +5. Error codes, their meaning and how to fix them can be found on [this page](https://jgromes.github.io/RadioLib/group__status__codes.html). + +**Sketch that is causing the module fail** + +```c++ +paste the sketch here, even if it is an unmodified example code +``` + +**Hardware setup** +Wiring diagram, schematic, pictures etc. + +**Debug mode output** +Enable all [debug levels](https://github.com/jgromes/RadioLib/wiki/Debug-mode) and paste the Serial monitor output here. + +**Additional info (please complete):** + - MCU: [e.g. Arduino Uno, ESP8266 etc.] + - Link to Arduino core: [e.g. https://github.com/stm32duino/Arduino_Core_STM32 when using official STM32 core. See readme for links to all supported cores] + - Wireless module type [e.g. CC1101, SX1268, etc.] + - Arduino IDE version [e.g. 1.8.5] + - Library version [e.g. 3.0.0] From 7f31cdab8fa6ecadf4cab4236443eae1441149c6 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 10 Jul 2020 08:20:45 +0200 Subject: [PATCH 261/455] Test doxygen TODOs --- src/Module.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index 6ce55043..774b409b 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -336,7 +336,7 @@ RADIOLIB_PIN_STATUS Module::digitalRead(RADIOLIB_PIN_TYPE pin) { } void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { - // TODO add tone support for platforms without tone() + /// \todo Add tone support for platforms without tone() #ifndef RADIOLIB_TONE_UNSUPPORTED if(pin != RADIOLIB_NC) { ::tone(pin, value); @@ -345,7 +345,7 @@ void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { } void Module::noTone(RADIOLIB_PIN_TYPE pin) { - // TODO add tone support for platforms without noTone() + /// \todo Add tone support for platforms without tone() #ifndef RADIOLIB_TONE_UNSUPPORTED if(pin != RADIOLIB_NC) { ::noTone(pin); From e97755a68becc43f8982479ba847c03262a60093 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 10 Jul 2020 08:51:05 +0200 Subject: [PATCH 262/455] [SX126x] Added Doxygen TODO --- src/modules/SX126x/SX1261.cpp | 2 +- src/modules/SX126x/SX1262.cpp | 2 +- src/modules/SX126x/SX1268.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/SX126x/SX1261.cpp b/src/modules/SX126x/SX1261.cpp index b0b626c2..1e035651 100644 --- a/src/modules/SX126x/SX1261.cpp +++ b/src/modules/SX126x/SX1261.cpp @@ -18,7 +18,7 @@ int16_t SX1261::setOutputPower(int8_t power) { RADIOLIB_ASSERT(state); // set output power - // TODO power ramp time configuration + /// \todo power ramp time configuration state = SX126x::setTxParams(power); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index a73cebe6..0d78eea5 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -84,7 +84,7 @@ int16_t SX1262::setOutputPower(int8_t power) { RADIOLIB_ASSERT(state); // set output power - // TODO power ramp time configuration + /// \todo power ramp time configuration state = SX126x::setTxParams(power); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index 673f5853..0addddf8 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -23,7 +23,7 @@ int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } -int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength,float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // execute common part int16_t state = SX126x::beginFSK(br, freqDev, rxBw, preambleLength, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); @@ -41,6 +41,7 @@ int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t return(state); } +/// \todo integers only (all modules - frequency, data rate, bandwidth etc.) int16_t SX1268::setFrequency(float freq, bool calibrate) { RADIOLIB_CHECK_RANGE(freq, 410.0, 810.0, ERR_INVALID_FREQUENCY); @@ -78,7 +79,7 @@ int16_t SX1268::setOutputPower(int8_t power) { RADIOLIB_ASSERT(state); // set output power - // TODO power ramp time configuration + /// \todo power ramp time configuration state = SX126x::setTxParams(power); RADIOLIB_ASSERT(state); From 6452ea401fac650378e141bd7959c52f0952fe21 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 10 Jul 2020 08:51:16 +0200 Subject: [PATCH 263/455] [SX127x] Added Doxygen TODOs --- src/modules/SX127x/SX127x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 3e464260..2890ff5f 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -680,7 +680,7 @@ int16_t SX127x::setBitRate(float br) { state = _mod->SPIsetRegValue(SX127X_REG_BITRATE_MSB, (bitRate & 0xFF00) >> 8, 7, 0); state |= _mod->SPIsetRegValue(SX127X_REG_BITRATE_LSB, bitRate & 0x00FF, 7, 0); - // TODO fractional part of bit rate setting (not in OOK) + /// \todo fractional part of bit rate setting (not in OOK) if(state == ERR_NONE) { SX127x::_br = br; } From a1583487b084b9dd9657ab6727b30a855d9867f7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 10 Jul 2020 08:51:23 +0200 Subject: [PATCH 264/455] [SX128x] Added Doxygen TODOs --- src/modules/SX128x/SX1282.cpp | 1 + src/modules/SX128x/SX1282.h | 2 -- src/modules/SX128x/SX128x.cpp | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/SX128x/SX1282.cpp b/src/modules/SX128x/SX1282.cpp index 2a77ffcd..33deee97 100644 --- a/src/modules/SX128x/SX1282.cpp +++ b/src/modules/SX128x/SX1282.cpp @@ -1,6 +1,7 @@ #include "SX1282.h" #if !defined(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 1e3b9be7..f6cbdbd7 100644 --- a/src/modules/SX128x/SX1282.h +++ b/src/modules/SX128x/SX1282.h @@ -9,8 +9,6 @@ #include "SX128x.h" #include "SX1280.h" -// TODO implement advanced ranging - /*! \class SX1282 diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 48d3b69f..8638ebc9 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -890,7 +890,7 @@ int16_t SX128x::setSyncWord(uint8_t* syncWord, uint8_t len) { if(_syncWordLen == 0) { _syncWordMatch = SX128X_GFSK_FLRC_SYNC_WORD_OFF; } else { - // TODO add support for multiple sync words + /// \todo add support for multiple sync words _syncWordMatch = SX128X_GFSK_FLRC_SYNC_WORD_1; } return(setPacketParamsGFSK(_preambleLengthGFSK, _syncWordLen, _syncWordMatch, _crcGFSK, _whitening)); @@ -1093,7 +1093,7 @@ uint32_t SX128x::getTimeOnAir(size_t len) { } else { // long interleaving - abandon hope all ye who enter here - // TODO implement this mess - SX1280 datasheet v3.0 section 7.4.4.2 + /// \todo implement this mess - SX1280 datasheet v3.0 section 7.4.4.2 } From 6c3dff49357c2ce902ac1c30fe6197387146ccb9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 10 Jul 2020 08:51:30 +0200 Subject: [PATCH 265/455] [Si443x] Added Doxygen TODOs --- src/modules/Si443x/Si443x.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 84534e09..8f2b9cfe 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -145,7 +145,7 @@ int16_t Si443x::transmitDirect(uint32_t frf) { // user requested to start transmitting immediately (required for RTTY) if(frf != 0) { // convert the 24-bit frequency to the format accepted by the module - // TODO integers only + /// \todo integers only float newFreq = frf / 6400.0; // check high/low band @@ -227,10 +227,10 @@ int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { clearIRQFlags(); // set packet length - // TODO variable packet length + /// \todo variable packet length _mod->SPIwriteRegister(SI443X_REG_TRANSMIT_PACKET_LENGTH, len); - // TODO use header as address field? + /// \todo use header as address field? (void)addr; // write packet to FIFO @@ -497,7 +497,7 @@ int16_t Si443x::setPreambleLength(uint8_t preambleLen) { } size_t Si443x::getPacketLength(bool update) { - // TODO variable length mode + /// \todo variable length mode if(!_packetLengthQueried && update) { _packetLength = _mod->SPIreadRegister(SI443X_REG_RECEIVED_PACKET_LENGTH); _packetLengthQueried = true; @@ -512,7 +512,7 @@ int16_t Si443x::setEncoding(uint8_t encoding) { RADIOLIB_ASSERT(state); // set encoding - // TODO - add inverted Manchester? + /// \todo - add inverted Manchester? switch(encoding) { case RADIOLIB_ENCODING_NRZ: return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_1, SI443X_MANCHESTER_INVERTED_OFF | SI443X_MANCHESTER_OFF | SI443X_WHITENING_OFF, 2, 0)); @@ -537,7 +537,7 @@ int16_t Si443x::setDataShaping(uint8_t sh) { case RADIOLIB_SHAPING_0_3: case RADIOLIB_SHAPING_0_5: case RADIOLIB_SHAPING_1_0: - // TODO implement fiter configuration - docs claim this should be possible, but seems undocumented + /// \todo implement fiter configuration - docs claim this should be possible, but seems undocumented return(_mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_1, SI443X_MANCHESTER_INVERTED_OFF | SI443X_MANCHESTER_OFF | SI443X_WHITENING_ON, 2, 0)); default: return(ERR_INVALID_ENCODING); From 29d24c916b36d047ff0478565d03844872416adf Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 10 Jul 2020 08:51:37 +0200 Subject: [PATCH 266/455] [XBee] Added Doxygen TODOs --- src/modules/XBee/XBee.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/XBee/XBee.cpp b/src/modules/XBee/XBee.cpp index 894c32b3..9b1abe73 100644 --- a/src/modules/XBee/XBee.cpp +++ b/src/modules/XBee/XBee.cpp @@ -391,7 +391,7 @@ void XBee::sendApiFrame(uint8_t type, uint8_t id, uint8_t* data, uint16_t length } int16_t XBee::readApiFrame(uint8_t frameID, uint8_t codePos, uint16_t timeout) { - // TODO: modemStatus frames may be sent at any time, interfering with frame parsing. Add check to make sure this does not happen. + /// \todo modemStatus frames may be sent at any time, interfering with frame parsing. Add check to make sure this does not happen. // get number of bytes in response (must be enough to read the length field uint16_t numBytes = getNumBytes(timeout/2, 3); From 735db87bb3dbf6c1477972fc83a80bed50fb794a Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 10 Jul 2020 08:51:43 +0200 Subject: [PATCH 267/455] [MQTT] Added Doxygen TODOs --- src/protocols/MQTT/MQTT.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/protocols/MQTT/MQTT.cpp b/src/protocols/MQTT/MQTT.cpp index fb4791f7..b86b548f 100644 --- a/src/protocols/MQTT/MQTT.cpp +++ b/src/protocols/MQTT/MQTT.cpp @@ -205,7 +205,7 @@ int16_t MQTTClient::publish(const char* topic, const char* message) { #endif return(state); - //TODO: implement QoS > 0 and PUBACK response checking + /// \todo implement QoS > 0 and PUBACK response checking } int16_t MQTTClient::subscribe(const char* topicFilter) { @@ -410,7 +410,6 @@ int16_t MQTTClient::check(void (*func)(const char*, const char*)) { uint8_t* dataIn = new uint8_t[numBytes]; _tl->receive(dataIn, numBytes); if(dataIn[0] == MQTT_PUBLISH << 4) { - // TODO: properly decode remaining length uint8_t remLenFieldLen = 0; uint32_t remainingLength = decodeLength(dataIn + 1, remLenFieldLen); From 4e943b5437733dba5e0a17475687cd4b7eaede20 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 10 Jul 2020 08:51:51 +0200 Subject: [PATCH 268/455] [RTTY] Added Doxygen TODOs --- src/protocols/RTTY/RTTY.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 657f55f1..686c3494 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -452,8 +452,7 @@ size_t RTTYClient::printNumber(unsigned long n, uint8_t base) { return(l); } -// TODO: improve ITA2 float print speed -// (characters are sent one at a time) +/// \todo improve ITA2 float print speed (characters are sent one at a time) size_t RTTYClient::printFloat(double number, uint8_t digits) { size_t n = 0; From a525c40e5522b0021e90372c233a9f4cd54ce6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Thu, 16 Jul 2020 17:55:43 +0200 Subject: [PATCH 269/455] [Si443x] Added tolerance to float comparison (#165) --- src/modules/Si443x/Si443x.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 8f2b9cfe..c1d2c20a 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -386,63 +386,64 @@ int16_t Si443x::setRxBandwidth(float rxBw) { filterSet = ((rxBw - 60.286)/10.7000 + 0.5); // this is the "Lord help thee who tread 'ere" section - no way to approximate this mess - } else if(rxBw == 142.8) { + /// \todo float tolerance equality as macro? + } else if(abs(rxBw - 142.8) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 1; filterSet = 4; - } else if(rxBw == 167.8) { + } else if(abs(rxBw - 167.8) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 1; filterSet = 5; - } else if(rxBw == 181.1) { + } else if(abs(rxBw - 181.1) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 1; filterSet = 6; - } else if(rxBw == 191.5) { + } else if(abs(rxBw - 191.5) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 15; - } else if(rxBw == 225.1) { + } else if(abs(rxBw - 225.1) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 1; - } else if(rxBw == 248.8) { + } else if(abs(rxBw - 248.8) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 2; - } else if(rxBw == 269.3) { + } else if(abs(rxBw - 269.3) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 3; - } else if(rxBw == 284.8) { + } else if(abs(rxBw - 284.8) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 4; - } else if(rxBw == 335.5) { + } else if(abs(rxBw -335.5) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 8; - } else if(rxBw == 391.8) { + } else if(abs(rxBw - 391.8) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 9; - } else if(rxBw == 420.2) { + } else if(abs(rxBw - 420.2) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 10; - } else if(rxBw == 468.4) { + } else if(abs(rxBw - 468.4) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 11; - } else if(rxBw == 518.8) { + } else if(abs(rxBw - 518.8) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 12; - } else if(rxBw == 577.0) { + } else if(abs(rxBw - 577.0) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 13; - } else if(rxBw == 620.7) { + } else if(abs(rxBw - 620.7) <= 0.001) { bypass = SI443X_BYPASS_DEC_BY_3_ON; decRate = 0; filterSet = 14; From 44dc0a4ea3af7b06967722190266793c4fc9ed72 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 17 Jul 2020 17:28:29 +0200 Subject: [PATCH 270/455] [Si443x] Fixed bit range and timeout on some modules (#165) --- src/modules/Si443x/Si443x.cpp | 52 +++++++++++++++++++---------------- src/modules/Si443x/Si443x.h | 1 + 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index c1d2c20a..53761ac3 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -84,12 +84,17 @@ int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) { } } - // set mode to standby - state = standby(); - // clear interrupt flags clearIRQFlags(); + // set mode to standby + standby(); + + // the next transmission will timeout without the following + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); + _mod->SPIsetRegValue(SI443X_REG_MODULATION_MODE_CONTROL_2, SI443X_TX_DATA_SOURCE_FIFO, 5, 4); + state = setFrequencyRaw(_freq); + return(state); } @@ -135,7 +140,8 @@ int16_t Si443x::standby() { // set RF switch (if present) _mod->setRfSwitchState(LOW, LOW); - return(_mod->SPIsetRegValue(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_XTAL_ON, 7, 0, 10)); + //return(_mod->SPIsetRegValue(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_XTAL_ON, 7, 0, 10)); + return(ERR_NONE); } int16_t Si443x::transmitDirect(uint32_t frf) { @@ -166,7 +172,7 @@ int16_t Si443x::transmitDirect(uint32_t frf) { // start direct transmission directMode(); - _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_TX_ON); + _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_TX_ON | SI443X_XTAL_ON); return(ERR_NONE); } @@ -176,7 +182,7 @@ int16_t Si443x::transmitDirect(uint32_t frf) { RADIOLIB_ASSERT(state); // start transmitting - _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_TX_ON); + _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_TX_ON | SI443X_XTAL_ON); return(state); } @@ -189,7 +195,7 @@ int16_t Si443x::receiveDirect() { RADIOLIB_ASSERT(state); // start receiving - _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON); + _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON | SI443X_XTAL_ON); return(state); } @@ -219,10 +225,6 @@ int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { _mod->SPIsetRegValue(SI443X_REG_OP_FUNC_CONTROL_2, SI443X_TX_FIFO_RESET, 0, 0); _mod->SPIsetRegValue(SI443X_REG_OP_FUNC_CONTROL_2, SI443X_TX_FIFO_CLEAR, 0, 0); - // set interrupt mapping - state = _mod->SPIsetRegValue(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_PACKET_SENT_ENABLED); - RADIOLIB_ASSERT(state); - // clear interrupt flags clearIRQFlags(); @@ -239,8 +241,12 @@ int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { // set RF switch (if present) _mod->setRfSwitchState(LOW, HIGH); + // set interrupt mapping + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_PACKET_SENT_ENABLED); + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); + // set mode to transmit - _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_TX_ON); + _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_TX_ON | SI443X_XTAL_ON); return(state); } @@ -254,20 +260,18 @@ int16_t Si443x::startReceive() { _mod->SPIsetRegValue(SI443X_REG_OP_FUNC_CONTROL_2, SI443X_RX_FIFO_RESET, 1, 1); _mod->SPIsetRegValue(SI443X_REG_OP_FUNC_CONTROL_2, SI443X_RX_FIFO_CLEAR, 1, 1); - // set interrupt mapping - state = _mod->SPIsetRegValue(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_VALID_PACKET_RECEIVED_ENABLED, SI443X_CRC_ERROR_ENABLED); - RADIOLIB_ASSERT(state); - state = _mod->SPIsetRegValue(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); - RADIOLIB_ASSERT(state); - // clear interrupt flags clearIRQFlags(); // set RF switch (if present) _mod->setRfSwitchState(HIGH, LOW); + // set interrupt mapping + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_PACKET_SENT_ENABLED); + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); + // set mode to receive - _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON); + _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON | SI443X_XTAL_ON); return(state); } @@ -494,7 +498,7 @@ int16_t Si443x::setPreambleLength(uint8_t preambleLen) { // set default preamble detection threshold to 50% of preamble length (in units of 4 bits) uint8_t preThreshold = preambleLen / 4; - return(_mod->SPIsetRegValue(SI443X_REG_PREAMBLE_DET_CONTROL, preThreshold << 4, 3, 7)); + return(_mod->SPIsetRegValue(SI443X_REG_PREAMBLE_DET_CONTROL, preThreshold << 4, 7, 3)); } size_t Si443x::getPacketLength(bool update) { @@ -557,6 +561,7 @@ int16_t Si443x::setFrequencyRaw(float newFreq) { // check high/low band uint8_t bandSelect = SI443X_BAND_SELECT_LOW; uint8_t freqBand = (newFreq / 10) - 24; + _freq = newFreq; if(newFreq >= 480.0) { bandSelect = SI443X_BAND_SELECT_HIGH; freqBand = (newFreq / 20) - 24; @@ -605,8 +610,8 @@ bool Si443x::findChip() { } void Si443x::clearIRQFlags() { - _mod->SPIreadRegister(SI443X_REG_INTERRUPT_STATUS_1); - _mod->SPIreadRegister(SI443X_REG_INTERRUPT_STATUS_2); + uint8_t buff[2]; + _mod->SPIreadRegisterBurst(SI443X_REG_INTERRUPT_STATUS_1, 2, buff); } int16_t Si443x::config() { @@ -615,8 +620,7 @@ int16_t Si443x::config() { RADIOLIB_ASSERT(state); // disable POR and chip ready interrupts - state = _mod->SPIsetRegValue(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); - RADIOLIB_ASSERT(state); + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); // disable packet header state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_2, SI443X_SYNC_WORD_TIMEOUT_ON | SI443X_HEADER_LENGTH_HEADER_NONE, 7, 4); diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index b5ffeb54..286ab144 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -792,6 +792,7 @@ class Si443x: public PhysicalLayer { float _br = 0; float _freqDev = 0; + float _freq = 0; size_t _packetLength = 0; bool _packetLengthQueried = false; From d934e61777ba4ccd08a732df85d8d9f78fc6963a Mon Sep 17 00:00:00 2001 From: halfbakery Date: Fri, 17 Jul 2020 22:55:11 +0200 Subject: [PATCH 271/455] [SX127x] Dio1Action precondition checks were inverted --- src/modules/SX127x/SX127x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 2890ff5f..bd5021db 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -403,14 +403,14 @@ void SX127x::clearDio0Action() { } void SX127x::setDio1Action(void (*func)(void)) { - if(_mod->getGpio() != RADIOLIB_NC) { + if(_mod->getGpio() == RADIOLIB_NC) { return; } attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING); } void SX127x::clearDio1Action() { - if(_mod->getGpio() != RADIOLIB_NC) { + if(_mod->getGpio() == RADIOLIB_NC) { return; } detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); From 8d92a5f402ef2609b4ba3b7e2ca3df0502292bfa Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 18 Jul 2020 07:09:33 +0200 Subject: [PATCH 272/455] [CC1101] Fixed inverted check (#167) --- src/modules/CC1101/CC1101.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 9fd98d99..659966ae 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -198,7 +198,7 @@ void CC1101::clearGdo0Action() { } void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { - if(_mod->getGpio() != RADIOLIB_NC) { + if(_mod->getGpio() == RADIOLIB_NC) { return; } Module::pinMode(_mod->getGpio(), INPUT); @@ -206,7 +206,7 @@ void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { } void CC1101::clearGdo2Action() { - if(_mod->getGpio() != RADIOLIB_NC) { + if(_mod->getGpio() == RADIOLIB_NC) { return; } detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); From 9432e3d1c3b627f62bae30d6516a3aabf3344ce8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 18 Jul 2020 07:09:44 +0200 Subject: [PATCH 273/455] [RF69] Fixed inverted check (#167) --- src/modules/RF69/RF69.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index ddffc532..f09c6e14 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -275,7 +275,7 @@ void RF69::clearDio0Action() { } void RF69::setDio1Action(void (*func)(void)) { - if(_mod->getGpio() != RADIOLIB_NC) { + if(_mod->getGpio() == RADIOLIB_NC) { return; } Module::pinMode(_mod->getGpio(), INPUT); @@ -283,7 +283,7 @@ void RF69::setDio1Action(void (*func)(void)) { } void RF69::clearDio1Action() { - if(_mod->getGpio() != RADIOLIB_NC) { + if(_mod->getGpio() == RADIOLIB_NC) { return; } detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); From 7c36a044e90740c116248bc7d4f9848e83073886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 18 Jul 2020 20:22:27 +0200 Subject: [PATCH 274/455] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8677ece..4a88b344 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ The list above is by no means exhaustive. Most of RadioLib code is independent o First of all, take a look at the [examples](https://github.com/jgromes/RadioLib/tree/master/examples) and the [Wiki](https://github.com/jgromes/RadioLib/wiki) - especially the [Basics](https://github.com/jgromes/RadioLib/wiki/Basics) page. There's a lot of useful information over there. If something isn't working as expected, try searching the [issues](https://github.com/jgromes/RadioLib/issues/). ### Help, my module isn't working! -The fastest way to get help is by creating an [issue](https://github.com/jgromes/RadioLib/issues/new?assignees=&labels=&template=bug_report.md&title=) using the appropriate template. It is also highly recommended to try running the examples first - their functionality is tested from time to time and they should work. Finally, RadioLib is still under development, which means that sometimes, backwards-incompatible changes might be introduced. Though these are kept at minimum, sometimes it is unavoidable. You can check the [release changelog](https://github.com/jgromes/RadioLib/releases) to find out if there's been such a major change recently. +The fastest way to get help is by creating an [issue](https://github.com/jgromes/RadioLib/issues/new/choose) using the appropriate template. It is also highly recommended to try running the examples first - their functionality is tested from time to time and they should work. Finally, RadioLib is still under development, which means that sometimes, backwards-incompatible changes might be introduced. Though these are kept at minimum, sometimes it is unavoidable. You can check the [release changelog](https://github.com/jgromes/RadioLib/releases) to find out if there's been such a major change recently. ### RadioLib doesn't support my module! What should I do? Start by creating new issue (if it doesn't exist yet). If you have some experience with Arduino and C/C++ in general, you can try to add the support yourself! Use the template files in `/extras/` folder to get started. This is by far the fastest way to implement new modules into RadioLib, since I can't be working on everything all the time. If you don't trust your programming skills enough to have a go at it yourself, don't worry. I will try to implement all requested modules, but it will take me a while. From 16bdae8dd31aec6d74a3b9b55df88cf723d0e34c Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 19 Jul 2020 18:08:43 +0200 Subject: [PATCH 275/455] Added missing keyword --- keywords.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/keywords.txt b/keywords.txt index a564bcf6..06932713 100644 --- a/keywords.txt +++ b/keywords.txt @@ -144,6 +144,7 @@ setGdo0Action KEYWORD2 setGdo2Action KEYWORD2 clearGdo0Action KEYWORD2 clearGdo2Action KEYWORD2 +setCrcFiltering KEYWORD2 # SX126x-specific setTCXO KEYWORD2 From 3c7dfa632b5c43d6e4bef1bbd12210e68aa8e2b7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 19 Jul 2020 18:08:48 +0200 Subject: [PATCH 276/455] [CC1101] Fixed incorrect default Rx bandwidth in doxygen --- src/modules/CC1101/CC1101.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index d2284aa2..8999d371 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -527,7 +527,7 @@ class CC1101: public PhysicalLayer { \param freqDev Frequency deviation from carrier frequency in kHz Defaults to 48.0 kHz. - \param rxBw Receiver bandwidth in kHz. Defaults to 125.0 kHz. + \param rxBw Receiver bandwidth in kHz. Defaults to 135.0 kHz. \param power Output power in dBm. Defaults to 10 dBm. From 892bd489639d1ac6239eef71231e20bac7624394 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 25 Jul 2020 16:15:05 +0200 Subject: [PATCH 277/455] [CC1101] Fixed SPI commands always using default SPI (#173) --- src/modules/CC1101/CC1101.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 659966ae..3b3eb356 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -853,10 +853,12 @@ void CC1101::SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len) { } void CC1101::SPIsendCommand(uint8_t cmd) { + SPIClass* spi = _mod->getSpi(); + SPISettings spiSettings = _mod->getSpiSettings(); Module::digitalWrite(_mod->getCs(), LOW); - SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0)); - SPI.transfer(cmd); - SPI.endTransaction(); + spi->beginTransaction(spiSettings); + spi->transfer(cmd); + spi->endTransaction(); Module::digitalWrite(_mod->getCs(), HIGH); } From febeba23e08682fdf773dc0e9f149c9b83718549 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:32:24 +0200 Subject: [PATCH 278/455] Added progmem macros --- src/BuildOpt.h | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 07a21840..7c8144d6 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -10,13 +10,16 @@ /* * Platform-specific configuration. * - * RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected, + * RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected. * RADIOLIB_PIN_TYPE - which type should be used for pin numbers in functions like digitalRead(). * RADIOLIB_PIN_MODE - which type should be used for pin modes in functions like pinMode(). * RADIOLIB_PIN_STATUS - which type should be used for pin values in functions like digitalWrite(). - * RADIOLIB_DIGITAL_PIN_TO_INTERRUPT - function to be used to convert digital pin number to interrupt pin number. * RADIOLIB_INTERRUPT_STATUS - which type should be used for pin changes in functions like attachInterrupt(). + * RADIOLIB_DIGITAL_PIN_TO_INTERRUPT - function/macro to be used to convert digital pin number to interrupt pin number. * RADIOLIB_NC - alias for unused pin, usually the largest possible value of RADIOLIB_PIN_TYPE. + * RADIOLIB_DEFAULT_SPI - default SPIClass instance to use. + * RADIOLIB_PROGMEM - macro to place variable into program storage (usually Flash). + * RADIOLIB_PROGMEM_READ_BYTE - function/macro to read variables saved in program storage (usually Flash). * RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - defined if the specific platform does not support SoftwareSerial. * RADIOLIB_HARDWARE_SERIAL_PORT - which hardware serial port should be used on platform that do not have SoftwareSerial support. * RADIOLIB_TONE_UNSUPPORTED - some platforms do not have tone()/noTone(), which is required for AFSK. @@ -43,6 +46,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) // the following must be defined if the Arduino core does not support SoftwareSerial library //#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED @@ -90,6 +95,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #elif defined(ESP8266) // ESP8266 boards @@ -101,6 +108,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) // RadioLib has ESP8266 driver, this must be disabled to use ESP8266 as platform #define RADIOLIB_EXCLUDE_ESP8266 @@ -115,6 +124,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #define RADIOLIB_TONE_UNSUPPORTED @@ -129,6 +140,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(digitalPinToPinName(p)) #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -142,6 +155,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -155,6 +170,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #define RADIOLIB_TONE_UNSUPPORTED @@ -169,6 +186,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #elif defined(ARDUINO_ARC32_TOOLS) // Intel Curie @@ -180,6 +199,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) // Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every @@ -191,6 +212,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #elif defined(AM_PART_APOLLO3) // Sparkfun Artemis boards @@ -202,6 +225,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #define RADIOLIB_TONE_UNSUPPORTED @@ -216,6 +241,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -232,6 +259,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 @@ -248,6 +277,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 #define RADIOLIB_TONE_UNSUPPORTED @@ -263,6 +294,8 @@ #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #endif #endif From 59c44d388371869d9b875e76e38ee6ee57293758 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:33:25 +0200 Subject: [PATCH 279/455] Added Module overrides for all Arduino core functions --- src/Module.cpp | 40 ++++++++++++++++++++++++----- src/Module.h | 70 ++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 93 insertions(+), 17 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index 774b409b..8d3e2e19 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -175,8 +175,8 @@ bool Module::ATsendData(uint8_t* data, uint32_t len) { bool Module::ATgetResponse() { char data[128]; char* dataPtr = data; - uint32_t start = millis(); - while(millis() - start < _ATtimeout) { + uint32_t start = Module::millis(); + while(Module::millis() - start < _ATtimeout) { while(ModuleSerial->available() > 0) { char c = ModuleSerial->read(); RADIOLIB_VERBOSE_PRINT(c); @@ -218,9 +218,9 @@ int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t // 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 = micros(); + uint32_t start = Module::micros(); uint8_t readValue; - while(micros() - start < (checkInterval * 1000)) { + while(Module::micros() - start < (checkInterval * 1000)) { readValue = SPIreadRegister(reg); if(readValue == newValue) { // check passed, we can stop the loop @@ -336,7 +336,7 @@ RADIOLIB_PIN_STATUS Module::digitalRead(RADIOLIB_PIN_TYPE pin) { } void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { - /// \todo Add tone support for platforms without tone() + // TODO add tone support for platforms without tone() #ifndef RADIOLIB_TONE_UNSUPPORTED if(pin != RADIOLIB_NC) { ::tone(pin, value); @@ -345,7 +345,7 @@ void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { } void Module::noTone(RADIOLIB_PIN_TYPE pin) { - /// \todo Add tone support for platforms without tone() + // TODO add tone support for platforms without noTone() #ifndef RADIOLIB_TONE_UNSUPPORTED if(pin != RADIOLIB_NC) { ::noTone(pin); @@ -353,6 +353,34 @@ void Module::noTone(RADIOLIB_PIN_TYPE pin) { #endif } +void Module::attachInterrupt(RADIOLIB_PIN_TYPE interruptNum, void (*userFunc)(void), RADIOLIB_INTERRUPT_STATUS mode) { + ::attachInterrupt(interruptNum, userFunc, mode); +} + +void Module::detachInterrupt(RADIOLIB_PIN_TYPE interruptNum) { + ::detachInterrupt(interruptNum); +} + +void Module::yield() { + ::yield(); +} + +void Module::delay(uint32_t ms) { + ::delay(ms); +} + +void Module::delayMicroseconds(uint32_t us) { + ::delayMicroseconds(us); +} + +uint32_t Module::millis() { + return(::millis()); +} + +uint32_t Module::micros() { + return(::micros()); +} + void Module::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { _useRfSwitch = true; _rxEn = rxEn; diff --git a/src/Module.h b/src/Module.h index aa12389f..3f1b9345 100644 --- a/src/Module.h +++ b/src/Module.h @@ -4,7 +4,6 @@ #include "TypeDef.h" #include -//#include #ifndef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #include #endif @@ -356,6 +355,27 @@ class Module { */ SPISettings getSpiSettings() const { return(_spiSettings); } + /*! + \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. + When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + + \param rxEn RX enable pin. + + \param txEn TX enable pin. + */ + void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + + /*! + \brief Set RF switch state. + + \param rxPinState Pin state to set on Tx enable pin (usually high to transmit). + + \param txPinState Pin state to set on Rx enable pin (usually high to receive). + */ + void setRfSwitchState(RADIOLIB_PIN_STATUS rxPinState, RADIOLIB_PIN_STATUS txPinState); + + // Arduino core overrides + /*! \brief Arduino core pinMode override that checks RADIOLIB_NC as alias for unused pin. @@ -400,23 +420,51 @@ class Module { static void noTone(RADIOLIB_PIN_TYPE pin); /*! - \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. - When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch! + \brief Arduino core attachInterrupt override. - \param rxEn RX enable pin. + \param interruptNum Interrupt number. - \param txEn TX enable pin. + \param userFunc Interrupt service routine. + + \param mode Pin hcange direction. */ - void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + static void attachInterrupt(RADIOLIB_PIN_TYPE interruptNum, void (*userFunc)(void), RADIOLIB_INTERRUPT_STATUS mode); /*! - \brief Set RF switch state. + \brief Arduino core detachInterrupt override. - \param rxPinState Pin state to set on Tx enable pin (usually high to transmit). - - \param txPinState Pin state to set on Rx enable pin (usually high to receive). + \param interruptNum Interrupt number. */ - void setRfSwitchState(RADIOLIB_PIN_STATUS rxPinState, RADIOLIB_PIN_STATUS txPinState); + static void detachInterrupt(RADIOLIB_PIN_TYPE interruptNum); + + /*! + \brief Arduino core yield override. + */ + static void yield(); + + /*! + \brief Arduino core delay override. + + \param ms Delay length in milliseconds. + */ + static void delay(uint32_t ms); + + /*! + \brief Arduino core delayMicroseconds override. + + \param us Delay length in microseconds. + */ + static void delayMicroseconds(uint32_t us); + + /*! + \brief Arduino core millis override. + */ + static uint32_t millis(); + + /*! + \brief Arduino core micros override. + */ + static uint32_t micros(); #ifndef RADIOLIB_GODMODE private: From 259b82a0063d20cc62a77b4a0b9595046a413c48 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:33:58 +0200 Subject: [PATCH 280/455] [CC1101] Added Module overrides for all Arduino core functions --- src/modules/CC1101/CC1101.cpp | 41 +++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 3b3eb356..885a7b2f 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -31,7 +31,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po RADIOLIB_DEBUG_PRINT(F(", expected 0x0014")); RADIOLIB_DEBUG_PRINTLN(); #endif - delay(10); + Module::delay(10); i++; } } @@ -101,13 +101,13 @@ int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for transmission start - while(!digitalRead(_mod->getIrq())) { - yield(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); } // wait for transmission end - while(digitalRead(_mod->getIrq())) { - yield(); + while(Module::digitalRead(_mod->getIrq())) { + Module::yield(); } // set mode to standby @@ -125,13 +125,13 @@ int16_t CC1101::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for sync word - while(!digitalRead(_mod->getIrq())) { - yield(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); } // wait for packet end - while(digitalRead(_mod->getIrq())) { - yield(); + while(Module::digitalRead(_mod->getIrq())) { + Module::yield(); } // read packet data @@ -190,26 +190,26 @@ int16_t CC1101::packetMode() { } void CC1101::setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, dir); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, dir); } void CC1101::clearGdo0Action() { - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) { - if(_mod->getGpio() == RADIOLIB_NC) { + if(_mod->getGpio() != RADIOLIB_NC) { return; } Module::pinMode(_mod->getGpio(), INPUT); - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, dir); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, dir); } void CC1101::clearGdo2Action() { - if(_mod->getGpio() == RADIOLIB_NC) { + if(_mod->getGpio() != RADIOLIB_NC) { return; } - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); } int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { @@ -737,7 +737,7 @@ int16_t CC1101::config() { SPIsendCommand(CC1101_CMD_RESET); // Wait a ridiculous amount of time to be sure radio is ready. - delay(150); + Module::delay(150); // enable automatic frequency synthesizer calibration int16_t state = SPIsetRegValue(CC1101_REG_MCSM0, CC1101_FS_AUTOCAL_IDLE_TO_RXTX, 5, 4); @@ -853,11 +853,20 @@ void CC1101::SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len) { } void CC1101::SPIsendCommand(uint8_t cmd) { + // get pointer to used SPI interface and the settings SPIClass* spi = _mod->getSpi(); SPISettings spiSettings = _mod->getSpiSettings(); + + // pull NSS low Module::digitalWrite(_mod->getCs(), LOW); + + // start transfer spi->beginTransaction(spiSettings); + + // send the command byte spi->transfer(cmd); + + // stop transfer spi->endTransaction(); Module::digitalWrite(_mod->getCs(), HIGH); } From 67239551b033b5d5f92f97dbdaff4d5c87623307 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:34:06 +0200 Subject: [PATCH 281/455] [ESP8266] Added Module overrides for all Arduino core functions --- src/modules/ESP8266/ESP8266.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index 98d8c8d5..fe62cc8e 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -30,13 +30,13 @@ int16_t ESP8266::reset() { } // wait for the module to start - delay(2000); + Module::delay(2000); // test AT setup - uint32_t start = millis(); - while (millis() - start < 3000) { + uint32_t start = Module::millis(); + while (Module::millis() - start < 3000) { if(!_mod->ATsendCommand("AT")) { - delay(100); + Module::delay(100); } else { return(ERR_NONE); } @@ -192,11 +192,11 @@ int16_t ESP8266::send(uint8_t* data, size_t len) { size_t ESP8266::receive(uint8_t* data, size_t len, uint32_t timeout) { size_t i = 0; - uint32_t start = millis(); + uint32_t start = Module::millis(); // wait until the required number of bytes is received or until timeout - while((millis() - start < timeout) && (i < len)) { - yield(); + while((Module::millis() - start < timeout) && (i < len)) { + Module::yield(); while(_mod->ModuleSerial->available() > 0) { uint8_t b = _mod->ModuleSerial->read(); RADIOLIB_DEBUG_PRINT(b); @@ -209,10 +209,10 @@ size_t ESP8266::receive(uint8_t* data, size_t len, uint32_t timeout) { size_t ESP8266::getNumBytes(uint32_t timeout, size_t minBytes) { // wait for available data - uint32_t start = millis(); + uint32_t start = Module::millis(); while(_mod->ModuleSerial->available() < (int16_t)minBytes) { - yield(); - if(millis() - start >= timeout) { + Module::yield(); + if(Module::millis() - start >= timeout) { return(0); } } @@ -220,16 +220,16 @@ size_t ESP8266::getNumBytes(uint32_t timeout, size_t minBytes) { // read response char rawStr[20]; uint8_t i = 0; - start = millis(); + start = Module::millis(); while(_mod->ModuleSerial->available() > 0) { - yield(); + Module::yield(); char c = _mod->ModuleSerial->read(); rawStr[i++] = c; if(c == ':') { rawStr[i++] = 0; break; } - if(millis() - start >= timeout) { + if(Module::millis() - start >= timeout) { rawStr[i++] = 0; break; } From 866e3c4c866cfca4b1380f2ebda3d189f3acbb68 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:34:12 +0200 Subject: [PATCH 282/455] [RF69] Added Module overrides for all Arduino core functions --- src/modules/RF69/RF69.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index f09c6e14..89a0f735 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -33,7 +33,7 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe RADIOLIB_DEBUG_PRINT(F(", expected 0x0024")); RADIOLIB_DEBUG_PRINTLN(); #endif - delay(10); + Module::delay(10); i++; } } @@ -102,9 +102,9 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe void RF69::reset() { Module::pinMode(_mod->getRst(), OUTPUT); Module::digitalWrite(_mod->getRst(), HIGH); - delay(1); + Module::delay(1); Module::digitalWrite(_mod->getRst(), LOW); - delay(10); + Module::delay(10); } int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) { @@ -116,11 +116,11 @@ int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for transmission end or timeout - uint32_t start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); + uint32_t start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); - if(micros() - start > timeout) { + if(Module::micros() - start > timeout) { standby(); clearIRQFlags(); return(ERR_TX_TIMEOUT); @@ -145,11 +145,11 @@ int16_t RF69::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for packet reception or timeout - uint32_t start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); + uint32_t start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); - if(micros() - start > timeout) { + if(Module::micros() - start > timeout) { standby(); clearIRQFlags(); return(ERR_RX_TIMEOUT); @@ -267,11 +267,11 @@ int16_t RF69::startReceive() { } void RF69::setDio0Action(void (*func)(void)) { - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); } void RF69::clearDio0Action() { - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } void RF69::setDio1Action(void (*func)(void)) { @@ -279,14 +279,14 @@ void RF69::setDio1Action(void (*func)(void)) { return; } Module::pinMode(_mod->getGpio(), INPUT); - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING); } void RF69::clearDio1Action() { if(_mod->getGpio() == RADIOLIB_NC) { return; } - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); } int16_t RF69::startTransmit(uint8_t* data, size_t len, uint8_t addr) { @@ -640,7 +640,7 @@ int16_t RF69::getTemperature() { // wait until measurement is finished while(_mod->SPIgetRegValue(RF69_REG_TEMP_1, 2, 2) == RF69_TEMP_MEAS_RUNNING) { // check every 10 us - delay(10); + Module::delay(10); } int8_t rawTemp = _mod->SPIgetRegValue(RF69_REG_TEMP_2); From 71045e829b7eb3157f9a744784243ee33ad8d527 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:34:19 +0200 Subject: [PATCH 283/455] [SX1231] Added Module overrides for all Arduino core functions --- src/modules/SX1231/SX1231.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index 3b4668e9..d11a19d7 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -31,7 +31,7 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po RADIOLIB_DEBUG_PRINT(F(", expected 0x0021 / 0x0022 / 0x0023")); RADIOLIB_DEBUG_PRINTLN(); #endif - delay(10); + Module::delay(10); i++; } } From 882ec98563bdacd432c6e0bcc3a78f28550fbd9d Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:34:27 +0200 Subject: [PATCH 284/455] [SX126x] Added Module overrides for all Arduino core functions --- src/modules/SX126x/SX126x.cpp | 72 +++++++++++++++++------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index fbd0edf4..edeaae73 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -159,7 +159,7 @@ int16_t SX126x::reset(bool verify) { // run the reset sequence Module::pinMode(_mod->getRst(), OUTPUT); Module::digitalWrite(_mod->getRst(), LOW); - delay(1); + Module::delay(1); Module::digitalWrite(_mod->getRst(), HIGH); // return immediately when verification is disabled @@ -168,7 +168,7 @@ int16_t SX126x::reset(bool verify) { } // set mode to standby - SX126x often refuses first few commands after reset - uint32_t start = millis(); + uint32_t start = Module::millis(); while(true) { // try to set mode to standby int16_t state = standby(); @@ -178,13 +178,13 @@ int16_t SX126x::reset(bool verify) { } // standby command failed, check timeout and try again - if(millis() - start >= 3000) { + if(Module::millis() - start >= 3000) { // timed out, possibly incorrect wiring return(state); } // wait a bit to not spam the module - delay(10); + Module::delay(10); } } @@ -223,16 +223,16 @@ int16_t SX126x::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for packet transmission or timeout - uint32_t start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); - if(micros() - start > timeout) { + uint32_t start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::micros() - start > timeout) { clearIrqStatus(); standby(); return(ERR_TX_TIMEOUT); } } - uint32_t elapsed = micros() - start; + uint32_t elapsed = Module::micros() - start; // update data rate _dataRate = (len*8.0)/((float)elapsed/1000000.0); @@ -283,10 +283,10 @@ int16_t SX126x::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for packet reception or timeout - uint32_t start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); - if(micros() - start > timeout) { + uint32_t start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::micros() - start > timeout) { fixImplicitTimeout(); clearIrqStatus(); standby(); @@ -354,8 +354,8 @@ int16_t SX126x::scanChannel() { RADIOLIB_ASSERT(state); // wait for channel activity detected or timeout - while(!digitalRead(_mod->getIrq())) { - yield(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); } // check CAD result @@ -384,7 +384,7 @@ int16_t SX126x::sleep(bool retainConfig) { int16_t state = SPIwriteCommand(SX126X_CMD_SET_SLEEP, &sleepMode, 1, false); // wait for SX126x to safely enter sleep mode - delay(1); + Module::delay(1); return(state); } @@ -402,11 +402,11 @@ int16_t SX126x::standby(uint8_t mode) { } void SX126x::setDio1Action(void (*func)(void)) { - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); } void SX126x::clearDio1Action() { - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { @@ -463,8 +463,8 @@ int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for BUSY to go low (= PA ramp up done) - while(digitalRead(_mod->getGpio())) { - yield(); + while(Module::digitalRead(_mod->getGpio())) { + Module::yield(); } return(state); @@ -1531,9 +1531,9 @@ int16_t SX126x::config(uint8_t modem) { RADIOLIB_ASSERT(state); // wait for calibration completion - delay(5); - while(digitalRead(_mod->getGpio())) { - yield(); + Module::delay(5); + while(Module::digitalRead(_mod->getGpio())) { + Module::yield(); } return(ERR_NONE); @@ -1565,14 +1565,14 @@ int16_t SX126x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d #endif // pull NSS low - digitalWrite(_mod->getCs(), LOW); + Module::digitalWrite(_mod->getCs(), LOW); // ensure BUSY is low (state machine ready) - uint32_t start = millis(); - while(digitalRead(_mod->getGpio())) { - yield(); - if(millis() - start >= timeout) { - digitalWrite(_mod->getCs(), HIGH); + uint32_t start = Module::millis(); + while(Module::digitalRead(_mod->getGpio())) { + Module::yield(); + if(Module::millis() - start >= timeout) { + Module::digitalWrite(_mod->getCs(), HIGH); return(ERR_SPI_CMD_TIMEOUT); } } @@ -1632,15 +1632,15 @@ int16_t SX126x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d // stop transfer spi->endTransaction(); - digitalWrite(_mod->getCs(), HIGH); + Module::digitalWrite(_mod->getCs(), HIGH); // wait for BUSY to go high and then low if(waitForBusy) { - delayMicroseconds(1); - start = millis(); - while(digitalRead(_mod->getGpio())) { - yield(); - if(millis() - start >= timeout) { + Module::delayMicroseconds(1); + start = Module::millis(); + while(Module::digitalRead(_mod->getGpio())) { + Module::yield(); + if(Module::millis() - start >= timeout) { status = SX126X_STATUS_CMD_TIMEOUT; break; } @@ -1690,7 +1690,7 @@ int16_t SX126x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d // not sure why, but it seems that long enough SPI transaction // (e.g. setPacketParams for GFSK) will fail without it #if defined(ARDUINO_ARCH_STM32) || defined(SAMD_SERIES) - delay(1); + Module::delay(1); #endif #endif From 6ff84d7b23f3af467c9441e27f68c8376177dcf7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:34:37 +0200 Subject: [PATCH 285/455] [SX127x] Added Module overrides for all Arduino core functions --- src/modules/SX127x/SX1272.cpp | 4 +-- src/modules/SX127x/SX1278.cpp | 4 +-- src/modules/SX127x/SX127x.cpp | 50 +++++++++++++++++------------------ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index cc3e8133..94732904 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -66,9 +66,9 @@ int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t void SX1272::reset() { Module::pinMode(_mod->getRst(), OUTPUT); Module::digitalWrite(_mod->getRst(), HIGH); - delay(1); + Module::delay(1); Module::digitalWrite(_mod->getRst(), LOW); - delay(5); + Module::delay(5); } int16_t SX1272::setFrequency(float freq) { diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index c4f6ff40..58ef91d4 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -61,9 +61,9 @@ int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t void SX1278::reset() { Module::pinMode(_mod->getRst(), OUTPUT); Module::digitalWrite(_mod->getRst(), LOW); - delay(1); + Module::delay(1); Module::digitalWrite(_mod->getRst(), HIGH); - delay(5); + Module::delay(5); } int16_t SX1278::setFrequency(float freq) { diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index bd5021db..704de5fc 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -143,10 +143,10 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for packet transmission or timeout - start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); - if(micros() - start > timeout) { + start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::micros() - start > timeout) { clearIRQFlags(); return(ERR_TX_TIMEOUT); } @@ -161,10 +161,10 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for transmission end or timeout - start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); - if(micros() - start > timeout) { + start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::micros() - start > timeout) { clearIRQFlags(); standby(); return(ERR_TX_TIMEOUT); @@ -175,7 +175,7 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) { } // update data rate - uint32_t elapsed = micros() - start; + uint32_t elapsed = Module::micros() - start; _dataRate = (len*8.0)/((float)elapsed/1000000.0); // clear interrupt flags @@ -197,9 +197,9 @@ int16_t SX127x::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for packet reception or timeout (100 LoRa symbols) - while(!digitalRead(_mod->getIrq())) { - yield(); - if(digitalRead(_mod->getGpio())) { + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::digitalRead(_mod->getGpio())) { clearIRQFlags(); return(ERR_RX_TIMEOUT); } @@ -214,10 +214,10 @@ int16_t SX127x::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for packet reception or timeout - uint32_t start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); - if(micros() - start > timeout) { + uint32_t start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::micros() - start > timeout) { clearIRQFlags(); return(ERR_RX_TIMEOUT); } @@ -255,9 +255,9 @@ int16_t SX127x::scanChannel() { RADIOLIB_ASSERT(state); // wait for channel activity detected or timeout - while(!digitalRead(_mod->getIrq())) { - yield(); - if(digitalRead(_mod->getGpio())) { + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::digitalRead(_mod->getGpio())) { clearIRQFlags(); return(PREAMBLE_DETECTED); } @@ -395,25 +395,25 @@ int16_t SX127x::startReceive(uint8_t len, uint8_t mode) { } void SX127x::setDio0Action(void (*func)(void)) { - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); } void SX127x::clearDio0Action() { - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } void SX127x::setDio1Action(void (*func)(void)) { if(_mod->getGpio() == RADIOLIB_NC) { return; } - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING); } void SX127x::clearDio1Action() { if(_mod->getGpio() == RADIOLIB_NC) { return; } - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio())); } int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { @@ -975,7 +975,7 @@ int8_t SX127x::getTempRaw() { _mod->SPIsetRegValue(SX127X_REG_IMAGE_CAL, SX127X_TEMP_MONITOR_ON, 0, 0); // wait - delayMicroseconds(200); + Module::delayMicroseconds(200); // disable temperature reading _mod->SPIsetRegValue(SX127X_REG_IMAGE_CAL, SX127X_TEMP_MONITOR_OFF, 0, 0); @@ -1093,7 +1093,7 @@ bool SX127x::findChip(uint8_t ver) { RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); RADIOLIB_DEBUG_PRINTLN(ver, HEX); #endif - delay(10); + Module::delay(10); i++; } } From 2aeffd914fa59869f0847affc35b23c745f223d5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:34:44 +0200 Subject: [PATCH 286/455] [SX128x] Added Module overrides for all Arduino core functions --- src/modules/SX128x/SX1280.cpp | 8 ++--- src/modules/SX128x/SX128x.cpp | 64 +++++++++++++++++------------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/modules/SX128x/SX1280.cpp b/src/modules/SX128x/SX1280.cpp index b0d513ef..0bb5b139 100644 --- a/src/modules/SX128x/SX1280.cpp +++ b/src/modules/SX128x/SX1280.cpp @@ -11,10 +11,10 @@ int16_t SX1280::range(bool master, uint32_t addr) { RADIOLIB_ASSERT(state); // wait until ranging is finished - uint32_t start = millis(); - while(!digitalRead(_mod->getIrq())) { - yield(); - if(millis() - start > 10000) { + uint32_t start = Module::millis(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::millis() - start > 10000) { clearIrqStatus(); standby(); return(ERR_RANGING_TIMEOUT); diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 8638ebc9..dfb97a1c 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -228,7 +228,7 @@ int16_t SX128x::reset(bool verify) { // run the reset sequence - same as SX126x, as SX128x docs don't seem to mention this Module::pinMode(_mod->getRst(), OUTPUT); Module::digitalWrite(_mod->getRst(), LOW); - delay(1); + Module::delay(1); Module::digitalWrite(_mod->getRst(), HIGH); // return immediately when verification is disabled @@ -237,7 +237,7 @@ int16_t SX128x::reset(bool verify) { } // set mode to standby - uint32_t start = millis(); + uint32_t start = Module::millis(); while(true) { // try to set mode to standby int16_t state = standby(); @@ -247,13 +247,13 @@ int16_t SX128x::reset(bool verify) { } // standby command failed, check timeout and try again - if(millis() - start >= 3000) { + if(Module::millis() - start >= 3000) { // timed out, possibly incorrect wiring return(state); } // wait a bit to not spam the module - delay(10); + Module::delay(10); } } @@ -285,10 +285,10 @@ int16_t SX128x::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for packet transmission or timeout - uint32_t start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); - if(micros() - start > timeout) { + uint32_t start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::micros() - start > timeout) { clearIrqStatus(); standby(); return(ERR_TX_TIMEOUT); @@ -329,10 +329,10 @@ int16_t SX128x::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for packet reception or timeout - uint32_t start = micros(); - while(!digitalRead(_mod->getIrq())) { - yield(); - if(micros() - start > timeout) { + uint32_t start = Module::micros(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::micros() - start > timeout) { clearIrqStatus(); standby(); return(ERR_RX_TIMEOUT); @@ -392,8 +392,8 @@ int16_t SX128x::scanChannel() { RADIOLIB_ASSERT(state); // wait for channel activity detected or timeout - while(!digitalRead(_mod->getIrq())) { - yield(); + while(!Module::digitalRead(_mod->getIrq())) { + Module::yield(); } // check CAD result @@ -422,7 +422,7 @@ int16_t SX128x::sleep(bool retainConfig) { int16_t state = SPIwriteCommand(SX128X_CMD_SET_SLEEP, &sleepConfig, 1, false); // wait for SX128x to safely enter sleep mode - delay(1); + Module::delay(1); return(state); } @@ -440,11 +440,11 @@ int16_t SX128x::standby(uint8_t mode) { } void SX128x::setDio1Action(void (*func)(void)) { - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING); } void SX128x::clearDio1Action() { - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { @@ -504,8 +504,8 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for BUSY to go low (= PA ramp up done) - while(digitalRead(_mod->getGpio())) { - yield(); + while(Module::digitalRead(_mod->getGpio())) { + Module::yield(); } return(state); @@ -1295,17 +1295,17 @@ int16_t SX128x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d #endif // ensure BUSY is low (state machine ready) - uint32_t start = millis(); - while(digitalRead(_mod->getGpio())) { - yield(); - if(millis() - start >= timeout) { - digitalWrite(_mod->getCs(), HIGH); + uint32_t start = Module::millis(); + while(Module::digitalRead(_mod->getGpio())) { + Module::yield(); + if(Module::millis() - start >= timeout) { + Module::digitalWrite(_mod->getCs(), HIGH); return(ERR_SPI_CMD_TIMEOUT); } } // pull NSS low - digitalWrite(_mod->getCs(), LOW); + Module::digitalWrite(_mod->getCs(), LOW); // start transfer spi->beginTransaction(spiSettings); @@ -1362,15 +1362,15 @@ int16_t SX128x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d // stop transfer spi->endTransaction(); - digitalWrite(_mod->getCs(), HIGH); + Module::digitalWrite(_mod->getCs(), HIGH); // wait for BUSY to go high and then low if(waitForBusy) { - delayMicroseconds(1); - start = millis(); - while(digitalRead(_mod->getGpio())) { - yield(); - if(millis() - start >= timeout) { + Module::delayMicroseconds(1); + start = Module::millis(); + while(Module::digitalRead(_mod->getGpio())) { + Module::yield(); + if(Module::millis() - start >= timeout) { status = SX128X_STATUS_CMD_TIMEOUT; break; } @@ -1420,7 +1420,7 @@ int16_t SX128x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d // not sure why, but it seems that long enough SPI transaction // (e.g. setPacketParams for GFSK) will fail without it #if defined(ARDUINO_ARCH_STM32) || defined(SAMD_SERIES) - delay(1); + Module::delay(1); #endif #endif From 41069d08480c48802d58ec0461cd720aa1845545 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:34:52 +0200 Subject: [PATCH 287/455] [Si443x] Added Module overrides for all Arduino core functions --- src/modules/Si443x/Si443x.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 53761ac3..ea3512f5 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -60,9 +60,9 @@ int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen) void Si443x::reset() { Module::pinMode(_mod->getRst(), OUTPUT); Module::digitalWrite(_mod->getRst(), HIGH); - delay(1); + Module::delay(1); Module::digitalWrite(_mod->getRst(), LOW); - delay(100); + Module::delay(100); } int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) { @@ -74,10 +74,10 @@ int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait for transmission end or timeout - uint32_t start = micros(); - while(digitalRead(_mod->getIrq())) { - yield(); - if(micros() - start > timeout) { + uint32_t start = Module::micros(); + while(Module::digitalRead(_mod->getIrq())) { + Module::yield(); + if(Module::micros() - start > timeout) { standby(); clearIRQFlags(); return(ERR_TX_TIMEOUT); @@ -107,9 +107,9 @@ int16_t Si443x::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for packet reception or timeout - uint32_t start = micros(); - while(digitalRead(_mod->getIrq())) { - if(micros() - start > timeout) { + uint32_t start = Module::micros(); + while(Module::digitalRead(_mod->getIrq())) { + if(Module::micros() - start > timeout) { standby(); clearIRQFlags(); return(ERR_RX_TIMEOUT); @@ -204,11 +204,11 @@ int16_t Si443x::packetMode() { } void Si443x::setIrqAction(void (*func)(void)) { - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING); } void Si443x::clearIrqAction() { - detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); + Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq())); } int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { @@ -601,7 +601,7 @@ bool Si443x::findChip() { RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); RADIOLIB_DEBUG_PRINTLN(SI443X_DEVICE_VERSION, HEX); #endif - delay(10); + Module::delay(10); i++; } } From 123b2f507ffbaf2c19e4bb06dbcb192cd0e1aa44 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:35:00 +0200 Subject: [PATCH 288/455] [XBee] Added Module overrides for all Arduino core functions --- src/modules/XBee/XBee.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/modules/XBee/XBee.cpp b/src/modules/XBee/XBee.cpp index 9b1abe73..37d51530 100644 --- a/src/modules/XBee/XBee.cpp +++ b/src/modules/XBee/XBee.cpp @@ -34,7 +34,7 @@ int16_t XBee::begin(long speed) { RADIOLIB_DEBUG_PRINTLN(state); RADIOLIB_DEBUG_PRINTLN(F("Resetting ...")); reset(); - delay(10); + Module::delay(10); _mod->ATemptyBuffer(); i++; } @@ -51,10 +51,10 @@ int16_t XBee::begin(long speed) { } void XBee::reset() { - pinMode(_mod->getRst(), OUTPUT); - digitalWrite(_mod->getRst(), LOW); - delay(1); - digitalWrite(_mod->getRst(), HIGH); + Module::pinMode(_mod->getRst(), OUTPUT); + Module::digitalWrite(_mod->getRst(), LOW); + Module::delay(1); + Module::digitalWrite(_mod->getRst(), HIGH); } int16_t XBee::transmit(uint8_t* dest, const char* payload, uint8_t radius) { @@ -216,11 +216,11 @@ int16_t XBeeSerial::begin(long speed) { } void XBeeSerial::reset() { - pinMode(_mod->getRst(), OUTPUT); - digitalWrite(_mod->getRst(), LOW); - delay(1); - digitalWrite(_mod->getRst(), HIGH); - pinMode(_mod->getRst(), INPUT); + Module::pinMode(_mod->getRst(), OUTPUT); + Module::digitalWrite(_mod->getRst(), LOW); + Module::delay(1); + Module::digitalWrite(_mod->getRst(), HIGH); + Module::pinMode(_mod->getRst(), INPUT); } int16_t XBeeSerial::setDestinationAddress(const char* destinationAddressHigh, const char* destinationAddressLow) { @@ -308,13 +308,13 @@ int16_t XBeeSerial::setPanId(const char* panId) { bool XBeeSerial::enterCmdMode() { for(uint8_t i = 0; i < 10; i++) { - delay(1000); + Module::delay(1000); _mod->ModuleSerial->write('+'); _mod->ModuleSerial->write('+'); _mod->ModuleSerial->write('+'); - delay(1000); + Module::delay(1000); if(_mod->ATgetResponse()) { return(true); @@ -403,10 +403,10 @@ int16_t XBee::readApiFrame(uint8_t frameID, uint8_t codePos, uint16_t timeout) { numBytes++; // wait until all response bytes are available (5s timeout) - uint32_t start = millis(); + uint32_t start = Module::millis(); while(_mod->ModuleSerial->available() < (int16_t)numBytes) { - yield(); - if(millis() - start >= timeout/2) { + Module::yield(); + if(Module::millis() - start >= timeout/2) { return(ERR_FRAME_MALFORMED); } } @@ -455,10 +455,10 @@ int16_t XBee::readApiFrame(uint8_t frameID, uint8_t codePos, uint16_t timeout) { uint16_t XBee::getNumBytes(uint32_t timeout, size_t minBytes) { // wait for available data - uint32_t start = millis(); + uint32_t start = Module::millis(); while((size_t)_mod->ModuleSerial->available() < minBytes) { - yield(); - if(millis() - start >= timeout) { + Module::yield(); + if(Module::millis() - start >= timeout) { return(0); } } @@ -468,7 +468,7 @@ uint16_t XBee::getNumBytes(uint32_t timeout, size_t minBytes) { uint8_t i = 0; RADIOLIB_DEBUG_PRINT(F("reading frame length: ")); while(_mod->ModuleSerial->available() > 0) { - yield(); + Module::yield(); uint8_t b = _mod->ModuleSerial->read(); RADIOLIB_DEBUG_PRINT(b, HEX); RADIOLIB_DEBUG_PRINT('\t'); From 3bbe84a899bf80f467fe388c3af3af0be186883f Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:35:11 +0200 Subject: [PATCH 289/455] [nRF24] Added Module overrides for all Arduino core functions --- src/modules/nRF24/nRF24.cpp | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 135e75af..0133b732 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -16,7 +16,7 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW Module::digitalWrite(_mod->getRst(), LOW); // wait for minimum power-on reset duration - delay(100); + Module::delay(100); // check SPI connection int16_t val = _mod->SPIgetRegValue(NRF24_REG_SETUP_AW); @@ -69,7 +69,7 @@ int16_t nRF24::standby() { // make sure carrier output is disabled _mod->SPIsetRegValue(NRF24_REG_RF_SETUP, NRF24_CONT_WAVE_OFF, 7, 7); _mod->SPIsetRegValue(NRF24_REG_RF_SETUP, NRF24_PLL_LOCK_OFF, 4, 4); - digitalWrite(_mod->getRst(), LOW); + Module::digitalWrite(_mod->getRst(), LOW); // use standby-1 mode return(_mod->SPIsetRegValue(NRF24_REG_CONFIG, NRF24_POWER_UP, 1, 1)); @@ -81,9 +81,9 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) { RADIOLIB_ASSERT(state); // wait until transmission is finished - uint32_t start = micros(); - while(digitalRead(_mod->getIrq())) { - yield(); + uint32_t start = Module::micros(); + while(Module::digitalRead(_mod->getIrq())) { + Module::yield(); // check maximum number of retransmits if(getStatus(NRF24_MAX_RT)) { @@ -93,7 +93,7 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) { } // check timeout: 15 retries * 4ms (max Tx time as per datasheet) - if(micros() - start >= 60000) { + if(Module::micros() - start >= 60000) { standby(); clearIRQ(); return(ERR_TX_TIMEOUT); @@ -112,12 +112,12 @@ int16_t nRF24::receive(uint8_t* data, size_t len) { RADIOLIB_ASSERT(state); // wait for Rx_DataReady or timeout - uint32_t start = micros(); - while(digitalRead(_mod->getIrq())) { - yield(); + uint32_t start = Module::micros(); + while(Module::digitalRead(_mod->getIrq())) { + Module::yield(); // check timeout: 15 retries * 4ms (max Tx time as per datasheet) - if(micros() - start >= 60000) { + if(Module::micros() - start >= 60000) { standby(); clearIRQ(); return(ERR_RX_TIMEOUT); @@ -139,7 +139,7 @@ int16_t nRF24::transmitDirect(uint32_t frf) { int16_t state = _mod->SPIsetRegValue(NRF24_REG_CONFIG, NRF24_PTX, 0, 0); state |= _mod->SPIsetRegValue(NRF24_REG_RF_SETUP, NRF24_CONT_WAVE_ON, 7, 7); state |= _mod->SPIsetRegValue(NRF24_REG_RF_SETUP, NRF24_PLL_LOCK_ON, 4, 4); - digitalWrite(_mod->getRst(), HIGH); + Module::digitalWrite(_mod->getRst(), HIGH); return(state); } @@ -150,7 +150,7 @@ int16_t nRF24::receiveDirect() { } void nRF24::setIrqAction(void (*func)(void)) { - attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING); + Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING); } int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) { @@ -186,9 +186,9 @@ int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) { SPIwriteTxPayload(data, len); // CE high to start transmitting - digitalWrite(_mod->getRst(), HIGH); - delay(1); - digitalWrite(_mod->getRst(), LOW); + Module::digitalWrite(_mod->getRst(), HIGH); + Module::delay(1); + Module::digitalWrite(_mod->getRst(), LOW); return(state); } @@ -211,10 +211,10 @@ int16_t nRF24::startReceive() { SPItransfer(NRF24_CMD_FLUSH_RX); // CE high to start receiving - digitalWrite(_mod->getRst(), HIGH); + Module::digitalWrite(_mod->getRst(), HIGH); // wait to enter Rx state - delay(1); + Module::delay(1); return(state); } @@ -539,7 +539,7 @@ int16_t nRF24::config() { // power up _mod->SPIsetRegValue(NRF24_REG_CONFIG, NRF24_POWER_UP, 1, 1); - delay(5); + Module::delay(5); return(state); } @@ -558,7 +558,7 @@ void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* data SPISettings spiSettings = _mod->getSpiSettings(); // start transfer - digitalWrite(_mod->getCs(), LOW); + Module::digitalWrite(_mod->getCs(), LOW); spi->beginTransaction(spiSettings); // send command @@ -577,7 +577,7 @@ void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* data // stop transfer spi->endTransaction(); - digitalWrite(_mod->getCs(), HIGH); + Module::digitalWrite(_mod->getCs(), HIGH); } #endif From 50dd6fce0ce9790d6908efc181d50110968c772a Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:35:43 +0200 Subject: [PATCH 290/455] [AX25] Added Module overrides for all Arduino core functions --- src/protocols/AX25/AX25.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index 7f5c0ef6..7de2bbbe 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -400,14 +400,14 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { // check each bit for(uint16_t mask = 0x80; mask >= 0x01; mask >>= 1) { - uint32_t start = micros(); + uint32_t start = Module::micros(); if(stuffedFrameBuff[i] & mask) { _audio->tone(AX25_AFSK_MARK, false); } else { _audio->tone(AX25_AFSK_SPACE, false); } - while(micros() - start < 833) { - yield(); + while(Module::micros() - start < 833) { + Module::yield(); } } From 172e60cd476c8c425d7b854b23913596b00304c1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:35:51 +0200 Subject: [PATCH 291/455] [HTTP] Added Module overrides for all Arduino core functions --- src/protocols/HTTP/HTTP.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/protocols/HTTP/HTTP.cpp b/src/protocols/HTTP/HTTP.cpp index 63b2fe95..fae9d8ae 100644 --- a/src/protocols/HTTP/HTTP.cpp +++ b/src/protocols/HTTP/HTTP.cpp @@ -64,8 +64,6 @@ int16_t HTTPClient::get(const char* url, String& response) { return(state); } - //delay(1000); - // get the response length size_t numBytes = _tl->getNumBytes(); if(numBytes == 0) { From e9650720924bdad442000f6edd672a13061a635d Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:36:02 +0200 Subject: [PATCH 292/455] [Hell] Added Module overrides for all Arduino core functions --- src/protocols/Hellschreiber/Hellschreiber.cpp | 8 ++++---- src/protocols/Hellschreiber/Hellschreiber.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/protocols/Hellschreiber/Hellschreiber.cpp b/src/protocols/Hellschreiber/Hellschreiber.cpp index 3a7bb6fc..d9caa41e 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.cpp +++ b/src/protocols/Hellschreiber/Hellschreiber.cpp @@ -39,13 +39,13 @@ size_t HellClient::printGlyph(uint8_t* buff) { // print the character for(uint8_t mask = 0x40; mask >= 0x01; mask >>= 1) { for(int8_t i = HELL_FONT_HEIGHT - 1; i >= 0; i--) { - uint32_t start = micros(); + uint32_t start = Module::micros(); if(buff[i] & mask) { transmitDirect(_base, _baseHz); } else { standby(); } - while(micros() - start < _pixelDuration); + while(Module::micros() - start < _pixelDuration); } } @@ -85,7 +85,7 @@ size_t HellClient::write(uint8_t b) { uint8_t buff[HELL_FONT_WIDTH]; buff[0] = 0x00; for(uint8_t i = 0; i < HELL_FONT_WIDTH - 2; i++) { - buff[i + 1] = pgm_read_byte(&HellFont[pos][i]); + buff[i + 1] = RADIOLIB_PROGMEM_READ_BYTE(&HellFont[pos][i]); } buff[HELL_FONT_WIDTH - 1] = 0x00; @@ -97,7 +97,7 @@ size_t HellClient::print(__FlashStringHelper* fstr) { PGM_P p = reinterpret_cast(fstr); size_t n = 0; while(true) { - char c = pgm_read_byte(p++); + char c = RADIOLIB_PROGMEM_READ_BYTE(p++); if(c == '\0') { break; } diff --git a/src/protocols/Hellschreiber/Hellschreiber.h b/src/protocols/Hellschreiber/Hellschreiber.h index bfe20473..f7c634cb 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.h +++ b/src/protocols/Hellschreiber/Hellschreiber.h @@ -14,7 +14,7 @@ // font definition: characters are stored in rows, // least significant byte of each character is the first row // Hellschreiber use 7x7 characters, but this simplified font uses only 5x5 - the extra bytes aren't stored -static const uint8_t HellFont[64][HELL_FONT_WIDTH - 2] PROGMEM = { +static const uint8_t HellFont[64][HELL_FONT_WIDTH - 2] RADIOLIB_PROGMEM = { { 0b0000000, 0b0000000, 0b0000000, 0b0000000, 0b0000000 }, // space { 0b0001000, 0b0001000, 0b0001000, 0b0000000, 0b0001000 }, // ! { 0b0010100, 0b0010100, 0b0000000, 0b0000000, 0b0000000 }, // " From 182a9688cb934d5f720564dfbbc58d4c6dd41ad2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:36:11 +0200 Subject: [PATCH 293/455] [Morse] Added Module overrides for all Arduino core functions --- src/protocols/Morse/Morse.cpp | 14 +++++++------- src/protocols/Morse/Morse.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/protocols/Morse/Morse.cpp b/src/protocols/Morse/Morse.cpp index 80a44d46..593d6278 100644 --- a/src/protocols/Morse/Morse.cpp +++ b/src/protocols/Morse/Morse.cpp @@ -64,12 +64,12 @@ size_t MorseClient::write(uint8_t b) { if(b == ' ') { RADIOLIB_DEBUG_PRINTLN(F("space")); standby(); - delay(4 * _dotLength); + Module::delay(4 * _dotLength); return(1); } // get morse code from lookup table - uint8_t code = pgm_read_byte(&MorseTable[(uint8_t)(toupper(b) - 32)]); + uint8_t code = RADIOLIB_PROGMEM_READ_BYTE(&MorseTable[(uint8_t)(toupper(b) - 32)]); // check unsupported characters if(code == MORSE_UNSUPORTED) { @@ -83,16 +83,16 @@ size_t MorseClient::write(uint8_t b) { if (code & MORSE_DASH) { RADIOLIB_DEBUG_PRINT('-'); transmitDirect(_base, _baseHz); - delay(3 * _dotLength); + Module::delay(3 * _dotLength); } else { RADIOLIB_DEBUG_PRINT('.'); transmitDirect(_base, _baseHz); - delay(_dotLength); + Module::delay(_dotLength); } // symbol space standby(); - delay(_dotLength); + Module::delay(_dotLength); // move onto the next bit code >>= 1; @@ -100,7 +100,7 @@ size_t MorseClient::write(uint8_t b) { // letter space standby(); - delay(2 * _dotLength); + Module::delay(2 * _dotLength); RADIOLIB_DEBUG_PRINTLN(); return(1); @@ -110,7 +110,7 @@ size_t MorseClient::print(__FlashStringHelper* fstr) { PGM_P p = reinterpret_cast(fstr); size_t n = 0; while(true) { - char c = pgm_read_byte(p++); + char c = RADIOLIB_PROGMEM_READ_BYTE(p++); if(c == '\0') { break; } diff --git a/src/protocols/Morse/Morse.h b/src/protocols/Morse/Morse.h index d94fad0d..caeec47e 100644 --- a/src/protocols/Morse/Morse.h +++ b/src/protocols/Morse/Morse.h @@ -14,7 +14,7 @@ // - Morse code representation is saved LSb first, using additional bit as guard // - position in array corresponds ASCII code minus MORSE_ASCII_OFFSET // - ASCII characters marked MORSE_UNSUPORTED do not have ITU-R M.1677-1 equivalent -static const uint8_t MorseTable[] PROGMEM = { +static const uint8_t MorseTable[] RADIOLIB_PROGMEM = { 0b00, // space 0b110101, // ! (unsupported) 0b1010010, // " From cc06be04de4cb19dbca8be14433b2531e5dded68 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:36:18 +0200 Subject: [PATCH 294/455] [PHY] Added Module overrides for all Arduino core functions --- src/protocols/PhysicalLayer/PhysicalLayer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index 9bb8e322..b0174c51 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -10,7 +10,7 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) { size_t len = 0; PGM_P p = reinterpret_cast(fstr); while(true) { - char c = pgm_read_byte(p++); + char c = RADIOLIB_PROGMEM_READ_BYTE(p++); len++; if(c == '\0') { break; @@ -27,7 +27,7 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) { // copy string from flash p = reinterpret_cast(fstr); for(size_t i = 0; i < len; i++) { - str[i] = pgm_read_byte(p + i); + str[i] = RADIOLIB_PROGMEM_READ_BYTE(p + i); } // transmit string From f15cc19577a16b1016a7c4e5e5b553c891d4acdb Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:36:25 +0200 Subject: [PATCH 295/455] [RTTY] Added Module overrides for all Arduino core functions --- src/protocols/RTTY/RTTY.cpp | 20 ++++++++++---------- src/protocols/RTTY/RTTY.h | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 686c3494..640a79a8 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -91,11 +91,11 @@ uint16_t ITA2String::getBits(char c) { // search ITA2 table uint16_t code = 0x0000; for(uint8_t i = 0; i < ITA2_LENGTH; i++) { - if(pgm_read_byte(&ITA2Table[i][0]) == c) { + if(RADIOLIB_PROGMEM_READ_BYTE(&ITA2Table[i][0]) == c) { // character is in letter shift code = (ITA2_LTRS << 5) | i; break; - } else if(pgm_read_byte(&ITA2Table[i][1]) == c) { + } else if(RADIOLIB_PROGMEM_READ_BYTE(&ITA2Table[i][1]) == c) { // character is in figures shift code = (ITA2_FIGS << 5) | i; break; @@ -217,7 +217,7 @@ size_t RTTYClient::print(__FlashStringHelper* fstr) { size_t len = 0; PGM_P p = reinterpret_cast(fstr); while(true) { - char c = pgm_read_byte(p++); + char c = RADIOLIB_PROGMEM_READ_BYTE(p++); len++; if(c == '\0') { break; @@ -234,7 +234,7 @@ size_t RTTYClient::print(__FlashStringHelper* fstr) { // copy string from flash p = reinterpret_cast(fstr); for(size_t i = 0; i < len; i++) { - str[i] = pgm_read_byte(p + i); + str[i] = RADIOLIB_PROGMEM_READ_BYTE(p + i); } size_t n = 0; @@ -407,18 +407,18 @@ size_t RTTYClient::println(double d, int digits) { } void RTTYClient::mark() { - uint32_t start = micros(); + uint32_t start = Module::micros(); transmitDirect(_base + _shift, _baseHz + _shiftHz); - while(micros() - start < _bitDuration) { - yield(); + while(Module::micros() - start < _bitDuration) { + Module::yield(); } } void RTTYClient::space() { - uint32_t start = micros(); + uint32_t start = Module::micros(); transmitDirect(_base, _baseHz); - while(micros() - start < _bitDuration) { - yield(); + while(Module::micros() - start < _bitDuration) { + Module::yield(); } } diff --git a/src/protocols/RTTY/RTTY.h b/src/protocols/RTTY/RTTY.h index baf89fe1..6eab5fec 100644 --- a/src/protocols/RTTY/RTTY.h +++ b/src/protocols/RTTY/RTTY.h @@ -15,10 +15,10 @@ // ITA2 character table: - position in array corresponds to 5-bit ITA2 code // - characters to the left are in letters shift, characters to the right in figures shift // - characters marked 0x7F do not have ASCII equivalent -static const char ITA2Table[ITA2_LENGTH][2] PROGMEM = {{'\0', '\0'}, {'E', '3'}, {'\n', '\n'}, {'A', '-'}, {' ', ' '}, {'S', '\''}, {'I', '8'}, {'U', '7'}, - {'\r', '\r'}, {'D', 0x05}, {'R', '4'}, {'J', '\a'}, {'N', ','}, {'F', '!'}, {'C', ':'}, {'K', '('}, - {'T', '5'}, {'Z', '+'}, {'L', ')'}, {'W', '2'}, {'H', 0x7F}, {'Y', '6'}, {'P', '0'}, {'Q', '1'}, - {'O', '9'}, {'B', '?'}, {'G', '&'}, {0x7F, 0x7F}, {'M', '.'}, {'X', '/'}, {'V', ';'}, {0x7F, 0x7F}}; +static const char ITA2Table[ITA2_LENGTH][2] RADIOLIB_PROGMEM = {{'\0', '\0'}, {'E', '3'}, {'\n', '\n'}, {'A', '-'}, {' ', ' '}, {'S', '\''}, {'I', '8'}, {'U', '7'}, + {'\r', '\r'}, {'D', 0x05}, {'R', '4'}, {'J', '\a'}, {'N', ','}, {'F', '!'}, {'C', ':'}, {'K', '('}, + {'T', '5'}, {'Z', '+'}, {'L', ')'}, {'W', '2'}, {'H', 0x7F}, {'Y', '6'}, {'P', '0'}, {'Q', '1'}, + {'O', '9'}, {'B', '?'}, {'G', '&'}, {0x7F, 0x7F}, {'M', '.'}, {'X', '/'}, {'V', ';'}, {0x7F, 0x7F}}; /*! \class ITA2String From 5eeba8fe51cb752f4d4c8a498febf8e2846c37d7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:36:31 +0200 Subject: [PATCH 296/455] [SSTV] Added Module overrides for all Arduino core functions --- src/protocols/SSTV/SSTV.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index 9fc9fd3e..8687cc6f 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -205,7 +205,7 @@ int16_t SSTVClient::begin(float base, const SSTVMode_t& mode, float correction) void SSTVClient::idle() { _phy->transmitDirect(); - tone(SSTV_TONE_LEADER); + this->tone(SSTV_TONE_LEADER); } void SSTVClient::sendHeader() { @@ -214,35 +214,35 @@ void SSTVClient::sendHeader() { _phy->transmitDirect(); // send the first part of header (leader-break-leader) - tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH); - tone(SSTV_TONE_BREAK, SSTV_HEADER_BREAK_LENGTH); - tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH); + this->tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH); + this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BREAK_LENGTH); + this->tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH); // VIS start bit - tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH); + this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH); // VIS code uint8_t parityCount = 0; for(uint8_t mask = 0x01; mask < 0x80; mask <<= 1) { if(_mode.visCode & mask) { - tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH); + this->tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH); parityCount++; } else { - tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH); + this->tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH); } } // VIS parity if(parityCount % 2 == 0) { // even parity - tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH); + this->tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH); } else { // odd parity - tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH); + this->tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH); } // VIS stop bit - tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH); + this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH); } void SSTVClient::sendLine(uint32_t* imgLine) { @@ -251,14 +251,14 @@ void SSTVClient::sendLine(uint32_t* imgLine) { _firstLine = false; // send start sync tone - tone(SSTV_TONE_BREAK, 9000); + this->tone(SSTV_TONE_BREAK, 9000); } // send all tones in sequence for(uint8_t i = 0; i < _mode.numTones; i++) { if((_mode.tones[i].type == tone_t::GENERIC) && (_mode.tones[i].len > 0)) { // sync/porch tones - tone(_mode.tones[i].freq, _mode.tones[i].len); + this->tone(_mode.tones[i].freq, _mode.tones[i].len); } else { // scan lines for(uint16_t j = 0; j < _mode.width; j++) { @@ -278,7 +278,7 @@ void SSTVClient::sendLine(uint32_t* imgLine) { case(tone_t::GENERIC): break; } - tone(SSTV_TONE_BRIGHTNESS_MIN + ((float)color * 3.1372549), _mode.scanPixelLen); + this->tone(SSTV_TONE_BRIGHTNESS_MIN + ((float)color * 3.1372549), _mode.scanPixelLen); } } } @@ -289,7 +289,7 @@ uint16_t SSTVClient::getPictureHeight() const { } void SSTVClient::tone(float freq, uint32_t len) { - uint32_t start = micros(); + uint32_t start = Module::micros(); #if !defined(RADIOLIB_EXCLUDE_AFSK) if(_audio != nullptr) { _audio->tone(freq, false); @@ -299,8 +299,8 @@ void SSTVClient::tone(float freq, uint32_t len) { #else _phy->transmitDirect(_base + (freq / _phy->getFreqStep())); #endif - while(micros() - start < len) { - yield(); + while(Module::micros() - start < len) { + Module::yield(); } } From 1a2d2800241deabae05f3c9ddba8e328aafde59e Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 1 Aug 2020 16:49:53 +0200 Subject: [PATCH 297/455] Bump version to 4.0.2 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 14217d0d..ab2a95f3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=4.0.1 +version=4.0.2 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 7c8144d6..3f49008d 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -368,7 +368,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) #define RADIOLIB_VERSION_MINOR (0x00) -#define RADIOLIB_VERSION_PATCH (0x01) +#define RADIOLIB_VERSION_PATCH (0x02) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From d7a620c8ea9abf108ee6b2a0ec9b7eeef91c431d Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 7 Aug 2020 17:45:39 +0200 Subject: [PATCH 298/455] [SX1272] Fixed incorrect FSK/OOK modulation check --- src/modules/SX127x/SX1272.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 94732904..ca1cc5a0 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -273,7 +273,7 @@ int16_t SX1272::setDataShaping(uint8_t sh) { } // check modulation - if(!SX127x::_ook) { + if(SX127x::_ook) { return(ERR_INVALID_MODULATION); } From db234a16afb42922b331c3060303b1d0f56d85ef Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 7 Aug 2020 17:46:13 +0200 Subject: [PATCH 299/455] [SX127x] Fixed packet length mode not checked correctly (#174) --- src/modules/SX127x/SX127x.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 704de5fc..39818f4b 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -453,7 +453,9 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { clearIRQFlags(); // set packet length - _mod->SPIwriteRegister(SX127X_REG_FIFO, len); + if (_packetLengthConfig == SX127X_PACKET_VARIABLE) { + _mod->SPIwriteRegister(SX127X_REG_FIFO, len); + } // check address filtering uint8_t filter = _mod->SPIgetRegValue(SX127X_REG_PACKET_CONFIG_1, 2, 1); @@ -865,7 +867,11 @@ size_t SX127x::getPacketLength(bool update) { } else if(modem == SX127X_FSK_OOK) { // get packet length if(!_packetLengthQueried && update) { - _packetLength = _mod->SPIreadRegister(SX127X_REG_FIFO); + if (_packetLengthConfig == SX127X_PACKET_VARIABLE) { + _packetLength = _mod->SPIreadRegister(SX127X_REG_FIFO); + } else { + _packetLength = _mod->SPIreadRegister(SX127X_REG_PAYLOAD_LENGTH_FSK); + } _packetLengthQueried = true; } } From 20193b784eb6dd2f7d64b7bd54ffdc1a4b969aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Wed, 12 Aug 2020 05:28:51 +0200 Subject: [PATCH 300/455] [RF69] Disabled SPI verification when writing frequency regs (#162) --- src/modules/RF69/RF69.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 89a0f735..7875f41b 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -382,11 +382,10 @@ int16_t RF69::setFrequency(float freq) { //set carrier frequency uint32_t FRF = (freq * (uint32_t(1) << RF69_DIV_EXPONENT)) / RF69_CRYSTAL_FREQ; - int16_t state = _mod->SPIsetRegValue(RF69_REG_FRF_MSB, (FRF & 0xFF0000) >> 16, 7, 0); - state |= _mod->SPIsetRegValue(RF69_REG_FRF_MID, (FRF & 0x00FF00) >> 8, 7, 0); - state |= _mod->SPIsetRegValue(RF69_REG_FRF_LSB, FRF & 0x0000FF, 7, 0); - - return(state); + _mod->SPIwriteRegister(RF69_REG_FRF_MSB, (FRF & 0xFF0000) >> 16); + _mod->SPIwriteRegister(RF69_REG_FRF_MID, (FRF & 0x00FF00) >> 8); + _mod->SPIwriteRegister(RF69_REG_FRF_LSB, FRF & 0x0000FF); + return(ERR_NONE); } int16_t RF69::setBitRate(float br) { From 3a8951912733fa793890b49561014c7f1693ce01 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 22 Aug 2020 08:05:41 +0200 Subject: [PATCH 301/455] Removed references to unused SoftwareSerial-only methods (#175) --- src/ISerial.cpp | 19 ------------------- src/ISerial.h | 8 -------- 2 files changed, 27 deletions(-) diff --git a/src/ISerial.cpp b/src/ISerial.cpp index dbfa6a30..650cfb06 100644 --- a/src/ISerial.cpp +++ b/src/ISerial.cpp @@ -33,25 +33,6 @@ void ISerial::flush() { _mod->ModuleSerial->flush(); } -// SoftwareSerial-only methods -#if !defined(RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED) -bool ISerial::listen() { - return(_mod->ModuleSerial->listen()); -} - -bool ISerial::isListening() { - return(_mod->ModuleSerial->isListening()); -} - -bool ISerial::stopListening() { - return(_mod->ModuleSerial->stopListening()); -} - -bool ISerial::overflow() { - return(_mod->ModuleSerial->overflow()); -} -#endif - size_t ISerial::print(const __FlashStringHelper *ifsh) { return(_mod->ModuleSerial->print(ifsh)); } diff --git a/src/ISerial.h b/src/ISerial.h index 34064934..0029234e 100644 --- a/src/ISerial.h +++ b/src/ISerial.h @@ -25,14 +25,6 @@ class ISerial { int available(); void flush(); - // SoftwareSerial-only methods - #if !defined(RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED) - bool listen(); - bool isListening(); - bool stopListening(); - bool overflow(); - #endif - size_t print(const __FlashStringHelper *); size_t print(const String &); size_t print(const char[]); From 0f62d85893e472bc5ff9ddd88eddd2953c6c3397 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 22 Aug 2020 08:47:53 +0200 Subject: [PATCH 302/455] [SX127x] Added missing beginFSK overrides for SX1276/77/79 --- src/modules/SX127x/SX1276.cpp | 22 ++++++++++++++++++++++ src/modules/SX127x/SX1276.h | 22 ++++++++++++++++++++++ src/modules/SX127x/SX1277.cpp | 22 ++++++++++++++++++++++ src/modules/SX127x/SX1277.h | 22 ++++++++++++++++++++++ src/modules/SX127x/SX1279.cpp | 22 ++++++++++++++++++++++ src/modules/SX127x/SX1279.h | 22 ++++++++++++++++++++++ 6 files changed, 132 insertions(+) diff --git a/src/modules/SX127x/SX1276.cpp b/src/modules/SX127x/SX1276.cpp index b331fe95..848f0949 100644 --- a/src/modules/SX127x/SX1276.cpp +++ b/src/modules/SX127x/SX1276.cpp @@ -36,6 +36,28 @@ int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } +int16_t SX1276::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, bool enableOOK) { + // execute common part + int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); + RADIOLIB_ASSERT(state); + + // configure settings not accessible by API + state = configFSK(); + RADIOLIB_ASSERT(state); + + // configure publicly accessible settings + state = setFrequency(freq); + RADIOLIB_ASSERT(state); + + state = setOutputPower(power); + RADIOLIB_ASSERT(state); + + state = setDataShaping(RADIOLIB_SHAPING_NONE); + RADIOLIB_ASSERT(state); + + return(state); +} + int16_t SX1276::setFrequency(float freq) { RADIOLIB_CHECK_RANGE(freq, 137.0, 1020.0, ERR_INVALID_FREQUENCY); diff --git a/src/modules/SX127x/SX1276.h b/src/modules/SX127x/SX1276.h index ec6e33d6..8c234a87 100644 --- a/src/modules/SX127x/SX1276.h +++ b/src/modules/SX127x/SX1276.h @@ -51,6 +51,28 @@ class SX1276: public SX1278 { */ int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); + /*! + \brief FSK modem initialization method. Must be called at least once from Arduino sketch to initialize the module. + + \param freq Carrier frequency in MHz. Allowed values range from 137.0 MHz to 525.0 MHz. + + \param br Bit rate of the FSK transmission in kbps (kilobits per second). Allowed values range from 1.2 to 300.0 kbps. + + \param freqDev Frequency deviation of the FSK transmission in kHz. Allowed values range from 0.6 to 200.0 kHz. + Note that the allowed range changes based on bit rate setting, so that the condition FreqDev + BitRate/2 <= 250 kHz is always met. + + \param rxBw Receiver bandwidth in kHz. Allowed values are 2.6, 3.1, 3.9, 5.2, 6.3, 7.8, 10.4, 12.5, 15.6, 20.8, 25, 31.3, 41.7, 50, 62.5, 83.3, 100, 125, 166.7, 200 and 250 kHz. + + \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. + + \param preambleLength Length of FSK preamble in bits. + + \param enableOOK Use OOK modulation instead of FSK. + + \returns \ref status_codes + */ + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 10, uint16_t preambleLength = 16, bool enableOOK = false); + // configuration methods /*! diff --git a/src/modules/SX127x/SX1277.cpp b/src/modules/SX127x/SX1277.cpp index 371c125e..005f1ca0 100644 --- a/src/modules/SX127x/SX1277.cpp +++ b/src/modules/SX127x/SX1277.cpp @@ -36,6 +36,28 @@ int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } +int16_t SX1277::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, bool enableOOK) { + // execute common part + int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); + RADIOLIB_ASSERT(state); + + // configure settings not accessible by API + state = configFSK(); + RADIOLIB_ASSERT(state); + + // configure publicly accessible settings + state = setFrequency(freq); + RADIOLIB_ASSERT(state); + + state = setOutputPower(power); + RADIOLIB_ASSERT(state); + + state = setDataShaping(RADIOLIB_SHAPING_NONE); + RADIOLIB_ASSERT(state); + + return(state); +} + int16_t SX1277::setFrequency(float freq) { RADIOLIB_CHECK_RANGE(freq, 137.0, 1020.0, ERR_INVALID_FREQUENCY); diff --git a/src/modules/SX127x/SX1277.h b/src/modules/SX127x/SX1277.h index 6598f066..e0ea539e 100644 --- a/src/modules/SX127x/SX1277.h +++ b/src/modules/SX127x/SX1277.h @@ -51,6 +51,28 @@ class SX1277: public SX1278 { */ int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); + /*! + \brief FSK modem initialization method. Must be called at least once from Arduino sketch to initialize the module. + + \param freq Carrier frequency in MHz. Allowed values range from 137.0 MHz to 525.0 MHz. + + \param br Bit rate of the FSK transmission in kbps (kilobits per second). Allowed values range from 1.2 to 300.0 kbps. + + \param freqDev Frequency deviation of the FSK transmission in kHz. Allowed values range from 0.6 to 200.0 kHz. + Note that the allowed range changes based on bit rate setting, so that the condition FreqDev + BitRate/2 <= 250 kHz is always met. + + \param rxBw Receiver bandwidth in kHz. Allowed values are 2.6, 3.1, 3.9, 5.2, 6.3, 7.8, 10.4, 12.5, 15.6, 20.8, 25, 31.3, 41.7, 50, 62.5, 83.3, 100, 125, 166.7, 200 and 250 kHz. + + \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. + + \param preambleLength Length of FSK preamble in bits. + + \param enableOOK Use OOK modulation instead of FSK. + + \returns \ref status_codes + */ + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 10, uint16_t preambleLength = 16, bool enableOOK = false); + // configuration methods /*! diff --git a/src/modules/SX127x/SX1279.cpp b/src/modules/SX127x/SX1279.cpp index 21d1f598..346643d0 100644 --- a/src/modules/SX127x/SX1279.cpp +++ b/src/modules/SX127x/SX1279.cpp @@ -36,6 +36,28 @@ int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync return(state); } +int16_t SX1279::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, bool enableOOK) { + // execute common part + int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); + RADIOLIB_ASSERT(state); + + // configure settings not accessible by API + state = configFSK(); + RADIOLIB_ASSERT(state); + + // configure publicly accessible settings + state = setFrequency(freq); + RADIOLIB_ASSERT(state); + + state = setOutputPower(power); + RADIOLIB_ASSERT(state); + + state = setDataShaping(RADIOLIB_SHAPING_NONE); + RADIOLIB_ASSERT(state); + + return(state); +} + int16_t SX1279::setFrequency(float freq) { RADIOLIB_CHECK_RANGE(freq, 137.0, 960.0, ERR_INVALID_FREQUENCY); diff --git a/src/modules/SX127x/SX1279.h b/src/modules/SX127x/SX1279.h index 27220119..ef6f29e3 100644 --- a/src/modules/SX127x/SX1279.h +++ b/src/modules/SX127x/SX1279.h @@ -51,6 +51,28 @@ class SX1279: public SX1278 { */ int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); + /*! + \brief FSK modem initialization method. Must be called at least once from Arduino sketch to initialize the module. + + \param freq Carrier frequency in MHz. Allowed values range from 137.0 MHz to 525.0 MHz. + + \param br Bit rate of the FSK transmission in kbps (kilobits per second). Allowed values range from 1.2 to 300.0 kbps. + + \param freqDev Frequency deviation of the FSK transmission in kHz. Allowed values range from 0.6 to 200.0 kHz. + Note that the allowed range changes based on bit rate setting, so that the condition FreqDev + BitRate/2 <= 250 kHz is always met. + + \param rxBw Receiver bandwidth in kHz. Allowed values are 2.6, 3.1, 3.9, 5.2, 6.3, 7.8, 10.4, 12.5, 15.6, 20.8, 25, 31.3, 41.7, 50, 62.5, 83.3, 100, 125, 166.7, 200 and 250 kHz. + + \param power Transmission output power in dBm. Allowed values range from 2 to 17 dBm. + + \param preambleLength Length of FSK preamble in bits. + + \param enableOOK Use OOK modulation instead of FSK. + + \returns \ref status_codes + */ + int16_t beginFSK(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 10, uint16_t preambleLength = 16, bool enableOOK = false); + // configuration methods /*! From 63b8d07abcaf4e0e2ab63f9e965df217970ff4a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 09:35:21 +0200 Subject: [PATCH 303/455] Added GH actions yml --- .github/workflows/main.yml | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..820a3956 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,60 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + Arduino-Uno: + runs-on: ubuntu-latest + steps: + - name: Install dependencies + - run: | + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh + export PATH=$PATH:$PWD/bin + arduino-cli core update-index; + arduino-cli core install arduino:avr; + + - uses: actions/checkout@v2 + + - name: Build all examples + - run: | + for example in $(find $PWD/examples -name '*.ino' | sort); do + # check whether to skip this sketch + if [ ! -z "$SKIP_PAT" ] && [[ ${example} =~ $SKIP_PAT ]]; then + # skip sketch + echo -e "\n\033[1;33mSkipped ${example##*/} (matched with $SKIP_PAT)\033[0m"; + else + # build sketch + echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; + arduino-cli compile --fqbn $BOARD $example --warnings=$WARNINGS + if [ $? -ne 0 ]; then + echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; + exit 1; + else + echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n"; + fi + fi + done + + Doxygen: + runs-on: ubuntu-latest + steps: + - name: Install Doxygen + - run: | + sudo apt-get update; + sudo apt-get install -y doxygen; + + - uses: actions/checkout@v2 + + - name: Generate docs + - run: doxygen Doxyfile + + - uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: docs/html From 051563aa73e72b8dd4724d3be148de01bc08ac65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 09:37:17 +0200 Subject: [PATCH 304/455] [CI] Syntax fix --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 820a3956..d596aa63 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install dependencies - - run: | + run: | curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh export PATH=$PATH:$PWD/bin arduino-cli core update-index; @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v2 - name: Build all examples - - run: | + run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch if [ ! -z "$SKIP_PAT" ] && [[ ${example} =~ $SKIP_PAT ]]; then @@ -44,14 +44,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Doxygen - - run: | + run: | sudo apt-get update; sudo apt-get install -y doxygen; - uses: actions/checkout@v2 - name: Generate docs - - run: doxygen Doxyfile + run: doxygen Doxyfile - uses: JamesIves/github-pages-deploy-action@releases/v3 with: From eb329f2690e5055ad1f1667f677921ec2c6080e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 09:42:55 +0200 Subject: [PATCH 305/455] [CI] Added missing paths --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d596aa63..86e5291a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,10 +13,13 @@ jobs: steps: - name: Install dependencies run: | - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh + mkdir -p ~/.local/bin + echo "::add-path::~/.local/bin" + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh export PATH=$PATH:$PWD/bin arduino-cli core update-index; arduino-cli core install arduino:avr; + export WARNINGS=all; - uses: actions/checkout@v2 From 5aa0a87bf01a4ca568e5b4afe18884246eaa096d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 09:53:36 +0200 Subject: [PATCH 306/455] [CI] Moved board install --- .github/workflows/main.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 86e5291a..0486b47b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,15 +11,18 @@ jobs: Arduino-Uno: runs-on: ubuntu-latest steps: - - name: Install dependencies + - name: Install arduino-cli run: | mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh export PATH=$PATH:$PWD/bin - arduino-cli core update-index; - arduino-cli core install arduino:avr; - export WARNINGS=all; + + - name: Install board + run: | + arduino-cli core update-index + arduino-cli core install arduino:avr + export WARNINGS=all - uses: actions/checkout@v2 From e781abb8844d1199c0d53fd3067d0b11e4b67dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 09:55:36 +0200 Subject: [PATCH 307/455] [CI] Added Arduino Uno test --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0486b47b..58003156 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,7 @@ jobs: run: | arduino-cli core update-index arduino-cli core install arduino:avr + export BOARD="arduino:avr:uno" export WARNINGS=all - uses: actions/checkout@v2 From e01458ba83bd156991bedf1f4d0611ea17619089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 10:03:21 +0200 Subject: [PATCH 308/455] [CI] Set env vars --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 58003156..bc5de18e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,8 +22,8 @@ jobs: run: | arduino-cli core update-index arduino-cli core install arduino:avr - export BOARD="arduino:avr:uno" - export WARNINGS=all + echo "::set-env name=BOARD::arduino:avr:uno" + echo "::set-env name=WARNINGS::all" - uses: actions/checkout@v2 From c7c745594798d63f7395cc9111432880e798577a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 10:14:01 +0200 Subject: [PATCH 309/455] [CI] Added library path to arduino-cli --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc5de18e..933308ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,6 @@ jobs: mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - export PATH=$PATH:$PWD/bin - name: Install board run: | @@ -37,7 +36,7 @@ jobs: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --fqbn $BOARD $example --warnings=$WARNINGS + arduino-cli compile --libraries $PWD/src/RadioLib.h --fqbn $BOARD $example --warnings=$WARNINGS if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From e5cf987c5920e2bd9ac08adf347711f46d616094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 10:15:22 +0200 Subject: [PATCH 310/455] [CI] Fix library path --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 933308ba..8e6cbf4a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --libraries $PWD/src/RadioLib.h --fqbn $BOARD $example --warnings=$WARNINGS + arduino-cli compile --libraries $PWD --fqbn $BOARD $example --warnings=$WARNINGS if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From 89acc33014c1e25f5e7fe647f72961f72cbb22ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 10:21:17 +0200 Subject: [PATCH 311/455] [CI] Added verbose output --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e6cbf4a..c910315d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --libraries $PWD --fqbn $BOARD $example --warnings=$WARNINGS + arduino-cli compile -v --libraries $PWD --fqbn $BOARD $example --warnings=$WARNINGS if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From 72d9de385b0a6ea4e711ece0edccdb6f3c2b9701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 10:26:02 +0200 Subject: [PATCH 312/455] [CI] Set absolute library path --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c910315d..64b43f8e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile -v --libraries $PWD --fqbn $BOARD $example --warnings=$WARNINGS + arduino-cli compile -v --libraries /home/runner/work/RadioLib --fqbn $BOARD $example --warnings=$WARNINGS if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From 2cd93bc42eefd3590a2366a03aa4ec2a4891b699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 10:27:25 +0200 Subject: [PATCH 313/455] [CI] Disabled arduino-cli verbose --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64b43f8e..eb52affa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile -v --libraries /home/runner/work/RadioLib --fqbn $BOARD $example --warnings=$WARNINGS + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn $BOARD $example --warnings=$WARNINGS if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From 03ea2dbc7fa5a33d26212fa1ef6e4c411b67cd29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 10:35:16 +0200 Subject: [PATCH 314/455] Update CI badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a88b344..17c48207 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# RadioLib [![Build Status](https://travis-ci.org/jgromes/RadioLib.svg?branch=master)](https://travis-ci.org/jgromes/RadioLib) +# RadioLib ![Build Status](https://github.com/jgromes/RadioLib/workflows/CI/badge.svg) ### _One radio library to rule them all!_ From 7baf597c97ab7ece8447f86924c37dda1ad746d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 10:58:55 +0200 Subject: [PATCH 315/455] [CI] Added test matrix --- .github/workflows/main.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb52affa..fa9bd4e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,8 +8,18 @@ on: jobs: - Arduino-Uno: + Build: + strategy: + matrix: + platform: ["arduino:avr", "arduino:samd"] + include: + - platform: "arduino:avr" + board: "arduino:avr:uno" + - platform: "arduino:samd" + board: "arduino:samd:arduino_zero_native" + runs-on: ubuntu-latest + steps: - name: Install arduino-cli run: | @@ -17,14 +27,14 @@ jobs: echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - - name: Install board + - name: Install platform run: | arduino-cli core update-index - arduino-cli core install arduino:avr - echo "::set-env name=BOARD::arduino:avr:uno" + arduino-cli core install ${{ matrix.platform }} echo "::set-env name=WARNINGS::all" - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 - name: Build all examples run: | @@ -36,7 +46,7 @@ jobs: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn $BOARD $example --warnings=$WARNINGS + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }} $example --warnings=$WARNINGS if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From 6a2f829a42126d39b5caddf42035d803d7c2196a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 11:18:42 +0200 Subject: [PATCH 316/455] [CI] Added build conditions --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa9bd4e3..d7832ab5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,24 +19,30 @@ jobs: board: "arduino:samd:arduino_zero_native" runs-on: ubuntu-latest + env: + run-build: ${{ (matrix.board == "arduino:avr:uno") || "contains(github.event.head_commit.message, 'CI_FORCE_BUILD'" || "contains(github.event.head_commit.message, 'Bump version to'" }} steps: - name: Install arduino-cli + if: ${{ run-build }} run: | mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - name: Install platform + if: ${{ run-build }} run: | arduino-cli core update-index arduino-cli core install ${{ matrix.platform }} echo "::set-env name=WARNINGS::all" - name: Checkout + if: ${{ run-build }} uses: actions/checkout@v2 - name: Build all examples + if: ${{ run-build }} run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch From b443509e82aa379c2b7d8d4f3a67de0c3b5b129e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 11:45:16 +0200 Subject: [PATCH 317/455] [CI] Change conditional to platform --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d7832ab5..bf100eee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest env: - run-build: ${{ (matrix.board == "arduino:avr:uno") || "contains(github.event.head_commit.message, 'CI_FORCE_BUILD'" || "contains(github.event.head_commit.message, 'Bump version to'" }} + run-build: ${{ (matrix.platform == "arduino:avr") || "contains(github.event.head_commit.message, 'CI_FORCE_BUILD'" || "contains(github.event.head_commit.message, 'Bump version to'" }} steps: - name: Install arduino-cli From 341cdcd6e3219b6654616ad2a37998edde3e57cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 11:46:16 +0200 Subject: [PATCH 318/455] [CI] Cahnge to single quotes --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bf100eee..a88c1c11 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest env: - run-build: ${{ (matrix.platform == "arduino:avr") || "contains(github.event.head_commit.message, 'CI_FORCE_BUILD'" || "contains(github.event.head_commit.message, 'Bump version to'" }} + run-build: ${{ (matrix.board == 'arduino:avr:uno') || "contains(github.event.head_commit.message, 'CI_FORCE_BUILD'" || "contains(github.event.head_commit.message, 'Bump version to'" }} steps: - name: Install arduino-cli From d7043befea627dfb19f14328f51c4428d6cefeea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 11:46:52 +0200 Subject: [PATCH 319/455] [CI] Removed redundant double quotes --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a88c1c11..1f9c004e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest env: - run-build: ${{ (matrix.board == 'arduino:avr:uno') || "contains(github.event.head_commit.message, 'CI_FORCE_BUILD'" || "contains(github.event.head_commit.message, 'Bump version to'" }} + run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_FORCE_BUILD' || contains(github.event.head_commit.message, 'Bump version to' }} steps: - name: Install arduino-cli From 7e999b96a610840e0f05b64c2e2158939cdc3c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 11:47:43 +0200 Subject: [PATCH 320/455] [CI] Fixed missing parentheses --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f9c004e..a58811a0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest env: - run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_FORCE_BUILD' || contains(github.event.head_commit.message, 'Bump version to' }} + run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_FORCE_BUILD') || contains(github.event.head_commit.message, 'Bump version to') }} steps: - name: Install arduino-cli From c29b4f90f39c4a9e06688d866c8ae76e8fc864e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 11:51:00 +0200 Subject: [PATCH 321/455] [CI] Added env specifier --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a58811a0..ce021fa4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,25 +24,25 @@ jobs: steps: - name: Install arduino-cli - if: ${{ run-build }} + if: ${{ env.run-build }} run: | mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - name: Install platform - if: ${{ run-build }} + if: ${{ env.run-build }} run: | arduino-cli core update-index arduino-cli core install ${{ matrix.platform }} echo "::set-env name=WARNINGS::all" - name: Checkout - if: ${{ run-build }} + if: ${{ env.run-build }} uses: actions/checkout@v2 - name: Build all examples - if: ${{ run-build }} + if: ${{ env.run-build }} run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch From 062cc75dc709047038f7b328f6964a123000461b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 11:55:06 +0200 Subject: [PATCH 322/455] [CI] Fixed expression evaluation --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce021fa4..7054e972 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,25 +24,25 @@ jobs: steps: - name: Install arduino-cli - if: ${{ env.run-build }} + if: ${{ env.run-build == 'true' }} run: | mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - name: Install platform - if: ${{ env.run-build }} + if: ${{ env.run-build == 'true' }} run: | arduino-cli core update-index arduino-cli core install ${{ matrix.platform }} echo "::set-env name=WARNINGS::all" - name: Checkout - if: ${{ env.run-build }} + if: ${{ env.run-build == 'true' }} uses: actions/checkout@v2 - name: Build all examples - if: ${{ env.run-build }} + if: ${{ env.run-build == 'true' }} run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch From 52c07230dfb37e98d2612a775aed608eb8374b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 12:05:36 +0200 Subject: [PATCH 323/455] [CI] Added Arduino Mega --- .github/workflows/main.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7054e972..5240eaf3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,16 +11,20 @@ jobs: Build: strategy: matrix: - platform: ["arduino:avr", "arduino:samd"] + platform: ['arduino:avr', 'arduino:samd'] include: - - platform: "arduino:avr" - board: "arduino:avr:uno" - - platform: "arduino:samd" - board: "arduino:samd:arduino_zero_native" + - platform: 'arduino:avr' + board: 'arduino:avr:uno' + - platform: 'arduino:avr' + board: 'arduino:avr:mega:cpu=atmega2560' + - platform: 'arduino:samd' + board: 'arduino:samd:arduino_zero_native' runs-on: ubuntu-latest + name: ${{ matrix.board }} env: run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_FORCE_BUILD') || contains(github.event.head_commit.message, 'Bump version to') }} + warnings: 'all' steps: - name: Install arduino-cli @@ -35,13 +39,12 @@ jobs: run: | arduino-cli core update-index arduino-cli core install ${{ matrix.platform }} - echo "::set-env name=WARNINGS::all" - - name: Checkout + - name: Checkout repository if: ${{ env.run-build == 'true' }} uses: actions/checkout@v2 - - name: Build all examples + - name: Build examples if: ${{ env.run-build == 'true' }} run: | for example in $(find $PWD/examples -name '*.ino' | sort); do @@ -52,7 +55,7 @@ jobs: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }} $example --warnings=$WARNINGS + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }} $example --warnings=${{ env.warnings }} if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From ed022580881ba95cc60e5cfb3d73c1c2e1e82d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 12:07:54 +0200 Subject: [PATCH 324/455] [CI] Swapped platform and board logic --- .github/workflows/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5240eaf3..5d7fd61c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,14 +11,14 @@ jobs: Build: strategy: matrix: - platform: ['arduino:avr', 'arduino:samd'] + board: ['arduino:avr:uno', 'arduino:avr:mega:cpu=atmega2560', 'arduino:samd:arduino_zero_native'] include: - - platform: 'arduino:avr' - board: 'arduino:avr:uno' - - platform: 'arduino:avr' - board: 'arduino:avr:mega:cpu=atmega2560' - - platform: 'arduino:samd' - board: 'arduino:samd:arduino_zero_native' + - board: 'arduino:avr:uno' + platform: 'arduino:avr' + - board: 'arduino:avr:mega:cpu=atmega2560' + platform: 'arduino:avr' + - board: 'arduino:samd:arduino_zero_native' + platform: 'arduino:samd' runs-on: ubuntu-latest name: ${{ matrix.board }} From e4e2de8c4938f5c0451afc222be3839b8ead0f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 12:25:57 +0200 Subject: [PATCH 325/455] [CI] Get platform from board name --- .github/workflows/main.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d7fd61c..10353e77 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,10 @@ jobs: Build: strategy: matrix: - board: ['arduino:avr:uno', 'arduino:avr:mega:cpu=atmega2560', 'arduino:samd:arduino_zero_native'] + board: + - arduino:avr:uno + - arduino:avr:mega:cpu=atmega2560 + - arduino:samd:arduino_zero_native include: - board: 'arduino:avr:uno' platform: 'arduino:avr' @@ -34,11 +37,18 @@ jobs: echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh + - name: Get platform name + uses: jungwinter/split@v1 + id: split + with: + msg: ${{ matrix.board }} + separator: ':' + - name: Install platform if: ${{ env.run-build == 'true' }} run: | arduino-cli core update-index - arduino-cli core install ${{ matrix.platform }} + arduino-cli core install ${{ format('{0}:{1}', steps.split.outputs_0, steps.split.outputs_1) }} - name: Checkout repository if: ${{ env.run-build == 'true' }} From af0e081328352e9bfeabbb13b68b9f6544c0bc6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 12:29:48 +0200 Subject: [PATCH 326/455] [CI] Changed input name --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 10353e77..3bd5c3d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,7 +42,7 @@ jobs: id: split with: msg: ${{ matrix.board }} - separator: ':' + seperator: ':' - name: Install platform if: ${{ env.run-build == 'true' }} From c60440a6fd2105de47591db2af324f50ef1ac3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 12:32:19 +0200 Subject: [PATCH 327/455] [CI] Fixed split output --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3bd5c3d9..fbd16398 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,7 @@ jobs: if: ${{ env.run-build == 'true' }} run: | arduino-cli core update-index - arduino-cli core install ${{ format('{0}:{1}', steps.split.outputs_0, steps.split.outputs_1) }} + arduino-cli core install ${{ format('{0}:{1}', steps.split.outputs._0, steps.split.outputs._1) }} - name: Checkout repository if: ${{ env.run-build == 'true' }} From 3b09f65bffbe47ba6266fe0bdc67b972750ebb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 12:59:30 +0200 Subject: [PATCH 328/455] [CI] Added platform-specific settings --- .github/workflows/main.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fbd16398..2bdbc13c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,14 +14,13 @@ jobs: board: - arduino:avr:uno - arduino:avr:mega:cpu=atmega2560 + - arduino:avr:leonardo + - esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K - arduino:samd:arduino_zero_native include: - - board: 'arduino:avr:uno' - platform: 'arduino:avr' - - board: 'arduino:avr:mega:cpu=atmega2560' - platform: 'arduino:avr' - - board: 'arduino:samd:arduino_zero_native' - platform: 'arduino:samd' + - board: esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K + index-url: http://arduino.esp8266.com/stable/package_esp8266com_index.json + skip-path: (HTTP|MQTT).*ino runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -44,10 +43,21 @@ jobs: msg: ${{ matrix.board }} seperator: ':' + - name: Prepare platform-specific settings + id: prep + env: + skip-path: '' + index-url: '' + run: | + if [[ ${{ contains(matrix.board, 'esp8266') }} =~ 'true' ]]; then + echo "::set-env name=skip-path::'HTTP|MQTT).*ino'" + echo "::set-env name=index-url::'--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json'" + fi + - name: Install platform if: ${{ env.run-build == 'true' }} run: | - arduino-cli core update-index + arduino-cli core update-index ${{ prep.env.index-url }} arduino-cli core install ${{ format('{0}:{1}', steps.split.outputs._0, steps.split.outputs._1) }} - name: Checkout repository @@ -59,9 +69,9 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "$SKIP_PAT" ] && [[ ${example} =~ $SKIP_PAT ]]; then + if [ ! -z "${{ prep.env.skip-path }}" ] && [[ ${example} =~ ${{ prep.env.skip-path }} ]]; then # skip sketch - echo -e "\n\033[1;33mSkipped ${example##*/} (matched with $SKIP_PAT)\033[0m"; + echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ prep.env.skip-path }})\033[0m"; else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; From dccb198338850a9f5940b3809b168ea21da7a999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:01:13 +0200 Subject: [PATCH 329/455] [CI] Fixed var name --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2bdbc13c..1545a12b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,6 @@ jobs: name: ${{ matrix.board }} env: run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_FORCE_BUILD') || contains(github.event.head_commit.message, 'Bump version to') }} - warnings: 'all' steps: - name: Install arduino-cli @@ -46,6 +45,7 @@ jobs: - name: Prepare platform-specific settings id: prep env: + warnings: 'all' skip-path: '' index-url: '' run: | @@ -57,7 +57,7 @@ jobs: - name: Install platform if: ${{ env.run-build == 'true' }} run: | - arduino-cli core update-index ${{ prep.env.index-url }} + arduino-cli core update-index ${{ steps.prep.env.index-url }} arduino-cli core install ${{ format('{0}:{1}', steps.split.outputs._0, steps.split.outputs._1) }} - name: Checkout repository @@ -69,13 +69,13 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ prep.env.skip-path }}" ] && [[ ${example} =~ ${{ prep.env.skip-path }} ]]; then + if [ ! -z "${{ steps.prep.env.skip-path }}" ] && [[ ${example} =~ ${{ steps.prep.env.skip-path }} ]]; then # skip sketch - echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ prep.env.skip-path }})\033[0m"; + echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.env.skip-path }})\033[0m"; else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }} $example --warnings=${{ env.warnings }} + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }} $example --warnings=${{ steps.prep.env.warnings }} if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From 12f09fd8fd59cca4996d9a8d56ffe69870873ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:03:28 +0200 Subject: [PATCH 330/455] [CI] Fixed bash quotes CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1545a12b..d0584f25 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -69,7 +69,7 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ steps.prep.env.skip-path }}" ] && [[ ${example} =~ ${{ steps.prep.env.skip-path }} ]]; then + if [ ! -z "${{ steps.prep.env.skip-path }}" ] && [[ ${example} =~ "${{ steps.prep.env.skip-path }}" ]]; then # skip sketch echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.env.skip-path }})\033[0m"; else From dbd23946a704cdae67631bbb05ddd55143b16506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:06:18 +0200 Subject: [PATCH 331/455] [CI] Fixed bash condition CI_FORCE_BUILD --- .github/workflows/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d0584f25..6609da79 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,10 +17,6 @@ jobs: - arduino:avr:leonardo - esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K - arduino:samd:arduino_zero_native - include: - - board: esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K - index-url: http://arduino.esp8266.com/stable/package_esp8266com_index.json - skip-path: (HTTP|MQTT).*ino runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -49,7 +45,7 @@ jobs: skip-path: '' index-url: '' run: | - if [[ ${{ contains(matrix.board, 'esp8266') }} =~ 'true' ]]; then + if [[ "${{ contains(matrix.board, 'esp8266') }}" =~ "true" ]]; then echo "::set-env name=skip-path::'HTTP|MQTT).*ino'" echo "::set-env name=index-url::'--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json'" fi From 790619d6308a651a34f9b79f683167825e4929f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:09:14 +0200 Subject: [PATCH 332/455] [CI] Bash fix CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6609da79..40576368 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,7 +45,7 @@ jobs: skip-path: '' index-url: '' run: | - if [[ "${{ contains(matrix.board, 'esp8266') }}" =~ "true" ]]; then + if [[ "${{ contains(matrix.board, 'esp8266') }}" == "true" ]]; then echo "::set-env name=skip-path::'HTTP|MQTT).*ino'" echo "::set-env name=index-url::'--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json'" fi From d8f60671056c12097ebf9fddf57f0fc26864d95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:13:58 +0200 Subject: [PATCH 333/455] [CI] Change platform env var handling CI_FORCE_BUILD --- .github/workflows/main.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 40576368..7b6d86de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,12 +42,15 @@ jobs: id: prep env: warnings: 'all' - skip-path: '' - index-url: '' run: | if [[ "${{ contains(matrix.board, 'esp8266') }}" == "true" ]]; then echo "::set-env name=skip-path::'HTTP|MQTT).*ino'" echo "::set-env name=index-url::'--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json'" + + else + echo "::set-env name=skip-path::''" + echo "::set-env name=index-url::''" + fi - name: Install platform From 2fc99be80081836052fa58a459ea5954944ca53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:16:31 +0200 Subject: [PATCH 334/455] [CI] Switched to outputs CI_FORCE_BUILD --- .github/workflows/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b6d86de..44fb175d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,19 +44,19 @@ jobs: warnings: 'all' run: | if [[ "${{ contains(matrix.board, 'esp8266') }}" == "true" ]]; then - echo "::set-env name=skip-path::'HTTP|MQTT).*ino'" - echo "::set-env name=index-url::'--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json'" + echo "::set-output name=skip-path::'HTTP|MQTT).*ino'" + echo "::set-output name=index-url::'--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json'" else - echo "::set-env name=skip-path::''" - echo "::set-env name=index-url::''" + echo "::set-output name=skip-path::''" + echo "::set-output name=index-url::''" fi - name: Install platform if: ${{ env.run-build == 'true' }} run: | - arduino-cli core update-index ${{ steps.prep.env.index-url }} + arduino-cli core update-index ${{ steps.prep.outputs.index-url }} arduino-cli core install ${{ format('{0}:{1}', steps.split.outputs._0, steps.split.outputs._1) }} - name: Checkout repository @@ -68,9 +68,9 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ steps.prep.env.skip-path }}" ] && [[ ${example} =~ "${{ steps.prep.env.skip-path }}" ]]; then + if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ "${{ steps.prep.outputs.skip-path }}" ]]; then # skip sketch - echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.env.skip-path }})\033[0m"; + echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; From 2397bd45df52641d9ec26a04afaf73abd297c363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:27:53 +0200 Subject: [PATCH 335/455] [CI] Fix index URL CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44fb175d..cc477bb3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,7 +56,7 @@ jobs: - name: Install platform if: ${{ env.run-build == 'true' }} run: | - arduino-cli core update-index ${{ steps.prep.outputs.index-url }} + arduino-cli core update-index ${{ format('{0}', steps.prep.outputs.index-url) }} arduino-cli core install ${{ format('{0}:{1}', steps.split.outputs._0, steps.split.outputs._1) }} - name: Checkout repository From 9e3c12c4b0f94694ac604bba47eb23cbc0f844d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:31:14 +0200 Subject: [PATCH 336/455] [CI[ Attempt to remove quotes CI_FORCE_BUILD --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cc477bb3..b1ad6ba3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,12 +44,12 @@ jobs: warnings: 'all' run: | if [[ "${{ contains(matrix.board, 'esp8266') }}" == "true" ]]; then - echo "::set-output name=skip-path::'HTTP|MQTT).*ino'" - echo "::set-output name=index-url::'--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json'" + echo "::set-output name=skip-path::HTTP|MQTT).*ino" + echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" else - echo "::set-output name=skip-path::''" - echo "::set-output name=index-url::''" + echo "::set-output name=skip-path::" + echo "::set-output name=index-url::" fi From 6b0b073e02602c72bd3888a856b2b93092afa3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:33:13 +0200 Subject: [PATCH 337/455] [CI] Added missing index URL CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b1ad6ba3..6c1f8a31 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: if: ${{ env.run-build == 'true' }} run: | arduino-cli core update-index ${{ format('{0}', steps.prep.outputs.index-url) }} - arduino-cli core install ${{ format('{0}:{1}', steps.split.outputs._0, steps.split.outputs._1) }} + arduino-cli core install ${{ format('{0}:{1} {2}', steps.split.outputs._0, steps.split.outputs._1, steps.prep.outputs.index-url) }} - name: Checkout repository if: ${{ env.run-build == 'true' }} From 4c219b5fab463d2911f3b2d1ac6146b60372baec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:40:19 +0200 Subject: [PATCH 338/455] [CI] Added more boards CI_FORCE_BUILD --- .github/workflows/main.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c1f8a31..aee2daec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,10 @@ jobs: - arduino:avr:leonardo - esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K - arduino:samd:arduino_zero_native + - esp32:esp32:esp32 + - STM32:stm32:GenF3:pnum=BLACKPILL_F303CC + - arduino:samd:arduino_zero_native + - arduino:sam:arduino_due_x runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -44,12 +48,14 @@ jobs: warnings: 'all' run: | if [[ "${{ contains(matrix.board, 'esp8266') }}" == "true" ]]; then - echo "::set-output name=skip-path::HTTP|MQTT).*ino" echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" - - else - echo "::set-output name=skip-path::" - echo "::set-output name=index-url::" + echo "::set-output name=skip-path::(HTTP|MQTT).*ino" + + elif [[ "${{ contains(matrix.board, 'esp32') }}" == "true" ]]; then + echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" + + elif [[ "${{ contains(matrix.board, 'esp32') }}" == "true" ]]; then + echo "::set-output name=index-url::--additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" fi From 8a0cd057de06591380c64ef45cd86e78365c389e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:41:43 +0200 Subject: [PATCH 339/455] [CI] Fixed check for STM32 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aee2daec..8e178964 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,7 +54,7 @@ jobs: elif [[ "${{ contains(matrix.board, 'esp32') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" - elif [[ "${{ contains(matrix.board, 'esp32') }}" == "true" ]]; then + elif [[ "${{ contains(matrix.board, 'STM32') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" fi From 840f26bfe82fad77cbe682b8faa9d9284be6f463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:43:22 +0200 Subject: [PATCH 340/455] [CI] Fixed run-build check CI_FORCE_BUILD --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e178964..646836a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,7 @@ jobs: curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - name: Get platform name + if: ${{ env.run-build == 'true' }} uses: jungwinter/split@v1 id: split with: @@ -43,6 +44,7 @@ jobs: seperator: ':' - name: Prepare platform-specific settings + if: ${{ env.run-build == 'true' }} id: prep env: warnings: 'all' From d8f677829de07aac35489d7acee69170af649237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:47:55 +0200 Subject: [PATCH 341/455] [CI] Install pyserial for ESP32 CI_FORCE_BUILD --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 646836a8..31eb94e8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,6 +54,7 @@ jobs: echo "::set-output name=skip-path::(HTTP|MQTT).*ino" elif [[ "${{ contains(matrix.board, 'esp32') }}" == "true" ]]; then + python -m pip install pyserial echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" elif [[ "${{ contains(matrix.board, 'STM32') }}" == "true" ]]; then From 12baadb385b94f23c765628d23c988ba3f4ee5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 13:54:58 +0200 Subject: [PATCH 342/455] [CI] Added nRF52 CI_FORCE_BUILD --- .github/workflows/main.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 31eb94e8..59a2272d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,6 +21,7 @@ jobs: - STM32:stm32:GenF3:pnum=BLACKPILL_F303CC - arduino:samd:arduino_zero_native - arduino:sam:arduino_due_x + - adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0 runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -49,17 +50,23 @@ jobs: env: warnings: 'all' run: | - if [[ "${{ contains(matrix.board, 'esp8266') }}" == "true" ]]; then + if [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" echo "::set-output name=skip-path::(HTTP|MQTT).*ino" - elif [[ "${{ contains(matrix.board, 'esp32') }}" == "true" ]]; then + elif [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then python -m pip install pyserial echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" - elif [[ "${{ contains(matrix.board, 'STM32') }}" == "true" ]]; then + elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" + elif [[ "${{ contains(matrix.board, 'adafruit:nrf52') }}" == "true" ]]; then + sudo apt-get update + sudo apt-get install -y python3 python3-pip python3-setuptools + pip3 install --user adafruit-nrfutil + echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" + fi - name: Install platform @@ -77,7 +84,7 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ "${{ steps.prep.outputs.skip-path }}" ]]; then + if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ '${{ steps.prep.outputs.skip-path }}' ]]; then # skip sketch echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; else @@ -98,8 +105,8 @@ jobs: steps: - name: Install Doxygen run: | - sudo apt-get update; - sudo apt-get install -y doxygen; + sudo apt-get update + sudo apt-get install -y doxygen - uses: actions/checkout@v2 From ce5ed55abc3489fa18966740636352819002f063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 14:01:06 +0200 Subject: [PATCH 343/455] [CI] Added nrfutil to path CI_FORCE_BUILD --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 59a2272d..92b7b3a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,6 +65,7 @@ jobs: sudo apt-get update sudo apt-get install -y python3 python3-pip python3-setuptools pip3 install --user adafruit-nrfutil + echo "::add-path::~/.local/bin/adafruit-nrfutil" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" fi From e8964f6e124e93f07fb3e98d0cea33a833953e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 14:06:44 +0200 Subject: [PATCH 344/455] [CI] pip install wheel CI_FORCE_BUILD --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 92b7b3a7..e6466836 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,6 +64,7 @@ jobs: elif [[ "${{ contains(matrix.board, 'adafruit:nrf52') }}" == "true" ]]; then sudo apt-get update sudo apt-get install -y python3 python3-pip python3-setuptools + pip3 install wheel pip3 install --user adafruit-nrfutil echo "::add-path::~/.local/bin/adafruit-nrfutil" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" From 06b2f5c4191479e168e0977cc6cdc5ffe30cdaa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 14:32:07 +0200 Subject: [PATCH 345/455] [CI] Moved nrfutils path CI_FORCE_BUILD --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e6466836..5e07762b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,7 +66,6 @@ jobs: sudo apt-get install -y python3 python3-pip python3-setuptools pip3 install wheel pip3 install --user adafruit-nrfutil - echo "::add-path::~/.local/bin/adafruit-nrfutil" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" fi @@ -84,6 +83,10 @@ jobs: - name: Build examples if: ${{ env.run-build == 'true' }} run: | + if [[ "${{ contains(matrix.board, 'adafruit:nrf52') }}" == "true" ]]; then + echo "::add-path::~/.local/bin/adafruit-nrfutil" + fi + for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ '${{ steps.prep.outputs.skip-path }}' ]]; then From 0a725df3fc4877afee65e235fde516046957f2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 14:39:02 +0200 Subject: [PATCH 346/455] [CI] Another attempt to fix nrfutil CI_FORCE_BUILD --- .github/workflows/main.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e07762b..bf4cd6c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,6 +66,7 @@ jobs: sudo apt-get install -y python3 python3-pip python3-setuptools pip3 install wheel pip3 install --user adafruit-nrfutil + echo "::add-path::~/.local/bin" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" fi @@ -83,10 +84,6 @@ jobs: - name: Build examples if: ${{ env.run-build == 'true' }} run: | - if [[ "${{ contains(matrix.board, 'adafruit:nrf52') }}" == "true" ]]; then - echo "::add-path::~/.local/bin/adafruit-nrfutil" - fi - for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ '${{ steps.prep.outputs.skip-path }}' ]]; then From 694e398d37b641f7d76c20d7951111c44c3a4291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 14:47:09 +0200 Subject: [PATCH 347/455] [CI] Dropped nrf52 support for now CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bf4cd6c5..891873ef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: - STM32:stm32:GenF3:pnum=BLACKPILL_F303CC - arduino:samd:arduino_zero_native - arduino:sam:arduino_due_x - - adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0 + # - adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0 runs-on: ubuntu-latest name: ${{ matrix.board }} From 66ee13adea155fdcbf7022ea44db7a4dc37a71ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 15:03:37 +0200 Subject: [PATCH 348/455] [CI] Fix bash quotes CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 891873ef..e349c1ce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,7 +86,7 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ '${{ steps.prep.outputs.skip-path }}' ]]; then + if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-path }} ]]; then # skip sketch echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; else From a90a6e96ae1e83a149fe5a09b8e0fa659cb42f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 15:06:17 +0200 Subject: [PATCH 349/455] [CI] More bash fixes CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e349c1ce..5c72f9f5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,7 +86,7 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-path }} ]]; then + if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ '${example}' =~ '${{ steps.prep.outputs.skip-path }}' ]]; then # skip sketch echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; else From 5690cea2193c1758b3e2929639ab8e35207dacdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 15:19:16 +0200 Subject: [PATCH 350/455] [CI] Try to fix skip path with format CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c72f9f5..0d29b2db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,7 +86,7 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ '${example}' =~ '${{ steps.prep.outputs.skip-path }}' ]]; then + if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ ${{ format("{0}", steps.prep.outputs.skip-path) }} ]]; then # skip sketch echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; else From 6d3759412b19d8d3f03973dfe5e6ed1951dd0b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 15:20:30 +0200 Subject: [PATCH 351/455] [CI] Added quotes CI_FORCE_BUILD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0d29b2db..88e5f937 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,7 +86,7 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ ${{ format("{0}", steps.prep.outputs.skip-path) }} ]]; then + if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ ${{ format('"{0}"', steps.prep.outputs.skip-path) }} ]]; then # skip sketch echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; else From 329ff2f4215e8602e3923a1205700d2530d082aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 15:46:07 +0200 Subject: [PATCH 352/455] [CI] skip fix CI_FORCE_BUILD --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 88e5f937..6275a5c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,9 +50,10 @@ jobs: env: warnings: 'all' run: | + echo "::set-output name=skip-path::''" if [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" - echo "::set-output name=skip-path::(HTTP|MQTT).*ino" + echo "::set-output name=skip-path::'(HTTP|MQTT).*ino'" elif [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then python -m pip install pyserial @@ -86,7 +87,7 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z "${{ steps.prep.outputs.skip-path }}" ] && [[ ${example} =~ ${{ format('"{0}"', steps.prep.outputs.skip-path) }} ]]; then + if [ ! -z ${{ steps.prep.outputs.skip-path }} ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-path }} ]]; then # skip sketch echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; else From 8568e9949d3513b97389c731ba06d8ee9bcc955e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 15:57:16 +0200 Subject: [PATCH 353/455] [CI] skip fix CI_FORCE_BUILD --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6275a5c0..91f25e57 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,7 +53,7 @@ jobs: echo "::set-output name=skip-path::''" if [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" - echo "::set-output name=skip-path::'(HTTP|MQTT).*ino'" + echo "::set-output name=skip-path::(HTTP|MQTT).*ino" elif [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then python -m pip install pyserial @@ -87,7 +87,7 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z ${{ steps.prep.outputs.skip-path }} ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-path }} ]]; then + if [ ! -z '${{ steps.prep.outputs.skip-path }}' ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-path }} ]]; then # skip sketch echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; else From 8f1303c0611306cd4df3742d075d0c6be9d499e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 16:11:03 +0200 Subject: [PATCH 354/455] [CI] Added remaining platforms CI_FORCE_BUILD --- .github/workflows/main.yml | 39 +++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91f25e57..927d6b58 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,13 @@ jobs: - arduino:samd:arduino_zero_native - arduino:sam:arduino_due_x # - adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0 + - Intel:arc32:arduino_101 + - arduino:megaavr:uno2018:mode=on + - SparkFun:apollo3:amap3redboard + - arduino:mbed:nano33ble + - stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz + - adafruit:samd:adafruit_feather_m0:usbstack=arduino,debug=off + - arduino-beta:mbed:envie_m4 runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -47,13 +54,15 @@ jobs: - name: Prepare platform-specific settings if: ${{ env.run-build == 'true' }} id: prep - env: - warnings: 'all' run: | - echo "::set-output name=skip-path::''" + # common settings - skip nothing, all warnings + echo "::set-output name=skip-pattern::''" + echo "::set-output name=warnings::'all'" + + # platform-dependent settings - board index URLs, skip paterns etc. if [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" - echo "::set-output name=skip-path::(HTTP|MQTT).*ino" + echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" elif [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then python -m pip install pyserial @@ -70,6 +79,22 @@ jobs: echo "::add-path::~/.local/bin" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" + elif [[ "${{ contains(matrix.board, 'SparkFun:apollo3') }}" == "true" ]]; then + echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" + echo "::set-output name=warnings::'none'" + + elif [[ "${{ contains(matrix.board, 'arduino:mbed') }}" == "true" ]]; then + echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" + + elif [[ "${{ contains(matrix.board, 'stm32duino:STM32F1') }}" == "true" ]]; then + echo "::set-output name=index-url::--additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json" + + elif [[ "${{ contains(matrix.board, 'adafruit:samd') }}" == "true" ]]; then + echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" + + elif [[ "${{ contains(matrix.board, 'arduino-beta:mbed') }}" == "true" ]]; then + echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" + fi - name: Install platform @@ -87,13 +112,13 @@ jobs: run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch - if [ ! -z '${{ steps.prep.outputs.skip-path }}' ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-path }} ]]; then + if [ ! -z '${{ steps.prep.outputs.skip-pattern }}' ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-pattern }} ]]; then # skip sketch - echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-path }})\033[0m"; + echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-pattern }})\033[0m"; else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }} $example --warnings=${{ steps.prep.env.warnings }} + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }} $example --warnings=${{ steps.prep.outputs.warnings }} if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From ee4b20d661e09b9b67d72a84878e55b09769b1f4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 22 Aug 2020 17:51:02 +0200 Subject: [PATCH 355/455] [CI] Added option to build single platform arduino:avr:mega --- .github/workflows/main.yml | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 927d6b58..2758735b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: Build: strategy: matrix: - board: + board: - arduino:avr:uno - arduino:avr:mega:cpu=atmega2560 - arduino:avr:leonardo @@ -29,12 +29,12 @@ jobs: - stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz - adafruit:samd:adafruit_feather_m0:usbstack=arduino,debug=off - arduino-beta:mbed:envie_m4 - + runs-on: ubuntu-latest name: ${{ matrix.board }} env: - run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_FORCE_BUILD') || contains(github.event.head_commit.message, 'Bump version to') }} - + run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, matrix.board) }} + steps: - name: Install arduino-cli if: ${{ env.run-build == 'true' }} @@ -42,7 +42,7 @@ jobs: mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - + - name: Get platform name if: ${{ env.run-build == 'true' }} uses: jungwinter/split@v1 @@ -50,7 +50,7 @@ jobs: with: msg: ${{ matrix.board }} seperator: ':' - + - name: Prepare platform-specific settings if: ${{ env.run-build == 'true' }} id: prep @@ -58,19 +58,19 @@ jobs: # common settings - skip nothing, all warnings echo "::set-output name=skip-pattern::''" echo "::set-output name=warnings::'all'" - + # platform-dependent settings - board index URLs, skip paterns etc. if [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" - + elif [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then python -m pip install pyserial echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" - + elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" - + elif [[ "${{ contains(matrix.board, 'adafruit:nrf52') }}" == "true" ]]; then sudo apt-get update sudo apt-get install -y python3 python3-pip python3-setuptools @@ -78,35 +78,35 @@ jobs: pip3 install --user adafruit-nrfutil echo "::add-path::~/.local/bin" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" - + elif [[ "${{ contains(matrix.board, 'SparkFun:apollo3') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" echo "::set-output name=warnings::'none'" - + elif [[ "${{ contains(matrix.board, 'arduino:mbed') }}" == "true" ]]; then echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" - + elif [[ "${{ contains(matrix.board, 'stm32duino:STM32F1') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json" - + elif [[ "${{ contains(matrix.board, 'adafruit:samd') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" - + elif [[ "${{ contains(matrix.board, 'arduino-beta:mbed') }}" == "true" ]]; then echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" - + fi - + - name: Install platform if: ${{ env.run-build == 'true' }} run: | arduino-cli core update-index ${{ format('{0}', steps.prep.outputs.index-url) }} arduino-cli core install ${{ format('{0}:{1} {2}', steps.split.outputs._0, steps.split.outputs._1, steps.prep.outputs.index-url) }} - + - name: Checkout repository if: ${{ env.run-build == 'true' }} uses: actions/checkout@v2 - + - name: Build examples if: ${{ env.run-build == 'true' }} run: | @@ -127,7 +127,7 @@ jobs: fi fi done - + Doxygen: runs-on: ubuntu-latest steps: @@ -135,12 +135,12 @@ jobs: run: | sudo apt-get update sudo apt-get install -y doxygen - + - uses: actions/checkout@v2 - + - name: Generate docs run: doxygen Doxyfile - + - uses: JamesIves/github-pages-deploy-action@releases/v3 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From caf8787ea21f5edb49204eef8dc284eae0e9c483 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 22 Aug 2020 17:52:36 +0200 Subject: [PATCH 356/455] [CI] Added missing format arduino:avr:mega --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2758735b..7bc566b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest name: ${{ matrix.board }} env: - run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, matrix.board) }} + run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format({0}, matrix.board)) }} steps: - name: Install arduino-cli From b158c1c72fcd3adf29480445533d23792842e1dc Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 22 Aug 2020 17:54:00 +0200 Subject: [PATCH 357/455] [CI] Added missing quotes --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7bc566b8..3cd03626 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest name: ${{ matrix.board }} env: - run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format({0}, matrix.board)) }} + run-build: ${{ (matrix.board == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format('{0}', matrix.board)) }} steps: - name: Install arduino-cli From c1c42cf31bdf07b030121e513e3f21f556947e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 18:09:06 +0200 Subject: [PATCH 358/455] [CI] Move board options to prep step --- .github/workflows/main.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3cd03626..0b7de029 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - arduino:avr:uno - arduino:avr:mega:cpu=atmega2560 - arduino:avr:leonardo - - esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K + - esp8266:esp8266:generic - arduino:samd:arduino_zero_native - esp32:esp32:esp32 - STM32:stm32:GenF3:pnum=BLACKPILL_F303CC @@ -38,7 +38,8 @@ jobs: steps: - name: Install arduino-cli if: ${{ env.run-build == 'true' }} - run: | + run: + | mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh @@ -54,13 +55,16 @@ jobs: - name: Prepare platform-specific settings if: ${{ env.run-build == 'true' }} id: prep - run: | - # common settings - skip nothing, all warnings + run: + | + # common settings - no extra options, skip nothing, all warnings + echo "::set-output name=options::" echo "::set-output name=skip-pattern::''" echo "::set-output name=warnings::'all'" # platform-dependent settings - board index URLs, skip paterns etc. if [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then + echo "::set-output name=options:::xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" @@ -99,7 +103,8 @@ jobs: - name: Install platform if: ${{ env.run-build == 'true' }} - run: | + run: + | arduino-cli core update-index ${{ format('{0}', steps.prep.outputs.index-url) }} arduino-cli core install ${{ format('{0}:{1} {2}', steps.split.outputs._0, steps.split.outputs._1, steps.prep.outputs.index-url) }} @@ -109,7 +114,8 @@ jobs: - name: Build examples if: ${{ env.run-build == 'true' }} - run: | + run: + | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch if [ ! -z '${{ steps.prep.outputs.skip-pattern }}' ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-pattern }} ]]; then @@ -118,7 +124,7 @@ jobs: else # build sketch echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }} $example --warnings=${{ steps.prep.outputs.warnings }} + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }}${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} if [ $? -ne 0 ]; then echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; exit 1; From 52c5275a9fc5197b687628182e0809cbc448aa41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 22 Aug 2020 18:15:45 +0200 Subject: [PATCH 359/455] [CI] Moved options arduino:avr:mega --- .github/workflows/main.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0b7de029..fe8d77bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,21 +13,21 @@ jobs: matrix: board: - arduino:avr:uno - - arduino:avr:mega:cpu=atmega2560 + - arduino:avr:mega - arduino:avr:leonardo - esp8266:esp8266:generic - arduino:samd:arduino_zero_native - esp32:esp32:esp32 - - STM32:stm32:GenF3:pnum=BLACKPILL_F303CC + - STM32:stm32:GenF3 - arduino:samd:arduino_zero_native - arduino:sam:arduino_due_x - # - adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0 + # - adafruit:nrf52:feather52832 - Intel:arc32:arduino_101 - - arduino:megaavr:uno2018:mode=on + - arduino:megaavr:uno2018 - SparkFun:apollo3:amap3redboard - arduino:mbed:nano33ble - - stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz - - adafruit:samd:adafruit_feather_m0:usbstack=arduino,debug=off + - stm32duino:STM32F1:mapleMini + - adafruit:samd:adafruit_feather_m0 - arduino-beta:mbed:envie_m4 runs-on: ubuntu-latest @@ -62,8 +62,11 @@ jobs: echo "::set-output name=skip-pattern::''" echo "::set-output name=warnings::'all'" - # platform-dependent settings - board index URLs, skip paterns etc. - if [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then + # platform-dependent settings - extra board options, board index URLs, skip patterns etc. + if [[ "${{ contains(matrix.board, 'arduino:avr:mega') }}" == "true" ]]; then + echo "::set-output name=options:::cpu=atmega2560" + + elif [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then echo "::set-output name=options:::xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" @@ -73,6 +76,7 @@ jobs: echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then + echo "::set-output name=options:::pnum=BLACKPILL_F303CC" echo "::set-output name=index-url::--additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" elif [[ "${{ contains(matrix.board, 'adafruit:nrf52') }}" == "true" ]]; then @@ -81,7 +85,11 @@ jobs: pip3 install wheel pip3 install --user adafruit-nrfutil echo "::add-path::~/.local/bin" + echo "::set-output name=options:::softdevice=s132v6,debug=l0" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" + + elif [[ "${{ contains(matrix.board, 'arduino:megaavr:uno2018') }}" == "true" ]]; then + echo "::set-output name=options:::mode=on" elif [[ "${{ contains(matrix.board, 'SparkFun:apollo3') }}" == "true" ]]; then echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" @@ -91,9 +99,11 @@ jobs: echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" elif [[ "${{ contains(matrix.board, 'stm32duino:STM32F1') }}" == "true" ]]; then + echo "::set-output name=options:::bootloader_version=original,cpu_speed=speed_72mhz" echo "::set-output name=index-url::--additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json" elif [[ "${{ contains(matrix.board, 'adafruit:samd') }}" == "true" ]]; then + echo "::set-output name=options:::usbstack=arduino,debug=off" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" elif [[ "${{ contains(matrix.board, 'arduino-beta:mbed') }}" == "true" ]]; then From 4735e41109fa83a21391dc00d58d5a121141a977 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 22 Aug 2020 18:23:15 +0200 Subject: [PATCH 360/455] [CI] Use absolute path (adafruit:nrf52:feather52832) --- .github/workflows/main.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe8d77bf..7a68eb39 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: - STM32:stm32:GenF3 - arduino:samd:arduino_zero_native - arduino:sam:arduino_due_x - # - adafruit:nrf52:feather52832 + - adafruit:nrf52:feather52832 - Intel:arc32:arduino_101 - arduino:megaavr:uno2018 - SparkFun:apollo3:amap3redboard @@ -38,7 +38,7 @@ jobs: steps: - name: Install arduino-cli if: ${{ env.run-build == 'true' }} - run: + run: | mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" @@ -55,7 +55,7 @@ jobs: - name: Prepare platform-specific settings if: ${{ env.run-build == 'true' }} id: prep - run: + run: | # common settings - no extra options, skip nothing, all warnings echo "::set-output name=options::" @@ -65,7 +65,7 @@ jobs: # platform-dependent settings - extra board options, board index URLs, skip patterns etc. if [[ "${{ contains(matrix.board, 'arduino:avr:mega') }}" == "true" ]]; then echo "::set-output name=options:::cpu=atmega2560" - + elif [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then echo "::set-output name=options:::xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" @@ -84,10 +84,10 @@ jobs: sudo apt-get install -y python3 python3-pip python3-setuptools pip3 install wheel pip3 install --user adafruit-nrfutil - echo "::add-path::~/.local/bin" + echo "::add-path::/home/runner/.local/bin" echo "::set-output name=options:::softdevice=s132v6,debug=l0" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" - + elif [[ "${{ contains(matrix.board, 'arduino:megaavr:uno2018') }}" == "true" ]]; then echo "::set-output name=options:::mode=on" @@ -113,7 +113,7 @@ jobs: - name: Install platform if: ${{ env.run-build == 'true' }} - run: + run: | arduino-cli core update-index ${{ format('{0}', steps.prep.outputs.index-url) }} arduino-cli core install ${{ format('{0}:{1} {2}', steps.split.outputs._0, steps.split.outputs._1, steps.prep.outputs.index-url) }} @@ -124,7 +124,7 @@ jobs: - name: Build examples if: ${{ env.run-build == 'true' }} - run: + run: | for example in $(find $PWD/examples -name '*.ino' | sort); do # check whether to skip this sketch From 5cba6a2c179c07d26afc47d8a2f523be743a056e Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 23 Aug 2020 17:05:42 +0200 Subject: [PATCH 361/455] Bump version to 4.0.3 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index ab2a95f3..9b3deb25 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=4.0.2 +version=4.0.3 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 3f49008d..f3962fce 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -368,7 +368,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) #define RADIOLIB_VERSION_MINOR (0x00) -#define RADIOLIB_VERSION_PATCH (0x02) +#define RADIOLIB_VERSION_PATCH (0x03) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From bdb033c3ec8ca12cbbf74a530a573b6250ff2fc7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 23 Aug 2020 18:43:10 +0200 Subject: [PATCH 362/455] [CI] Cleaned up CI file --- .github/workflows/main.yml | 82 ++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a68eb39..c8604e99 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,27 +8,27 @@ on: jobs: - Build: + build: strategy: matrix: board: - arduino:avr:uno - arduino:avr:mega - arduino:avr:leonardo - - esp8266:esp8266:generic - - arduino:samd:arduino_zero_native - - esp32:esp32:esp32 - - STM32:stm32:GenF3 - - arduino:samd:arduino_zero_native - - arduino:sam:arduino_due_x - - adafruit:nrf52:feather52832 - - Intel:arc32:arduino_101 - - arduino:megaavr:uno2018 - - SparkFun:apollo3:amap3redboard - arduino:mbed:nano33ble - - stm32duino:STM32F1:mapleMini - - adafruit:samd:adafruit_feather_m0 - arduino-beta:mbed:envie_m4 + - arduino:megaavr:uno2018 + - arduino:sam:arduino_due_x + - arduino:samd:arduino_zero_native + - arduino:samd:arduino_zero_native + - adafruit:samd:adafruit_feather_m0 + - adafruit:nrf52:feather52832 + - esp32:esp32:esp32 + - esp8266:esp8266:generic + - Intel:arc32:arduino_101 + - SparkFun:apollo3:amap3redboard + - STM32:stm32:GenF3 + - stm32duino:STM32F1:mapleMini runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -64,22 +64,28 @@ jobs: # platform-dependent settings - extra board options, board index URLs, skip patterns etc. if [[ "${{ contains(matrix.board, 'arduino:avr:mega') }}" == "true" ]]; then + # Arduino Mega echo "::set-output name=options:::cpu=atmega2560" - elif [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then - echo "::set-output name=options:::xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" - echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" + elif [[ "${{ contains(matrix.board, 'arduino:mbed') }}" == "true" ]]; then + # Arduino Nano 33 BLE echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" - elif [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then - python -m pip install pyserial - echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" + elif [[ "${{ contains(matrix.board, 'arduino-beta:mbed') }}" == "true" ]]; then + # Arduino Portenta H7 + echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" - elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then - echo "::set-output name=options:::pnum=BLACKPILL_F303CC" - echo "::set-output name=index-url::--additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" + elif [[ "${{ contains(matrix.board, 'arduino:megaavr:uno2018') }}" == "true" ]]; then + # Arduino Uno WiFi + echo "::set-output name=options:::mode=on" + + elif [[ "${{ contains(matrix.board, 'adafruit:samd') }}" == "true" ]]; then + # Adafruit SAMD + echo "::set-output name=options:::usbstack=arduino,debug=off" + echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" elif [[ "${{ contains(matrix.board, 'adafruit:nrf52') }}" == "true" ]]; then + # Adafruit Feather nRF52 sudo apt-get update sudo apt-get install -y python3 python3-pip python3-setuptools pip3 install wheel @@ -88,27 +94,32 @@ jobs: echo "::set-output name=options:::softdevice=s132v6,debug=l0" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" - elif [[ "${{ contains(matrix.board, 'arduino:megaavr:uno2018') }}" == "true" ]]; then - echo "::set-output name=options:::mode=on" + elif [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then + # ESP32 + python -m pip install pyserial + echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" + + elif [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then + # ESP8266 + echo "::set-output name=options:::xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" + echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" + echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" elif [[ "${{ contains(matrix.board, 'SparkFun:apollo3') }}" == "true" ]]; then + # SparkFun Apollo echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" echo "::set-output name=warnings::'none'" - elif [[ "${{ contains(matrix.board, 'arduino:mbed') }}" == "true" ]]; then - echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" + elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then + # STM32 (official core) + echo "::set-output name=options:::pnum=BLACKPILL_F303CC" + echo "::set-output name=index-url::--additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json" elif [[ "${{ contains(matrix.board, 'stm32duino:STM32F1') }}" == "true" ]]; then + # STM32 (unofficial core) echo "::set-output name=options:::bootloader_version=original,cpu_speed=speed_72mhz" echo "::set-output name=index-url::--additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json" - elif [[ "${{ contains(matrix.board, 'adafruit:samd') }}" == "true" ]]; then - echo "::set-output name=options:::usbstack=arduino,debug=off" - echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" - - elif [[ "${{ contains(matrix.board, 'arduino-beta:mbed') }}" == "true" ]]; then - echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" - fi - name: Install platform @@ -144,7 +155,7 @@ jobs: fi done - Doxygen: + doxygen: runs-on: ubuntu-latest steps: - name: Install Doxygen @@ -157,7 +168,8 @@ jobs: - name: Generate docs run: doxygen Doxyfile - - uses: JamesIves/github-pages-deploy-action@releases/v3 + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@releases/v3 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH: gh-pages From 3252e4344ad36bbc321acf3318cf6110be5b9a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 1 Sep 2020 09:14:27 +0200 Subject: [PATCH 363/455] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..456e8704 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,62 @@ +name: "CodeQL" + +on: + push: + branches: [master] + pull_request: + # The branches below must be a subset of the branches above + branches: [master] + schedule: + - cron: '0 8 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + # Override automatic language detection by changing the below list + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] + language: ['cpp'] + # Learn more... + # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From 1ee1089006896651c650173f254a3b259c2c4852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 1 Sep 2020 09:36:57 +0200 Subject: [PATCH 364/455] [QL] Set up Arduino build --- .github/workflows/codeql-analysis.yml | 48 ++++++++++++++------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 456e8704..38bb3fbf 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -4,10 +4,7 @@ on: push: branches: [master] pull_request: - # The branches below must be a subset of the branches above branches: [master] - schedule: - - cron: '0 8 * * 0' jobs: analyze: @@ -17,11 +14,7 @@ jobs: strategy: fail-fast: false matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] language: ['cpp'] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - name: Checkout repository @@ -41,22 +34,31 @@ jobs: uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release + + - name: Setup arduino-cli + run: + | + mkdir -p ~/.local/bin + echo "::add-path::~/.local/bin" + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh + arduino-cli core update-index + arduino-cli core install arduino:avr + + - name: Build examples + if: ${{ env.run-build == 'true' }} + run: + | + for example in $(find $PWD/examples -name '*.ino' | sort); do + # build sketch + echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $example --warnings=all + if [ $? -ne 0 ]; then + echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; + exit 1; + else + echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n"; + fi + done - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From 73d1d23314acc3574744dbbbdae8129beba71750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 1 Sep 2020 09:41:09 +0200 Subject: [PATCH 365/455] [QL] Fix arduino-cli install --- .github/workflows/codeql-analysis.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 38bb3fbf..8f61f694 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,17 +35,22 @@ jobs: with: languages: ${{ matrix.language }} - - name: Setup arduino-cli + - name: Install arduino-cli run: | mkdir -p ~/.local/bin echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh + + + + - name: Install platform + run: + | arduino-cli core update-index arduino-cli core install arduino:avr - name: Build examples - if: ${{ env.run-build == 'true' }} run: | for example in $(find $PWD/examples -name '*.ino' | sort); do From 7d43c54d949575c904633e333d5b25439332a3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 1 Sep 2020 09:58:52 +0200 Subject: [PATCH 366/455] [QL] Compile just one example --- .github/workflows/codeql-analysis.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8f61f694..fb8e9a68 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -50,20 +50,9 @@ jobs: arduino-cli core update-index arduino-cli core install arduino:avr - - name: Build examples + - name: Build example run: - | - for example in $(find $PWD/examples -name '*.ino' | sort); do - # build sketch - echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $example --warnings=all - if [ $? -ne 0 ]; then - echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; - exit 1; - else - echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n"; - fi - done + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $PWD/examples/SX126x_Transmit/SX126x_Transmit.ino --warnings=all - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From 0bb314063fdadc41fb2f61c195a4cd5d42700674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 1 Sep 2020 10:06:04 +0200 Subject: [PATCH 367/455] \ --- .github/workflows/codeql-analysis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fb8e9a68..ed40f648 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,8 +42,6 @@ jobs: echo "::add-path::~/.local/bin" curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - - - name: Install platform run: | @@ -52,7 +50,7 @@ jobs: - name: Build example run: - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $PWD/examples/SX126x_Transmit/SX126x_Transmit.ino --warnings=all + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno /home/runner/work/RadioLib/examples/SX126x_Transmit/SX126x_Transmit.ino --warnings=all - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From 5e50851610a1d2592632c233e27d7cefab0bb311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 1 Sep 2020 10:09:11 +0200 Subject: [PATCH 368/455] [QL] Fixed example path --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index ed40f648..6dde07cc 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -50,7 +50,7 @@ jobs: - name: Build example run: - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno /home/runner/work/RadioLib/examples/SX126x_Transmit/SX126x_Transmit.ino --warnings=all + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno /home/runner/work/RadioLib/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino --warnings=all - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From a3a0719fa33eda142b826695ddb022f33d778bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 1 Sep 2020 10:13:13 +0200 Subject: [PATCH 369/455] [QL] Fixed path --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6dde07cc..131904de 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -50,7 +50,7 @@ jobs: - name: Build example run: - arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno /home/runner/work/RadioLib/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino --warnings=all + arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $PWD/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino --warnings=all - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From e282937e6fa6b6d4e2e75aafe337d845986d1b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Mon, 7 Sep 2020 20:16:34 +0200 Subject: [PATCH 370/455] [CodeQL] Static link fix --- .github/workflows/codeql-analysis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 131904de..5ce7c4a3 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -47,6 +47,12 @@ jobs: | arduino-cli core update-index arduino-cli core install arduino:avr + # static link fix from https://github.com/github/securitylab/discussions/171 + for i in ~/.arduino*/packages/arduino/tools/avr-gcc/*/bin/*; do + mv "$i" "$i.real"; + printf '#!/usr/bin/sh\nexec "'"$i"'.real" ${1+"$@"}\n' > "$i"; + chmod +x "$i"; + done - name: Build example run: From deae19e892ba09b4b6735d86b3c365faeb895310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Mon, 7 Sep 2020 21:10:45 +0200 Subject: [PATCH 371/455] [CodeQL] Moved static fix --- .github/workflows/codeql-analysis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5ce7c4a3..057fe900 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -47,6 +47,10 @@ jobs: | arduino-cli core update-index arduino-cli core install arduino:avr + + - name: Static link + run: + | # static link fix from https://github.com/github/securitylab/discussions/171 for i in ~/.arduino*/packages/arduino/tools/avr-gcc/*/bin/*; do mv "$i" "$i.real"; From 38b3f33c82b2bc1bdd5014f8cfeafd77235f168a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 12 Sep 2020 13:01:41 +0200 Subject: [PATCH 372/455] [CodeQL] Use /bin/bash interperter --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 057fe900..3d8328d9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -54,7 +54,7 @@ jobs: # static link fix from https://github.com/github/securitylab/discussions/171 for i in ~/.arduino*/packages/arduino/tools/avr-gcc/*/bin/*; do mv "$i" "$i.real"; - printf '#!/usr/bin/sh\nexec "'"$i"'.real" ${1+"$@"}\n' > "$i"; + printf '#!/bin/bash\nexec "'"$i"'.real" ${1+"$@"}\n' > "$i"; chmod +x "$i"; done From b337b5e22f3dcb1feabc51059f1d29c6017fefac Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Sep 2020 13:41:45 +0200 Subject: [PATCH 373/455] [AX25] Replaced constant with macro --- src/protocols/AX25/AX25.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index 7de2bbbe..c2e5899e 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -406,7 +406,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { } else { _audio->tone(AX25_AFSK_SPACE, false); } - while(Module::micros() - start < 833) { + while(Module::micros() - start < AX25_AFSK_TONE_DURATION) { Module::yield(); } } From f17b1d413a264ed4b4cfa78c8ee95fa2ac780010 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Sep 2020 13:44:05 +0200 Subject: [PATCH 374/455] [AX25] Fixed CodeQL alerts --- src/protocols/AX25/AX25.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index c2e5899e..5397a2d1 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -234,7 +234,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { // set destination callsign - all address field bytes are shifted by one bit to make room for HDLC address extension bit memset(frameBuffPtr, ' ' << 1, AX25_MAX_CALLSIGN_LEN); - for(uint8_t i = 0; i < strlen(frame->destCallsign); i++) { + for(size_t i = 0; i < strlen(frame->destCallsign); i++) { *(frameBuffPtr + i) = frame->destCallsign[i] << 1; } frameBuffPtr += AX25_MAX_CALLSIGN_LEN; @@ -244,7 +244,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { // set source callsign - all address field bytes are shifted by one bit to make room for HDLC address extension bit memset(frameBuffPtr, ' ' << 1, AX25_MAX_CALLSIGN_LEN); - for(uint8_t i = 0; i < strlen(frame->srcCallsign); i++) { + for(size_t i = 0; i < strlen(frame->srcCallsign); i++) { *(frameBuffPtr + i) = frame->srcCallsign[i] << 1; } frameBuffPtr += AX25_MAX_CALLSIGN_LEN; @@ -255,7 +255,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { // set repeater callsigns for(uint16_t i = 0; i < frame->numRepeaters; i++) { memset(frameBuffPtr, ' ' << 1, AX25_MAX_CALLSIGN_LEN); - for(uint8_t j = 0; j < strlen(frame->repeaterCallsigns[i]); j++) { + for(size_t j = 0; j < strlen(frame->repeaterCallsigns[i]); j++) { *(frameBuffPtr + j) = frame->repeaterCallsigns[i][j] << 1; } frameBuffPtr += AX25_MAX_CALLSIGN_LEN; @@ -314,7 +314,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { // stuff bits (skip preamble and both flags) uint16_t stuffedFrameBuffLenBits = 8*(_preambleLen + 1); uint8_t count = 0; - for(uint16_t i = 0; i < frameBuffLen + 2; i++) { + for(size_t i = 0; i < frameBuffLen + 2; i++) { for(int8_t shift = 7; shift >= 0; shift--) { uint16_t stuffedFrameBuffPos = stuffedFrameBuffLenBits + 7 - 2*(stuffedFrameBuffLenBits%8); if((frameBuff[i] >> shift) & 0x01) { From ffe1c38c1f3b7dcbb46eec5fdc3f91c6f81646cd Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Sep 2020 13:45:08 +0200 Subject: [PATCH 375/455] [XBee] Fixed CodeQL alerts --- src/modules/XBee/XBee.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/XBee/XBee.cpp b/src/modules/XBee/XBee.cpp index 37d51530..73bb934e 100644 --- a/src/modules/XBee/XBee.cpp +++ b/src/modules/XBee/XBee.cpp @@ -374,13 +374,13 @@ void XBee::sendApiFrame(uint8_t type, uint8_t id, uint8_t* data, uint16_t length // calculate the checksum uint8_t checksum = 0; - for(uint16_t i = 3; i < frameLength - 1; i++) { + for(size_t i = 3; i < frameLength - 1; i++) { checksum += frame[i]; } frame[5 + length] = 0xFF - checksum; // send the frame - for(uint16_t i = 0; i < frameLength; i++) { + for(size_t i = 0; i < frameLength; i++) { _mod->ModuleSerial->write(frame[i]); } From b650d15f7661086a48e561a645dacbf4ad923746 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Sep 2020 13:45:53 +0200 Subject: [PATCH 376/455] [SX127x] Fixed CodeQL alerts --- src/modules/SX127x/SX127x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 39818f4b..891142c5 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -755,7 +755,7 @@ int16_t SX127x::setSyncWord(uint8_t* syncWord, size_t len) { RADIOLIB_CHECK_RANGE(len, 1, 8, ERR_INVALID_SYNC_WORD); // sync word must not contain value 0x00 - for(uint8_t i = 0; i < len; i++) { + for(size_t i = 0; i < len; i++) { if(syncWord[i] == 0x00) { return(ERR_INVALID_SYNC_WORD); } From 3c25c76b9bbe404a2b4b4699d124f593eee563c6 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Sep 2020 13:47:39 +0200 Subject: [PATCH 377/455] [RTTY] Fixed CodeQL alerts --- src/protocols/RTTY/RTTY.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 640a79a8..0d0552bf 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -195,7 +195,7 @@ size_t RTTYClient::write(uint8_t* buff, size_t len) { size_t RTTYClient::write(uint8_t b) { space(); - for(uint16_t mask = 0x01; mask <= (uint16_t)(0x01 << (_dataBits - 1)); mask <<= 1) { + for(uint16_t mask = 0x01; mask <= (uint16_t)(0x01 << (uint16_t)(_dataBits - 1)); mask <<= 1) { if(b & mask) { mark(); } else { From b8d83c8792a4f96bca0d622329e690055ee57666 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Sep 2020 13:53:28 +0200 Subject: [PATCH 378/455] [RTTY] Force mask type --- src/protocols/RTTY/RTTY.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 0d0552bf..30caf9d7 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -195,7 +195,8 @@ size_t RTTYClient::write(uint8_t* buff, size_t len) { size_t RTTYClient::write(uint8_t b) { space(); - for(uint16_t mask = 0x01; mask <= (uint16_t)(0x01 << (uint16_t)(_dataBits - 1)); mask <<= 1) { + uint16_t maxDataMask = 0x01 << (_dataBits - 1); + for(uint16_t mask = 0x01; mask <= maxDataMask; mask <<= 1) { if(b & mask) { mark(); } else { From 7ea94eb01ad7c3069db2d9f4b369aa69a8ee416e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 12 Sep 2020 14:01:38 +0200 Subject: [PATCH 379/455] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..1a32eacc --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of Conduct + +Don't be an a*shole. From 08f86da3a66140211debf8da25ce54ed40316258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Sat, 12 Sep 2020 14:03:31 +0200 Subject: [PATCH 380/455] Create SECURITY.md --- SECURITY.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..b43ea5c1 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +## Reporting a Vulnerability + +RadioLib is provided as-is without any warranty, and is not intended to be used in security-critical applications. However, if you discover a vulnerability within the library code, please report it to gromes.jan@gmail.com. From e7fb5551921c06a2d9bef2eac317fc49958ca749 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 13 Sep 2020 17:52:40 +0200 Subject: [PATCH 381/455] [PHY] Added TRNG support (#178) --- src/protocols/PhysicalLayer/PhysicalLayer.cpp | 24 +++++++++++++++ src/protocols/PhysicalLayer/PhysicalLayer.h | 29 ++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index b0174c51..b30a0cf9 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -143,3 +143,27 @@ int16_t PhysicalLayer::receive(String& str, size_t len) { float PhysicalLayer::getFreqStep() const { return(_freqStep); } + +int32_t PhysicalLayer::random(int32_t max) { + if(max == 0) { + return(0); + } + + // get random bytes from the radio + uint8_t randBuff[4]; + for(uint8_t i = 0; i < 4; i++) { + randBuff[i] = random(); + } + + // create 32-bit TRNG number + int32_t randNum = ((int32_t)randBuff[0] << 24) | ((int32_t)randBuff[1] << 16) | ((int32_t)randBuff[2] << 8) | ((int32_t)randBuff[3]); + return(randNum % max); +} + +int32_t PhysicalLayer::random(int32_t min, int32_t max) { + if(min >= max) { + return(min); + } + + return(PhysicalLayer::random(max - min) + min); +} diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.h b/src/protocols/PhysicalLayer/PhysicalLayer.h index 11bfb490..d817fbcc 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.h +++ b/src/protocols/PhysicalLayer/PhysicalLayer.h @@ -216,7 +216,7 @@ class PhysicalLayer { float getFreqStep() const; /*! - \brief Query modem for the packet length of received payload. + \brief Query modem for the packet length of received payload. Must be implemented in module class. \param update Update received packet length. Will return cached value when set to false. @@ -224,6 +224,33 @@ class PhysicalLayer { */ virtual size_t getPacketLength(bool update = true) = 0; + /*! + \brief Get truly random number in range 0 - max. + + \param max The maximum value of the random number (non-inclusive). + + \returns Random number. + */ + int32_t random(int32_t max); + + /*! + \brief Get truly random number in range min - max. + + \param min The minimum value of the random number (inclusive). + + \param max The maximum value of the random number (non-inclusive). + + \returns Random number. + */ + int32_t random(int32_t min, int32_t max); + + /*! + \brief Get one truly random byte from RSSI noise. Must be implemented in module class. + + \returns TRNG byte. + */ + virtual uint8_t random() = 0; + #ifndef RADIOLIB_GODMODE private: #endif From 5376931b023ceb9980d5f07378541a553cf045d2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 13 Sep 2020 17:52:53 +0200 Subject: [PATCH 382/455] [nRF24] Added TRNG support --- src/modules/nRF24/nRF24.cpp | 6 ++++++ src/modules/nRF24/nRF24.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 0133b732..e0c4c57d 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -503,6 +503,12 @@ int16_t nRF24::setEncoding(uint8_t encoding) { return(ERR_NONE); } +uint8_t nRF24::random() { + // nRF24 is unable to measure RSSI, hence no TRNG + // this method is implemented only for PhysicalLayer compatibility + return(0); +} + void nRF24::clearIRQ() { // clear status bits _mod->SPIsetRegValue(NRF24_REG_STATUS, NRF24_RX_DR | NRF24_TX_DS | NRF24_MAX_RT, 6, 4); diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index d1e7a8b3..d4943a04 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -464,6 +464,13 @@ class nRF24: public PhysicalLayer { */ int16_t setEncoding(uint8_t encoding) override; + /*! + \brief Dummy random method, to ensure PhysicalLayer compatibility. + + \returns Always returns 0. + */ + uint8_t random(); + #ifndef RADIOLIB_GODMODE private: #endif From 5e1285783aaf6c6473e4a8e2aa9544b5ea3b1029 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 13 Sep 2020 17:53:01 +0200 Subject: [PATCH 383/455] [Si443x] Added TRNG support --- src/modules/Si443x/Si443x.cpp | 19 +++++++++++++++++++ src/modules/Si443x/Si443x.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index ea3512f5..7ab570fe 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -553,6 +553,25 @@ void Si443x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { _mod->setRfSwitchPins(rxEn, txEn); } +uint8_t Si443x::random() { + // set mode to Rx + _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON | SI443X_XTAL_ON); + + // wait a bit for the RSSI reading to stabilise + Module::delay(10); + + // read RSSI value 8 times, always keep just the least significant bit + uint8_t randByte = 0x00; + for(uint8_t i = 0; i < 8; i++) { + randByte |= ((_mod->SPIreadRegister(SI443X_REG_RSSI) & 0x01) << i); + } + + // set mode to standby + standby(); + + return(randByte); +} + int16_t Si443x::setFrequencyRaw(float newFreq) { // set mode to standby int16_t state = standby(); diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 286ab144..9064d4ca 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -785,6 +785,13 @@ class Si443x: public PhysicalLayer { */ void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + /*! + \brief Get one truly random byte from RSSI noise. + + \returns TRNG byte. + */ + uint8_t random(); + #ifndef RADIOLIB_GODMODE protected: #endif From 3cc55806cf05d64c54c3f250dd8b99379d168d17 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 13 Sep 2020 17:53:07 +0200 Subject: [PATCH 384/455] [SX128x] Added TRNG support --- src/modules/SX128x/SX128x.cpp | 6 ++++++ src/modules/SX128x/SX128x.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index dfb97a1c..ed545178 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1122,6 +1122,12 @@ void SX128x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { _mod->setRfSwitchPins(rxEn, txEn); } +uint8_t SX128x::random() { + // it's unclear whether SX128x can measure RSSI while not receiving a packet + // this method is implemented only for PhysicalLayer compatibility + return(0); +} + uint8_t SX128x::getStatus() { uint8_t data = 0; SPIreadCommand(SX128X_CMD_GET_STATUS, &data, 1); diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index bf82c0cc..5763e527 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -753,6 +753,13 @@ class SX128x: public PhysicalLayer { */ void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + /*! + \brief Dummy random method, to ensure PhysicalLayer compatibility. + + \returns Always returns 0. + */ + uint8_t random(); + #ifndef RADIOLIB_GODMODE protected: #endif From 04195ee0d2b7dff5727a87b53edd694a251f50c0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 13 Sep 2020 17:53:16 +0200 Subject: [PATCH 385/455] [SX127x] Added TRNG support --- src/modules/SX127x/SX127x.cpp | 25 +++++++++++++++++++++++++ src/modules/SX127x/SX127x.h | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 891142c5..0b877fd3 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -958,6 +958,31 @@ void SX127x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { _mod->setRfSwitchPins(rxEn, txEn); } +uint8_t SX127x::random() { + // check active modem + uint8_t rssiValueReg = SX127X_REG_RSSI_WIDEBAND; + if(getActiveModem() == SX127X_FSK_OOK) { + rssiValueReg = SX127X_REG_RSSI_VALUE_FSK; + } + + // set mode to Rx + setMode(SX127X_RX); + + // wait a bit for the RSSI reading to stabilise + Module::delay(10); + + // read RSSI value 8 times, always keep just the least significant bit + uint8_t randByte = 0x00; + for(uint8_t i = 0; i < 8; i++) { + randByte |= ((_mod->SPIreadRegister(rssiValueReg) & 0x01) << i); + } + + // set mode to standby + setMode(SX127X_STANDBY); + + return(randByte); +} + int8_t SX127x::getTempRaw() { int8_t temp = 0; uint8_t previousOpMode; diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 61953144..f7f44166 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -931,6 +931,13 @@ class SX127x: public PhysicalLayer { */ void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + /*! + \brief Get one truly random byte from RSSI noise. + + \returns TRNG byte. + */ + uint8_t random(); + #ifndef RADIOLIB_GODMODE protected: #endif From b40ad5c2f77f6d691a8e922404b67e996f99d134 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 13 Sep 2020 17:53:23 +0200 Subject: [PATCH 386/455] [SX126x] Added TRNG support --- src/modules/SX126x/SX126x.cpp | 21 +++++++++++++++++++++ src/modules/SX126x/SX126x.h | 9 ++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index edeaae73..203133eb 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1173,6 +1173,27 @@ int16_t SX126x::autoLDRO() { return(ERR_NONE); } +uint8_t SX126x::random() { + // set mode to Rx + setRx(SX126X_RX_TIMEOUT_INF); + + // wait a bit for the RSSI reading to stabilise + Module::delay(10); + + // read RSSI value 8 times, always keep just the least significant bit + uint8_t randByte = 0x00; + for(uint8_t i = 0; i < 8; i++) { + uint8_t val = 0x00; + readRegister(SX126X_REG_RANDOM_NUMBER_0, &val, sizeof(uint8_t)); + randByte |= ((val & 0x01) << i); + } + + // set mode to standby + standby(); + + return(randByte); +} + int16_t SX126x::setTCXO(float voltage, uint32_t delay) { // set mode to standby standby(); diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 3d45266a..0778ea6e 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -854,7 +854,7 @@ class SX126x: public PhysicalLayer { /*! \brief Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to - the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX1278::autoLDRO() + the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX126x::autoLDRO() \param enable Force LDRO to be always enabled (true) or disabled (false). @@ -870,6 +870,13 @@ class SX126x: public PhysicalLayer { */ int16_t autoLDRO(); + /*! + \brief Get one truly random byte from RSSI noise. + + \returns TRNG byte. + */ + uint8_t random(); + #ifndef RADIOLIB_GODMODE protected: #endif From ff8d9d672df033b52dccf17225611bb600b47eb1 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 13 Sep 2020 17:53:30 +0200 Subject: [PATCH 387/455] [RF69] Added TRNG support --- src/modules/RF69/RF69.cpp | 19 +++++++++++++++++++ src/modules/RF69/RF69.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 7875f41b..b47c522e 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -764,6 +764,25 @@ void RF69::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { _mod->setRfSwitchPins(rxEn, txEn); } +uint8_t RF69::random() { + // set mode to Rx + setMode(RF69_RX); + + // wait a bit for the RSSI reading to stabilise + Module::delay(10); + + // read RSSI value 8 times, always keep just the least significant bit + uint8_t randByte = 0x00; + for(uint8_t i = 0; i < 8; i++) { + randByte |= ((_mod->SPIreadRegister(RF69_REG_RSSI_VALUE) & 0x01) << i); + } + + // set mode to standby + setMode(RF69_STANDBY); + + return(randByte); +} + int16_t RF69::config() { int16_t state = ERR_NONE; diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 63b63513..0c2294a2 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -820,6 +820,13 @@ class RF69: public PhysicalLayer { */ void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + /*! + \brief Get one truly random byte from RSSI noise. + + \returns TRNG byte. + */ + uint8_t random(); + #ifndef RADIOLIB_GODMODE protected: #endif From 35f02ed40205db2329882feb7d62f78b2c234e14 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 13 Sep 2020 17:53:37 +0200 Subject: [PATCH 388/455] [CC1101] Added TRNG support --- src/modules/CC1101/CC1101.cpp | 45 +++++++++++++++++++++++++---------- src/modules/CC1101/CC1101.h | 7 ++++++ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 885a7b2f..264a23b4 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -554,7 +554,7 @@ int16_t CC1101::setNodeAddress(uint8_t nodeAddr, uint8_t numBroadcastAddrs) { int16_t CC1101::disableAddressFiltering() { // disable address filtering - int16_t state = _mod->SPIsetRegValue(CC1101_REG_PKTCTRL1, CC1101_ADR_CHK_NONE, 1, 0); + int16_t state = SPIsetRegValue(CC1101_REG_PKTCTRL1, CC1101_ADR_CHK_NONE, 1, 0); RADIOLIB_ASSERT(state); // set node address to default (0x00) @@ -610,9 +610,9 @@ uint8_t CC1101::getLQI() const { size_t CC1101::getPacketLength(bool update) { if(!_packetLengthQueried && update) { if (_packetLengthConfig == CC1101_LENGTH_CONFIG_VARIABLE) { - _packetLength = _mod->SPIreadRegister(CC1101_REG_FIFO); + _packetLength = SPIreadRegister(CC1101_REG_FIFO); } else { - _packetLength = _mod->SPIreadRegister(CC1101_REG_PKTLEN); + _packetLength = SPIreadRegister(CC1101_REG_PKTLEN); } _packetLengthQueried = true; @@ -693,10 +693,10 @@ int16_t CC1101::setDataShaping(uint8_t sh) { // set data shaping switch(sh) { case RADIOLIB_SHAPING_NONE: - state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_2_FSK, 6, 4); + state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_2_FSK, 6, 4); break; case RADIOLIB_SHAPING_0_5: - state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_GFSK, 6, 4); + state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_GFSK, 6, 4); break; default: return(ERR_INVALID_DATA_SHAPING); @@ -712,17 +712,17 @@ int16_t CC1101::setEncoding(uint8_t encoding) { // set encoding switch(encoding) { case RADIOLIB_ENCODING_NRZ: - state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3); + state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3); RADIOLIB_ASSERT(state); - return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6)); + return(SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6)); case RADIOLIB_ENCODING_MANCHESTER: - state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_ON, 3, 3); + state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_ON, 3, 3); RADIOLIB_ASSERT(state); - return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6)); + return(SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6)); case RADIOLIB_ENCODING_WHITENING: - state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3); + state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3); RADIOLIB_ASSERT(state); - return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_ON, 6, 6)); + return(SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_ON, 6, 6)); default: return(ERR_INVALID_ENCODING); } @@ -732,6 +732,25 @@ void CC1101::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { _mod->setRfSwitchPins(rxEn, txEn); } +uint8_t CC1101::random() { + // set mode to Rx + SPIsendCommand(CC1101_CMD_RX); + + // wait a bit for the RSSI reading to stabilise + Module::delay(10); + + // read RSSI value 8 times, always keep just the least significant bit + uint8_t randByte = 0x00; + for(uint8_t i = 0; i < 8; i++) { + randByte |= ((SPIreadRegister(CC1101_REG_RSSI) & 0x01) << i); + } + + // set mode to standby + SPIsendCommand(CC1101_CMD_IDLE); + + return(randByte); +} + int16_t CC1101::config() { // Reset the radio. Registers may be dirty from previous usage. SPIsendCommand(CC1101_CMD_RESET); @@ -795,11 +814,11 @@ int16_t CC1101::setPacketMode(uint8_t mode, uint8_t len) { } // set PKTCTRL0.LENGTH_CONFIG - int16_t state = _mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, mode, 1, 0); + int16_t state = SPIsetRegValue(CC1101_REG_PKTCTRL0, mode, 1, 0); RADIOLIB_ASSERT(state); // set length to register - state = _mod->SPIsetRegValue(CC1101_REG_PKTLEN, len); + state = SPIsetRegValue(CC1101_REG_PKTLEN, len); RADIOLIB_ASSERT(state); // update the cached value diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 8999d371..0d95a0ba 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -874,6 +874,13 @@ class CC1101: public PhysicalLayer { */ void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn); + /*! + \brief Get one truly random byte from RSSI noise. + + \returns TRNG byte. + */ + uint8_t random(); + #ifndef RADIOLIB_GODMODE private: #endif From cd142df4b9f577903bed826722550a361305403d Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 19 Sep 2020 19:48:21 +0200 Subject: [PATCH 389/455] [CC1101] Added 0x04 as valid version register value (#183) --- src/modules/CC1101/CC1101.cpp | 4 ++-- src/modules/CC1101/CC1101.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 264a23b4..dfe67bc2 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -17,7 +17,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po bool flagFound = false; while((i < 10) && !flagFound) { uint8_t version = SPIreadRegister(CC1101_REG_VERSION); - if(version == 0x14) { + if((version == CC1101_VERSION_CURRENT) || (version == CC1101_VERSION_LEGACY)) { flagFound = true; } else { #ifdef RADIOLIB_DEBUG @@ -747,7 +747,7 @@ uint8_t CC1101::random() { // set mode to standby SPIsendCommand(CC1101_CMD_IDLE); - + return(randByte); } diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 0d95a0ba..850df7ac 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -455,7 +455,8 @@ #define CC1101_PARTNUM 0x00 // CC1101_REG_VERSION -#define CC1101_VERSION 0x14 +#define CC1101_VERSION_CURRENT 0x14 +#define CC1101_VERSION_LEGACY 0x04 // CC1101_REG_MARCSTATE #define CC1101_MARC_STATE_SLEEP 0x00 // 4 0 main radio control state: sleep From bb1bb59afffba1a2a238e78dcdc443de94d29a1f Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 22 Sep 2020 07:49:27 +0200 Subject: [PATCH 390/455] [SX126x] Added option to disable TCXO using SX126x::setTCXO(0) (#99) --- src/modules/SX126x/SX126x.cpp | 5 +++++ src/modules/SX126x/SX126x.h | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 203133eb..e01d0b81 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1203,6 +1203,11 @@ int16_t SX126x::setTCXO(float voltage, uint32_t delay) { clearDeviceErrors(); } + // check 0 V disable + if(abs(voltage - 0.0) <= 0.001) { + return(reset(true)); + } + // check alowed voltage values uint8_t data[4]; if(abs(voltage - 1.6) <= 0.001) { diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 0778ea6e..46b510f8 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -733,9 +733,12 @@ class SX126x: public PhysicalLayer { /*! \brief Sets TCXO (Temperature Compensated Crystal Oscillator) configuration. - \param TCXO reference voltage in volts. Allowed values are 1.6, 1.7, 1.8, 2.2. 2.4, 2.7, 3.0 and 3.3 V + \param TCXO reference voltage in volts. Allowed values are 1.6, 1.7, 1.8, 2.2. 2.4, 2.7, 3.0 and 3.3 V. Set to 0 to disable TCXO. + NOTE: After setting this parameter to 0, the module will be reset (since there's no other way to disable TCXO). \param TCXO timeout in us. Defaults to 5000 us. + + \returns \ref status_codes */ int16_t setTCXO(float voltage, uint32_t delay = 5000); From 598eb34ad537c78f356f948aa1444fa5ea43e6fe Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 9 Oct 2020 18:55:31 +0200 Subject: [PATCH 391/455] Bump version to 4.0.4 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 9b3deb25..c5e072d1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=4.0.3 +version=4.0.4 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index f3962fce..e0f080ce 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -368,7 +368,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) #define RADIOLIB_VERSION_MINOR (0x00) -#define RADIOLIB_VERSION_PATCH (0x03) +#define RADIOLIB_VERSION_PATCH (0x04) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From e96fd0f8af3f2509f4b70fef687571d3b91887a2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 9 Oct 2020 20:10:12 +0200 Subject: [PATCH 392/455] Replace workflow add-path commands with echo to env file --- .github/workflows/codeql-analysis.yml | 14 +++++++------- .github/workflows/main.yml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3d8328d9..d95c71d9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,30 +34,30 @@ jobs: uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} - + - name: Install arduino-cli run: | mkdir -p ~/.local/bin - echo "::add-path::~/.local/bin" + echo "~/.local/bin" >> $GITHUB_PATH curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - + - name: Install platform run: | arduino-cli core update-index arduino-cli core install arduino:avr - + - name: Static link run: | # static link fix from https://github.com/github/securitylab/discussions/171 - for i in ~/.arduino*/packages/arduino/tools/avr-gcc/*/bin/*; do + for i in ~/.arduino*/packages/arduino/tools/avr-gcc/*/bin/*; do mv "$i" "$i.real"; printf '#!/bin/bash\nexec "'"$i"'.real" ${1+"$@"}\n' > "$i"; - chmod +x "$i"; + chmod +x "$i"; done - + - name: Build example run: arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $PWD/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino --warnings=all diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8604e99..671da426 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,7 @@ jobs: run: | mkdir -p ~/.local/bin - echo "::add-path::~/.local/bin" + echo "~/.local/bin" >> $GITHUB_PATH curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh - name: Get platform name @@ -90,7 +90,7 @@ jobs: sudo apt-get install -y python3 python3-pip python3-setuptools pip3 install wheel pip3 install --user adafruit-nrfutil - echo "::add-path::/home/runner/.local/bin" + echo "/home/runner/.local/bin" >> $GITHUB_PATH echo "::set-output name=options:::softdevice=s132v6,debug=l0" echo "::set-output name=index-url::--additional-urls https://www.adafruit.com/package_adafruit_index.json" From e549039b15591c231199482e09cb87457a9a4398 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 13 Oct 2020 19:25:15 +0200 Subject: [PATCH 393/455] [SX127x] Fixed incorrect shaping register (#186) --- src/modules/SX127x/SX1278.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 58ef91d4..938118ac 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -356,13 +356,13 @@ int16_t SX1278::setDataShaping(uint8_t sh) { // set data shaping switch(sh) { case RADIOLIB_SHAPING_NONE: - return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1278_NO_SHAPING, 6, 5)); + return(_mod->SPIsetRegValue(SX127X_REG_PA_RAMP, SX1278_NO_SHAPING, 6, 5)); case RADIOLIB_SHAPING_0_3: - return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1278_FSK_GAUSSIAN_0_3, 6, 5)); + return(_mod->SPIsetRegValue(SX127X_REG_PA_RAMP, SX1278_FSK_GAUSSIAN_0_3, 6, 5)); case RADIOLIB_SHAPING_0_5: - return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1278_FSK_GAUSSIAN_0_5, 6, 5)); + return(_mod->SPIsetRegValue(SX127X_REG_PA_RAMP, SX1278_FSK_GAUSSIAN_0_5, 6, 5)); case RADIOLIB_SHAPING_1_0: - return(_mod->SPIsetRegValue(SX127X_REG_OP_MODE, SX1278_FSK_GAUSSIAN_1_0, 6, 5)); + return(_mod->SPIsetRegValue(SX127X_REG_PA_RAMP, SX1278_FSK_GAUSSIAN_1_0, 6, 5)); default: return(ERR_INVALID_DATA_SHAPING); } From 5d92240f8964f59e3b6a6e5e265b2bed7b21d325 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 28 Oct 2020 11:24:05 +0100 Subject: [PATCH 394/455] Added support for tone on ESP32 (#190) --- src/Module.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index 8d3e2e19..fe419e92 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -336,20 +336,36 @@ RADIOLIB_PIN_STATUS Module::digitalRead(RADIOLIB_PIN_TYPE pin) { } void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { - // TODO add tone support for platforms without tone() - #ifndef RADIOLIB_TONE_UNSUPPORTED - if(pin != RADIOLIB_NC) { - ::tone(pin, value); + if(pin == RADIOLIB_NC) { + return; } + + #if !defined(RADIOLIB_TONE_UNSUPPORTED) + ::tone(pin, value); + #else + #if defined(ESP32) + // ESP32 - emulate tone() via LED driver on channel 15 + if(ledcRead(15)) { + return; + } + ledcAttachPin(pin, 15); + ledcWriteTone(15, value); + #endif #endif } void Module::noTone(RADIOLIB_PIN_TYPE pin) { - // TODO add tone support for platforms without noTone() - #ifndef RADIOLIB_TONE_UNSUPPORTED - if(pin != RADIOLIB_NC) { - ::noTone(pin); + if(pin == RADIOLIB_NC) { + return; } + + #if !defined(RADIOLIB_TONE_UNSUPPORTED) + ::noTone(pin); + #else + #if defined(ESP32) + ledcDetachPin(pin); + ledcWrite(15, 0); + #endif #endif } From dbc35c814e8512109258956335feebbc8b4d2521 Mon Sep 17 00:00:00 2001 From: jgromes Date: Wed, 28 Oct 2020 11:45:58 +0100 Subject: [PATCH 395/455] Removed RADIOLIB_TONE_UNSUPPORTED flag from Apollo3 and STM32 unofficial --- src/BuildOpt.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index e0f080ce..f3f0d538 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -229,7 +229,6 @@ #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - #define RADIOLIB_TONE_UNSUPPORTED #elif defined(ARDUINO_ARDUINO_NANO33BLE) // Arduino Nano 33 BLE @@ -281,7 +280,6 @@ #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - #define RADIOLIB_TONE_UNSUPPORTED #else // other platforms not covered by the above list - this may or may not work From 4cdbcb60c5f5e8bcaec96f3f59da90ed12be5e26 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 29 Oct 2020 07:53:51 +0100 Subject: [PATCH 396/455] Changed ESP32 tone emulation channel to 1 --- src/BuildOpt.h | 3 +++ src/Module.cpp | 11 ++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index f3f0d538..adafecf3 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -128,7 +128,10 @@ #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + + // ESP32 doesn't support tone(), but it can be emulated via LED control peripheral #define RADIOLIB_TONE_UNSUPPORTED + #define RADIOLIB_TONE_ESP32_CHANNEL (1) #elif defined(ARDUINO_ARCH_STM32) // official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32) diff --git a/src/Module.cpp b/src/Module.cpp index fe419e92..2205b326 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -344,12 +344,9 @@ void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) { ::tone(pin, value); #else #if defined(ESP32) - // ESP32 - emulate tone() via LED driver on channel 15 - if(ledcRead(15)) { - return; - } - ledcAttachPin(pin, 15); - ledcWriteTone(15, value); + // ESP32 tone() emulation + ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL); + ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, value); #endif #endif } @@ -364,7 +361,7 @@ void Module::noTone(RADIOLIB_PIN_TYPE pin) { #else #if defined(ESP32) ledcDetachPin(pin); - ledcWrite(15, 0); + ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0); #endif #endif } From 4816d7383e8ac1a7dc868564b4618b0bc8839f99 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 29 Oct 2020 16:33:41 +0100 Subject: [PATCH 397/455] Bump version to 4.0.5 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index c5e072d1..b66c4b9d 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=4.0.4 +version=4.0.5 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index adafecf3..9a518d9d 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -369,7 +369,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) #define RADIOLIB_VERSION_MINOR (0x00) -#define RADIOLIB_VERSION_PATCH (0x04) +#define RADIOLIB_VERSION_PATCH (0x05) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From d58ffee4432f66f3310276ffbdfe5109a21f22c2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 29 Oct 2020 16:46:53 +0100 Subject: [PATCH 398/455] [CI] Disable Arduino Portenta build (fails to install) CI_BUILD_ALL --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 671da426..af8060bc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: - arduino:avr:mega - arduino:avr:leonardo - arduino:mbed:nano33ble - - arduino-beta:mbed:envie_m4 + #- arduino-beta:mbed:envie_m4 - arduino:megaavr:uno2018 - arduino:sam:arduino_due_x - arduino:samd:arduino_zero_native From 063b643a7b5bf233f35e9f046318b9acdff5c5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 3 Nov 2020 15:42:37 +0100 Subject: [PATCH 399/455] [Si443x] Fixed frequency deviation 0 for RTTY (#195) --- src/modules/Si443x/Si443x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 7ab570fe..0e6d695a 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -342,7 +342,7 @@ int16_t Si443x::setFrequencyDeviation(float freqDev) { if(state == ERR_NONE) { _freqDev = freqDev; } - + return(state); } RADIOLIB_CHECK_RANGE(freqDev, 0.625, 320.0, ERR_INVALID_FREQUENCY_DEVIATION); From c8ff0234b327ba15e6ba3d644de8bbb27ebb410b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Tue, 3 Nov 2020 16:02:14 +0100 Subject: [PATCH 400/455] [CI] Use arduino:mbed instead of beta for Portenta H7 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index af8060bc..a68f9450 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: - arduino:avr:mega - arduino:avr:leonardo - arduino:mbed:nano33ble - #- arduino-beta:mbed:envie_m4 + - arduino:mbed:envie_m4 - arduino:megaavr:uno2018 - arduino:sam:arduino_due_x - arduino:samd:arduino_zero_native From 9b5eed83d2952496d3091cfc64ac4c499826abe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Thu, 5 Nov 2020 21:29:41 +0100 Subject: [PATCH 401/455] [RTTY] Fixed idle (#195) --- src/protocols/RTTY/RTTY.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index 30caf9d7..74973f4f 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -173,7 +173,6 @@ int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t enc } void RTTYClient::idle() { - transmitDirect(); mark(); } From c127712c5e4c90ad17ffe721ccbe025fb2d0cb21 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 19 Nov 2020 17:07:32 +0100 Subject: [PATCH 402/455] [SX127x] Added check for LoRa header CRC mismatch (#200) --- src/TypeDef.h | 5 +++++ src/modules/SX127x/SX1272.cpp | 1 + src/modules/SX127x/SX1278.cpp | 1 + src/modules/SX127x/SX127x.cpp | 11 +++++++++-- src/modules/SX127x/SX127x.h | 1 + 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/TypeDef.h b/src/TypeDef.h index aa4c41af..a2726ded 100644 --- a/src/TypeDef.h +++ b/src/TypeDef.h @@ -283,6 +283,11 @@ */ #define ERR_INVALID_ENCODING -23 +/*! + \brief LoRa packet header has been damaged. +*/ +#define ERR_LORA_HEADER_DAMAGED -24 + // RF69-specific status codes /*! diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index ca1cc5a0..4cfa2e07 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -361,6 +361,7 @@ float SX1272::getRSSI() { int16_t SX1272::setCRC(bool enableCRC) { if(getActiveModem() == SX127X_LORA) { // set LoRa CRC + SX127x::_crcEnabled = enableCRC; if(enableCRC) { return(_mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, SX1272_RX_CRC_MODE_ON, 2, 2)); } else { diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 938118ac..ca0b8fab 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -439,6 +439,7 @@ float SX1278::getRSSI() { int16_t SX1278::setCRC(bool enableCRC) { if(getActiveModem() == SX127X_LORA) { // set LoRa CRC + SX127x::_crcEnabled = enableCRC; if(enableCRC) { return(_mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, SX1278_RX_CRC_MODE_ON, 2, 2)); } else { diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 0b877fd3..c6fa95a9 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -490,11 +490,18 @@ int16_t SX127x::readData(uint8_t* data, size_t len) { length = getPacketLength(); } - // check integrity CRC + // check packet header integrity + if(_crcEnabled && (_mod->SPIgetRegValue(SX127X_REG_HOP_CHANNEL, 6, 6)) == 0) { + // CRC is disabled according to packet header and enabled according to user + // most likely damaged packet header + clearIRQFlags(); + return(ERR_LORA_HEADER_DAMAGED); + } + + // check payload CRC if(_mod->SPIgetRegValue(SX127X_REG_IRQ_FLAGS, 5, 5) == SX127X_CLEAR_IRQ_FLAG_PAYLOAD_CRC_ERROR) { // clear interrupt flags clearIRQFlags(); - return(ERR_CRC_MISMATCH); } diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index f7f44166..27bf3f6c 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -950,6 +950,7 @@ class SX127x: public PhysicalLayer { float _br = 0; float _rxBw = 0; bool _ook = false; + bool _crcEnabled = false; int16_t setFrequencyRaw(float newFreq); int16_t config(); From 6e18dea7e1c5dafe8e319d40ec0e6dec0e3b48a6 Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 19 Nov 2020 21:12:05 +0100 Subject: [PATCH 403/455] Delete old Travis CI config file --- .travis.yml | 195 ---------------------------------------------------- 1 file changed, 195 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 46945334..00000000 --- a/.travis.yml +++ /dev/null @@ -1,195 +0,0 @@ -env: - global: - matrix: - # see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options - # and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt - - BOARD="arduino:avr:uno" - - BOARD="arduino:avr:mega:cpu=atmega2560" - - BOARD="arduino:avr:leonardo" - - BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K" - - BOARD="esp32:esp32:esp32" - - BOARD="STM32:stm32:GenF3:pnum=BLACKPILL_F303CC" - - BOARD="arduino:samd:arduino_zero_native" - - BOARD="arduino:sam:arduino_due_x" - - BOARD="adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0" - - BOARD="Intel:arc32:arduino_101" - - BOARD="arduino:megaavr:uno2018:mode=on" - - BOARD="SparkFun:apollo3:amap3redboard" - - BOARD="arduino:mbed:nano33ble" - - BOARD="stm32duino:STM32F1:mapleMini:bootloader_version=original,cpu_speed=speed_72mhz" - - BOARD="adafruit:samd:adafruit_feather_m0:usbstack=arduino,debug=off" - - BOARD="arduino-beta:mbed:envie_m4" - -addons: - apt: - packages: - # required for Adafruit nRF52 (adafruit-nrfutil package) - - python3 - - python3-pip - - python3-setuptools - -before_install: - # install Arduino CLI - - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh - - export PATH=$PATH:$PWD/bin - - # check every board in matrix and install 3rd party definitions - - | - if [[ "$BOARD" =~ "arduino:avr:uno" ]]; then - export BUILD_EXAMPLES=true; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install arduino:avr; - - elif [[ "$BOARD" =~ "arduino:avr:mega" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install arduino:avr; - - elif [[ "$BOARD" =~ "arduino:avr:leonardo" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install arduino:avr; - - elif [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index --additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json; - arduino-cli core install esp8266:esp8266 --additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json; - export SKIP_PAT='(HTTP|MQTT).*ino'; - - elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json; - arduino-cli core install esp32:esp32 --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json; - - elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index --additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json; - arduino-cli core install STM32:stm32 --additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json; - - elif [[ "$BOARD" =~ "arduino:samd:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install arduino:samd; - - elif [[ "$BOARD" =~ "arduino:sam:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install arduino:sam; - - elif [[ "$BOARD" =~ "adafruit:nrf52:" ]]; then - pip3 install --user adafruit-nrfutil; - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index --additional-urls https://www.adafruit.com/package_adafruit_index.json; - arduino-cli core install adafruit:nrf52 --additional-urls https://www.adafruit.com/package_adafruit_index.json; - - elif [[ "$BOARD" =~ "Intel:arc32:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install Intel:arc32; - - elif [[ "$BOARD" =~ "arduino:megaavr:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install arduino:megaavr; - - elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=none; - arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json; - arduino-cli core install SparkFun:apollo3 --additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json; - - elif [[ "$BOARD" =~ "arduino:mbed:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install arduino:mbed; - export SKIP_PAT='(HTTP|MQTT).*ino'; - - elif [[ "$BOARD" =~ "stm32duino:STM32F1:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index --additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json; - arduino-cli core install stm32duino:STM32F1 --additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json; - - elif [[ "$BOARD" =~ "adafruit:samd:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index --additional-urls https://www.adafruit.com/package_adafruit_index.json - arduino-cli core install adafruit:samd --additional-urls https://www.adafruit.com/package_adafruit_index.json - - elif [[ "$BOARD" =~ "arduino-beta:mbed:" ]]; then - export BUILD_EXAMPLES=false; - export WARNINGS=all; - arduino-cli core update-index; - arduino-cli core install arduino-beta:mbed; - export SKIP_PAT='(HTTP|MQTT).*ino'; - - fi - - # check if this release commit (or forced build) and if so, build for every board - - if [[ "$TRAVIS_COMMIT_MESSAGE" =~ "Bump version to" || "$TRAVIS_COMMIT_MESSAGE" =~ "TRAVIS_FORCE_BUILD" ]]; then - export BUILD_EXAMPLES=true; - fi - -# create directory to save the library and create symbolic link -install: - - mkdir -p $HOME/Arduino/libraries - - ln -s $PWD $HOME/Arduino/libraries/RadioLib - -# only build the master branch -branches: - only: - - master - -script: - # build all example sketches - - | - if [ ! -z "$BUILD_EXAMPLES" ] && [ "$BUILD_EXAMPLES" = true ] ; then - for example in $(find $PWD/examples -name '*.ino' | sort); do - # check whether to skip this sketch - if [ ! -z "$SKIP_PAT" ] && [[ ${example} =~ $SKIP_PAT ]]; then - # skip sketch - echo -e "\n\033[1;33mSkipped ${example##*/} (matched with $SKIP_PAT)\033[0m"; - else - # build sketch - echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; - arduino-cli compile --fqbn $BOARD $example --warnings=$WARNINGS - if [ $? -ne 0 ]; then - echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; - exit 1; - else - echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n"; - fi - fi - done - else - echo -e "\n\033[1;33mExample builds skipped for $BOARD\033[0m"; - fi - - # generate Doxygen documentation (only for Arduino UNO) - - if [ $BOARD = "arduino:avr:uno" ]; then - sudo apt-get update; - sudo apt-get install -y doxygen; - doxygen Doxyfile; - fi - -# deploy Doxygen docs on master branch and only when building for Arduino UNO -deploy: - provider: pages - skip_cleanup: true - local_dir: docs/html - github_token: $GH_REPO_TOKEN - on: - branch: master - condition: $BOARD = "arduino:avr:uno" From ff520e2a15cfb111cf973da7ac23d9f77661f826 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 20 Nov 2020 17:52:17 +0100 Subject: [PATCH 404/455] [SX127x] Added method to read version register (#204) --- keywords.txt | 1 + src/modules/SX127x/SX127x.cpp | 8 ++++++-- src/modules/SX127x/SX127x.h | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/keywords.txt b/keywords.txt index 06932713..e117eec2 100644 --- a/keywords.txt +++ b/keywords.txt @@ -130,6 +130,7 @@ getTempRaw KEYWORD2 setRfSwitchPins KEYWORD2 forceLDRO KEYWORD2 autoLDRO KEYWORD2 +getChipVersion KEYWORD2 # RF69-specific setAESKey KEYWORD2 diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index c6fa95a9..6635b71b 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -990,6 +990,10 @@ uint8_t SX127x::random() { return(randByte); } +int16_t SX127x::getChipVersion() { + return(_mod->SPIgetRegValue(SX127X_REG_VERSION)); +} + int8_t SX127x::getTempRaw() { int8_t temp = 0; uint8_t previousOpMode; @@ -1116,7 +1120,7 @@ bool SX127x::findChip(uint8_t ver) { reset(); // check version register - uint8_t version = _mod->SPIreadRegister(SX127X_REG_VERSION); + int16_t version = getChipVersion(); if(version == ver) { flagFound = true; } else { @@ -1126,7 +1130,7 @@ bool SX127x::findChip(uint8_t ver) { RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SX127X_REG_VERSION == ")); char buffHex[12]; - sprintf(buffHex, "0x%02X", version); + sprintf(buffHex, "0x%04X", version); RADIOLIB_DEBUG_PRINT(buffHex); RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); RADIOLIB_DEBUG_PRINTLN(ver, HEX); diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 27bf3f6c..a42605e1 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -938,6 +938,13 @@ class SX127x: public PhysicalLayer { */ uint8_t random(); + /*! + \brief Read version SPI register. Should return SX1278_CHIP_VERSION (0x12) or SX1272_CHIP_VERSION (0x22) if SX127x is connected and working. + + \returns Version register contents or \ref status_codes + */ + int16_t getChipVersion(); + #ifndef RADIOLIB_GODMODE protected: #endif From b4701c370ba83ff39d15dad9859d9ef78517368f Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 20 Nov 2020 17:52:32 +0100 Subject: [PATCH 405/455] [CC1101] Added method to read version register --- src/modules/CC1101/CC1101.cpp | 9 +++++++-- src/modules/CC1101/CC1101.h | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index dfe67bc2..b5499504 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -16,7 +16,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po uint8_t i = 0; bool flagFound = false; while((i < 10) && !flagFound) { - uint8_t version = SPIreadRegister(CC1101_REG_VERSION); + int16_t version = getChipVersion(); if((version == CC1101_VERSION_CURRENT) || (version == CC1101_VERSION_LEGACY)) { flagFound = true; } else { @@ -28,7 +28,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po char buffHex[7]; sprintf(buffHex, "0x%04X", version); RADIOLIB_DEBUG_PRINT(buffHex); - RADIOLIB_DEBUG_PRINT(F(", expected 0x0014")); + RADIOLIB_DEBUG_PRINT(F(", expected 0x0004/0x0014")); RADIOLIB_DEBUG_PRINTLN(); #endif Module::delay(10); @@ -751,6 +751,11 @@ uint8_t CC1101::random() { return(randByte); } + +int16_t CC1101::getChipVersion() { + return(_mod->SPIgetRegValue(CC1101_REG_VERSION)); +} + int16_t CC1101::config() { // Reset the radio. Registers may be dirty from previous usage. SPIsendCommand(CC1101_CMD_RESET); diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 850df7ac..51432c1a 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -882,6 +882,13 @@ class CC1101: public PhysicalLayer { */ uint8_t random(); + /*! + \brief Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working. + + \returns Version register contents or \ref status_codes + */ + int16_t getChipVersion(); + #ifndef RADIOLIB_GODMODE private: #endif From 4c62de06cfe1e8aea976cdc82203398d9aba3e30 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 20 Nov 2020 17:52:47 +0100 Subject: [PATCH 406/455] [RF69] Added method to read version register --- src/modules/RF69/RF69.cpp | 8 ++++++-- src/modules/RF69/RF69.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index b47c522e..8ddf23b1 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -18,8 +18,8 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe reset(); // check version register - uint8_t version = _mod->SPIreadRegister(RF69_REG_VERSION); - if(version == 0x24) { + int16_t version = getChipVersion(); + if(version == RF69_CHIP_VERSION) { flagFound = true; } else { #ifdef RADIOLIB_DEBUG @@ -783,6 +783,10 @@ uint8_t RF69::random() { return(randByte); } +int16_t RF69::getChipVersion() { + return(_mod->SPIgetRegValue(RF69_REG_VERSION)); +} + int16_t RF69::config() { int16_t state = ERR_NONE; diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 0c2294a2..e2c1d0a1 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -162,6 +162,9 @@ // RF69_REG_LISTEN_3 #define RF69_LISTEN_COEF_RX 0x20 // 7 0 duration of Rx phase in Listen mode +// RF69_REG_VERSION +#define RF69_CHIP_VERSION 0x24 // 7 0 + // RF69_REG_PA_LEVEL #define RF69_PA0_OFF 0b00000000 // 7 7 PA0 disabled #define RF69_PA0_ON 0b10000000 // 7 7 PA0 enabled (default) @@ -827,6 +830,13 @@ class RF69: public PhysicalLayer { */ uint8_t random(); + /*! + \brief Read version SPI register. Should return RF69_CHIP_VERSION (0x24) if SX127x is connected and working. + + \returns Version register contents or \ref status_codes + */ + int16_t getChipVersion(); + #ifndef RADIOLIB_GODMODE protected: #endif From 3c832171f02afcb02953b73cf784ed8e5e04b049 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 20 Nov 2020 17:52:55 +0100 Subject: [PATCH 407/455] [SX1231] Added method to read version register --- src/modules/SX1231/SX1231.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index d11a19d7..77d19bdc 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -15,7 +15,7 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po uint8_t i = 0; bool flagFound = false; while((i < 10) && !flagFound) { - uint8_t version = _mod->SPIreadRegister(RF69_REG_VERSION); + int16_t version = getChipVersion(); if((version == 0x21) || (version == 0x22) || (version == 0x23)) { flagFound = true; _chipRevision = version; @@ -25,7 +25,7 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po RADIOLIB_DEBUG_PRINT(i + 1); RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RF69_REG_VERSION == ")); - char buffHex[7]; + char buffHex[12]; sprintf(buffHex, "0x%04X", version); RADIOLIB_DEBUG_PRINT(buffHex); RADIOLIB_DEBUG_PRINT(F(", expected 0x0021 / 0x0022 / 0x0023")); From 36afff855dcd41f0e6860c6ffb8b51fa24c50e13 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 20 Nov 2020 17:53:03 +0100 Subject: [PATCH 408/455] [Si443x] Added method to read version register --- src/modules/Si443x/Si443x.cpp | 10 +++++++--- src/modules/Si443x/Si443x.h | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 0e6d695a..4a424d69 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -572,6 +572,10 @@ uint8_t Si443x::random() { return(randByte); } +int16_t Si443x::getChipVersion() { + return(_mod->SPIgetRegValue(SI443X_REG_DEVICE_VERSION)); +} + int16_t Si443x::setFrequencyRaw(float newFreq) { // set mode to standby int16_t state = standby(); @@ -605,7 +609,7 @@ bool Si443x::findChip() { reset(); // check version register - uint8_t version = _mod->SPIreadRegister(SI443X_REG_DEVICE_VERSION); + int16_t version = getChipVersion(); if(version == SI443X_DEVICE_VERSION) { flagFound = true; } else { @@ -614,8 +618,8 @@ bool Si443x::findChip() { RADIOLIB_DEBUG_PRINT(i + 1); RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SI443X_REG_DEVICE_VERSION == ")); - char buffHex[5]; - sprintf(buffHex, "0x%02X", version); + char buffHex[12]; + sprintf(buffHex, "0x%04X", version); RADIOLIB_DEBUG_PRINT(buffHex); RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); RADIOLIB_DEBUG_PRINTLN(SI443X_DEVICE_VERSION, HEX); diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 9064d4ca..f187d291 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -792,6 +792,13 @@ class Si443x: public PhysicalLayer { */ uint8_t random(); + /*! + \brief Read version SPI register. Should return SI443X_DEVICE_VERSION (0x06) if Si443x is connected and working. + + \returns Version register contents or \ref status_codes + */ + int16_t getChipVersion(); + #ifndef RADIOLIB_GODMODE protected: #endif From 8e3d89c4f5fa9ae9c97f19bc5eeed7cefc32e5dd Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 20 Nov 2020 18:40:16 +0100 Subject: [PATCH 409/455] Bump version to 4.0.6 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index b66c4b9d..b77acb04 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=4.0.5 +version=4.0.6 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 9a518d9d..68fb351e 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -369,7 +369,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) #define RADIOLIB_VERSION_MINOR (0x00) -#define RADIOLIB_VERSION_PATCH (0x05) +#define RADIOLIB_VERSION_PATCH (0x06) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From f670cc33619c21af6e50b3465b20b806c3df1dd5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 11:46:33 +0100 Subject: [PATCH 410/455] Changed structure of extras folder --- ...iThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4.bin | Bin .../AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4.bin | Bin extras/{ => template}/ModuleTemplate.cpp | 0 extras/{ => template}/ModuleTemplate.h | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename extras/{ => bin}/AiThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4.bin (100%) rename extras/{ => bin}/AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4.bin (100%) rename extras/{ => template}/ModuleTemplate.cpp (100%) rename extras/{ => template}/ModuleTemplate.h (100%) diff --git a/extras/AiThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4.bin b/extras/bin/AiThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4.bin similarity index 100% rename from extras/AiThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4.bin rename to extras/bin/AiThinker_ESP8266_DIO_32M_32M_20160615_V1.5.4.bin diff --git a/extras/AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4.bin b/extras/bin/AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4.bin similarity index 100% rename from extras/AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4.bin rename to extras/bin/AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4.bin diff --git a/extras/ModuleTemplate.cpp b/extras/template/ModuleTemplate.cpp similarity index 100% rename from extras/ModuleTemplate.cpp rename to extras/template/ModuleTemplate.cpp diff --git a/extras/ModuleTemplate.h b/extras/template/ModuleTemplate.h similarity index 100% rename from extras/ModuleTemplate.h rename to extras/template/ModuleTemplate.h From 61f4fb5190edcbc12571d94d6889c6152dc4f09f Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 11:48:17 +0100 Subject: [PATCH 411/455] Update gitignore --- .gitignore | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 3f9ff239..591da307 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,10 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - # Arduino Library Development file .development -# Arduino testing sketches -examples/test/ - # Atom *.tags *.tags1 + +# Debug decoder +extras/decoder/log.txt +extras/decoder/out.txt From eea595a5ae4ea45b0aa34e93ba08d7b792f584bc Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 11:48:35 +0100 Subject: [PATCH 412/455] Added debug decoder script --- extras/decoder/DebugDecoder.py | 103 +++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 extras/decoder/DebugDecoder.py diff --git a/extras/decoder/DebugDecoder.py b/extras/decoder/DebugDecoder.py new file mode 100644 index 00000000..5e19ae30 --- /dev/null +++ b/extras/decoder/DebugDecoder.py @@ -0,0 +1,103 @@ +import re, sys, argparse +from pathlib import Path +from argparse import RawTextHelpFormatter + + +def get_macro_name(value, macros): + for macro in macros: + if macro[1] == value: + return macro[0] + return 'UNKNOWN_VALUE' + + +def get_macro_value(value): + return ' 0x{0:02X}\n'.format(int(value, 16)) + + +parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter, description=''' + RadioLib debug output decoder script. Turns RadioLib Serial dumps into readable text. + + Step-by-step guid on how to use the decoder: + 1. Uncomment lines 312 (#define RADIOLIB_DEBUG) and 313 (#define RADIOLIB_VERBOSE) in RadioLib/src/BuildOpt.h + 2. Recompile and upload the failing Arduino sketch + 3. Open Arduino IDE Serial Monitor and enable timestamps + 4. Copy the Serial output and save it into a .txt file + 5. Run this script + + Output will be saved in the file specified by --out and printed to the terminal +''') +parser.add_argument('file', metavar='file', type=str, help='Text file of the debug output') +parser.add_argument('--out', metavar='out', default='./out.txt', type=str, help='Where to save the decoded file (defaults to ./out.txt)') +args = parser.parse_args() + +# open the log file +log = open(args.file, 'r').readlines() + +# find modules that are in use +used_modules = [] +pattern_module = re.compile('(([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?.[0-9]{3} -> )?M\t') +for entry in log: + m = pattern_module.search(entry) + if m != None: + used_modules.append(entry[m.end():].rstrip()) + +# get paths to all relevant header files +header_files = [] +for path in Path('../../src').rglob('*.h'): + for module in used_modules: + if module in path.name: + header_files.append(path) + +# extract names of address macros from the header files +macro_addresses = [] +pattern_define = re.compile('#define \w* +\w*(\n| +\/\/){1}') +for path in header_files: + file = open(path, 'r').readlines() + for line in file: + m = pattern_define.search(line) + if m != None: + s = re.split(' +', m.group().rstrip()) + if (s.__len__() > 1) and ('_REG' in s[1]): + macro_addresses.append([s[1], int(s[2], 0)]) + +''' +# extract names of value macros for each adddress macro +macro_values = [] +for path in header_files: + file = open(path, 'r').readlines() + for line in file: + for module in used_modules: + pattern_addr_macro = re.compile('\/\/ SI443X_REG_\w+'.format(module.capitalize())) +''' + +# parse every line in the log file +out = [] +pattern_debug = re.compile('(([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?.[0-9]{3} -> )?[RWM]\t.+') +for entry in log: + m = pattern_debug.search(entry) + if m != None: + s = re.split('( |\t)+', entry.rstrip()) + cmd_len = int((s.__len__() - 7)/2) + new_entry = s[0] + s[1] + s[2] + s[3] + if s[4] == 'W': + macro_address = int(s[6], 16) + new_entry += 'write {0:>2} 0x{1:02X} {2}\n'.format(cmd_len, macro_address, get_macro_name(macro_address, macro_addresses)) + for i in range(cmd_len): + new_entry += get_macro_value(s[8 + 2*i]); + elif s[4] == 'R': + macro_address = int(s[6], 16) + new_entry += 'read {0:>2} 0x{1:02X} {2}\n'.format(cmd_len, macro_address, get_macro_name(macro_address, macro_addresses)) + for i in range(cmd_len): + new_entry += get_macro_value(s[8 + 2*i]); + elif s[4] == 'M': + new_entry += 'module {}\n'.format(s[6]) + out.append(new_entry) + else: + out.append(entry) + +# write the output file +out_file = open(args.out, 'w') +for line in out: + print(line, end='') + out_file.write(line) +out_file.close() From ea464ce10da5677f3897d8c972fa0f7d68c717e5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:04:00 +0100 Subject: [PATCH 413/455] [Si443x] Update markers for debug decoder --- src/modules/Si443x/Si4430.cpp | 1 + src/modules/Si443x/Si4431.cpp | 1 + src/modules/Si443x/Si4432.cpp | 1 + src/modules/Si443x/Si443x.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/Si443x/Si4430.cpp b/src/modules/Si443x/Si4430.cpp index 778ee9dd..9114ac4b 100644 --- a/src/modules/Si443x/Si4430.cpp +++ b/src/modules/Si443x/Si4430.cpp @@ -9,6 +9,7 @@ int16_t Si4430::begin(float freq, float br, float freqDev, float rxBw, int8_t po // execute common part int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen); RADIOLIB_ASSERT(state); + RADIOLIB_DEBUG_PRINTLN(F("M\tSi4430")); // configure publicly accessible settings state = setFrequency(freq); diff --git a/src/modules/Si443x/Si4431.cpp b/src/modules/Si443x/Si4431.cpp index 88e43396..6f406165 100644 --- a/src/modules/Si443x/Si4431.cpp +++ b/src/modules/Si443x/Si4431.cpp @@ -9,6 +9,7 @@ int16_t Si4431::begin(float freq, float br, float freqDev, float rxBw, int8_t po // execute common part int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen); RADIOLIB_ASSERT(state); + RADIOLIB_DEBUG_PRINTLN(F("M\tSi4431")); // configure publicly accessible settings state = setFrequency(freq); diff --git a/src/modules/Si443x/Si4432.cpp b/src/modules/Si443x/Si4432.cpp index 8037edcf..aef6dc53 100644 --- a/src/modules/Si443x/Si4432.cpp +++ b/src/modules/Si443x/Si4432.cpp @@ -9,6 +9,7 @@ int16_t Si4432::begin(float freq, float br, float freqDev, float rxBw, int8_t po // execute common part int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen); RADIOLIB_ASSERT(state); + RADIOLIB_DEBUG_PRINTLN(F("M\tSi4432")); // configure publicly accessible settings state = setFrequency(freq); diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 4a424d69..fe1d15a6 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -18,7 +18,7 @@ int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen) _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { - RADIOLIB_DEBUG_PRINTLN(F("Found Si443x!")); + RADIOLIB_DEBUG_PRINTLN(F("M\tSi443x")); } // clear POR interrupt @@ -609,7 +609,7 @@ bool Si443x::findChip() { reset(); // check version register - int16_t version = getChipVersion(); + uint8_t version = _mod->SPIreadRegister(SI443X_REG_DEVICE_VERSION); if(version == SI443X_DEVICE_VERSION) { flagFound = true; } else { @@ -618,8 +618,8 @@ bool Si443x::findChip() { RADIOLIB_DEBUG_PRINT(i + 1); RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SI443X_REG_DEVICE_VERSION == ")); - char buffHex[12]; - sprintf(buffHex, "0x%04X", version); + char buffHex[5]; + sprintf(buffHex, "0x%02X", version); RADIOLIB_DEBUG_PRINT(buffHex); RADIOLIB_DEBUG_PRINT(F(", expected 0x00")); RADIOLIB_DEBUG_PRINTLN(SI443X_DEVICE_VERSION, HEX); From dc05904ae4941e6ee2ba284c52f06fdbf5ab1d50 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:04:26 +0100 Subject: [PATCH 414/455] [nRF24] Update markers for debug decoder --- src/modules/nRF24/nRF24.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index e0c4c57d..5ab8b19f 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -25,6 +25,7 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } + RADIOLIB_DEBUG_PRINTLN(F("M\tnRF24")); // configure settings inaccessible by public API int16_t state = config(); From 6bc6777cac500555c626a3c7fc6e9f92e0fc2813 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:04:39 +0100 Subject: [PATCH 415/455] [CC1101] Update markers for debug decoder --- src/modules/CC1101/CC1101.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index b5499504..3892f0d5 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -41,7 +41,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { - RADIOLIB_DEBUG_PRINTLN(F("Found CC1101! (match by CC1101_REG_VERSION == 0x14)")); + RADIOLIB_DEBUG_PRINTLN(F("M\tCC1101")); } // configure settings not accessible by API From ef50f9e1e81d2a5ae75c87570dddf67b760da1b3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:04:47 +0100 Subject: [PATCH 416/455] [RF69] Update markers for debug decoder --- src/modules/RF69/RF69.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 8ddf23b1..c5350fc8 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -43,7 +43,7 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); } else { - RADIOLIB_DEBUG_PRINTLN(F("Found RF69! (match by RF69_REG_VERSION == 0x24)")); + RADIOLIB_DEBUG_PRINTLN(F("M\tRF69")); } // configure settings not accessible by API From 936eb262a117d98a94b39485ee4aa97a3e1bc70b Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:04:57 +0100 Subject: [PATCH 417/455] [RFM9x] Update markers for debug decoder --- src/modules/RFM9x/RFM95.cpp | 2 ++ src/modules/RFM9x/RFM96.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/modules/RFM9x/RFM95.cpp b/src/modules/RFM9x/RFM95.cpp index f2b4a302..b6a84e7e 100644 --- a/src/modules/RFM9x/RFM95.cpp +++ b/src/modules/RFM9x/RFM95.cpp @@ -16,6 +16,8 @@ int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW // some other error return(state); } + RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278")); + RADIOLIB_DEBUG_PRINTLN(F("M\tRFM95")); // configure settings not accessible by API state = config(); diff --git a/src/modules/RFM9x/RFM96.cpp b/src/modules/RFM9x/RFM96.cpp index c2f43f0e..d7854c9f 100644 --- a/src/modules/RFM9x/RFM96.cpp +++ b/src/modules/RFM9x/RFM96.cpp @@ -16,6 +16,8 @@ int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW // some other error return(state); } + RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278")); + RADIOLIB_DEBUG_PRINTLN(F("M\tRFM96")); // configure settings not accessible by API state = config(); From 5e22589e058d315577baf534d7cf5e5cfa3fc795 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:05:04 +0100 Subject: [PATCH 418/455] [SX1231] Update markers for debug decoder --- src/modules/SX1231/SX1231.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX1231/SX1231.cpp b/src/modules/SX1231/SX1231.cpp index 77d19bdc..3148556f 100644 --- a/src/modules/SX1231/SX1231.cpp +++ b/src/modules/SX1231/SX1231.cpp @@ -40,13 +40,13 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po RADIOLIB_DEBUG_PRINTLN(F("No SX1231 found!")); _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); - } else { - RADIOLIB_DEBUG_PRINTLN(F("Found SX1231!")); } + RADIOLIB_DEBUG_PRINTLN(F("M\tSX1231")); // configure settings not accessible by API int16_t state = config(); RADIOLIB_ASSERT(state); + RADIOLIB_DEBUG_PRINTLN(F("M\tRF69")); // configure publicly accessible settings state = setFrequency(freq); From d1cbe133e236ac3a702e5ee5ca8aeaba23fb74cf Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:05:36 +0100 Subject: [PATCH 419/455] [SX126x] Update markers for debug decoder --- src/modules/SX126x/SX126x.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index e01d0b81..63b5ebc8 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -10,6 +10,7 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, uint16 _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); Module::pinMode(_mod->getGpio(), INPUT); + RADIOLIB_DEBUG_PRINTLN(F("M\tSX126x")); // BW in kHz and SF are required in order to calculate LDRO for setModulationParams _bwKhz = bw; @@ -80,6 +81,7 @@ int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleL _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); Module::pinMode(_mod->getGpio(), INPUT); + RADIOLIB_DEBUG_PRINTLN(F("M\tSX126x")); // initialize configuration variables (will be overwritten during public settings configuration) _br = 21333; // 48.0 kbps From b7bf1505949879d70a9c7b2f4ef3868c4d4460e3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:05:42 +0100 Subject: [PATCH 420/455] [SX127x] Update markers for debug decoder --- src/modules/SX127x/SX127x.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 6635b71b..a08b0374 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -16,9 +16,8 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLe RADIOLIB_DEBUG_PRINTLN(F("No SX127x found!")); _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); - } else { - RADIOLIB_DEBUG_PRINTLN(F("Found SX127x!")); } + RADIOLIB_DEBUG_PRINTLN(F("M\tSX127x")); // set mode to standby int16_t state = standby(); @@ -59,9 +58,8 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB RADIOLIB_DEBUG_PRINTLN(F("No SX127x found!")); _mod->term(RADIOLIB_USE_SPI); return(ERR_CHIP_NOT_FOUND); - } else { - RADIOLIB_DEBUG_PRINTLN(F("Found SX127x!")); } + RADIOLIB_DEBUG_PRINTLN(F("M\tSX127x")); // check currently active modem int16_t state; From 721645d384b4ae4cd43973627bf59880be9b719a Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:05:49 +0100 Subject: [PATCH 421/455] [SX128x] Update markers for debug decoder --- src/modules/SX128x/SX128x.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index ed545178..7a4821f5 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -10,6 +10,7 @@ int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, int8_t power _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); Module::pinMode(_mod->getGpio(), INPUT); + RADIOLIB_DEBUG_PRINTLN(F("M\tSX128x")); // initialize LoRa modulation variables _bwKhz = bw; @@ -61,6 +62,7 @@ int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); Module::pinMode(_mod->getGpio(), INPUT); + RADIOLIB_DEBUG_PRINTLN(F("M\tSX128x")); // initialize GFSK modulation variables _brKbps = br; @@ -123,6 +125,7 @@ int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, u _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); Module::pinMode(_mod->getGpio(), INPUT); + RADIOLIB_DEBUG_PRINTLN(F("M\tSX128x")); // initialize BLE modulation variables _brKbps = br; @@ -171,6 +174,7 @@ int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uin _mod->init(RADIOLIB_USE_SPI); Module::pinMode(_mod->getIrq(), INPUT); Module::pinMode(_mod->getGpio(), INPUT); + RADIOLIB_DEBUG_PRINTLN(F("M\tSX128x")); // initialize FLRC modulation variables _brKbps = br; From 2096a811d4230640c6abc92fb19cf060419b7840 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 5 Dec 2020 12:06:12 +0100 Subject: [PATCH 422/455] Added TODO list for debug decoder --- extras/decoder/DebugDecoder.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extras/decoder/DebugDecoder.py b/extras/decoder/DebugDecoder.py index 5e19ae30..330326f6 100644 --- a/extras/decoder/DebugDecoder.py +++ b/extras/decoder/DebugDecoder.py @@ -3,6 +3,15 @@ from pathlib import Path from argparse import RawTextHelpFormatter +''' +TODO list: + 1. Parse macro values (the names of bits in all registers in header file) + 2. Failed SPI write handling + 3. SX126x/SX128x handling + 4. AT handling +''' + + def get_macro_name(value, macros): for macro in macros: if macro[1] == value: From 81135e0ae5ef981c5d19e004562aba3afc2d5ee9 Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 8 Dec 2020 17:31:54 +0100 Subject: [PATCH 423/455] [CC1101] Fixed version register check (#208) --- src/modules/CC1101/CC1101.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 3892f0d5..37d77398 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -753,7 +753,7 @@ uint8_t CC1101::random() { int16_t CC1101::getChipVersion() { - return(_mod->SPIgetRegValue(CC1101_REG_VERSION)); + return(SPIgetRegValue(CC1101_REG_VERSION)); } int16_t CC1101::config() { From 8438aa93ef40d7df9529f9e978564ea6ca2fe6f4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 25 Dec 2020 09:37:06 +0100 Subject: [PATCH 424/455] [SX127x] Fixed incorrect CRC configuration (#217) --- src/modules/SX127x/SX1272.cpp | 4 ++-- src/modules/SX127x/SX1278.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 4cfa2e07..35ff6abe 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -415,12 +415,12 @@ int16_t SX1272::setSpreadingFactorRaw(uint8_t newSpreadingFactor) { // write registers if(newSpreadingFactor == SX127X_SF_6) { - state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_HEADER_IMPL_MODE | SX1272_RX_CRC_MODE_ON, 2, 1); + state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_HEADER_IMPL_MODE | SX127x::_crcEnabled ? SX1272_RX_CRC_MODE_ON : SX1272_RX_CRC_MODE_OFF, 2, 1); state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, SX127X_SF_6 | SX127X_TX_MODE_SINGLE, 7, 3); state |= _mod->SPIsetRegValue(SX127X_REG_DETECT_OPTIMIZE, SX127X_DETECT_OPTIMIZE_SF_6, 2, 0); state |= _mod->SPIsetRegValue(SX127X_REG_DETECTION_THRESHOLD, SX127X_DETECTION_THRESHOLD_SF_6); } else { - state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_HEADER_EXPL_MODE | SX1272_RX_CRC_MODE_ON, 2, 1); + state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_HEADER_EXPL_MODE | SX127x::_crcEnabled ? SX1272_RX_CRC_MODE_ON : SX1272_RX_CRC_MODE_OFF, 2, 1); state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, newSpreadingFactor | SX127X_TX_MODE_SINGLE, 7, 3); state |= _mod->SPIsetRegValue(SX127X_REG_DETECT_OPTIMIZE, SX127X_DETECT_OPTIMIZE_SF_7_12, 2, 0); state |= _mod->SPIsetRegValue(SX127X_REG_DETECTION_THRESHOLD, SX127X_DETECTION_THRESHOLD_SF_7_12); diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index ca0b8fab..1c958e44 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -493,12 +493,12 @@ int16_t SX1278::setSpreadingFactorRaw(uint8_t newSpreadingFactor) { // write registers if(newSpreadingFactor == SX127X_SF_6) { state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1278_HEADER_IMPL_MODE, 0, 0); - state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, SX127X_SF_6 | SX127X_TX_MODE_SINGLE | SX1278_RX_CRC_MODE_ON, 7, 2); + state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, SX127X_SF_6 | SX127X_TX_MODE_SINGLE | SX127x::_crcEnabled ? SX1278_RX_CRC_MODE_ON : SX1278_RX_CRC_MODE_OFF, 7, 2); state |= _mod->SPIsetRegValue(SX127X_REG_DETECT_OPTIMIZE, SX127X_DETECT_OPTIMIZE_SF_6, 2, 0); state |= _mod->SPIsetRegValue(SX127X_REG_DETECTION_THRESHOLD, SX127X_DETECTION_THRESHOLD_SF_6); } else { state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1278_HEADER_EXPL_MODE, 0, 0); - state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, newSpreadingFactor | SX127X_TX_MODE_SINGLE | SX1278_RX_CRC_MODE_ON, 7, 2); + state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, newSpreadingFactor | SX127X_TX_MODE_SINGLE | SX127x::_crcEnabled ? SX1278_RX_CRC_MODE_ON : SX1278_RX_CRC_MODE_OFF, 7, 2); state |= _mod->SPIsetRegValue(SX127X_REG_DETECT_OPTIMIZE, SX127X_DETECT_OPTIMIZE_SF_7_12, 2, 0); state |= _mod->SPIsetRegValue(SX127X_REG_DETECTION_THRESHOLD, SX127X_DETECTION_THRESHOLD_SF_7_12); } From 533131f83f9001742b40d873c96c328c89f524c6 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 25 Dec 2020 14:17:07 +0100 Subject: [PATCH 425/455] Fixed unitialized variable warning --- src/Module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module.cpp b/src/Module.cpp index 2205b326..029d6934 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -219,7 +219,7 @@ int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t // 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 = Module::micros(); - uint8_t readValue; + uint8_t readValue = 0x00; while(Module::micros() - start < (checkInterval * 1000)) { readValue = SPIreadRegister(reg); if(readValue == newValue) { From 65379c477233732a08d856462155deb64aa3ee9d Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 25 Dec 2020 14:21:41 +0100 Subject: [PATCH 426/455] Added support for MegaCoreX --- .github/workflows/main.yml | 5 +++++ src/BuildOpt.h | 15 ++++++++++++++- src/ISerial.cpp | 4 ++++ src/ISerial.h | 9 ++++----- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a68f9450..c4a32fa6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,7 @@ jobs: - SparkFun:apollo3:amap3redboard - STM32:stm32:GenF3 - stm32duino:STM32F1:mapleMini + - MegaCoreX:megaavr:4809 runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -120,6 +121,10 @@ jobs: echo "::set-output name=options:::bootloader_version=original,cpu_speed=speed_72mhz" echo "::set-output name=index-url::--additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json" + elif [[ "${{ contains(matrix.board, 'MegaCoreX:megaavr') }}" == "true" ]]; then + # MegaCoreX + echo "::set-output name=index-url::--additional-urls https://mcudude.github.io/MegaCoreX/package_MCUdude_MegaCoreX_index.json" + fi - name: Install platform diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 68fb351e..6221de31 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -85,7 +85,7 @@ //#define RADIOLIB_EXCLUDE_SSTV #else - #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) + #if 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. #define RADIOLIB_PLATFORM "Arduino AVR" #define RADIOLIB_PIN_TYPE uint8_t @@ -284,6 +284,19 @@ #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(ARDUINO_ARCH_MEGAAVR) + // MegaCoreX by MCUdude (https://github.com/MCUdude/MegaCoreX) + #define RADIOLIB_PLATFORM "MegaCoreX" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) + #else // other platforms not covered by the above list - this may or may not work #define RADIOLIB_PLATFORM "Unknown" diff --git a/src/ISerial.cpp b/src/ISerial.cpp index 650cfb06..7822e5c2 100644 --- a/src/ISerial.cpp +++ b/src/ISerial.cpp @@ -33,9 +33,11 @@ void ISerial::flush() { _mod->ModuleSerial->flush(); } +#ifndef ARDUINO_ARCH_MEGAAVR size_t ISerial::print(const __FlashStringHelper *ifsh) { return(_mod->ModuleSerial->print(ifsh)); } +#endif size_t ISerial::print(const String &s) { return(_mod->ModuleSerial->print(s)); @@ -77,9 +79,11 @@ size_t ISerial::print(const Printable& x) { return(_mod->ModuleSerial->print(x)); } +#ifndef ARDUINO_ARCH_MEGAAVR size_t ISerial::println(const __FlashStringHelper *ifsh) { return(_mod->ModuleSerial->println(ifsh)); } +#endif size_t ISerial::println(const String &s) { return(_mod->ModuleSerial->println(s)); diff --git a/src/ISerial.h b/src/ISerial.h index 0029234e..d34ff09d 100644 --- a/src/ISerial.h +++ b/src/ISerial.h @@ -3,11 +3,6 @@ #include "Module.h" -#include - -#include "WString.h" -#include "Printable.h" - /*! \class ISerial @@ -25,7 +20,9 @@ class ISerial { int available(); void flush(); + #ifndef ARDUINO_ARCH_MEGAAVR size_t print(const __FlashStringHelper *); + #endif size_t print(const String &); size_t print(const char[]); size_t print(char); @@ -37,7 +34,9 @@ class ISerial { size_t print(double, int = 2); size_t print(const Printable&); + #ifndef ARDUINO_ARCH_MEGAAVR size_t println(const __FlashStringHelper *); + #endif size_t println(const String &s); size_t println(const char[]); size_t println(char); From 073fca8e827998cb03f9d8f1e5bc20702f5274c7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 25 Dec 2020 14:24:10 +0100 Subject: [PATCH 427/455] Update readme for MegaCoreX (MegaCoreX:megaavr:4809) --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 17c48207..08c28fa7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x * [__STM32__ (official core)](https://github.com/stm32duino/Arduino_Core_STM32) - STM32 Nucleo, Discovery, Maple, BluePill, BlackPill etc. * [__STM32__ (unofficial core)](https://github.com/rogerclarkmelbourne/Arduino_STM32) - STM32F1 and STM32F4-based boards +* __MCUdude__ + * [__MegaCoreX__](https://github.com/MCUdude/MegaCoreX) - megaAVR-0 series (ATmega4809, ATmega3209 etc.) + The list above is by no means exhaustive. Most of RadioLib code is independent of the used platform, so as long as your board is running some Arduino-compatible core, RadioLib should work. Compilation of all examples is tested for all platforms prior to releasing new version. ### In development: From 8ad7d1be4555bd830d81bcd3d0f8b8af713b1b9d Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 29 Dec 2020 08:41:22 +0100 Subject: [PATCH 428/455] [CC1101] Clarify ternary operator priority --- src/modules/CC1101/CC1101.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 37d77398..1373c0ca 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -630,23 +630,20 @@ int16_t CC1101::variablePacketLengthMode(uint8_t maxLen) { } int16_t CC1101::enableSyncWordFiltering(uint8_t maxErrBits, bool requireCarrierSense) { - switch (maxErrBits){ + switch(maxErrBits){ case 0: // in 16 bit sync word, expect all 16 bits - return (SPIsetRegValue(CC1101_REG_MDMCFG2, - requireCarrierSense ? CC1101_SYNC_MODE_16_16_THR : CC1101_SYNC_MODE_16_16, 2, 0)); + return(SPIsetRegValue(CC1101_REG_MDMCFG2, (requireCarrierSense ? CC1101_SYNC_MODE_16_16_THR : CC1101_SYNC_MODE_16_16), 2, 0)); case 1: // in 16 bit sync word, expect at least 15 bits - return (SPIsetRegValue(CC1101_REG_MDMCFG2, - requireCarrierSense ? CC1101_SYNC_MODE_15_16_THR : CC1101_SYNC_MODE_15_16, 2, 0)); + return(SPIsetRegValue(CC1101_REG_MDMCFG2, (requireCarrierSense ? CC1101_SYNC_MODE_15_16_THR : CC1101_SYNC_MODE_15_16), 2, 0)); default: - return (ERR_INVALID_SYNC_WORD); + return(ERR_INVALID_SYNC_WORD); } } int16_t CC1101::disableSyncWordFiltering(bool requireCarrierSense) { - return(SPIsetRegValue(CC1101_REG_MDMCFG2, - requireCarrierSense ? CC1101_SYNC_MODE_NONE_THR : CC1101_SYNC_MODE_NONE, 2, 0)); + return(SPIsetRegValue(CC1101_REG_MDMCFG2, (requireCarrierSense ? CC1101_SYNC_MODE_NONE_THR : CC1101_SYNC_MODE_NONE), 2, 0)); } int16_t CC1101::setCrcFiltering(bool crcOn) { From 1dcb873f22b9e38f50b2e71e7bf0dd23c4a3822f Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 29 Dec 2020 08:41:31 +0100 Subject: [PATCH 429/455] [nRF24] Clarify ternary operator priority --- src/modules/nRF24/nRF24.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index 5ab8b19f..a251ca17 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -458,32 +458,32 @@ int16_t nRF24::setCrcFiltering(bool crcOn) { } // Disable CRC - return _mod->SPIsetRegValue(NRF24_REG_CONFIG, crcOn ? NRF24_CRC_ON : NRF24_CRC_OFF, 3, 3); + return _mod->SPIsetRegValue(NRF24_REG_CONFIG, (crcOn ? NRF24_CRC_ON : NRF24_CRC_OFF), 3, 3); } int16_t nRF24::setAutoAck(bool autoAckOn){ - return _mod->SPIsetRegValue(NRF24_REG_EN_AA, autoAckOn ? NRF24_AA_ALL_ON : NRF24_AA_ALL_OFF, 5, 0); + return _mod->SPIsetRegValue(NRF24_REG_EN_AA, (autoAckOn ? NRF24_AA_ALL_ON : NRF24_AA_ALL_OFF), 5, 0); } int16_t nRF24::setAutoAck(uint8_t pipeNum, bool autoAckOn){ switch(pipeNum) { case 0: - return _mod->SPIsetRegValue(NRF24_REG_EN_AA, autoAckOn ? NRF24_AA_P0_ON : NRF24_AA_P0_OFF, 0, 0); + return _mod->SPIsetRegValue(NRF24_REG_EN_AA, (autoAckOn ? NRF24_AA_P0_ON : NRF24_AA_P0_OFF), 0, 0); break; case 1: - return _mod->SPIsetRegValue(NRF24_REG_EN_AA, autoAckOn ? NRF24_AA_P1_ON : NRF24_AA_P1_OFF, 1, 1); + return _mod->SPIsetRegValue(NRF24_REG_EN_AA, (autoAckOn ? NRF24_AA_P1_ON : NRF24_AA_P1_OFF), 1, 1); break; case 2: - return _mod->SPIsetRegValue(NRF24_REG_EN_AA, autoAckOn ? NRF24_AA_P2_ON : NRF24_AA_P2_OFF, 2, 2); + return _mod->SPIsetRegValue(NRF24_REG_EN_AA, (autoAckOn ? NRF24_AA_P2_ON : NRF24_AA_P2_OFF), 2, 2); break; case 3: - return _mod->SPIsetRegValue(NRF24_REG_EN_AA, autoAckOn ? NRF24_AA_P3_ON : NRF24_AA_P3_OFF, 3, 3); + return _mod->SPIsetRegValue(NRF24_REG_EN_AA, (autoAckOn ? NRF24_AA_P3_ON : NRF24_AA_P3_OFF), 3, 3); break; case 4: - return _mod->SPIsetRegValue(NRF24_REG_EN_AA, autoAckOn ? NRF24_AA_P4_ON : NRF24_AA_P4_OFF, 4, 4); + return _mod->SPIsetRegValue(NRF24_REG_EN_AA, (autoAckOn ? NRF24_AA_P4_ON : NRF24_AA_P4_OFF), 4, 4); break; case 5: - return _mod->SPIsetRegValue(NRF24_REG_EN_AA, autoAckOn ? NRF24_AA_P5_ON : NRF24_AA_P5_OFF, 5, 5); + return _mod->SPIsetRegValue(NRF24_REG_EN_AA, (autoAckOn ? NRF24_AA_P5_ON : NRF24_AA_P5_OFF), 5, 5); break; default: return (ERR_INVALID_PIPE_NUMBER); From c63c8f376f88b93e324a5239b4cd1e5cef779ebd Mon Sep 17 00:00:00 2001 From: jgromes Date: Tue, 29 Dec 2020 08:41:48 +0100 Subject: [PATCH 430/455] [SX127x] Clarify ternary operator priority (#217) --- src/modules/SX127x/SX1272.cpp | 4 ++-- src/modules/SX127x/SX1278.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 35ff6abe..e4c0bb60 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -415,12 +415,12 @@ int16_t SX1272::setSpreadingFactorRaw(uint8_t newSpreadingFactor) { // write registers if(newSpreadingFactor == SX127X_SF_6) { - state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_HEADER_IMPL_MODE | SX127x::_crcEnabled ? SX1272_RX_CRC_MODE_ON : SX1272_RX_CRC_MODE_OFF, 2, 1); + state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_HEADER_IMPL_MODE | (SX127x::_crcEnabled ? SX1272_RX_CRC_MODE_ON : SX1272_RX_CRC_MODE_OFF), 2, 1); state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, SX127X_SF_6 | SX127X_TX_MODE_SINGLE, 7, 3); state |= _mod->SPIsetRegValue(SX127X_REG_DETECT_OPTIMIZE, SX127X_DETECT_OPTIMIZE_SF_6, 2, 0); state |= _mod->SPIsetRegValue(SX127X_REG_DETECTION_THRESHOLD, SX127X_DETECTION_THRESHOLD_SF_6); } else { - state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_HEADER_EXPL_MODE | SX127x::_crcEnabled ? SX1272_RX_CRC_MODE_ON : SX1272_RX_CRC_MODE_OFF, 2, 1); + state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1272_HEADER_EXPL_MODE | (SX127x::_crcEnabled ? SX1272_RX_CRC_MODE_ON : SX1272_RX_CRC_MODE_OFF), 2, 1); state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, newSpreadingFactor | SX127X_TX_MODE_SINGLE, 7, 3); state |= _mod->SPIsetRegValue(SX127X_REG_DETECT_OPTIMIZE, SX127X_DETECT_OPTIMIZE_SF_7_12, 2, 0); state |= _mod->SPIsetRegValue(SX127X_REG_DETECTION_THRESHOLD, SX127X_DETECTION_THRESHOLD_SF_7_12); diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 1c958e44..906c4e07 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -493,12 +493,12 @@ int16_t SX1278::setSpreadingFactorRaw(uint8_t newSpreadingFactor) { // write registers if(newSpreadingFactor == SX127X_SF_6) { state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1278_HEADER_IMPL_MODE, 0, 0); - state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, SX127X_SF_6 | SX127X_TX_MODE_SINGLE | SX127x::_crcEnabled ? SX1278_RX_CRC_MODE_ON : SX1278_RX_CRC_MODE_OFF, 7, 2); + state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, SX127X_SF_6 | SX127X_TX_MODE_SINGLE | (SX127x::_crcEnabled ? SX1278_RX_CRC_MODE_ON : SX1278_RX_CRC_MODE_OFF), 7, 2); state |= _mod->SPIsetRegValue(SX127X_REG_DETECT_OPTIMIZE, SX127X_DETECT_OPTIMIZE_SF_6, 2, 0); state |= _mod->SPIsetRegValue(SX127X_REG_DETECTION_THRESHOLD, SX127X_DETECTION_THRESHOLD_SF_6); } else { state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_1, SX1278_HEADER_EXPL_MODE, 0, 0); - state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, newSpreadingFactor | SX127X_TX_MODE_SINGLE | SX127x::_crcEnabled ? SX1278_RX_CRC_MODE_ON : SX1278_RX_CRC_MODE_OFF, 7, 2); + state |= _mod->SPIsetRegValue(SX127X_REG_MODEM_CONFIG_2, newSpreadingFactor | SX127X_TX_MODE_SINGLE | (SX127x::_crcEnabled ? SX1278_RX_CRC_MODE_ON : SX1278_RX_CRC_MODE_OFF), 7, 2); state |= _mod->SPIsetRegValue(SX127X_REG_DETECT_OPTIMIZE, SX127X_DETECT_OPTIMIZE_SF_7_12, 2, 0); state |= _mod->SPIsetRegValue(SX127X_REG_DETECTION_THRESHOLD, SX127X_DETECTION_THRESHOLD_SF_7_12); } From b0af8cf8192c86e99450ff061b45cfd679ec7371 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 2 Jan 2021 17:25:42 +0100 Subject: [PATCH 431/455] Bump version to 4.1.0 --- library.properties | 2 +- src/BuildOpt.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.properties b/library.properties index b77acb04..474e24b0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=4.0.6 +version=4.1.0 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 6221de31..fdb6bc20 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -381,8 +381,8 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) -#define RADIOLIB_VERSION_MINOR (0x00) -#define RADIOLIB_VERSION_PATCH (0x06) +#define RADIOLIB_VERSION_MINOR (0x01) +#define RADIOLIB_VERSION_PATCH (0x00) #define RADIOLIB_VERSION_EXTRA (0x00) #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA)) From 7a0601da14b6a488433bb8f345d3e10cc744084b Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 2 Jan 2021 17:31:40 +0100 Subject: [PATCH 432/455] [CI] Removed duplicate Arduino Zero build --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c4a32fa6..390adf54 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,6 @@ jobs: - arduino:megaavr:uno2018 - arduino:sam:arduino_due_x - arduino:samd:arduino_zero_native - - arduino:samd:arduino_zero_native - adafruit:samd:adafruit_feather_m0 - adafruit:nrf52:feather52832 - esp32:esp32:esp32 From 22975cbcee32cebf626273d715854bd1e81e21d8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 2 Jan 2021 17:41:13 +0100 Subject: [PATCH 433/455] Create separate Arduino SAMD platform (SAMD core >= 1.8.11) CI_BUILD_ALL --- src/BuildOpt.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index fdb6bc20..91f1fe87 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -148,9 +148,24 @@ #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(ARDUINO_ARCH_SAMD) + // Arduino SAMD (Zero, MKR, etc.) + #define RADIOLIB_PLATFORM "Arduino SAMD" + #define RADIOLIB_PIN_TYPE pin_size_t + #define RADIOLIB_PIN_MODE PinMode + #define RADIOLIB_PIN_STATUS PinStatus + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(SAMD_SERIES) - // Arduino SAMD (Zero, MKR, etc.) and Adafruit SAMD boards (M0 and M4) - #define RADIOLIB_PLATFORM "Arduino/Adafruit SAMD" + // Adafruit SAMD boards (M0 and M4) + #define RADIOLIB_PLATFORM "Adafruit SAMD" #define RADIOLIB_PIN_TYPE uint32_t #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t From 2f68d38f35d61200d3a50e2dd39ef918933eef86 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 2 Jan 2021 17:44:21 +0100 Subject: [PATCH 434/455] Swap Arduino and Adafruit SAMD detection order --- src/BuildOpt.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 91f1fe87..096e9676 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -148,21 +148,6 @@ #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - #elif defined(ARDUINO_ARCH_SAMD) - // Arduino SAMD (Zero, MKR, etc.) - #define RADIOLIB_PLATFORM "Arduino SAMD" - #define RADIOLIB_PIN_TYPE pin_size_t - #define RADIOLIB_PIN_MODE PinMode - #define RADIOLIB_PIN_STATUS PinStatus - #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) - #define RADIOLIB_NC (0xFF) - #define RADIOLIB_DEFAULT_SPI SPI - #define RADIOLIB_PROGMEM PROGMEM - #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) - #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 - #elif defined(SAMD_SERIES) // Adafruit SAMD boards (M0 and M4) #define RADIOLIB_PLATFORM "Adafruit SAMD" @@ -178,6 +163,21 @@ #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(ARDUINO_ARCH_SAMD) + // Arduino SAMD (Zero, MKR, etc.) + #define RADIOLIB_PLATFORM "Arduino SAMD" + #define RADIOLIB_PIN_TYPE pin_size_t + #define RADIOLIB_PIN_MODE PinMode + #define RADIOLIB_PIN_STATUS PinStatus + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) + #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED + #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(__SAM3X8E__) // Arduino Due #define RADIOLIB_PLATFORM "Arduino Due" From 6061145ae6ada52f55a2c85f623811b140d88919 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 2 Jan 2021 17:46:45 +0100 Subject: [PATCH 435/455] Force CI build CI_BUILD_ALL --- src/BuildOpt.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 096e9676..6c208a28 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -393,7 +393,6 @@ */ #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } } - // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) #define RADIOLIB_VERSION_MINOR (0x01) From 0b835f9fcf1af1d8eab55605cb0bd94d5a221ae5 Mon Sep 17 00:00:00 2001 From: Kihun Song Date: Thu, 4 Feb 2021 14:27:23 +0900 Subject: [PATCH 436/455] Added getRSSIInst command for SX126x --- src/modules/SX126x/SX126x.cpp | 7 +++++++ src/modules/SX126x/SX126x.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 63b5ebc8..db491cdf 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1130,6 +1130,13 @@ uint32_t SX126x::getTimeOnAir(size_t len) { } } +uint8_t SX126x::getRSSIInst() { + uint8_t data[3] = {0, 0, 0}; // RssiInst, Status, RFU + SPIreadCommand(SX126X_CMD_GET_RSSI_INST, data, 3); + + return data[0]; +} + int16_t SX126x::implicitHeader(size_t len) { return(setHeaderType(SX126X_LORA_HEADER_IMPLICIT, len)); } diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 46b510f8..b0c50b79 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -806,6 +806,13 @@ class SX126x: public PhysicalLayer { */ uint32_t getTimeOnAir(size_t len); + /*! + \brief Get instantaneous RSSI value in FSK mode. Can be used for LBT implementation, checking for interference before transmitting. + + \returns Instantaneous RSSI value in (-2)*dBm + */ + uint8_t getRSSIInst(); + /*! \brief Set implicit header mode for future reception/transmission. From 318ac691d01d7ac7d74c022a9f8b5fd001fdcaa2 Mon Sep 17 00:00:00 2001 From: Kihun Song Date: Thu, 4 Feb 2021 14:59:32 +0900 Subject: [PATCH 437/455] comments --- src/modules/SX126x/SX126x.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index b0c50b79..16a955a5 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -807,9 +807,9 @@ class SX126x: public PhysicalLayer { uint32_t getTimeOnAir(size_t len); /*! - \brief Get instantaneous RSSI value in FSK mode. Can be used for LBT implementation, checking for interference before transmitting. + \brief Get instantaneous RSSI value during recption of the packet. Should switch to FSK receive mode for LBT implementation. - \returns Instantaneous RSSI value in (-2)*dBm + \returns Instantaneous RSSI value in (-2)*dBm. */ uint8_t getRSSIInst(); From 9e4f8977018e4e4fcf946c104d9eaa611e1515ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Thu, 4 Feb 2021 08:30:27 +0100 Subject: [PATCH 438/455] Added separate doxygen workflow --- .github/workflows/doxygen.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/doxygen.yml diff --git a/.github/workflows/doxygen.yml b/.github/workflows/doxygen.yml new file mode 100644 index 00000000..ae645667 --- /dev/null +++ b/.github/workflows/doxygen.yml @@ -0,0 +1,26 @@ +name: Doxygen + +on: + push: + branches: [ master ] + workflow_dispatch: + +jobs: + doxygen: + runs-on: ubuntu-latest + steps: + - name: Install Doxygen + run: | + sudo apt-get update + sudo apt-get install -y doxygen + - uses: actions/checkout@v2 + + - name: Generate docs + run: doxygen Doxyfile + + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: docs/html From 8a209472f3a2b9a5a1ca0ff49b538cb7c6448e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grome=C5=A1?= Date: Thu, 4 Feb 2021 08:31:49 +0100 Subject: [PATCH 439/455] Removed doxygen job from CI --- .github/workflows/main.yml | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 390adf54..16339ea2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,7 @@ on: branches: [ master ] pull_request: branches: [ master ] + workflow_dispatch: jobs: @@ -158,23 +159,3 @@ jobs: fi fi done - - doxygen: - runs-on: ubuntu-latest - steps: - - name: Install Doxygen - run: | - sudo apt-get update - sudo apt-get install -y doxygen - - - uses: actions/checkout@v2 - - - name: Generate docs - run: doxygen Doxyfile - - - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@releases/v3 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: docs/html From d6330cfe443cefa67899065bb1b803b629e07300 Mon Sep 17 00:00:00 2001 From: Kihun Song Date: Thu, 4 Feb 2021 16:51:05 +0900 Subject: [PATCH 440/455] Convert arbitrary unit to dBm --- src/modules/SX126x/SX126x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index db491cdf..cbe356fb 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1130,11 +1130,11 @@ uint32_t SX126x::getTimeOnAir(size_t len) { } } -uint8_t SX126x::getRSSIInst() { +float SX126x::getRSSIInst() { uint8_t data[3] = {0, 0, 0}; // RssiInst, Status, RFU SPIreadCommand(SX126X_CMD_GET_RSSI_INST, data, 3); - return data[0]; + return (float)data[0] / (-2.0); } int16_t SX126x::implicitHeader(size_t len) { From 07cc802f9b0bc223450cc376b5d0d313a93d9230 Mon Sep 17 00:00:00 2001 From: Kihun Song Date: Thu, 4 Feb 2021 17:02:52 +0900 Subject: [PATCH 441/455] Convert arbitrary unit to dBm --- src/modules/SX126x/SX126x.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 16a955a5..ee99a27f 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -809,9 +809,9 @@ class SX126x: public PhysicalLayer { /*! \brief Get instantaneous RSSI value during recption of the packet. Should switch to FSK receive mode for LBT implementation. - \returns Instantaneous RSSI value in (-2)*dBm. + \returns Instantaneous RSSI value in dBm, in steps of 0.5dBm */ - uint8_t getRSSIInst(); + float getRSSIInst(); /*! \brief Set implicit header mode for future reception/transmission. From 4a5e48962e2644e5704e079ed1c34cd8529cf2f3 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 19:58:31 +0100 Subject: [PATCH 442/455] Updated Apollo3 platform definition (#239) --- src/BuildOpt.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 6c208a28..99547b43 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -233,12 +233,12 @@ #define RADIOLIB_PROGMEM PROGMEM #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) - #elif defined(AM_PART_APOLLO3) - // Sparkfun Artemis boards - #define RADIOLIB_PLATFORM "Sparkfun Artemis" - #define RADIOLIB_PIN_TYPE uint8_t - #define RADIOLIB_PIN_MODE uint8_t - #define RADIOLIB_PIN_STATUS uint8_t + #elif defined(ARDUINO_ARCH_APOLLO3) + // Sparkfun Apollo3 boards + #define RADIOLIB_PLATFORM "Sparkfun Apollo3" + #define RADIOLIB_PIN_TYPE pin_size_t + #define RADIOLIB_PIN_MODE Arduino_PinMode + #define RADIOLIB_PIN_STATUS PinStatus #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFF) @@ -248,6 +248,9 @@ #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + // Apollo3 uses mbed libraries, which already contain ESP8266 driver + #define RADIOLIB_EXCLUDE_ESP8266 + #elif defined(ARDUINO_ARDUINO_NANO33BLE) // Arduino Nano 33 BLE #define RADIOLIB_PLATFORM "Arduino Nano 33 BLE" From a9fecdb181f9841b5eb2fd34f95b300d6270dbad Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 19:59:50 +0100 Subject: [PATCH 443/455] Updated CI workflow (SparkFun:apollo3:sfe_artemis) --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16339ea2..7ec52c01 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: - esp32:esp32:esp32 - esp8266:esp8266:generic - Intel:arc32:arduino_101 - - SparkFun:apollo3:amap3redboard + - SparkFun:apollo3:sfe_artemis - STM32:stm32:GenF3 - stm32duino:STM32F1:mapleMini - MegaCoreX:megaavr:4809 From 098e611eae99a59e07afd4e7bd7f41dbcf3e1d2a Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 20:02:54 +0100 Subject: [PATCH 444/455] Updated SparkFun Apollo3 core (SparkFun:apollo3:sfe_artemis) --- .github/workflows/main.yml | 2 +- examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino | 1 + .../Si443x/Si443x_Receive/Si443x_Receive.ino | 2 +- .../Si443x_Receive_Interrupt.ino | 12 +- .../Si443x_Transmit/Si443x_Transmit.ino | 3 +- src/modules/AX5243/AX5243.cpp | 12 + src/modules/AX5243/AX5243.h | 263 ++++++++++++++++++ src/modules/Si443x/Si443x.cpp | 17 +- 8 files changed, 301 insertions(+), 11 deletions(-) create mode 100644 src/modules/AX5243/AX5243.cpp create mode 100644 src/modules/AX5243/AX5243.h diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ec52c01..445282cd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -108,7 +108,7 @@ jobs: elif [[ "${{ contains(matrix.board, 'SparkFun:apollo3') }}" == "true" ]]; then # SparkFun Apollo - echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" + echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json" echo "::set-output name=warnings::'none'" elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then diff --git a/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino b/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino index 80c3c67f..32f0a18f 100644 --- a/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino +++ b/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino @@ -40,6 +40,7 @@ RTTYClient rtty(&radio); void setup() { Serial.begin(9600); + while(!Serial); // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); diff --git a/examples/Si443x/Si443x_Receive/Si443x_Receive.ino b/examples/Si443x/Si443x_Receive/Si443x_Receive.ino index 846e46e3..5265ffff 100644 --- a/examples/Si443x/Si443x_Receive/Si443x_Receive.ino +++ b/examples/Si443x/Si443x_Receive/Si443x_Receive.ino @@ -25,7 +25,7 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 radio = new Module(10, 2, 9); +Si4432 radio = new Module(D8, D2, D0); // or using RadioShield // https://github.com/jgromes/RadioShield diff --git a/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino b/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino index e890b08d..dc5fb89c 100644 --- a/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino +++ b/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino @@ -21,14 +21,14 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 radio = new Module(10, 2, 9); +Si4432 radio = new Module(D8, D2, D0); // or using RadioShield // https://github.com/jgromes/RadioShield //Si4432 radio = RadioShield.ModuleA; void setup() { - Serial.begin(9600); + Serial.begin(115200); // initialize Si4432 with default settings Serial.print(F("[Si4432] Initializing ... ")); @@ -76,7 +76,7 @@ volatile bool enableInterrupt = true; // is received by the module // IMPORTANT: this function MUST be 'void' type // and MUST NOT have any arguments! -void setFlag(void) { +IRAM_ATTR void setFlag(void) { // check if the interrupt is enabled if(!enableInterrupt) { return; @@ -87,6 +87,12 @@ void setFlag(void) { } void loop() { + Serial.print(radio._mod->SPIreadRegister(SI443X_REG_DEVICE_STATUS), HEX); + Serial.print('\t'); + Serial.print(radio._mod->SPIreadRegister(SI443X_REG_INTERRUPT_STATUS_1), HEX); + Serial.print('\t'); + Serial.println(radio._mod->SPIreadRegister(SI443X_REG_INTERRUPT_STATUS_2), HEX); + // check if the flag is set if(receivedFlag) { // disable the interrupt service routine while diff --git a/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino b/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino index ca267624..4aec648d 100644 --- a/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino +++ b/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino @@ -23,7 +23,8 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 radio = new Module(10, 2, 9); +//Si4432 radio = new Module(5, 26, 25); +Si4432 radio = new Module(D8, D2, D0); // or using RadioShield // https://github.com/jgromes/RadioShield diff --git a/src/modules/AX5243/AX5243.cpp b/src/modules/AX5243/AX5243.cpp new file mode 100644 index 00000000..cbafa5ef --- /dev/null +++ b/src/modules/AX5243/AX5243.cpp @@ -0,0 +1,12 @@ +#include "AX5243.h" +#if !defined(RADIOLIB_EXCLUDE_AX5243) + +AX5243::AX5243(Module* module) : PhysicalLayer(AX5243_FREQUENCY_STEP_SIZE, AX5243_MAX_PACKET_LENGTH) { + _mod = module; +} + +int16_t AX5243::begin() { + return(ERR_NONE); +} + +#endif diff --git a/src/modules/AX5243/AX5243.h b/src/modules/AX5243/AX5243.h new file mode 100644 index 00000000..985d4108 --- /dev/null +++ b/src/modules/AX5243/AX5243.h @@ -0,0 +1,263 @@ +#if !defined(_RADIOLIB_AX5243_H) && !defined(RADIOLIB_EXCLUDE_AX5243) +#define _RADIOLIB_AX5243_H + +#include "../../TypeDef.h" +#include "../../Module.h" + +#include "../../protocols/PhysicalLayer/PhysicalLayer.h" + +// AX5243 physical layer properties +#define AX5243_FREQUENCY_STEP_SIZE (0.98) +#define AX5243_MAX_PACKET_LENGTH (256) + +// AX5243 register map +#define AX5243_REG_REVISION (0x0000) +#define AX5243_REG_SCRATCH (0x0001) +#define AX5243_REG_PWR_MODE (0x0002) +#define AX5243_REG_POW_STAT (0x0003) +#define AX5243_REG_POW_STICKY_STAT (0x0004) +#define AX5243_REG_POW_IRQ_MASK (0x0005) +#define AX5243_REG_IRQ_MASK_1 (0x0006) +#define AX5243_REG_IRQ_MASK_0 (0x0007) +#define AX5243_REG_RADIO_EVENTS_MASK_1 (0x0008) +#define AX5243_REG_RADIO_EVENTS_MASK_0 (0x0009) +#define AX5243_REG_IRQ_INVERSION_1 (0x000A) +#define AX5243_REG_IRQ_INVERSION_0 (0x000B) +#define AX5243_REG_IRQ_REQUEST_1 (0x000C) +#define AX5243_REG_IRQ_REQUEST_0 (0x000D) +#define AX5243_REG_RADIO_EVENT_REQ_1 (0x000E) +#define AX5243_REG_RADIO_EVENT_REQ_0 (0x000F) +#define AX5243_REG_MODULATION (0x0010) +#define AX5243_REG_ENCODING (0x0011) +#define AX5243_REG_FRAMING (0x0012) +#define AX5243_REG_CRC_INIT_3 (0x0014) +#define AX5243_REG_CRC_INIT_2 (0x0015) +#define AX5243_REG_CRC_INIT_1 (0x0016) +#define AX5243_REG_CRC_INIT_0 (0x0017) +#define AX5243_REG_FEC (0x0018) +#define AX5243_REG_FEC_SYNC (0x0019) +#define AX5243_REG_FEC_STATUS (0x001A) +#define AX5243_REG_RADIO_STATE (0x001C) +#define AX5243_REG_XTAL_STATUS (0x001D) +#define AX5243_REG_PIN_STATE (0x0020) +#define AX5243_REG_PIN_FUNC_SYSCLK (0x0021) +#define AX5243_REG_PIN_FUNC_DCLK (0x0022) +#define AX5243_REG_PIN_FUNC_DATA (0x0023) +#define AX5243_REG_PIN_FUNC_IRQ (0x0024) +#define AX5243_REG_PIN_FUNC_ANTSEL (0x0025) +#define AX5243_REG_PIN_FUNC_PWRAMP (0x0026) +#define AX5243_REG_PWRAMP (0x0027) +#define AX5243_REG_FIFO_STAT (0x0028) +#define AX5243_REG_FIFO_DATA (0x0029) +#define AX5243_REG_FIFO_COUNT_1 (0x002A) +#define AX5243_REG_FIFO_COUNT_0 (0x002B) +#define AX5243_REG_FIFO_FREE_1 (0x002C) +#define AX5243_REG_FIFO_FREE_0 (0x002D) +#define AX5243_REG_FIFO_THRESH_1 (0x002E) +#define AX5243_REG_FIFO_THRESH_0 (0x002F) +#define AX5243_REG_PLL_LOOP (0x0030) +#define AX5243_REG_PLL_CPI (0x0031) +#define AX5243_REG_PLL_VCO_DIV (0x0032) +#define AX5243_REG_PLL_RANGING_A (0x0033) +#define AX5243_REG_FREQ_A_3 (0x0034) +#define AX5243_REG_FREQ_A_2 (0x0035) +#define AX5243_REG_FREQ_A_1 (0x0036) +#define AX5243_REG_FREQ_A_0 (0x0037) +#define AX5243_REG_PLL_LOOP_BOOST (0x0038) +#define AX5243_REG_PLL_CPI_BOOST (0x0039) +#define AX5243_REG_PLL_RANGING_B (0x003B) +#define AX5243_REG_FREQ_B_3 (0x003C) +#define AX5243_REG_FREQ_B_2 (0x003D) +#define AX5243_REG_FREQ_B_1 (0x003E) +#define AX5243_REG_FREQ_B_0 (0x003F) +#define AX5243_REG_RSSI (0x0040) +#define AX5243_REG_BGND_RSSI (0x0041) +#define AX5243_REG_DIVERSITY (0x0042) +#define AX5243_REG_AGC_COUNTER (0x0043) +#define AX5243_REG_TRK_DATARATE_2 (0x0045) +#define AX5243_REG_TRK_DATARATE_1 (0x0046) +#define AX5243_REG_TRK_DATARATE_0 (0x0047) +#define AX5243_REG_TRK_AMPL_1 (0x0048) +#define AX5243_REG_TRK_AMPL_0 (0x0049) +#define AX5243_REG_TRK_PHASE_1 (0x004A) +#define AX5243_REG_TRK_PHASE_0 (0x004B) +#define AX5243_REG_TRK_RF_FREQ_2 (0x004D) +#define AX5243_REG_TRK_RF_FREQ_1 (0x004E) +#define AX5243_REG_TRK_RF_FREQ_0 (0x004F) +#define AX5243_REG_TRK_FREQ_2 (0x0050) +#define AX5243_REG_TRK_FREQ_1 (0x0051) +#define AX5243_REG_TRK_FSK_DEMOD_1 (0x0052) +#define AX5243_REG_TRK_FSK_DEMOD_0 (0x0053) +#define AX5243_REG_TIMER_2 (0x0059) +#define AX5243_REG_TIMER_1 (0x005A) +#define AX5243_REG_TIMER_0 (0x005B) +#define AX5243_REG_WAKEUP_TIMER_1 (0x0068) +#define AX5243_REG_WAKEUP_TIMER_0 (0x0069) +#define AX5243_REG_WAKEUP_1 (0x006A) +#define AX5243_REG_WAKEUP_0 (0x006B) +#define AX5243_REG_WAKEUP_FREQ_1 (0x006C) +#define AX5243_REG_WAKEUP_FREQ_0 (0x006D) +#define AX5243_REG_WAKEUP_XO_EARLY (0x006E) +#define AX5243_REG_IF_FREQ_1 (0x0100) +#define AX5243_REG_IF_FREQ_0 (0x0101) +#define AX5243_REG_DECIMATION (0x0102) +#define AX5243_REG_RX_DATA_RATE_2 (0x0103) +#define AX5243_REG_RX_DATA_RATE_1 (0x0104) +#define AX5243_REG_RX_DATA_RATE_0 (0x0105) +#define AX5243_REG_MAX_DR_OFFSET_2 (0x0106) +#define AX5243_REG_MAX_DR_OFFSET_1 (0x0107) +#define AX5243_REG_MAX_DR_OFFSET_0 (0x0108) +#define AX5243_REG_MAX_RF_OFFSET_2 (0x0109) +#define AX5243_REG_MAX_RF_OFFSET_1 (0x010A) +#define AX5243_REG_MAX_RF_OFFSET_0 (0x010B) +#define AX5243_REG_FSK_DMAX_1 (0x010C) +#define AX5243_REG_FSK_DMAX_0 (0x010D) +#define AX5243_REG_FSK_DMIN_1 (0x010E) +#define AX5243_REG_FSK_DMIN_0 (0x010F) +#define AX5243_REG_AFSK_SPACE_1 (0x0110) +#define AX5243_REG_AFSK_SPACE_0 (0x0111) +#define AX5243_REG_AFSK_MARK_1 (0x0112) +#define AX5243_REG_AFSK_MARK_0 (0x0113) +#define AX5243_REG_AFSK_CTRL (0x0114) +#define AX5243_REG_AMPL_FILTER (0x0115) +#define AX5243_REG_FREQUENCY_LEAK (0x0116) +#define AX5243_REG_RX_PARAM_SETS (0x0117) +#define AX5243_REG_RX_PARAM_CUR_SET (0x0118) +#define AX5243_REG_RX_PARAM_SET_0 (0x0120) +#define AX5243_REG_RX_PARAM_SET_1 (0x0130) +#define AX5243_REG_RX_PARAM_SET_2 (0x0140) +#define AX5243_REG_RX_PARAM_SET_3 (0x0150) +#define AX5243_REG_RXPAR_AGC_GAIN (0x0000) +#define AX5243_REG_RXPAR_AGC_TARGET (0x0001) +#define AX5243_REG_RXPAR_AGC_HYST (0x0002) +#define AX5243_REG_RXPAR_AGC_MIN_MAX (0x0003) +#define AX5243_REG_RXPAR_TIME_GAIN (0x0004) +#define AX5243_REG_RXPAR_DR_GAIN (0x0005) +#define AX5243_REG_RXPAR_PHASE_GAIN (0x0006) +#define AX5243_REG_RXPAR_FREQ_GAIN_A (0x0007) +#define AX5243_REG_RXPAR_FREQ_GAIN_B (0x0008) +#define AX5243_REG_RXPAR_FREQ_GAIN_C (0x0009) +#define AX5243_REG_RXPAR_FREQ_GAIN_D (0x000A) +#define AX5243_REG_RXPAR_AMPL_GAIN (0x000B) +#define AX5243_REG_RXPAR_FREQ_DEV_1 (0x000C) +#define AX5243_REG_RXPAR_FREQ_DEV_0 (0x000D) +#define AX5243_REG_RXPAR_FOUR_FSK (0x000E) +#define AX5243_REG_RXPAR_BB_OFFS_RES (0x000F) +#define AX5243_REG_MOD_CFG_F (0x0160) +#define AX5243_REG_FSK_DEV_2 (0x0161) +#define AX5243_REG_FSK_DEV_1 (0x0162) +#define AX5243_REG_FSK_DEV_0 (0x0163) +#define AX5243_REG_MOD_CFG_A (0x0164) +#define AX5243_REG_TX_RATE_2 (0x0165) +#define AX5243_REG_TX_RATE_1 (0x0166) +#define AX5243_REG_TX_RATE_0 (0x0167) +#define AX5243_REG_TX_PWR_COEFF_A_1 (0x0168) +#define AX5243_REG_TX_PWR_COEFF_A_0 (0x0169) +#define AX5243_REG_TX_PWR_COEFF_B_1 (0x016A) +#define AX5243_REG_TX_PWR_COEFF_B_0 (0x016B) +#define AX5243_REG_TX_PWR_COEFF_C_1 (0x016C) +#define AX5243_REG_TX_PWR_COEFF_C_0 (0x016D) +#define AX5243_REG_TX_PWR_COEFF_D_1 (0x016E) +#define AX5243_REG_TX_PWR_COEFF_D_0 (0x016F) +#define AX5243_REG_TX_PWR_COEFF_E_1 (0x0170) +#define AX5243_REG_TX_PWR_COEFF_E_0 (0x0171) +#define AX5243_REG_PLL_VCO_I (0x0180) +#define AX5243_REG_PLL_VCO_IR (0x0181) +#define AX5243_REG_PLL_LOCK_DET (0x0182) +#define AX5243_REG_PLL_RNG_CLK (0x0183) +#define AX5243_REG_XTAL_CAP (0x0184) +#define AX5243_REG_BB_TUNE (0x0188) +#define AX5243_REG_BB_OFFS_CAP (0x0189) +#define AX5243_REG_PKT_ADDR_CFG (0x0200) +#define AX5243_REG_PKT_LEN_CFG (0x0201) +#define AX5243_REG_PKT_LEN_OFFSET (0x0202) +#define AX5243_REG_PKT_MAX_LEN (0x0203) +#define AX5243_REG_PKT_ADDR_3 (0x0204) +#define AX5243_REG_PKT_ADDR_2 (0x0205) +#define AX5243_REG_PKT_ADDR_1 (0x0206) +#define AX5243_REG_PKT_ADDR_0 (0x0207) +#define AX5243_REG_PKT_ADDR_MASK_3 (0x0208) +#define AX5243_REG_PKT_ADDR_MASK_2 (0x0209) +#define AX5243_REG_PKT_ADDR_MASK_1 (0x020A) +#define AX5243_REG_PKT_ADDR_MASK_0 (0x020B) +#define AX5243_REG_MATCH_0_PAT_3 (0x0210) +#define AX5243_REG_MATCH_0_PAT_2 (0x0211) +#define AX5243_REG_MATCH_0_PAT_1 (0x0212) +#define AX5243_REG_MATCH_0_PAT_0 (0x0213) +#define AX5243_REG_MATCH_0_LEN (0x0214) +#define AX5243_REG_MATCH_0_MIN (0x0215) +#define AX5243_REG_MATCH_0_MAX (0x0216) +#define AX5243_REG_MATCH_1_PAT_1 (0x0218) +#define AX5243_REG_MATCH_1_PAT_0 (0x0219) +#define AX5243_REG_MATCH_1_LEN (0x021C) +#define AX5243_REG_MATCH_1_MIN (0x021D) +#define AX5243_REG_MATCH_1_MAX (0x021E) +#define AX5243_REG_TMG_TX_BOOST (0x0220) +#define AX5243_REG_TMG_TX_SETTLE (0x0221) +#define AX5243_REG_TMG_RX_BOOST (0x0223) +#define AX5243_REG_TMG_RX_SETTLE (0x0224) +#define AX5243_REG_TMG_RX_OFFS_ACQ (0x0225) +#define AX5243_REG_TMG_RX_COARSE_ACQ (0x0226) +#define AX5243_REG_TMG_RX_AGC (0x0227) +#define AX5243_REG_TMG_RX_RSSI (0x0228) +#define AX5243_REG_TMG_RX_PREAMBLE_1 (0x0229) +#define AX5243_REG_TMG_RX_PREAMBLE_2 (0x022A) +#define AX5243_REG_TMG_RX_PREAMBLE_3 (0x022B) +#define AX5243_REG_RSSI_REFERENCE (0x022C) +#define AX5243_REG_RSSI_ABS_THR (0x022D) +#define AX5243_REG_BGND_RSSI_GAIN (0x022E) +#define AX5243_REG_BGND_RSSI_THR (0x022F) +#define AX5243_REG_PKT_CHUNK_SIZE (0x0230) +#define AX5243_REG_PKT_MISC_FLAGS (0x0231) +#define AX5243_REG_PKT_STORE_FLAGS (0x0232) +#define AX5243_REG_PKT_ACCEPT_FLAGS (0x0233) +#define AX5243_REG_GP_ADC_CTRL (0x0300) +#define AX5243_REG_GP_ADC_PERIOD (0x0301) +#define AX5243_REG_GP_ADC_13_VALUE_1 (0x0308) +#define AX5243_REG_GP_ADC_13_VALUE_0 (0x0309) +#define AX5243_REG_LP_OSC_CONFIG (0x0310) +#define AX5243_REG_LP_OSC_STATUS (0x0311) +#define AX5243_REG_LP_OSC_FILTER_1 (0x0312) +#define AX5243_REG_LP_OSC_FILTER_0 (0x0313) +#define AX5243_REG_LP_OSC_REF_1 (0x0314) +#define AX5243_REG_LP_OSC_REF_0 (0x0315) +#define AX5243_REG_LP_OSC_FREQ_1 (0x0316) +#define AX5243_REG_LP_OSC_FREQ_0 (0x0317) +#define AX5243_REG_LP_OSC_PER_1 (0x0318) +#define AX5243_REG_LP_OSC_PER_0 (0x0319) +#define AX5243_REG_DAC_VALUE_1 (0x0330) +#define AX5243_REG_DAC_VALUE_0 (0x0331) +#define AX5243_REG_DAC_CONFIG (0x0332) + +/*! + \class AX5243 + + \brief Control class for %AX5243 module. +*/ +class AX5243: public PhysicalLayer { + public: + // introduce PhysicalLayer overloads + using PhysicalLayer::transmit; + using PhysicalLayer::receive; + using PhysicalLayer::startTransmit; + using PhysicalLayer::readData; + + /*! + \brief Default constructor. + + \param mod Instance of Module that will be used to communicate with the radio. + */ + AX5243(Module* module); + + // basic methods + + int16_t begin(); + +#ifndef RADIOLIB_GODMODE + private: +#endif + Module* _mod; + +}; + +#endif diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index fe1d15a6..a7eda1e3 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -267,11 +267,14 @@ int16_t Si443x::startReceive() { _mod->setRfSwitchState(HIGH, LOW); // set interrupt mapping - _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_PACKET_SENT_ENABLED); + //_mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_PACKET_SENT_ENABLED); + //_mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_VALID_PACKET_RECEIVED_ENABLED | SI443X_CRC_ERROR_ENABLED); _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); // set mode to receive _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON | SI443X_XTAL_ON); + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); return(state); } @@ -572,10 +575,6 @@ uint8_t Si443x::random() { return(randByte); } -int16_t Si443x::getChipVersion() { - return(_mod->SPIgetRegValue(SI443X_REG_DEVICE_VERSION)); -} - int16_t Si443x::setFrequencyRaw(float newFreq) { // set mode to standby int16_t state = standby(); @@ -597,6 +596,7 @@ int16_t Si443x::setFrequencyRaw(float newFreq) { state = _mod->SPIsetRegValue(SI443X_REG_FREQUENCY_BAND_SELECT, bandSelect | freqBand, 5, 0); state |= _mod->SPIsetRegValue(SI443X_REG_NOM_CARRIER_FREQUENCY_1, (uint8_t)((freqCarrier & 0xFF00) >> 8)); state |= _mod->SPIsetRegValue(SI443X_REG_NOM_CARRIER_FREQUENCY_0, (uint8_t)(freqCarrier & 0xFF)); + //state |= _mod->SPIsetRegValue(SI443X_REG_AFC_LIMITER, 80); return(state); } @@ -647,10 +647,17 @@ int16_t Si443x::config() { // disable packet header state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_2, SI443X_SYNC_WORD_TIMEOUT_ON | SI443X_HEADER_LENGTH_HEADER_NONE, 7, 4); + //state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_2, SI443X_HEADER_LENGTH_HEADER_3210 | SI443X_FIXED_PACKET_LENGTH_OFF | SI443X_SYNC_LENGTH_SYNC_32, 6, 1); RADIOLIB_ASSERT(state); // disable packet header checking state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_1, SI443X_BROADCAST_ADDR_CHECK_NONE | SI443X_RECEIVED_HEADER_CHECK_NONE); + //state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_1, SI443X_BROADCAST_ADDR_CHECK_BYTE3 | SI443X_RECEIVED_HEADER_CHECK_BYTE3); + RADIOLIB_ASSERT(state); + + state = _mod->SPIsetRegValue(SI443X_REG_GPIO0_CONFIG, 0x12); + RADIOLIB_ASSERT(state); + state = _mod->SPIsetRegValue(SI443X_REG_GPIO1_CONFIG, 0x15); RADIOLIB_ASSERT(state); return(state); From e04aea52dd55a95a48ae77c5bd5d9fa948a2babf Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 20:12:08 +0100 Subject: [PATCH 445/455] Revert "Updated SparkFun Apollo3 core (SparkFun:apollo3:sfe_artemis)" This reverts commit 098e611eae99a59e07afd4e7bd7f41dbcf3e1d2a. --- .github/workflows/main.yml | 2 +- examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino | 1 - .../Si443x/Si443x_Receive/Si443x_Receive.ino | 2 +- .../Si443x_Receive_Interrupt.ino | 12 +- .../Si443x_Transmit/Si443x_Transmit.ino | 3 +- src/modules/AX5243/AX5243.cpp | 12 - src/modules/AX5243/AX5243.h | 263 ------------------ src/modules/Si443x/Si443x.cpp | 17 +- 8 files changed, 11 insertions(+), 301 deletions(-) delete mode 100644 src/modules/AX5243/AX5243.cpp delete mode 100644 src/modules/AX5243/AX5243.h diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 445282cd..7ec52c01 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -108,7 +108,7 @@ jobs: elif [[ "${{ contains(matrix.board, 'SparkFun:apollo3') }}" == "true" ]]; then # SparkFun Apollo - echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json" + echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" echo "::set-output name=warnings::'none'" elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then diff --git a/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino b/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino index 32f0a18f..80c3c67f 100644 --- a/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino +++ b/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino @@ -40,7 +40,6 @@ RTTYClient rtty(&radio); void setup() { Serial.begin(9600); - while(!Serial); // initialize SX1278 with default settings Serial.print(F("[SX1278] Initializing ... ")); diff --git a/examples/Si443x/Si443x_Receive/Si443x_Receive.ino b/examples/Si443x/Si443x_Receive/Si443x_Receive.ino index 5265ffff..846e46e3 100644 --- a/examples/Si443x/Si443x_Receive/Si443x_Receive.ino +++ b/examples/Si443x/Si443x_Receive/Si443x_Receive.ino @@ -25,7 +25,7 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 radio = new Module(D8, D2, D0); +Si4432 radio = new Module(10, 2, 9); // or using RadioShield // https://github.com/jgromes/RadioShield diff --git a/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino b/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino index dc5fb89c..e890b08d 100644 --- a/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino +++ b/examples/Si443x/Si443x_Receive_Interrupt/Si443x_Receive_Interrupt.ino @@ -21,14 +21,14 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -Si4432 radio = new Module(D8, D2, D0); +Si4432 radio = new Module(10, 2, 9); // or using RadioShield // https://github.com/jgromes/RadioShield //Si4432 radio = RadioShield.ModuleA; void setup() { - Serial.begin(115200); + Serial.begin(9600); // initialize Si4432 with default settings Serial.print(F("[Si4432] Initializing ... ")); @@ -76,7 +76,7 @@ volatile bool enableInterrupt = true; // is received by the module // IMPORTANT: this function MUST be 'void' type // and MUST NOT have any arguments! -IRAM_ATTR void setFlag(void) { +void setFlag(void) { // check if the interrupt is enabled if(!enableInterrupt) { return; @@ -87,12 +87,6 @@ IRAM_ATTR void setFlag(void) { } void loop() { - Serial.print(radio._mod->SPIreadRegister(SI443X_REG_DEVICE_STATUS), HEX); - Serial.print('\t'); - Serial.print(radio._mod->SPIreadRegister(SI443X_REG_INTERRUPT_STATUS_1), HEX); - Serial.print('\t'); - Serial.println(radio._mod->SPIreadRegister(SI443X_REG_INTERRUPT_STATUS_2), HEX); - // check if the flag is set if(receivedFlag) { // disable the interrupt service routine while diff --git a/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino b/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino index 4aec648d..ca267624 100644 --- a/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino +++ b/examples/Si443x/Si443x_Transmit/Si443x_Transmit.ino @@ -23,8 +23,7 @@ // nSEL pin: 10 // nIRQ pin: 2 // SDN pin: 9 -//Si4432 radio = new Module(5, 26, 25); -Si4432 radio = new Module(D8, D2, D0); +Si4432 radio = new Module(10, 2, 9); // or using RadioShield // https://github.com/jgromes/RadioShield diff --git a/src/modules/AX5243/AX5243.cpp b/src/modules/AX5243/AX5243.cpp deleted file mode 100644 index cbafa5ef..00000000 --- a/src/modules/AX5243/AX5243.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "AX5243.h" -#if !defined(RADIOLIB_EXCLUDE_AX5243) - -AX5243::AX5243(Module* module) : PhysicalLayer(AX5243_FREQUENCY_STEP_SIZE, AX5243_MAX_PACKET_LENGTH) { - _mod = module; -} - -int16_t AX5243::begin() { - return(ERR_NONE); -} - -#endif diff --git a/src/modules/AX5243/AX5243.h b/src/modules/AX5243/AX5243.h deleted file mode 100644 index 985d4108..00000000 --- a/src/modules/AX5243/AX5243.h +++ /dev/null @@ -1,263 +0,0 @@ -#if !defined(_RADIOLIB_AX5243_H) && !defined(RADIOLIB_EXCLUDE_AX5243) -#define _RADIOLIB_AX5243_H - -#include "../../TypeDef.h" -#include "../../Module.h" - -#include "../../protocols/PhysicalLayer/PhysicalLayer.h" - -// AX5243 physical layer properties -#define AX5243_FREQUENCY_STEP_SIZE (0.98) -#define AX5243_MAX_PACKET_LENGTH (256) - -// AX5243 register map -#define AX5243_REG_REVISION (0x0000) -#define AX5243_REG_SCRATCH (0x0001) -#define AX5243_REG_PWR_MODE (0x0002) -#define AX5243_REG_POW_STAT (0x0003) -#define AX5243_REG_POW_STICKY_STAT (0x0004) -#define AX5243_REG_POW_IRQ_MASK (0x0005) -#define AX5243_REG_IRQ_MASK_1 (0x0006) -#define AX5243_REG_IRQ_MASK_0 (0x0007) -#define AX5243_REG_RADIO_EVENTS_MASK_1 (0x0008) -#define AX5243_REG_RADIO_EVENTS_MASK_0 (0x0009) -#define AX5243_REG_IRQ_INVERSION_1 (0x000A) -#define AX5243_REG_IRQ_INVERSION_0 (0x000B) -#define AX5243_REG_IRQ_REQUEST_1 (0x000C) -#define AX5243_REG_IRQ_REQUEST_0 (0x000D) -#define AX5243_REG_RADIO_EVENT_REQ_1 (0x000E) -#define AX5243_REG_RADIO_EVENT_REQ_0 (0x000F) -#define AX5243_REG_MODULATION (0x0010) -#define AX5243_REG_ENCODING (0x0011) -#define AX5243_REG_FRAMING (0x0012) -#define AX5243_REG_CRC_INIT_3 (0x0014) -#define AX5243_REG_CRC_INIT_2 (0x0015) -#define AX5243_REG_CRC_INIT_1 (0x0016) -#define AX5243_REG_CRC_INIT_0 (0x0017) -#define AX5243_REG_FEC (0x0018) -#define AX5243_REG_FEC_SYNC (0x0019) -#define AX5243_REG_FEC_STATUS (0x001A) -#define AX5243_REG_RADIO_STATE (0x001C) -#define AX5243_REG_XTAL_STATUS (0x001D) -#define AX5243_REG_PIN_STATE (0x0020) -#define AX5243_REG_PIN_FUNC_SYSCLK (0x0021) -#define AX5243_REG_PIN_FUNC_DCLK (0x0022) -#define AX5243_REG_PIN_FUNC_DATA (0x0023) -#define AX5243_REG_PIN_FUNC_IRQ (0x0024) -#define AX5243_REG_PIN_FUNC_ANTSEL (0x0025) -#define AX5243_REG_PIN_FUNC_PWRAMP (0x0026) -#define AX5243_REG_PWRAMP (0x0027) -#define AX5243_REG_FIFO_STAT (0x0028) -#define AX5243_REG_FIFO_DATA (0x0029) -#define AX5243_REG_FIFO_COUNT_1 (0x002A) -#define AX5243_REG_FIFO_COUNT_0 (0x002B) -#define AX5243_REG_FIFO_FREE_1 (0x002C) -#define AX5243_REG_FIFO_FREE_0 (0x002D) -#define AX5243_REG_FIFO_THRESH_1 (0x002E) -#define AX5243_REG_FIFO_THRESH_0 (0x002F) -#define AX5243_REG_PLL_LOOP (0x0030) -#define AX5243_REG_PLL_CPI (0x0031) -#define AX5243_REG_PLL_VCO_DIV (0x0032) -#define AX5243_REG_PLL_RANGING_A (0x0033) -#define AX5243_REG_FREQ_A_3 (0x0034) -#define AX5243_REG_FREQ_A_2 (0x0035) -#define AX5243_REG_FREQ_A_1 (0x0036) -#define AX5243_REG_FREQ_A_0 (0x0037) -#define AX5243_REG_PLL_LOOP_BOOST (0x0038) -#define AX5243_REG_PLL_CPI_BOOST (0x0039) -#define AX5243_REG_PLL_RANGING_B (0x003B) -#define AX5243_REG_FREQ_B_3 (0x003C) -#define AX5243_REG_FREQ_B_2 (0x003D) -#define AX5243_REG_FREQ_B_1 (0x003E) -#define AX5243_REG_FREQ_B_0 (0x003F) -#define AX5243_REG_RSSI (0x0040) -#define AX5243_REG_BGND_RSSI (0x0041) -#define AX5243_REG_DIVERSITY (0x0042) -#define AX5243_REG_AGC_COUNTER (0x0043) -#define AX5243_REG_TRK_DATARATE_2 (0x0045) -#define AX5243_REG_TRK_DATARATE_1 (0x0046) -#define AX5243_REG_TRK_DATARATE_0 (0x0047) -#define AX5243_REG_TRK_AMPL_1 (0x0048) -#define AX5243_REG_TRK_AMPL_0 (0x0049) -#define AX5243_REG_TRK_PHASE_1 (0x004A) -#define AX5243_REG_TRK_PHASE_0 (0x004B) -#define AX5243_REG_TRK_RF_FREQ_2 (0x004D) -#define AX5243_REG_TRK_RF_FREQ_1 (0x004E) -#define AX5243_REG_TRK_RF_FREQ_0 (0x004F) -#define AX5243_REG_TRK_FREQ_2 (0x0050) -#define AX5243_REG_TRK_FREQ_1 (0x0051) -#define AX5243_REG_TRK_FSK_DEMOD_1 (0x0052) -#define AX5243_REG_TRK_FSK_DEMOD_0 (0x0053) -#define AX5243_REG_TIMER_2 (0x0059) -#define AX5243_REG_TIMER_1 (0x005A) -#define AX5243_REG_TIMER_0 (0x005B) -#define AX5243_REG_WAKEUP_TIMER_1 (0x0068) -#define AX5243_REG_WAKEUP_TIMER_0 (0x0069) -#define AX5243_REG_WAKEUP_1 (0x006A) -#define AX5243_REG_WAKEUP_0 (0x006B) -#define AX5243_REG_WAKEUP_FREQ_1 (0x006C) -#define AX5243_REG_WAKEUP_FREQ_0 (0x006D) -#define AX5243_REG_WAKEUP_XO_EARLY (0x006E) -#define AX5243_REG_IF_FREQ_1 (0x0100) -#define AX5243_REG_IF_FREQ_0 (0x0101) -#define AX5243_REG_DECIMATION (0x0102) -#define AX5243_REG_RX_DATA_RATE_2 (0x0103) -#define AX5243_REG_RX_DATA_RATE_1 (0x0104) -#define AX5243_REG_RX_DATA_RATE_0 (0x0105) -#define AX5243_REG_MAX_DR_OFFSET_2 (0x0106) -#define AX5243_REG_MAX_DR_OFFSET_1 (0x0107) -#define AX5243_REG_MAX_DR_OFFSET_0 (0x0108) -#define AX5243_REG_MAX_RF_OFFSET_2 (0x0109) -#define AX5243_REG_MAX_RF_OFFSET_1 (0x010A) -#define AX5243_REG_MAX_RF_OFFSET_0 (0x010B) -#define AX5243_REG_FSK_DMAX_1 (0x010C) -#define AX5243_REG_FSK_DMAX_0 (0x010D) -#define AX5243_REG_FSK_DMIN_1 (0x010E) -#define AX5243_REG_FSK_DMIN_0 (0x010F) -#define AX5243_REG_AFSK_SPACE_1 (0x0110) -#define AX5243_REG_AFSK_SPACE_0 (0x0111) -#define AX5243_REG_AFSK_MARK_1 (0x0112) -#define AX5243_REG_AFSK_MARK_0 (0x0113) -#define AX5243_REG_AFSK_CTRL (0x0114) -#define AX5243_REG_AMPL_FILTER (0x0115) -#define AX5243_REG_FREQUENCY_LEAK (0x0116) -#define AX5243_REG_RX_PARAM_SETS (0x0117) -#define AX5243_REG_RX_PARAM_CUR_SET (0x0118) -#define AX5243_REG_RX_PARAM_SET_0 (0x0120) -#define AX5243_REG_RX_PARAM_SET_1 (0x0130) -#define AX5243_REG_RX_PARAM_SET_2 (0x0140) -#define AX5243_REG_RX_PARAM_SET_3 (0x0150) -#define AX5243_REG_RXPAR_AGC_GAIN (0x0000) -#define AX5243_REG_RXPAR_AGC_TARGET (0x0001) -#define AX5243_REG_RXPAR_AGC_HYST (0x0002) -#define AX5243_REG_RXPAR_AGC_MIN_MAX (0x0003) -#define AX5243_REG_RXPAR_TIME_GAIN (0x0004) -#define AX5243_REG_RXPAR_DR_GAIN (0x0005) -#define AX5243_REG_RXPAR_PHASE_GAIN (0x0006) -#define AX5243_REG_RXPAR_FREQ_GAIN_A (0x0007) -#define AX5243_REG_RXPAR_FREQ_GAIN_B (0x0008) -#define AX5243_REG_RXPAR_FREQ_GAIN_C (0x0009) -#define AX5243_REG_RXPAR_FREQ_GAIN_D (0x000A) -#define AX5243_REG_RXPAR_AMPL_GAIN (0x000B) -#define AX5243_REG_RXPAR_FREQ_DEV_1 (0x000C) -#define AX5243_REG_RXPAR_FREQ_DEV_0 (0x000D) -#define AX5243_REG_RXPAR_FOUR_FSK (0x000E) -#define AX5243_REG_RXPAR_BB_OFFS_RES (0x000F) -#define AX5243_REG_MOD_CFG_F (0x0160) -#define AX5243_REG_FSK_DEV_2 (0x0161) -#define AX5243_REG_FSK_DEV_1 (0x0162) -#define AX5243_REG_FSK_DEV_0 (0x0163) -#define AX5243_REG_MOD_CFG_A (0x0164) -#define AX5243_REG_TX_RATE_2 (0x0165) -#define AX5243_REG_TX_RATE_1 (0x0166) -#define AX5243_REG_TX_RATE_0 (0x0167) -#define AX5243_REG_TX_PWR_COEFF_A_1 (0x0168) -#define AX5243_REG_TX_PWR_COEFF_A_0 (0x0169) -#define AX5243_REG_TX_PWR_COEFF_B_1 (0x016A) -#define AX5243_REG_TX_PWR_COEFF_B_0 (0x016B) -#define AX5243_REG_TX_PWR_COEFF_C_1 (0x016C) -#define AX5243_REG_TX_PWR_COEFF_C_0 (0x016D) -#define AX5243_REG_TX_PWR_COEFF_D_1 (0x016E) -#define AX5243_REG_TX_PWR_COEFF_D_0 (0x016F) -#define AX5243_REG_TX_PWR_COEFF_E_1 (0x0170) -#define AX5243_REG_TX_PWR_COEFF_E_0 (0x0171) -#define AX5243_REG_PLL_VCO_I (0x0180) -#define AX5243_REG_PLL_VCO_IR (0x0181) -#define AX5243_REG_PLL_LOCK_DET (0x0182) -#define AX5243_REG_PLL_RNG_CLK (0x0183) -#define AX5243_REG_XTAL_CAP (0x0184) -#define AX5243_REG_BB_TUNE (0x0188) -#define AX5243_REG_BB_OFFS_CAP (0x0189) -#define AX5243_REG_PKT_ADDR_CFG (0x0200) -#define AX5243_REG_PKT_LEN_CFG (0x0201) -#define AX5243_REG_PKT_LEN_OFFSET (0x0202) -#define AX5243_REG_PKT_MAX_LEN (0x0203) -#define AX5243_REG_PKT_ADDR_3 (0x0204) -#define AX5243_REG_PKT_ADDR_2 (0x0205) -#define AX5243_REG_PKT_ADDR_1 (0x0206) -#define AX5243_REG_PKT_ADDR_0 (0x0207) -#define AX5243_REG_PKT_ADDR_MASK_3 (0x0208) -#define AX5243_REG_PKT_ADDR_MASK_2 (0x0209) -#define AX5243_REG_PKT_ADDR_MASK_1 (0x020A) -#define AX5243_REG_PKT_ADDR_MASK_0 (0x020B) -#define AX5243_REG_MATCH_0_PAT_3 (0x0210) -#define AX5243_REG_MATCH_0_PAT_2 (0x0211) -#define AX5243_REG_MATCH_0_PAT_1 (0x0212) -#define AX5243_REG_MATCH_0_PAT_0 (0x0213) -#define AX5243_REG_MATCH_0_LEN (0x0214) -#define AX5243_REG_MATCH_0_MIN (0x0215) -#define AX5243_REG_MATCH_0_MAX (0x0216) -#define AX5243_REG_MATCH_1_PAT_1 (0x0218) -#define AX5243_REG_MATCH_1_PAT_0 (0x0219) -#define AX5243_REG_MATCH_1_LEN (0x021C) -#define AX5243_REG_MATCH_1_MIN (0x021D) -#define AX5243_REG_MATCH_1_MAX (0x021E) -#define AX5243_REG_TMG_TX_BOOST (0x0220) -#define AX5243_REG_TMG_TX_SETTLE (0x0221) -#define AX5243_REG_TMG_RX_BOOST (0x0223) -#define AX5243_REG_TMG_RX_SETTLE (0x0224) -#define AX5243_REG_TMG_RX_OFFS_ACQ (0x0225) -#define AX5243_REG_TMG_RX_COARSE_ACQ (0x0226) -#define AX5243_REG_TMG_RX_AGC (0x0227) -#define AX5243_REG_TMG_RX_RSSI (0x0228) -#define AX5243_REG_TMG_RX_PREAMBLE_1 (0x0229) -#define AX5243_REG_TMG_RX_PREAMBLE_2 (0x022A) -#define AX5243_REG_TMG_RX_PREAMBLE_3 (0x022B) -#define AX5243_REG_RSSI_REFERENCE (0x022C) -#define AX5243_REG_RSSI_ABS_THR (0x022D) -#define AX5243_REG_BGND_RSSI_GAIN (0x022E) -#define AX5243_REG_BGND_RSSI_THR (0x022F) -#define AX5243_REG_PKT_CHUNK_SIZE (0x0230) -#define AX5243_REG_PKT_MISC_FLAGS (0x0231) -#define AX5243_REG_PKT_STORE_FLAGS (0x0232) -#define AX5243_REG_PKT_ACCEPT_FLAGS (0x0233) -#define AX5243_REG_GP_ADC_CTRL (0x0300) -#define AX5243_REG_GP_ADC_PERIOD (0x0301) -#define AX5243_REG_GP_ADC_13_VALUE_1 (0x0308) -#define AX5243_REG_GP_ADC_13_VALUE_0 (0x0309) -#define AX5243_REG_LP_OSC_CONFIG (0x0310) -#define AX5243_REG_LP_OSC_STATUS (0x0311) -#define AX5243_REG_LP_OSC_FILTER_1 (0x0312) -#define AX5243_REG_LP_OSC_FILTER_0 (0x0313) -#define AX5243_REG_LP_OSC_REF_1 (0x0314) -#define AX5243_REG_LP_OSC_REF_0 (0x0315) -#define AX5243_REG_LP_OSC_FREQ_1 (0x0316) -#define AX5243_REG_LP_OSC_FREQ_0 (0x0317) -#define AX5243_REG_LP_OSC_PER_1 (0x0318) -#define AX5243_REG_LP_OSC_PER_0 (0x0319) -#define AX5243_REG_DAC_VALUE_1 (0x0330) -#define AX5243_REG_DAC_VALUE_0 (0x0331) -#define AX5243_REG_DAC_CONFIG (0x0332) - -/*! - \class AX5243 - - \brief Control class for %AX5243 module. -*/ -class AX5243: public PhysicalLayer { - public: - // introduce PhysicalLayer overloads - using PhysicalLayer::transmit; - using PhysicalLayer::receive; - using PhysicalLayer::startTransmit; - using PhysicalLayer::readData; - - /*! - \brief Default constructor. - - \param mod Instance of Module that will be used to communicate with the radio. - */ - AX5243(Module* module); - - // basic methods - - int16_t begin(); - -#ifndef RADIOLIB_GODMODE - private: -#endif - Module* _mod; - -}; - -#endif diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index a7eda1e3..fe1d15a6 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -267,14 +267,11 @@ int16_t Si443x::startReceive() { _mod->setRfSwitchState(HIGH, LOW); // set interrupt mapping - //_mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_PACKET_SENT_ENABLED); - //_mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); - _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_VALID_PACKET_RECEIVED_ENABLED | SI443X_CRC_ERROR_ENABLED); + _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_1, SI443X_PACKET_SENT_ENABLED); _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); // set mode to receive _mod->SPIwriteRegister(SI443X_REG_OP_FUNC_CONTROL_1, SI443X_RX_ON | SI443X_XTAL_ON); - _mod->SPIwriteRegister(SI443X_REG_INTERRUPT_ENABLE_2, 0x00); return(state); } @@ -575,6 +572,10 @@ uint8_t Si443x::random() { return(randByte); } +int16_t Si443x::getChipVersion() { + return(_mod->SPIgetRegValue(SI443X_REG_DEVICE_VERSION)); +} + int16_t Si443x::setFrequencyRaw(float newFreq) { // set mode to standby int16_t state = standby(); @@ -596,7 +597,6 @@ int16_t Si443x::setFrequencyRaw(float newFreq) { state = _mod->SPIsetRegValue(SI443X_REG_FREQUENCY_BAND_SELECT, bandSelect | freqBand, 5, 0); state |= _mod->SPIsetRegValue(SI443X_REG_NOM_CARRIER_FREQUENCY_1, (uint8_t)((freqCarrier & 0xFF00) >> 8)); state |= _mod->SPIsetRegValue(SI443X_REG_NOM_CARRIER_FREQUENCY_0, (uint8_t)(freqCarrier & 0xFF)); - //state |= _mod->SPIsetRegValue(SI443X_REG_AFC_LIMITER, 80); return(state); } @@ -647,17 +647,10 @@ int16_t Si443x::config() { // disable packet header state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_2, SI443X_SYNC_WORD_TIMEOUT_ON | SI443X_HEADER_LENGTH_HEADER_NONE, 7, 4); - //state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_2, SI443X_HEADER_LENGTH_HEADER_3210 | SI443X_FIXED_PACKET_LENGTH_OFF | SI443X_SYNC_LENGTH_SYNC_32, 6, 1); RADIOLIB_ASSERT(state); // disable packet header checking state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_1, SI443X_BROADCAST_ADDR_CHECK_NONE | SI443X_RECEIVED_HEADER_CHECK_NONE); - //state = _mod->SPIsetRegValue(SI443X_REG_HEADER_CONTROL_1, SI443X_BROADCAST_ADDR_CHECK_BYTE3 | SI443X_RECEIVED_HEADER_CHECK_BYTE3); - RADIOLIB_ASSERT(state); - - state = _mod->SPIsetRegValue(SI443X_REG_GPIO0_CONFIG, 0x12); - RADIOLIB_ASSERT(state); - state = _mod->SPIsetRegValue(SI443X_REG_GPIO1_CONFIG, 0x15); RADIOLIB_ASSERT(state); return(state); From bc2de34e39eb312cbf0a608e4b35c9df1fd856a2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 20:15:19 +0100 Subject: [PATCH 446/455] Updated SparkFun Apollo3 core (SparkFun:apollo3:sfe_artemis) --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ec52c01..445282cd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -108,7 +108,7 @@ jobs: elif [[ "${{ contains(matrix.board, 'SparkFun:apollo3') }}" == "true" ]]; then # SparkFun Apollo - echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" + echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json" echo "::set-output name=warnings::'none'" elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then From e4dc5626a9ce0939c2be355fa4e0d1cab14ffb53 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 22:59:31 +0100 Subject: [PATCH 447/455] CI Added missing skip patter SparkFun:apollo3:sfe_artemis --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 445282cd..cb291490 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -110,6 +110,7 @@ jobs: # SparkFun Apollo echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json" echo "::set-output name=warnings::'none'" + echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino" elif [[ "${{ contains(matrix.board, 'STM32:stm32') }}" == "true" ]]; then # STM32 (official core) From aad4b84b8979c014cbfc62cfca91b5d93f6eb872 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 23:15:09 +0100 Subject: [PATCH 448/455] Added default argument for SPISettings (#239) --- src/Module.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module.h b/src/Module.h index 3f1b9345..685a2eb5 100644 --- a/src/Module.h +++ b/src/Module.h @@ -86,9 +86,9 @@ class Module { \param spi SPI interface to be used, can also use software SPI implementations. - \param spiSettings SPI interface settings. + \param spiSettings SPI interface settings. Defaults to 2 MHz clock, MSB first, mode 0. */ - Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings); + Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0)); /*! \brief Generic module constructor. From bac2be15768df5fe5a3d72b82e4d08263428ee4a Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 23:25:02 +0100 Subject: [PATCH 449/455] [SX126x] Simplify SPI slowdown --- src/modules/SX126x/SX126x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index cbe356fb..8a1809ca 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1724,7 +1724,7 @@ int16_t SX126x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d // some faster platforms require a short delay here // not sure why, but it seems that long enough SPI transaction // (e.g. setPacketParams for GFSK) will fail without it - #if defined(ARDUINO_ARCH_STM32) || defined(SAMD_SERIES) + #if defined(RADIOLIB_SPI_SLOWDOWN) Module::delay(1); #endif #endif From b24a523c3744bde75822e0d39d1131c91943511d Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 23:25:07 +0100 Subject: [PATCH 450/455] [SX128x] Simplify SPI slowdown --- src/modules/SX128x/SX128x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 7a4821f5..e2990218 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1429,7 +1429,7 @@ int16_t SX128x::SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* d // some faster platforms require a short delay here // not sure why, but it seems that long enough SPI transaction // (e.g. setPacketParams for GFSK) will fail without it - #if defined(ARDUINO_ARCH_STM32) || defined(SAMD_SERIES) + #if defined(RADIOLIB_SPI_SLOWDOWN) Module::delay(1); #endif #endif From 158b30c38337e0e62282110a2274f79d18d9e9b8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 5 Feb 2021 23:25:26 +0100 Subject: [PATCH 451/455] Added missing SX126x/8x SPI slowdown on Apollo3 --- src/BuildOpt.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 99547b43..212434d3 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -148,6 +148,9 @@ #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + // slow down SX126x/8x SPI on this platform + #define RADIOLIB_SPI_SLOWDOWN + #elif defined(SAMD_SERIES) // Adafruit SAMD boards (M0 and M4) #define RADIOLIB_PLATFORM "Adafruit SAMD" @@ -163,6 +166,9 @@ #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + // slow down SX126x/8x SPI on this platform + #define RADIOLIB_SPI_SLOWDOWN + #elif defined(ARDUINO_ARCH_SAMD) // Arduino SAMD (Zero, MKR, etc.) #define RADIOLIB_PLATFORM "Arduino SAMD" @@ -251,6 +257,9 @@ // Apollo3 uses mbed libraries, which already contain ESP8266 driver #define RADIOLIB_EXCLUDE_ESP8266 + // slow down SX126x/8x SPI on this platform + #define RADIOLIB_SPI_SLOWDOWN + #elif defined(ARDUINO_ARDUINO_NANO33BLE) // Arduino Nano 33 BLE #define RADIOLIB_PLATFORM "Arduino Nano 33 BLE" From bc613daf23d8b2421994a3c04222de728df2b51c Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 7 Feb 2021 17:51:55 +0100 Subject: [PATCH 452/455] [SX127x] Moved non-configurable parameters config into base class --- src/modules/RFM9x/RFM95.cpp | 4 ---- src/modules/RFM9x/RFM96.cpp | 6 +----- src/modules/SX127x/SX1272.cpp | 8 -------- src/modules/SX127x/SX1273.cpp | 4 ---- src/modules/SX127x/SX1276.cpp | 8 -------- src/modules/SX127x/SX1277.cpp | 8 -------- src/modules/SX127x/SX1278.cpp | 8 -------- src/modules/SX127x/SX1279.cpp | 8 -------- src/modules/SX127x/SX127x.cpp | 19 ++++++++++++++----- 9 files changed, 15 insertions(+), 58 deletions(-) diff --git a/src/modules/RFM9x/RFM95.cpp b/src/modules/RFM9x/RFM95.cpp index b6a84e7e..ff614852 100644 --- a/src/modules/RFM9x/RFM95.cpp +++ b/src/modules/RFM9x/RFM95.cpp @@ -19,10 +19,6 @@ int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278")); RADIOLIB_DEBUG_PRINTLN(F("M\tRFM95")); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/RFM9x/RFM96.cpp b/src/modules/RFM9x/RFM96.cpp index d7854c9f..2d6978b9 100644 --- a/src/modules/RFM9x/RFM96.cpp +++ b/src/modules/RFM9x/RFM96.cpp @@ -18,11 +18,7 @@ int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW } RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278")); RADIOLIB_DEBUG_PRINTLN(F("M\tRFM96")); - - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - + // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index e4c0bb60..f6b23efc 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -10,10 +10,6 @@ int16_t SX1272::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // mitigation of receiver spurious response // see SX1272/73 Errata, section 2.2 for details state = _mod->SPIsetRegValue(0x31, 0b10000000, 7, 7); @@ -46,10 +42,6 @@ int16_t SX1272::beginFSK(float freq, float br, float rxBw, float freqDev, int8_t int16_t state = SX127x::beginFSK(SX1272_CHIP_VERSION, br, rxBw, freqDev, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1273.cpp b/src/modules/SX127x/SX1273.cpp index 97178f81..49e12e3c 100644 --- a/src/modules/SX127x/SX1273.cpp +++ b/src/modules/SX127x/SX1273.cpp @@ -10,10 +10,6 @@ int16_t SX1273::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1272_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // mitigation of receiver spurious response // see SX1272/73 Errata, section 2.2 for details state = _mod->SPIsetRegValue(0x31, 0b10000000, 7, 7); diff --git a/src/modules/SX127x/SX1276.cpp b/src/modules/SX127x/SX1276.cpp index 848f0949..fa99cef2 100644 --- a/src/modules/SX127x/SX1276.cpp +++ b/src/modules/SX127x/SX1276.cpp @@ -10,10 +10,6 @@ int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -41,10 +37,6 @@ int16_t SX1276::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1277.cpp b/src/modules/SX127x/SX1277.cpp index 005f1ca0..284b7c87 100644 --- a/src/modules/SX127x/SX1277.cpp +++ b/src/modules/SX127x/SX1277.cpp @@ -10,10 +10,6 @@ int16_t SX1277::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -41,10 +37,6 @@ int16_t SX1277::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 906c4e07..efa065c6 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -10,10 +10,6 @@ int16_t SX1278::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -41,10 +37,6 @@ int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX1279.cpp b/src/modules/SX127x/SX1279.cpp index 346643d0..ad580404 100644 --- a/src/modules/SX127x/SX1279.cpp +++ b/src/modules/SX127x/SX1279.cpp @@ -10,10 +10,6 @@ int16_t SX1279::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync int16_t state = SX127x::begin(SX1278_CHIP_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = config(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); @@ -41,10 +37,6 @@ int16_t SX1279::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t int16_t state = SX127x::beginFSK(SX1278_CHIP_VERSION, br, freqDev, rxBw, preambleLength, enableOOK); RADIOLIB_ASSERT(state); - // configure settings not accessible by API - state = configFSK(); - RADIOLIB_ASSERT(state); - // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index a08b0374..e842cdd0 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -23,6 +23,10 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLe int16_t state = standby(); RADIOLIB_ASSERT(state); + // configure settings not accessible by API + state = config(); + RADIOLIB_ASSERT(state); + // check active modem if(getActiveModem() != SX127X_LORA) { // set LoRa mode @@ -61,8 +65,15 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB } RADIOLIB_DEBUG_PRINTLN(F("M\tSX127x")); + // set mode to standby + int16_t state = standby(); + RADIOLIB_ASSERT(state); + + // configure settings not accessible by API + state = configFSK(); + RADIOLIB_ASSERT(state); + // check currently active modem - int16_t state; if(getActiveModem() != SX127X_FSK_OOK) { // set FSK mode state = setActiveModem(SX127X_FSK_OOK); @@ -1059,7 +1070,7 @@ int16_t SX127x::configFSK() { _mod->SPIwriteRegister(SX127X_REG_IRQ_FLAGS_2, SX127X_FLAG_FIFO_OVERRUN); // set packet configuration - state = _mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_1, SX127X_PACKET_VARIABLE | SX127X_DC_FREE_WHITENING | SX127X_CRC_ON | SX127X_CRC_AUTOCLEAR_ON | SX127X_ADDRESS_FILTERING_OFF | SX127X_CRC_WHITENING_TYPE_CCITT, 7, 0); + state = _mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_1, SX127X_PACKET_VARIABLE | SX127X_DC_FREE_NONE | SX127X_CRC_ON | SX127X_CRC_AUTOCLEAR_ON | SX127X_ADDRESS_FILTERING_OFF | SX127X_CRC_WHITENING_TYPE_CCITT, 7, 0); state |= _mod->SPIsetRegValue(SX127X_REG_PACKET_CONFIG_2, SX127X_DATA_MODE_PACKET | SX127X_IO_HOME_OFF, 6, 5); RADIOLIB_ASSERT(state); @@ -1078,10 +1089,8 @@ int16_t SX127x::configFSK() { state |= _mod->SPIsetRegValue(SX127X_REG_RX_TIMEOUT_3, SX127X_TIMEOUT_SIGNAL_SYNC_OFF); RADIOLIB_ASSERT(state); - // enable preamble detector and set preamble length + // enable preamble detector state = _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_DETECT, SX127X_PREAMBLE_DETECTOR_ON | SX127X_PREAMBLE_DETECTOR_2_BYTE | SX127X_PREAMBLE_DETECTOR_TOL); - state |= _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_MSB_FSK, SX127X_PREAMBLE_SIZE_MSB); - state |= _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_LSB_FSK, SX127X_PREAMBLE_SIZE_LSB); return(state); } From f1d51fd1b9c53846486f1f745c2f290c377ffcb5 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 7 Feb 2021 17:52:17 +0100 Subject: [PATCH 453/455] [SX127x] Fixed FSK preamble unit --- src/modules/SX127x/SX127x.cpp | 7 ++++--- src/modules/SX127x/SX127x.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index e842cdd0..fe22a1e7 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -599,9 +599,10 @@ int16_t SX127x::setPreambleLength(uint16_t preambleLength) { return(state); } else if(modem == SX127X_FSK_OOK) { - // set preamble length - state = _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_MSB_FSK, (uint8_t)((preambleLength >> 8) & 0xFF)); - state |= _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_LSB_FSK, (uint8_t)(preambleLength & 0xFF)); + // set preamble length (in bytes) + uint16_t numBytes = preambleLength / 8; + state = _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_MSB_FSK, (uint8_t)((numBytes >> 8) & 0xFF)); + state |= _mod->SPIsetRegValue(SX127X_REG_PREAMBLE_LSB_FSK, (uint8_t)(numBytes & 0xFF)); return(state); } diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index a42605e1..98906354 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -745,9 +745,9 @@ class SX127x: public PhysicalLayer { int16_t setCurrentLimit(uint8_t currentLimit); /*! - \brief Sets %LoRa preamble length. Allowed values range from 6 to 65535. Only available in %LoRa mode. + \brief Sets %LoRa or FSK preamble length. Allowed values range from 6 to 65535 in %LoRa mode or 0 to 65535 in FSK mode. - \param preambleLength Preamble length to be set (in symbols). + \param preambleLength Preamble length to be set (in symbols when in LoRa mode or bits in FSK mode). \returns \ref status_codes */ From 02593bfba4c3827db06a0bbba00a8372c14fa2fe Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 7 Feb 2021 18:00:58 +0100 Subject: [PATCH 454/455] Bump version to 4.2.0 --- library.properties | 2 +- src/BuildOpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 474e24b0..1b97e255 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RadioLib -version=4.1.0 +version=4.2.0 author=Jan Gromes maintainer=Jan Gromes sentence=Universal wireless communication library for Arduino diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 212434d3..f14078ca 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -407,7 +407,7 @@ // version definitions #define RADIOLIB_VERSION_MAJOR (0x04) -#define RADIOLIB_VERSION_MINOR (0x01) +#define RADIOLIB_VERSION_MINOR (0x02) #define RADIOLIB_VERSION_PATCH (0x00) #define RADIOLIB_VERSION_EXTRA (0x00) From da3015f7b80be2a0860b67f3f99ac453f3b3502c Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 12 Feb 2021 20:21:27 +0100 Subject: [PATCH 455/455] Fixed STM32 digital pin to interrupt macro (#249) --- src/BuildOpt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuildOpt.h b/src/BuildOpt.h index f14078ca..17c69cbc 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -140,7 +140,7 @@ #define RADIOLIB_PIN_MODE uint32_t #define RADIOLIB_PIN_STATUS uint32_t #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS - #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(digitalPinToPinName(p)) + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) #define RADIOLIB_NC (0xFFFFFFFF) #define RADIOLIB_DEFAULT_SPI SPI #define RADIOLIB_PROGMEM PROGMEM