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;
135 std::shared_ptr<SMInterface> shm;
143 sid(
id), pubname(name) {}
146 typedef std::unordered_map<uniset::ObjectId, MQTTInfo> MQTTMap;
150 RangeInfo(
long min,
long max,
const std::string& t ): rmin(min), rmax(max), text(t) {}
155 bool check(
long val )
const;
167 std::list<RangeInfo> rlist;
169 void check( mosqpp::mosquittopp* serv,
long value, std::shared_ptr<DebugStream>& log,
const std::string& myname );
171 std::string replace(
RangeInfo* ri,
long value );
174 typedef std::unordered_map<uniset::ObjectId, MQTTTextInfo> MQTTTextMap;
177 MQTTTextMap textpublist;
183 bool connectOK = {
false };
184 std::string host = {
"localhost" };
186 int keepalive = { 60 };
191 #endif // _MQTTPublisher_H_