ElectronicCats / Beelan-LoRaWAN

A LoRaWAN library for compatible arduino board
https://www.beelan.mx
MIT License
191 stars 78 forks source link

Unable to set the frequency plan in the main program #120

Closed IoTThinks closed 2 years ago

IoTThinks commented 2 years ago

Is there any way to set the frequency plan in the main Arduino program? The "define" in the main Arduino program will not affect the "define" in the Config.h.

The code in Config.h will never run and the default frequency plan is always EU_868. So library users must edit the Config.h to set the frequency plan.

We should have a function to set frequency plan instead. https://github.com/BeelanMX/Beelan-LoRaWAN/blob/master/src/arduino-rfm/Config.h#L12

//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(EU_868) && !defined(US_915) && !defined(AU_915)

//LoRaWAN freq band
//#define AS_923
#define EU_868
//#define US_915
//#define AU_915

#ifdef US_915
//Select the subband youre working on
// make sure your gateway is working in one of these bands
#define SUBND_0 // 902.3 - 903.7 Mhz
//#define SUBND_1     // 903.9 - 905.3 Mhz TTN
//#define SUBND_2     // 905.5 - 906.9 Mhz
//#define SUBND_3     // 907.1 - 908.5 Mhz
//#define SUBND_4     // 908.7 - 910.1 Mhz
//#define SUBND_5     // 910.3 - 911.7 Mhz
//#define SUBND_6     // 911.9 - 913.3 Mhz
//#define SUBND_7     // 913.5 - 914.9 Mhz
#endif

#ifdef AU_915
//Select the subband youre working on
// make sure your gateway is working in one of these bands
#define SUBND_0 // 915.2 - 916.6 Mhz
//#define SUBND_1     // 916.8 - 918.2 Mhz
//#define SUBND_2     // 918.4 - 919.8 Mhz
//#define SUBND_3     // 920.0 - 921.4 Mhz
//#define SUBND_4     // 921.6 - 923.0 Mhz
//#define SUBND_5     // 923.2 - 924.6 Mhz
//#define SUBND_6     // 924.8 - 926.2 Mhz
//#define SUBND_7     // 926.4 - 927.8 Mhz
#endif
#endif
IoTThinks commented 2 years ago

Already added a pull request. To close the issue.