17 #ifndef _MQTTPublisher_H_
18 #define _MQTTPublisher_H_
20 #include <unordered_map>
23 #include <mosquittopp.h>
24 #include "UObject_SK.h"
25 #include "SMInterface.h"
26 #include "SharedMemory.h"
27 #include "extensions/Extensions.h"
107 protected mosqpp::mosquittopp,
112 const std::string& prefix =
"mqtt" );
116 static std::shared_ptr<MQTTPublisher>
init_mqttpublisher(
int argc,
const char*
const* argv,
118 const std::string& prefix =
"mqtt" );
121 static void help_print(
int argc,
const char*
const* argv );
123 virtual void on_connect(
int rc)
override;
124 virtual void on_message(
const struct mosquitto_message* message)
override;
125 virtual void on_subscribe(
int mid,
int qos_count,
const int* granted_qos)
override;
130 virtual void askSensors( UniversalIO::UIOCommand cmd )
override;
132 virtual void sigterm(
int signo )
override;
136 std::shared_ptr<SMInterface> shm;
144 sid(
id), pubname(name) {}
147 typedef std::unordered_map<uniset::ObjectId, MQTTInfo> MQTTMap;
151 RangeInfo(
long min,
long max,
const std::string& t ): rmin(min), rmax(max), text(t) {}
156 bool check(
long val )
const;
168 std::list<RangeInfo> rlist;
170 void check( mosqpp::mosquittopp* serv,
long value, std::shared_ptr<DebugStream>& log,
const std::string& myname );
172 std::string replace(
RangeInfo* ri,
long value );
175 typedef std::unordered_map<uniset::ObjectId, MQTTTextInfo> MQTTTextMap;
178 MQTTTextMap textpublist;
184 bool connectOK = {
false };
185 std::string host = {
"localhost" };
187 int keepalive = { 60 };
192 #endif // _MQTTPublisher_H_