Skip to content

Commit

Permalink
Refactor - remove ksSafeList
Browse files Browse the repository at this point in the history
  • Loading branch information
cziter15 committed Oct 8, 2023
1 parent 42cb332 commit cd3196f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion firmware/src/apps/config/RaespDeviceConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace apps::config
addComponent<ksf::comps::ksLed>(CFG_STATUS_LED);
addComponent<ksf::comps::ksLed>(CFG_RADIO_LED);

return ksApplication::init();
return true;
}

bool RaespDeviceConfig::loop()
Expand Down
4 changes: 0 additions & 4 deletions firmware/src/apps/raesp/RaespDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ namespace apps::raesp
/* Create RadioCommander component. */
radioCommanderWp = addComponent<comps::RadioCommander>(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()})
{
Expand Down
6 changes: 3 additions & 3 deletions firmware/src/apps/raesp/comps/RadioCommander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ksf::comps::ksMqttConnector>();
mqttConnWp = app->findComponent<ksf::comps::ksMqttConnector>();

if (auto mqttConnSp{mqttConnWp.lock()})
{
Expand Down Expand Up @@ -159,7 +159,7 @@ namespace apps::raesp::comps
command.repeats--;
}

bool RadioCommander::loop()
bool RadioCommander::loop(ksf::ksApplication* app)
{
if (!commandQueue.empty())
{
Expand Down
4 changes: 2 additions & 2 deletions firmware/src/apps/raesp/comps/RadioCommander.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions firmware/src/apps/raesp/comps/TempSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ksf::comps::ksMqttConnector>();
mqttConnWp = app->findComponent<ksf::comps::ksMqttConnector>();
return true;
}

Expand Down Expand Up @@ -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. */
Expand All @@ -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()})
Expand Down
10 changes: 4 additions & 6 deletions firmware/src/apps/raesp/comps/TempSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ksf::comps::ksMqttConnector> mqttConnWp; // Weak pointer to mqtt connector.
std::unique_ptr<DS18B20> ds18handler; // Temp sensor handle ptr.

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit cd3196f

Please sign in to comment.