diff --git a/.github/workflows/BuildLibrary.yml b/.github/workflows/BuildLibrary.yml index c211221..5ecd268 100644 --- a/.github/workflows/BuildLibrary.yml +++ b/.github/workflows/BuildLibrary.yml @@ -29,10 +29,15 @@ jobs: ############################################################################################################# arduino-boards-fqbn: - arduino:avr:uno - - arduino:avr:leonardo + - arduino:avr:uno|All-US_915 + - arduino:avr:leonardo|All-US_915 + - arduino:samd:nano_33_iot|All-US_915 - arduino:samd:nano_33_iot - - arduino:mbed:nano33ble - - esp8266:esp8266:huzzah:eesz=4M3M,xtal=80 + - arduino:mbed:nano33ble|All-US_915 + - esp8266:esp8266:huzzah:eesz=4M3M,xtal=80|All-US_915 + - rp2040:rp2040:generic|All-US_915 + #- esp32:esp32:esp32:FlashFreq=80 + #- esp32:esp32:featheresp32:FlashFreq=80|All-US_915 # Specify parameters for each board. # Parameters can be: platform-url, examples-exclude and examples-build-properties @@ -40,15 +45,81 @@ jobs: ############################################################################################################# include: - arduino-boards-fqbn: arduino:avr:uno - - - arduino-boards-fqbn: arduino:avr:leonardo - + sketch-names: class_c_abp.ino,class_c_otaa_ack.ino # Comma separated list of sketch names (no path required) or patterns to use in build + build-properties: + class_c_abp: + -DDEBUG + -DEU_868 + -D_CLASS_C_ + class_c_otaa_ack: + -DDEBUG + -DEU_868 + -D_CLASS_C_ + All: + -DEU_868 + -DDEBUG + - arduino-boards-fqbn: arduino:avr:uno|All-US_915 + build-properties: + All: + -DUS_915 + -DDEBUG + - arduino-boards-fqbn: arduino:avr:leonardo|All-US_915 + build-properties: + All: + -DUS_915 + -DDEBUG - arduino-boards-fqbn: arduino:samd:nano_33_iot - - - arduino-boards-fqbn: arduino:mbed:nano33ble - - - arduino-boards-fqbn: esp8266:esp8266:huzzah:eesz=4M3M,xtal=80 + build-properties: + class_c_abp: + -DDEBUG + -DEU_868 + -D_CLASS_C_ + class_c_otaa_ack: + -DDEBUG + -DEU_868 + -D_CLASS_C_ + All: + -DEU_868 + - arduino-boards-fqbn: arduino:samd:nano_33_iot|All-US_915 + build-properties: + All: + -DUS_915 + -DDEBUG + - arduino-boards-fqbn: arduino:mbed:nano33ble|All-US_915 + build-properties: + All: + -DUS_915 + -DDEBUG + - arduino-boards-fqbn: esp8266:esp8266:huzzah:eesz=4M3M,xtal=80|All-US_915 platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json + build-properties: + All: + -DUS_915 + -DDEBUG + - arduino-boards-fqbn: rp2040:rp2040:generic|All-US_915 + platform-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + build-properties: + All: + -DUS_915 + -DDEBUG + #- arduino-boards-fqbn: esp32:esp32:esp32:FlashFreq=80 + # platform-url: https://github.com/espressif/arduino-esp32/releases/download/3.0.0-alpha2/package_esp32_dev_index.json + # extra-arduino-cli-args: "--warnings default" + # build-properties: + # class_c_abp: + # -DEU_868 + # -D_CLASS_C_ + # class_c_otaa_ack: + # -DEU_868 + # -D_CLASS_C_ + #All: + # -DEU_868 + #- arduino-boards-fqbn: esp32:esp32:featheresp32:FlashFreq=80|All-US_915 + # platform-url: https://github.com/espressif/arduino-esp32/releases/download/3.0.0-alpha2/package_esp32_dev_index.json + # extra-arduino-cli-args: "--warnings default" + # build-properties: + # All: + # -DUS_915 # Do not cancel all jobs / architectures if one job fails fail-fast: false @@ -65,4 +136,6 @@ jobs: with: arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }} platform-url: ${{ matrix.platform-url }} - examples-exclude: DetectingReaders + build-properties: ${{ toJson(matrix.build-properties) }} + extra-arduino-cli-args: ${{ matrix.extra-arduino-cli-args }} + diff --git a/examples/class-C-ABP/class_c_ABP/class_c_ABP.ino b/examples/class-C-ABP/class_c_ABP/class_c_ABP.ino deleted file mode 100644 index ef50ad9..0000000 --- a/examples/class-C-ABP/class_c_ABP/class_c_ABP.ino +++ /dev/null @@ -1,75 +0,0 @@ -#include - -//ABP Credentials -const char *devAddr = "00000000"; -const char *nwkSKey = "00000000000000000000000000000000"; -const char *appSKey = "00000000000000000000000000000000"; - -const unsigned long interval = 20000; // 10 s interval to send message -unsigned long previousMillis = 0; // will store last time message sent -unsigned int counter = 0; // message counter - -char myStr[50]; -char outStr[255]; -byte recvStatus = 0; - -const sRFM_pins RFM_pins = { - .CS = 6, - .RST = 7, - .DIO0 = 8, - .DIO1 = 9, - .DIO2 = -1, - .DIO5 = -1, -}; - - -void setup() { - // Setup loraid access - Serial.begin(115200); - delay(5000); - Serial.println("Start.."); - if(!lora.init()){ - Serial.println("RFM95 not detected"); - delay(5000); - return; - } - - // Set LoRaWAN Class change CLASS_A or CLASS_C - lora.setDeviceClass(CLASS_C); - - // Set Data Rate - lora.setDataRate(SF7BW125); - - // set channel to random - lora.setChannel(MULTI); - - // Put ABP Key and DevAddress here - lora.setNwkSKey(nwkSKey); - lora.setAppSKey(appSKey); - lora.setDevAddr(devAddr); -} - -void loop() { - - // Check interval overflow - if(millis() - previousMillis > interval) { - previousMillis = millis(); - - sprintf(myStr, "Counter-%d", counter); - - Serial.print("Sending: "); - Serial.println(myStr); - - lora.sendUplink(myStr, strlen(myStr), 0, 1); - counter++; - } - - recvStatus = lora.readData(outStr); - if(recvStatus) { - Serial.print("====>> "); - Serial.println(outStr); - } - - // Check Lora RX - lora.update(); -} \ No newline at end of file diff --git a/examples/send-class-A-ABP/send-class-A-ABP.ino b/examples/class_a_abp/class_a_abp.ino similarity index 100% rename from examples/send-class-A-ABP/send-class-A-ABP.ino rename to examples/class_a_abp/class_a_abp.ino diff --git a/examples/send-class-A-OTAA/send-class-A-OTAA.ino b/examples/class_a_otaa/class_a_otaa.ino similarity index 100% rename from examples/send-class-A-OTAA/send-class-A-OTAA.ino rename to examples/class_a_otaa/class_a_otaa.ino diff --git a/examples/class-C-ABP/class-C-ABP.ino b/examples/class_c_abp/class_c_abp.ino similarity index 100% rename from examples/class-C-ABP/class-C-ABP.ino rename to examples/class_c_abp/class_c_abp.ino diff --git a/examples/Class-C-OTAA-ACK/Class-C-OTAA-ACK.cpp b/examples/class_c_otaa_ack/class_c_otaa_ack.ino similarity index 100% rename from examples/Class-C-OTAA-ACK/Class-C-OTAA-ACK.cpp rename to examples/class_c_otaa_ack/class_c_otaa_ack.ino diff --git a/examples/class-C-ABP/serialToLoRaWAN/serialToLoRaWAN.ino b/examples/serialToLoRaWAN/serialToLoRaWAN.ino similarity index 100% rename from examples/class-C-ABP/serialToLoRaWAN/serialToLoRaWAN.ino rename to examples/serialToLoRaWAN/serialToLoRaWAN.ino diff --git a/src/arduino-rfm/Config.h b/src/arduino-rfm/Config.h index a7d09c5..e883c75 100644 --- a/src/arduino-rfm/Config.h +++ b/src/arduino-rfm/Config.h @@ -1,25 +1,25 @@ -//Uncomment for debug -//#define DEBUG - // To define your LoRaWAN frequency band here +//#define US_915 //#define AS_923 //#define AS_923_2 -#define EU_868 -//#define US_915 +//#define EU_868 //#define AU_915 -#define IN_865 +//#define IN_865 + +#if !defined(AS_923) && !defined(AS_923_2) && !defined(EU_868) && !defined(US_915) && !defined(AU_915) &&!defined(IN_865) +#error "Select the Region in Config.h" +#endif // If you dont define _CLASS_C_, CLASS_A mode will be on -#define _CLASS_C_ +//#define _CLASS_C_ + +//Uncomment for debug +//#define DEBUG // Define max payload size used for this node #define MAX_UPLINK_PAYLOAD_SIZE 220 #define MAX_DOWNLINK_PAYLOAD_SIZE 220 -#if !defined(AS_923) && !defined(AS_923_2) && !defined(EU_868) && !defined(US_915) && !defined(AU_915) &&!defined(IN_865) -#define US_915 // Define default Region -#endif - #ifdef US_915 //Select the subband you're working on // make sure your gateway is working with the selected subband diff --git a/src/arduino-rfm/lorawan-arduino-rfm.cpp b/src/arduino-rfm/lorawan-arduino-rfm.cpp index b032319..48e2008 100644 --- a/src/arduino-rfm/lorawan-arduino-rfm.cpp +++ b/src/arduino-rfm/lorawan-arduino-rfm.cpp @@ -436,6 +436,7 @@ bool LoRaWANClass::readAck(void) return false; } +#ifdef _CLASS_C_ void LoRaWANClass::switchToClassC(sSettings *LoRa_Settings) { lora.setDeviceClass(CLASS_C); @@ -443,6 +444,7 @@ void LoRaWANClass::switchToClassC(sSettings *LoRa_Settings) LoRa_Settings->Datarate_Rx = SF12BW125; //set RX2 datarate 12 RFM_Continuous_Receive(LoRa_Settings); } +#endif void LoRaWANClass::onMessage(void(*callback)(sBuffer *Data_Rx, bool isConfirmed, uint8_t fPort)) { diff --git a/test/testFullfrequency/testFullfrequency.ino b/test/testFullfrequency/testFullfrequency.ino index e2c7aec..a348a10 100644 --- a/test/testFullfrequency/testFullfrequency.ino +++ b/test/testFullfrequency/testFullfrequency.ino @@ -36,7 +36,7 @@ byte recvStatus = 0; byte _dataRate; byte _channel; -byte _times; +byte times; const sRFM_pins RFM_pins = { .CS = 20, @@ -65,7 +65,7 @@ void setup() { counter.val = 0; _channel = 0; // 0 - 7 _dataRate = 0; // 0 - 3 - _times = 0; + times = 0; // Put ABP Key and DevAddress here lora.setNwkSKey(nwkSKey); @@ -77,8 +77,8 @@ void loop() { currentMillis = millis(); // Check interval overflow if(currentMillis - previousMillis > interval) { - if(_times > 0){ - _times = 0; + if(times > 0){ + times = 0; _dataRate++; if (_dataRate > 3){ _dataRate = 0; @@ -106,13 +106,13 @@ void loop() { payload[0] = _channel; payload[1] = _dataRate; payload[2] = 15; - payload[3] = _times + 1; + payload[3] = times + 1; payload[4] = counter._cb[1]; payload[5] = counter._cb[0]; lora.sendUplink(payload, 6, 0, 1); counter.val++; - _times++; + times++; } // Check Lora RX diff --git a/test/testOTAA/testOTAA.ino b/test/testOTAA/testOTAA.ino index f3a3775..61981f2 100644 --- a/test/testOTAA/testOTAA.ino +++ b/test/testOTAA/testOTAA.ino @@ -35,7 +35,7 @@ byte recvStatus = 0; byte _dataRate; byte _channel; -byte _times; +byte times; const sRFM_pins RFM_pins = { .CS = 20, @@ -64,7 +64,7 @@ void setup() { counter.val = 0; _channel = 0; // 0 - 7 _dataRate = 0; // 0 - 3 - _times = 0; + times = 0; lora.setDevEUI(devEui); lora.setAppEUI(appEui); @@ -83,8 +83,8 @@ void loop() { currentMillis = millis(); // Check interval overflow if(currentMillis - previousMillis > interval) { - if(_times > 0){ - _times = 0; + if(times > 0){ + times = 0; _dataRate++; if (_dataRate > 3){ _dataRate = 0; @@ -112,13 +112,13 @@ void loop() { payload[0] = _channel; payload[1] = _dataRate; payload[2] = 15; - payload[3] = _times + 1; + payload[3] = times + 1; payload[4] = counter._cb[1]; payload[5] = counter._cb[0]; lora.sendUplink(payload, 6, 0, 1); counter.val++; - _times++; + times++; } // Check Lora RX