From f65132652c7c5fff749af7ce746bee05df98d279 Mon Sep 17 00:00:00 2001 From: Ollo Date: Tue, 20 Jun 2023 17:53:19 +0200 Subject: [PATCH] Optional features can be controlled via platformio.ini and are mentioned in firmware name on MQTT --- esp32/include/ControllerConfiguration.h | 16 +++++++++++++--- esp32/include/HomieConfiguration.h | 2 +- esp32/platformio.ini | 3 +++ esp32/src/main.cpp | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index c1c0f48..8afcebc 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -80,14 +80,24 @@ /** \addtogroup Configuration * @{ */ -#define FIRMWARE_VERSION "2.71 HW0.10b" -#define TIMED_LIGHT_PIN CUSTOM1_PIN5 -#define FLOWMETER_PIN CUSTOM1_PIN1 #ifdef FLOWMETER_PIN #define FLOWMETER_PULSES_PER_ML 2.2 + #define FIRMWARE_FEATURE1 "Flow" +#else + #define FIRMWARE_FEATURE1 "" #endif +#ifdef TIMED_LIGHT_PIN + #define FIRMWARE_FEATURE2 "Light" +#else + #define FIRMWARE_FEATURE2 "" +#endif + +#define FIRMWARE_BASENAME "PlantControl" +#define FIRMWARE_NAME FIRMWARE_BASENAME FIRMWARE_FEATURE1 FIRMWARE_FEATURE2 +#define FIRMWARE_VERSION "2.71 HW0.10b" + #define MOIST_SENSOR_MAX_FRQ 5200 // 60kHz (500Hz margin) #define MOIST_SENSOR_MIN_FRQ 500 // 0.5kHz (500Hz margin) diff --git a/esp32/include/HomieConfiguration.h b/esp32/include/HomieConfiguration.h index f133962..bcfd672 100644 --- a/esp32/include/HomieConfiguration.h +++ b/esp32/include/HomieConfiguration.h @@ -103,7 +103,7 @@ HomieSetting ntpServer("ntpServer", "NTP server (pool.ntp.org as d **/ #define GENERATE_PLANT(plant, strplant) \ - HomieSetting mSensorDry##plant = HomieSetting("dry" strplant, "Plant " strplant "- Moist sensor dry %"); \ + HomieSetting mSensorDry##plant = HomieSetting("dry" strplant, "Plant" strplant " - Moist sensor dry %"); \ HomieSetting mPumpAllowedHourRangeStart##plant = HomieSetting("hourstart" strplant, "Plant" strplant " - Range pump allowed hour start (0-23)"); \ HomieSetting mPumpAllowedHourRangeEnd##plant = HomieSetting("hourend" strplant, "Plant" strplant " - Range pump allowed hour end (0-23)"); \ HomieSetting mPumpOnlyWhenLowLight##plant = HomieSetting("lowLight" strplant, "Plant" strplant " - Enable the Pump only, when there is no sunlight"); \ diff --git a/esp32/platformio.ini b/esp32/platformio.ini index 3c05e8c..af2722e 100644 --- a/esp32/platformio.ini +++ b/esp32/platformio.ini @@ -20,6 +20,9 @@ build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -DPLANT4_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE -DPLANT5_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE -DPLANT6_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE + -DTIMED_LIGHT_PIN=CUSTOM1_PIN5 + -DFLOWMETER_PIN=CUSTOM1_PIN1 + board_build.partitions = defaultWithSmallerSpiffs.csv ;#https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index b97f17e..900d804 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -808,7 +808,7 @@ void safeSetup() } /************************* Start Homie Framework ***************/ - Homie_setFirmware("PlantControl", FIRMWARE_VERSION); + Homie_setFirmware(FIRMWARE_NAME, FIRMWARE_VERSION); Homie.disableLedFeedback(); Homie_setBrand("PlantControl"); // Set default values