diff --git a/firmware/src/apps/config/RaespDeviceConfig.cpp b/firmware/src/apps/config/RaespDeviceConfig.cpp index 77509a7..382022a 100644 --- a/firmware/src/apps/config/RaespDeviceConfig.cpp +++ b/firmware/src/apps/config/RaespDeviceConfig.cpp @@ -22,7 +22,7 @@ namespace apps::config addComponent(CFG_STATUS_LED); addComponent(CFG_RADIO_LED); - return ksApplication::init(); + return true; } bool RaespDeviceConfig::loop() diff --git a/firmware/src/apps/raesp/RaespDevice.cpp b/firmware/src/apps/raesp/RaespDevice.cpp index cceccec..461139b 100644 --- a/firmware/src/apps/raesp/RaespDevice.cpp +++ b/firmware/src/apps/raesp/RaespDevice.cpp @@ -45,10 +45,6 @@ namespace apps::raesp /* Create RadioCommander component. */ radioCommanderWp = addComponent(CFG_NSS_PIN, CFG_DIO0_PIN, CFG_RST_PIN, CFG_DIO2_PIN, wifiLedWp, radioLedWp); - /* Try to initialize superclass. It will initialize our components and tcpip (due to WiFi component). */ - if (!ksApplication::init()) - return false; - /* Bind to MQTT callbacks. */ if (auto mqttConnSp{mqttConnWp.lock()}) { diff --git a/firmware/src/apps/raesp/comps/RadioCommander.cpp b/firmware/src/apps/raesp/comps/RadioCommander.cpp index e2b7f58..9820e51 100644 --- a/firmware/src/apps/raesp/comps/RadioCommander.cpp +++ b/firmware/src/apps/raesp/comps/RadioCommander.cpp @@ -33,9 +33,9 @@ namespace apps::raesp::comps protocols::proto_prepare_txpin(dio2pin); } - bool RadioCommander::postInit(ksf::ksApplication* owner) + bool RadioCommander::postInit(ksf::ksApplication* app) { - mqttConnWp = owner->findComponent(); + mqttConnWp = app->findComponent(); if (auto mqttConnSp{mqttConnWp.lock()}) { @@ -159,7 +159,7 @@ namespace apps::raesp::comps command.repeats--; } - bool RadioCommander::loop() + bool RadioCommander::loop(ksf::ksApplication* app) { if (!commandQueue.empty()) { diff --git a/firmware/src/apps/raesp/comps/RadioCommander.h b/firmware/src/apps/raesp/comps/RadioCommander.h index 2720260..c27c274 100644 --- a/firmware/src/apps/raesp/comps/RadioCommander.h +++ b/firmware/src/apps/raesp/comps/RadioCommander.h @@ -116,10 +116,10 @@ namespace apps::raesp::comps /* Handles RadioCommander logic. - + @param app Application object. @return True on success, false on fail. */ - bool loop() override; + bool loop(ksf::ksApplication* app) override; /* Stops all TX. Will clear radio command queue. diff --git a/firmware/src/apps/raesp/comps/TempSensor.cpp b/firmware/src/apps/raesp/comps/TempSensor.cpp index 17f2343..4233d27 100644 --- a/firmware/src/apps/raesp/comps/TempSensor.cpp +++ b/firmware/src/apps/raesp/comps/TempSensor.cpp @@ -20,10 +20,9 @@ namespace apps::raesp::comps : dataPin(dataPin), enabPin(enabPin), resolution(resolution), measurementTimer(tempUpdateInterval) {} - bool TempSensor::init(ksf::ksApplication* owner) + bool TempSensor::init(ksf::ksApplication* app) { - this->owner = owner; - mqttConnWp = owner->findComponent(); + mqttConnWp = app->findComponent(); return true; } @@ -71,7 +70,7 @@ namespace apps::raesp::comps else { /* Queue ourselves for removal. */ - owner->markComponentToRemove(shared_from_this()); + componentState = ksf::ksComponentState::ToBeRemoved; } /* Disable power for the sensor. */ @@ -95,7 +94,7 @@ namespace apps::raesp::comps GPEC = cachedGPEC; // GPEC registry. } - bool TempSensor::loop() + bool TempSensor::loop(ksf::ksApplication* app) { if (measurementTimer.triggered()) if (auto mqttConnSp{mqttConnWp.lock()}) diff --git a/firmware/src/apps/raesp/comps/TempSensor.h b/firmware/src/apps/raesp/comps/TempSensor.h index a606848..7ceb436 100644 --- a/firmware/src/apps/raesp/comps/TempSensor.h +++ b/firmware/src/apps/raesp/comps/TempSensor.h @@ -21,8 +21,6 @@ namespace apps::raesp::comps KSF_RTTI_DECLARATIONS(TempSensor, ksf::ksComponent) protected: - ksf::ksApplication* owner{nullptr}; // Parent application pointer. - std::weak_ptr mqttConnWp; // Weak pointer to mqtt connector. std::unique_ptr ds18handler; // Temp sensor handle ptr. @@ -74,14 +72,14 @@ namespace apps::raesp::comps @param owner Pointer to owning application. @return True on success, false on fail. */ - bool init(ksf::ksApplication* owner) override; + bool init(ksf::ksApplication* app) override; - /* + /* Handles TempSensor logic. - + @param app Pointer to owning application. @return True on success, false on fail. */ - bool loop() override; + bool loop(ksf::ksApplication* app) override; /* Destructor to free up resources.