Fixing configuration system - part 1: sensors

Fixed the configuration system for sensor nodes. Gateway nodes are still to be fixed (work still in process :) )
This has been addressed in #71

Important: For this system to work and make the onboarding easier for new users, global settings must be used by default and therefore local settings must be commented out by default.
This commit is contained in:
Sascha 2022-07-21 14:01:51 +02:00
parent d6201fdd6d
commit cfa57e388b
4 changed files with 119 additions and 15 deletions

View File

@ -17,13 +17,30 @@
#include <LoRa.h>
#endif
#ifdef FDRS_GLOBALS
#define FDRS_BAND GLOBAL_LORA_BAND
#define FDRS_SF GLOBAL_LORA_SF
#else
// enable to get detailed info from where single configuration macros have been taken
//#define DEBUG_NODE_CONFIG
#ifdef USE_LORA
// select LoRa band configuration
#if defined(LORA_BAND)
#define FDRS_BAND LORA_BAND
#elif defined (GLOBAL_LORA_BAND)
#define FDRS_BAND GLOBAL_LORA_BAND
#else
// ASSERT("NO LORA-BAND defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
#endif //LORA_BAND
// select LoRa SF configuration
#if defined(LORA_SF)
#define FDRS_SF LORA_SF
#endif
#elif defined (GLOBAL_LORA_SF)
#define FDRS_SF GLOBAL_LORA_SF
#else
// ASSERT("NO LORA-SF defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
#endif //LORA_SF
#endif //USE_LORA
#ifdef FDRS_DEBUG
#define DBG(a) (Serial.println(a))
@ -49,6 +66,37 @@ uint32_t wait_time = 0;
DataReading fdrsData[espnow_size];
uint8_t data_count = 0;
void debugConfig() {
#ifdef USE_LORA
DBG("----------------------------------------------------");
DBG("SENSOR LORA CONFIG");
DBG("----------------------------------------------------");
#if defined(LORA_BAND)
DBG("LoRa Band used from LORA_BAND : " + String(FDRS_BAND));
#elif defined (GLOBAL_LORA_BAND)
DBG("LoRa Band used from GLOBAL_LORA_BAND: " + String(FDRS_BAND));
#else
DBG("NO LORA-BAND defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
//exit(0);
#endif //LORA-BAND
#if defined(LORA_SF)
DBG("LoRa SF used from LORA_SF : " + String(FDRS_SF));
#elif defined (GLOBAL_LORA_SF)
DBG("LoRa SF used from GLOBAL_LORA_SF : " + String(FDRS_SF));
#else
// ASSERT("NO LORA-SF defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
DBG("NO LORA-SF defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
//exit(0);
#endif //LORA-BAND
DBG("----------------------------------------------------");
DBG("");
#endif //USE_LORA
}
void beginFDRS() {
#ifdef FDRS_DEBUG
Serial.begin(115200);
@ -102,8 +150,12 @@ void beginFDRS() {
}
LoRa.setSpreadingFactor(FDRS_SF);
DBG(" LoRa Initialized.");
#ifdef DEBUG_NODE_CONFIG
debugConfig();
#else
DBG("LoRa Band: " + String(FDRS_BAND));
DBG("LoRa SF : " + String(FDRS_SF));
#endif //DEBUG_NODE_CONFIG
#endif // USE_LORA
}

View File

@ -25,5 +25,5 @@
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
#define LORA_BAND 915E6
#define LORA_SF 7
//#define LORA_BAND 915E6
//#define LORA_SF 7

View File

@ -57,8 +57,8 @@
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
#define LORA_BAND 915E6
#define LORA_SF 7
//#define LORA_BAND 915E6
//#define LORA_SF 7
// Buffer Delays - in milliseconds - Uncomment to enable any buffer

View File

@ -17,13 +17,30 @@
#include <LoRa.h>
#endif
#ifdef FDRS_GLOBALS
#define FDRS_BAND GLOBAL_LORA_BAND
#define FDRS_SF GLOBAL_LORA_SF
#else
// enable to get detailed info from where single configuration macros have been taken
//#define DEBUG_NODE_CONFIG
#ifdef USE_LORA
// select LoRa band configuration
#if defined(LORA_BAND)
#define FDRS_BAND LORA_BAND
#elif defined (GLOBAL_LORA_BAND)
#define FDRS_BAND GLOBAL_LORA_BAND
#else
// ASSERT("NO LORA-BAND defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
#endif //LORA_BAND
// select LoRa SF configuration
#if defined(LORA_SF)
#define FDRS_SF LORA_SF
#endif
#elif defined (GLOBAL_LORA_SF)
#define FDRS_SF GLOBAL_LORA_SF
#else
// ASSERT("NO LORA-SF defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
#endif //LORA_SF
#endif //USE_LORA
#ifdef FDRS_DEBUG
#define DBG(a) (Serial.println(a))
@ -49,6 +66,37 @@ uint32_t wait_time = 0;
DataReading fdrsData[espnow_size];
uint8_t data_count = 0;
void debugConfig() {
#ifdef USE_LORA
DBG("----------------------------------------------------");
DBG("SENSOR LORA CONFIG");
DBG("----------------------------------------------------");
#if defined(LORA_BAND)
DBG("LoRa Band used from LORA_BAND : " + String(FDRS_BAND));
#elif defined (GLOBAL_LORA_BAND)
DBG("LoRa Band used from GLOBAL_LORA_BAND: " + String(FDRS_BAND));
#else
DBG("NO LORA-BAND defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
//exit(0);
#endif //LORA-BAND
#if defined(LORA_SF)
DBG("LoRa SF used from LORA_SF : " + String(FDRS_SF));
#elif defined (GLOBAL_LORA_SF)
DBG("LoRa SF used from GLOBAL_LORA_SF : " + String(FDRS_SF));
#else
// ASSERT("NO LORA-SF defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
DBG("NO LORA-SF defined! Please define in fdrs_globals.h (recommended) or in fdrs_sensor_config.h");
//exit(0);
#endif //LORA-BAND
DBG("----------------------------------------------------");
DBG("");
#endif //USE_LORA
}
void beginFDRS() {
#ifdef FDRS_DEBUG
Serial.begin(115200);
@ -102,9 +150,13 @@ void beginFDRS() {
}
LoRa.setSpreadingFactor(FDRS_SF);
DBG(" LoRa Initialized.");
#ifdef DEBUG_NODE_CONFIG
debugConfig();
#else
DBG("LoRa Band: " + String(FDRS_BAND));
DBG("LoRa SF : " + String(FDRS_SF));
#endif
#endif //DEBUG_NODE_CONFIG
#endif // USE_LORA
}
void transmitLoRa(uint8_t* mac, DataReading * packet, uint8_t len) {