From 7fc57ffc8c0fa1aba843b95d11d1383bfc6f08df Mon Sep 17 00:00:00 2001 From: Oliver Fueckert Date: Tue, 30 Aug 2022 08:52:47 +0200 Subject: [PATCH] - Improve config system allowing a user customizable config_override.h file to ensure git pulls don't require merges - Move DTU_RADIO_ID to config.h to allow for easy customization for multiple DTUs with non conflicting radio IDs --- tools/esp8266/.gitignore | 1 + tools/esp8266/README.md | 6 +++-- tools/esp8266/config.h | 7 ++++++ tools/esp8266/config_override_example.h | 30 +++++++++++++++++++++++++ tools/esp8266/hmRadio.h | 1 - tools/esp8266/platformio.ini | 4 +++- 6 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 tools/esp8266/config_override_example.h diff --git a/tools/esp8266/.gitignore b/tools/esp8266/.gitignore index 89cc49cb..3e881135 100644 --- a/tools/esp8266/.gitignore +++ b/tools/esp8266/.gitignore @@ -3,3 +3,4 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +config_override.h diff --git a/tools/esp8266/README.md b/tools/esp8266/README.md index 8ea1ade0..24a3de4a 100644 --- a/tools/esp8266/README.md +++ b/tools/esp8266/README.md @@ -20,10 +20,12 @@ This code can be compiled using Visual Studio Code and **PlatformIO** Addon. The ### Optional Configuration before compilation -- number of supported inverters (set to 3 by default) `defines.h` -- DTU radio id `hmRadio.h` +- number of supported inverters (set to 3 by default) `config.h` +- DTU radio id `config.h` (default = 1234567801) - unformated list in webbrowser `/livedata` `config.h`, `LIVEDATA_VISUALIZED` +Alternativly, instead of modifying `config.h`, `config_override_example.h` can be copied to `config_override.h` and customized. +config_override.h is excluded from version control and stays local. ## Flash ESP with firmware diff --git a/tools/esp8266/config.h b/tools/esp8266/config.h index 8331c273..e27a2e09 100644 --- a/tools/esp8266/config.h +++ b/tools/esp8266/config.h @@ -36,6 +36,9 @@ #define DEF_RF24_CE_PIN 2 #define DEF_RF24_IRQ_PIN 0 +// default radio ID +#define DTU_RADIO_ID ((uint64_t)0x1234567801ULL) + // default NRF24 power, possible values (0 - 3) #define DEF_AMPLIFIERPOWER 2 @@ -96,4 +99,8 @@ // changes the style of "/setup" page, visualized = nicer #define LIVEDATA_VISUALIZED +#if __has_include("config_override.h") + #include "config_override.h" +#endif + #endif /*__CONFIG_H__*/ diff --git a/tools/esp8266/config_override_example.h b/tools/esp8266/config_override_example.h new file mode 100644 index 00000000..dbaf54df --- /dev/null +++ b/tools/esp8266/config_override_example.h @@ -0,0 +1,30 @@ +//----------------------------------------------------------------------------- +// 2022 Ahoy, https://www.mikrocontroller.net/topic/525778 +// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +//----------------------------------------------------------------------------- + +#ifndef __CONFIG_OVERRIDE_H__ +#define __CONFIG_OVERRIDE_H__ + +// override fallback WiFi info + +// each ovveride must be preceeded with an #undef statement +#undef FB_WIFI_SSID +#define FB_WIFI_SSID "MY_SSID" + +// each ovveride must be preceeded with an #undef statement +#undef FB_WIFI_PWD +#define FB_WIFI_PWD "MY_WIFI_KEY" + +// ESP32 default pinout +#undef DEF_RF24_CS_PIN +#define DEF_RF24_CS_PIN 5 +#undef DEF_RF24_CE_PIN +#define DEF_RF24_CE_PIN 4 +#undef DEF_RF24_IRQ_PIN +#define DEF_RF24_IRQ_PIN 16 + +#undef DTU_RADIO_ID +#define DTU_RADIO_ID ((uint64_t)0x1234567802ULL) + +#endif /*__CONFIG_OVERRIDE_H__*/ diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index 7decd2c2..be2a1509 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -16,7 +16,6 @@ #define DEFAULT_RECV_CHANNEL 3 #define SPI_SPEED 1000000 -#define DTU_RADIO_ID ((uint64_t)0x1234567801ULL) #define DUMMY_RADIO_ID ((uint64_t)0xDEADBEEF01ULL) #define RF_CHANNELS 5 diff --git a/tools/esp8266/platformio.ini b/tools/esp8266/platformio.ini index ee0ad242..48b292c7 100644 --- a/tools/esp8266/platformio.ini +++ b/tools/esp8266/platformio.ini @@ -14,9 +14,11 @@ src_dir = . [env] framework = arduino +build_flags = + -include "config.h" ; ;;;;; Possible Debug options ;;;;;; ; https://docs.platformio.org/en/latest/platforms/espressif8266.html#debug-level -;build_flags = -DDEBUG_ESP_PORT=Serial + ;-DDEBUG_ESP_PORT=Serial ;-DDEBUG_ESP_CORE ;-DDEBUG_ESP_WIFI ;-DDEBUG_ESP_HTTP_CLIENT