From 9ff546b7b7a9dbfea9645aeceb2ec6fdc086ba48 Mon Sep 17 00:00:00 2001 From: Ollo Date: Sun, 28 Nov 2021 16:02:08 +0100 Subject: [PATCH 1/2] Remove Exception stuff --- esp32/platformio.ini | 2 +- esp32/src/main.cpp | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/esp32/platformio.ini b/esp32/platformio.ini index 110308f..c6aac22 100644 --- a/esp32/platformio.ini +++ b/esp32/platformio.ini @@ -12,7 +12,7 @@ platform = espressif32 board = esp32doit-devkit-v1 framework = arduino -build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -fexceptions -lstdc++-exc +build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY board_build.partitions = defaultWithSmallerSpiffs.csv diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 918f310..db6d8c5 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -641,7 +641,6 @@ void pumpActiveLoop() void safeSetup() { - throw std::runtime_error("Shit happened"); /* reduce power consumption */ setCpuFrequencyMhz(80); @@ -832,18 +831,7 @@ void safeSetup() */ void setup() { - try - { - safeSetup(); - } - catch (const std::exception &e) - { - Serial.printf("Exception thrown: \"%s\"", e.what()); - } - catch (...) - { - Serial.println("Other exception thrown."); - } + safeSetup(); } void selfTest() From 16a722816c8b2152bf318e0de49499d72e147811 Mon Sep 17 00:00:00 2001 From: Ollo Date: Mon, 29 Nov 2021 17:25:08 +0100 Subject: [PATCH 2/2] Use only Homie compliant datatypes: https://homieiot.github.io/specification/spec-core-v3_0_1/# --- esp32/include/HomieConfiguration.h | 2 +- esp32/src/PlantCtrl.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/esp32/include/HomieConfiguration.h b/esp32/include/HomieConfiguration.h index 293b4d8..4a1a7fa 100644 --- a/esp32/include/HomieConfiguration.h +++ b/esp32/include/HomieConfiguration.h @@ -24,7 +24,7 @@ * @{ **/ -#define NUMBER_TYPE "Number" /**< numberic information, published or read in Homie */ +#define NUMBER_TYPE "Float" /**< numberic information, published or read in Homie */ /** * @name Temperatur Node diff --git a/esp32/src/PlantCtrl.cpp b/esp32/src/PlantCtrl.cpp index 68f1a22..73e6aa4 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -198,9 +198,9 @@ void Plant::setSwitchHandler(HomieInternals::PropertyInputHandler f) { void Plant::advertise(void) { // Advertise topics - mPump = this->mPlant->advertise("switch").setName("Pump").setDatatype("boolean"); - this->mPlant->advertise("lastPump").setName("lastPump").setDatatype("Number").setUnit("unixtime"); - this->mPlant->advertise("moist").setName("Percent").setDatatype("Number").setUnit("%"); - this->mPlant->advertise("moistraw").setName("adc").setDatatype("Number").setUnit("3.3/4096V"); - this->mPlant->advertise("state").setName("state").setDatatype("string"); + mPump = this->mPlant->advertise("switch").setName("Pump").setDatatype("Boolean"); + this->mPlant->advertise("lastPump").setName("lastPump").setDatatype("Integer").setUnit("unixtime"); + this->mPlant->advertise("moist").setName("Percent").setDatatype("Float").setUnit("%"); + this->mPlant->advertise("moistraw").setName("adc").setDatatype("Float").setUnit("3.3/4096V"); + this->mPlant->advertise("state").setName("state").setDatatype("String"); }