Move task initialization from init method to constructor

This saves flash
This commit is contained in:
Thomas Basler 2024-01-20 11:24:57 +01:00
parent 251d197fb6
commit 7bc1a17fac
23 changed files with 172 additions and 157 deletions

View File

@ -6,6 +6,7 @@
class DatastoreClass { class DatastoreClass {
public: public:
DatastoreClass();
void init(Scheduler& scheduler); void init(Scheduler& scheduler);
// Sum of yield total of all enabled inverters, a inverter which is just disabled at night is also included // Sum of yield total of all enabled inverters, a inverter which is just disabled at night is also included

View File

@ -8,6 +8,7 @@
class InverterSettingsClass { class InverterSettingsClass {
public: public:
InverterSettingsClass();
void init(Scheduler& scheduler); void init(Scheduler& scheduler);
private: private:

View File

@ -11,6 +11,7 @@
class MessageOutputClass : public Print { class MessageOutputClass : public Print {
public: public:
MessageOutputClass();
void init(Scheduler& scheduler); void init(Scheduler& scheduler);
size_t write(uint8_t c) override; size_t write(uint8_t c) override;
size_t write(const uint8_t* buffer, size_t size) override; size_t write(const uint8_t* buffer, size_t size) override;

View File

@ -6,6 +6,7 @@
class MqttHandleDtuClass { class MqttHandleDtuClass {
public: public:
MqttHandleDtuClass();
void init(Scheduler& scheduler); void init(Scheduler& scheduler);
private: private:

View File

@ -51,6 +51,7 @@ const byteAssign_fieldDeviceClass_t deviceFieldAssignment[] = {
class MqttHandleHassClass { class MqttHandleHassClass {
public: public:
MqttHandleHassClass();
void init(Scheduler& scheduler); void init(Scheduler& scheduler);
void publishConfig(); void publishConfig();
void forceUpdate(); void forceUpdate();

View File

@ -8,6 +8,7 @@
class MqttHandleInverterClass { class MqttHandleInverterClass {
public: public:
MqttHandleInverterClass();
void init(Scheduler& scheduler); void init(Scheduler& scheduler);
static String getTopic(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const FieldId_t fieldId); static String getTopic(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const FieldId_t fieldId);

View File

@ -5,6 +5,7 @@
class MqttHandleInverterTotalClass { class MqttHandleInverterTotalClass {
public: public:
MqttHandleInverterTotalClass();
void init(Scheduler& scheduler); void init(Scheduler& scheduler);
private: private:

View File

@ -6,6 +6,7 @@
class WebApiDtuClass { class WebApiDtuClass {
public: public:
WebApiDtuClass();
void init(AsyncWebServer& server, Scheduler& scheduler); void init(AsyncWebServer& server, Scheduler& scheduler);
private: private:

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2023 Thomas Basler and others * Copyright (C) 2023-2024 Thomas Basler and others
*/ */
#include "Datastore.h" #include "Datastore.h"
#include "Configuration.h" #include "Configuration.h"
@ -8,12 +8,14 @@
DatastoreClass Datastore; DatastoreClass Datastore;
DatastoreClass::DatastoreClass()
: _loopTask(1 * TASK_SECOND, TASK_FOREVER, std::bind(&DatastoreClass::loop, this))
{
}
void DatastoreClass::init(Scheduler& scheduler) void DatastoreClass::init(Scheduler& scheduler)
{ {
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&DatastoreClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.setInterval(1 * TASK_SECOND);
_loopTask.enable(); _loopTask.enable();
} }

View File

@ -35,6 +35,7 @@ static const char* const i18n_yield_total_kwh[] = { "total: %.1f kWh", "Ges.: %.
static const char* const i18n_date_format[] = { "%m/%d/%Y %H:%M", "%d.%m.%Y %H:%M", "%d/%m/%Y %H:%M" }; static const char* const i18n_date_format[] = { "%m/%d/%Y %H:%M", "%d.%m.%Y %H:%M", "%d/%m/%Y %H:%M" };
DisplayGraphicClass::DisplayGraphicClass() DisplayGraphicClass::DisplayGraphicClass()
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&DisplayGraphicClass::loop, this))
{ {
} }
@ -55,8 +56,6 @@ void DisplayGraphicClass::init(Scheduler& scheduler, const DisplayType_t type, c
_diagram.init(scheduler, _display); _diagram.init(scheduler, _display);
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&DisplayGraphicClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.setInterval(_period); _loopTask.setInterval(_period);
_loopTask.enable(); _loopTask.enable();
} }

View File

@ -8,6 +8,8 @@
#include <algorithm> #include <algorithm>
DisplayGraphicDiagramClass::DisplayGraphicDiagramClass() DisplayGraphicDiagramClass::DisplayGraphicDiagramClass()
: _averageTask(1 * TASK_SECOND, TASK_FOREVER, std::bind(&DisplayGraphicDiagramClass::averageLoop, this))
, _dataPointTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&DisplayGraphicDiagramClass::dataPointLoop, this))
{ {
} }
@ -16,14 +18,9 @@ void DisplayGraphicDiagramClass::init(Scheduler& scheduler, U8G2* display)
_display = display; _display = display;
scheduler.addTask(_averageTask); scheduler.addTask(_averageTask);
_averageTask.setCallback(std::bind(&DisplayGraphicDiagramClass::averageLoop, this));
_averageTask.setIterations(TASK_FOREVER);
_averageTask.setInterval(1 * TASK_SECOND);
_averageTask.enable(); _averageTask.enable();
scheduler.addTask(_dataPointTask); scheduler.addTask(_dataPointTask);
_dataPointTask.setCallback(std::bind(&DisplayGraphicDiagramClass::dataPointLoop, this));
_dataPointTask.setIterations(TASK_FOREVER);
updatePeriod(); updatePeriod();
_dataPointTask.enable(); _dataPointTask.enable();
} }
@ -58,7 +55,7 @@ uint32_t DisplayGraphicDiagramClass::getSecondsPerDot()
void DisplayGraphicDiagramClass::updatePeriod() void DisplayGraphicDiagramClass::updatePeriod()
{ {
// Calculate seconds per datapoint // Calculate seconds per datapoint
_dataPointTask.setInterval(Configuration.get().Display.Diagram.Duration * TASK_SECOND / MAX_DATAPOINTS ); _dataPointTask.setInterval(Configuration.get().Display.Diagram.Duration * TASK_SECOND / MAX_DATAPOINTS);
} }
void DisplayGraphicDiagramClass::redraw(uint8_t screenSaverOffsetX, uint8_t xPos, uint8_t yPos, uint8_t width, uint8_t height, bool isFullscreen) void DisplayGraphicDiagramClass::redraw(uint8_t screenSaverOffsetX, uint8_t xPos, uint8_t yPos, uint8_t width, uint8_t height, bool isFullscreen)
@ -110,7 +107,9 @@ void DisplayGraphicDiagramClass::redraw(uint8_t screenSaverOffsetX, uint8_t xPos
if (maxWatts > 0 && isFullscreen) { if (maxWatts > 0 && isFullscreen) {
// draw y axis ticks // draw y axis ticks
const uint16_t yAxisWattPerTick = maxWatts <= 100 ? 10 : maxWatts <= 1000 ? 100 : maxWatts < 5000 ? 500 : 1000; const uint16_t yAxisWattPerTick = maxWatts <= 100 ? 10 : maxWatts <= 1000 ? 100
: maxWatts < 5000 ? 500
: 1000;
const uint8_t yAxisTickSizePixel = height / (maxWatts / yAxisWattPerTick); const uint8_t yAxisTickSizePixel = height / (maxWatts / yAxisWattPerTick);
for (int16_t tickYPos = graphPosY + height; tickYPos > graphPosY - arrow_size; tickYPos -= yAxisTickSizePixel) { for (int16_t tickYPos = graphPosY + height; tickYPos > graphPosY - arrow_size; tickYPos -= yAxisTickSizePixel) {

View File

@ -25,6 +25,12 @@
InverterSettingsClass InverterSettings; InverterSettingsClass InverterSettings;
InverterSettingsClass::InverterSettingsClass()
: _settingsTask(INVERTER_UPDATE_SETTINGS_INTERVAL, TASK_FOREVER, std::bind(&InverterSettingsClass::settingsLoop, this))
, _hoyTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&InverterSettingsClass::hoyLoop, this))
{
}
void InverterSettingsClass::init(Scheduler& scheduler) void InverterSettingsClass::init(Scheduler& scheduler)
{ {
const CONFIG_T& config = Configuration.get(); const CONFIG_T& config = Configuration.get();
@ -91,14 +97,9 @@ void InverterSettingsClass::init(Scheduler& scheduler)
} }
scheduler.addTask(_hoyTask); scheduler.addTask(_hoyTask);
_hoyTask.setCallback(std::bind(&InverterSettingsClass::hoyLoop, this));
_hoyTask.setIterations(TASK_FOREVER);
_hoyTask.enable(); _hoyTask.enable();
scheduler.addTask(_settingsTask); scheduler.addTask(_settingsTask);
_settingsTask.setCallback(std::bind(&InverterSettingsClass::settingsLoop, this));
_settingsTask.setIterations(TASK_FOREVER);
_settingsTask.setInterval(INVERTER_UPDATE_SETTINGS_INTERVAL);
_settingsTask.enable(); _settingsTask.enable();
} }
@ -119,7 +120,7 @@ void InverterSettingsClass::settingsLoop()
inv->setEnablePolling(inv_cfg.Poll_Enable && (SunPosition.isDayPeriod() || inv_cfg.Poll_Enable_Night)); inv->setEnablePolling(inv_cfg.Poll_Enable && (SunPosition.isDayPeriod() || inv_cfg.Poll_Enable_Night));
inv->setEnableCommands(inv_cfg.Command_Enable && (SunPosition.isDayPeriod() || inv_cfg.Command_Enable_Night)); inv->setEnableCommands(inv_cfg.Command_Enable && (SunPosition.isDayPeriod() || inv_cfg.Command_Enable_Night));
} }
} }
void InverterSettingsClass::hoyLoop() void InverterSettingsClass::hoyLoop()
{ {

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2023 Thomas Basler and others * Copyright (C) 2023-2024 Thomas Basler and others
*/ */
#include "Led_Single.h" #include "Led_Single.h"
#include "Configuration.h" #include "Configuration.h"
@ -38,6 +38,8 @@ const uint8_t pwmTable[] = {
#define LED_OFF 0 #define LED_OFF 0
LedSingleClass::LedSingleClass() LedSingleClass::LedSingleClass()
: _setTask(LEDSINGLE_UPDATE_INTERVAL * TASK_MILLISECOND, TASK_FOREVER, std::bind(&LedSingleClass::setLoop, this))
, _outputTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&LedSingleClass::outputLoop, this))
{ {
} }
@ -62,14 +64,9 @@ void LedSingleClass::init(Scheduler& scheduler)
if (ledActive) { if (ledActive) {
scheduler.addTask(_outputTask); scheduler.addTask(_outputTask);
_outputTask.setCallback(std::bind(&LedSingleClass::outputLoop, this));
_outputTask.setIterations(TASK_FOREVER);
_outputTask.enable(); _outputTask.enable();
scheduler.addTask(_setTask); scheduler.addTask(_setTask);
_setTask.setCallback(std::bind(&LedSingleClass::setLoop, this));
_setTask.setInterval(LEDSINGLE_UPDATE_INTERVAL * TASK_MILLISECOND);
_setTask.setIterations(TASK_FOREVER);
_setTask.enable(); _setTask.enable();
} }
} }

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2022-2023 Thomas Basler and others * Copyright (C) 2022-2024 Thomas Basler and others
*/ */
#include "MessageOutput.h" #include "MessageOutput.h"
@ -8,11 +8,14 @@
MessageOutputClass MessageOutput; MessageOutputClass MessageOutput;
MessageOutputClass::MessageOutputClass()
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&MessageOutputClass::loop, this))
{
}
void MessageOutputClass::init(Scheduler& scheduler) void MessageOutputClass::init(Scheduler& scheduler)
{ {
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&MessageOutputClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.enable(); _loopTask.enable();
} }

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2022-2023 Thomas Basler and others * Copyright (C) 2022-2024 Thomas Basler and others
*/ */
#include "MqttHandleDtu.h" #include "MqttHandleDtu.h"
#include "Configuration.h" #include "Configuration.h"
@ -10,11 +10,14 @@
MqttHandleDtuClass MqttHandleDtu; MqttHandleDtuClass MqttHandleDtu;
MqttHandleDtuClass::MqttHandleDtuClass()
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&MqttHandleDtuClass::loop, this))
{
}
void MqttHandleDtuClass::init(Scheduler& scheduler) void MqttHandleDtuClass::init(Scheduler& scheduler)
{ {
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&MqttHandleDtuClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.setInterval(Configuration.get().Mqtt.PublishInterval * TASK_SECOND); _loopTask.setInterval(Configuration.get().Mqtt.PublishInterval * TASK_SECOND);
_loopTask.enable(); _loopTask.enable();
} }

View File

@ -11,11 +11,14 @@
MqttHandleHassClass MqttHandleHass; MqttHandleHassClass MqttHandleHass;
MqttHandleHassClass::MqttHandleHassClass()
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&MqttHandleHassClass::loop, this))
{
}
void MqttHandleHassClass::init(Scheduler& scheduler) void MqttHandleHassClass::init(Scheduler& scheduler)
{ {
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&MqttHandleHassClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.enable(); _loopTask.enable();
} }
@ -53,7 +56,7 @@ void MqttHandleHassClass::publishConfig()
const CONFIG_T& config = Configuration.get(); const CONFIG_T& config = Configuration.get();
// publish DTU sensors // publish DTU sensors
publishDtuSensor("IP", "", "diagnostic", "mdi:network-outline", "", ""); publishDtuSensor("IP", "", "diagnostic", "mdi:network-outline", "", "");
publishDtuSensor("WiFi Signal", "signal_strength", "diagnostic", "", "dBm", "rssi"); publishDtuSensor("WiFi Signal", "signal_strength", "diagnostic", "", "dBm", "rssi");
publishDtuSensor("Uptime", "duration", "diagnostic", "", "s", ""); publishDtuSensor("Uptime", "duration", "diagnostic", "", "s", "");

View File

@ -18,6 +18,11 @@
MqttHandleInverterClass MqttHandleInverter; MqttHandleInverterClass MqttHandleInverter;
MqttHandleInverterClass::MqttHandleInverterClass()
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&MqttHandleInverterClass::loop, this))
{
}
void MqttHandleInverterClass::init(Scheduler& scheduler) void MqttHandleInverterClass::init(Scheduler& scheduler)
{ {
using std::placeholders::_1; using std::placeholders::_1;
@ -36,8 +41,6 @@ void MqttHandleInverterClass::init(Scheduler& scheduler)
MqttSettings.subscribe(String(topic + "+/cmd/" + TOPIC_SUB_RESTART), 0, std::bind(&MqttHandleInverterClass::onMqttMessage, this, _1, _2, _3, _4, _5, _6)); MqttSettings.subscribe(String(topic + "+/cmd/" + TOPIC_SUB_RESTART), 0, std::bind(&MqttHandleInverterClass::onMqttMessage, this, _1, _2, _3, _4, _5, _6));
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&MqttHandleInverterClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.setInterval(Configuration.get().Mqtt.PublishInterval * TASK_SECOND); _loopTask.setInterval(Configuration.get().Mqtt.PublishInterval * TASK_SECOND);
_loopTask.enable(); _loopTask.enable();
} }

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2023 Thomas Basler and others * Copyright (C) 2023-2024 Thomas Basler and others
*/ */
#include "MqttHandleInverterTotal.h" #include "MqttHandleInverterTotal.h"
#include "Configuration.h" #include "Configuration.h"
@ -10,11 +10,14 @@
MqttHandleInverterTotalClass MqttHandleInverterTotal; MqttHandleInverterTotalClass MqttHandleInverterTotal;
MqttHandleInverterTotalClass::MqttHandleInverterTotalClass()
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&MqttHandleInverterTotalClass::loop, this))
{
}
void MqttHandleInverterTotalClass::init(Scheduler& scheduler) void MqttHandleInverterTotalClass::init(Scheduler& scheduler)
{ {
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&MqttHandleInverterTotalClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.setInterval(Configuration.get().Mqtt.PublishInterval * TASK_SECOND); _loopTask.setInterval(Configuration.get().Mqtt.PublishInterval * TASK_SECOND);
_loopTask.enable(); _loopTask.enable();
} }

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2022-2023 Thomas Basler and others * Copyright (C) 2022-2024 Thomas Basler and others
*/ */
#include "NetworkSettings.h" #include "NetworkSettings.h"
#include "Configuration.h" #include "Configuration.h"
@ -12,7 +12,8 @@
#include <ETH.h> #include <ETH.h>
NetworkSettingsClass::NetworkSettingsClass() NetworkSettingsClass::NetworkSettingsClass()
: _apIp(192, 168, 4, 1) : _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&NetworkSettingsClass::loop, this))
, _apIp(192, 168, 4, 1)
, _apNetmask(255, 255, 255, 0) , _apNetmask(255, 255, 255, 0)
{ {
_dnsServer.reset(new DNSServer()); _dnsServer.reset(new DNSServer());
@ -29,8 +30,6 @@ void NetworkSettingsClass::init(Scheduler& scheduler)
setupMode(); setupMode();
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&NetworkSettingsClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.enable(); _loopTask.enable();
} }

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2023 Thomas Basler and others * Copyright (C) 2023-2024 Thomas Basler and others
*/ */
#include "SunPosition.h" #include "SunPosition.h"
#include "Configuration.h" #include "Configuration.h"
@ -10,15 +10,13 @@
SunPositionClass SunPosition; SunPositionClass SunPosition;
SunPositionClass::SunPositionClass() SunPositionClass::SunPositionClass()
: _loopTask(5 * TASK_SECOND, TASK_FOREVER, std::bind(&SunPositionClass::loop, this))
{ {
} }
void SunPositionClass::init(Scheduler& scheduler) void SunPositionClass::init(Scheduler& scheduler)
{ {
scheduler.addTask(_loopTask); scheduler.addTask(_loopTask);
_loopTask.setCallback(std::bind(&SunPositionClass::loop, this));
_loopTask.setIterations(TASK_FOREVER);
_loopTask.setInterval(5 * TASK_SECOND);
_loopTask.enable(); _loopTask.enable();
} }

View File

@ -9,6 +9,11 @@
#include <AsyncJson.h> #include <AsyncJson.h>
#include <Hoymiles.h> #include <Hoymiles.h>
WebApiDtuClass::WebApiDtuClass()
: _applyDataTask(TASK_IMMEDIATE, TASK_ONCE, std::bind(&WebApiDtuClass::applyDataTaskCb, this))
{
}
void WebApiDtuClass::init(AsyncWebServer& server, Scheduler& scheduler) void WebApiDtuClass::init(AsyncWebServer& server, Scheduler& scheduler)
{ {
using std::placeholders::_1; using std::placeholders::_1;
@ -19,8 +24,6 @@ void WebApiDtuClass::init(AsyncWebServer& server, Scheduler& scheduler)
_server->on("/api/dtu/config", HTTP_POST, std::bind(&WebApiDtuClass::onDtuAdminPost, this, _1)); _server->on("/api/dtu/config", HTTP_POST, std::bind(&WebApiDtuClass::onDtuAdminPost, this, _1));
scheduler.addTask(_applyDataTask); scheduler.addTask(_applyDataTask);
_applyDataTask.setCallback(std::bind(&WebApiDtuClass::applyDataTaskCb, this));
_applyDataTask.setIterations(TASK_ONCE);
} }
void WebApiDtuClass::applyDataTaskCb() void WebApiDtuClass::applyDataTaskCb()

View File

@ -10,6 +10,7 @@
WebApiWsConsoleClass::WebApiWsConsoleClass() WebApiWsConsoleClass::WebApiWsConsoleClass()
: _ws("/console") : _ws("/console")
, _wsCleanupTask(1 * TASK_SECOND, TASK_FOREVER, std::bind(&WebApiWsConsoleClass::wsCleanupTaskCb, this))
{ {
} }
@ -20,9 +21,6 @@ void WebApiWsConsoleClass::init(AsyncWebServer& server, Scheduler& scheduler)
MessageOutput.register_ws_output(&_ws); MessageOutput.register_ws_output(&_ws);
scheduler.addTask(_wsCleanupTask); scheduler.addTask(_wsCleanupTask);
_wsCleanupTask.setCallback(std::bind(&WebApiWsConsoleClass::wsCleanupTaskCb, this));
_wsCleanupTask.setIterations(TASK_FOREVER);
_wsCleanupTask.setInterval(1 * TASK_SECOND);
_wsCleanupTask.enable(); _wsCleanupTask.enable();
} }

View File

@ -13,6 +13,8 @@
WebApiWsLiveClass::WebApiWsLiveClass() WebApiWsLiveClass::WebApiWsLiveClass()
: _ws("/livedata") : _ws("/livedata")
, _wsCleanupTask(1 * TASK_SECOND, TASK_FOREVER, std::bind(&WebApiWsLiveClass::wsCleanupTaskCb, this))
, _sendDataTask(1 * TASK_SECOND, TASK_FOREVER, std::bind(&WebApiWsLiveClass::sendDataTaskCb, this))
{ {
} }
@ -32,15 +34,9 @@ void WebApiWsLiveClass::init(AsyncWebServer& server, Scheduler& scheduler)
_ws.onEvent(std::bind(&WebApiWsLiveClass::onWebsocketEvent, this, _1, _2, _3, _4, _5, _6)); _ws.onEvent(std::bind(&WebApiWsLiveClass::onWebsocketEvent, this, _1, _2, _3, _4, _5, _6));
scheduler.addTask(_wsCleanupTask); scheduler.addTask(_wsCleanupTask);
_wsCleanupTask.setCallback(std::bind(&WebApiWsLiveClass::wsCleanupTaskCb, this));
_wsCleanupTask.setIterations(TASK_FOREVER);
_wsCleanupTask.setInterval(1 * TASK_SECOND);
_wsCleanupTask.enable(); _wsCleanupTask.enable();
scheduler.addTask(_sendDataTask); scheduler.addTask(_sendDataTask);
_sendDataTask.setCallback(std::bind(&WebApiWsLiveClass::sendDataTaskCb, this));
_sendDataTask.setIterations(TASK_FOREVER);
_sendDataTask.setInterval(1 * TASK_SECOND);
_sendDataTask.enable(); _sendDataTask.enable();
} }