mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 04:26:58 +03:00
Improve MQTT (#1232)
added shared variable for autointerval to use it as MQTT LWT timeout
This commit is contained in:
@@ -29,6 +29,8 @@ extern "C" {
|
|||||||
|
|
||||||
static const char* TAG = "flow_controll";
|
static const char* TAG = "flow_controll";
|
||||||
|
|
||||||
|
float AutoIntervalShared = 10;
|
||||||
|
|
||||||
|
|
||||||
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
||||||
std::string _classname = "";
|
std::string _classname = "";
|
||||||
@@ -155,11 +157,6 @@ bool ClassFlowControll::isAutoStart(long &_intervall)
|
|||||||
return AutoStart;
|
return AutoStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClassFlowControll::getAutoInterval()
|
|
||||||
{
|
|
||||||
return AutoIntervall * 60; // AutoIntervall: Minuten -> seconds
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
||||||
{
|
{
|
||||||
ClassFlow* cfc = NULL;
|
ClassFlow* cfc = NULL;
|
||||||
@@ -515,6 +512,8 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
LogFile.setLogLevel((esp_log_level_t)(stoi(zerlegt[1]))); // Gets mapped to esp_log_level_t
|
LogFile.setLogLevel((esp_log_level_t)(stoi(zerlegt[1]))); // Gets mapped to esp_log_level_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoIntervalShared = AutoIntervall;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public:
|
|||||||
std::string doSingleStep(std::string _stepname, std::string _host);
|
std::string doSingleStep(std::string _stepname, std::string _host);
|
||||||
|
|
||||||
bool isAutoStart(long &_intervall);
|
bool isAutoStart(long &_intervall);
|
||||||
int getAutoInterval();
|
|
||||||
|
|
||||||
std::string* getActStatus();
|
std::string* getActStatus();
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ extern const char* libfive_git_version(void);
|
|||||||
extern const char* libfive_git_revision(void);
|
extern const char* libfive_git_revision(void);
|
||||||
extern const char* libfive_git_branch(void);
|
extern const char* libfive_git_branch(void);
|
||||||
|
|
||||||
|
extern float AutoIntervalShared;
|
||||||
|
|
||||||
std::vector<NumberPost*>* NUMBERS;
|
std::vector<NumberPost*>* NUMBERS;
|
||||||
bool HomeassistantDiscovery = false;
|
bool HomeassistantDiscovery = false;
|
||||||
|
|
||||||
@@ -163,8 +165,6 @@ void GotConnected(std::string maintopic, int SetRetainFlag) {
|
|||||||
publishRuntimeData(maintopic, SetRetainFlag);
|
publishRuntimeData(maintopic, SetRetainFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ClassFlowMQTT::SetInitialParameter(void)
|
void ClassFlowMQTT::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
uri = "";
|
uri = "";
|
||||||
@@ -202,23 +202,17 @@ ClassFlowMQTT::ClassFlowMQTT(std::vector<ClassFlow*>* lfc)
|
|||||||
ListFlowControll = lfc;
|
ListFlowControll = lfc;
|
||||||
for (int i = 0; i < ListFlowControll->size(); ++i)
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
{
|
{
|
||||||
// ESP_LOGW(TAG, "LCF: %s", ((*ListFlowControll)[i])->name().c_str());
|
|
||||||
|
|
||||||
if (((*ListFlowControll)[i])->name().compare("ClassFlowPostProcessing") == 0)
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowPostProcessing") == 0)
|
||||||
{
|
{
|
||||||
flowpostprocessing = (ClassFlowPostProcessing*) (*ListFlowControll)[i];
|
flowpostprocessing = (ClassFlowPostProcessing*) (*ListFlowControll)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO this does not work since ClassFlowControll is not in the list!
|
|
||||||
/* if (((*ListFlowControll)[i])->name().compare("ClassFlowControll") == 0)
|
|
||||||
{
|
|
||||||
ClassFlowControll *cfc = (ClassFlowControll*) (*ListFlowControll)[i];
|
|
||||||
this->keepAlive = cfc->getAutoInterval()* 2.5; // Allow at least than 2 failed rounds before we are threated as disconnected
|
|
||||||
ESP_LOGW(TAG, "KEEPALIVE: %d", this->keepAlive);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NUMBERS = flowpostprocessing->GetNumbers();
|
NUMBERS = flowpostprocessing->GetNumbers();
|
||||||
|
keepAlive = AutoIntervalShared * 60 * 2.5; // TODO find better way to access AutoIntervall in ClassFlowControll
|
||||||
|
|
||||||
|
LogFile.WriteToFile(ESP_LOG_INFO, "Digitizer interval is " + std::to_string(AutoIntervalShared) +
|
||||||
|
" minutes => setting MQTT LWT timeout to " + std::to_string(keepAlive/60) + " minutes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassFlowMQTT::ClassFlowMQTT(std::vector<ClassFlow*>* lfc, ClassFlow *_prev)
|
ClassFlowMQTT::ClassFlowMQTT(std::vector<ClassFlow*>* lfc, ClassFlow *_prev)
|
||||||
|
|||||||
Reference in New Issue
Block a user