NetBurner 3.5.6
PDF Version
mqtt.h
Go to the documentation of this file.
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5#ifndef __MQTT_API_H
6#define __MQTT_API_H
7
8#include <predef.h>
9#include <constants.h>
10#include <config_obj.h>
11#include <config_fs_bulkstore.h>
12#include <nettimer.h>
13#include <mqtt/msg_types.h>
14#include <mqtt/mqtt_msg_reqs.h>
16#include <json_lexer.h>
17#include <pins.h>
18#ifdef NB_SSL_SUPPORTED
19#include <crypto/NetBurner/NbSslCtx.h>
20#endif
21
27void UserMain(void*pd); // leaving this out of the group to avoid a documentation mess
28
48#define MQTT_WAIT (TICKS_PER_SECOND*10)
49#define MQTT_TLS_NEGOTIATE_TIMEOUT (TICKS_PER_SECOND*50)
50
51#define MQTT_OBJ_PRIORITY_COUNT (16)
52#define MQTT_OBJ_PRIORITY_MAX 0
53#define MQTT_OBJ_PRIORITY_MIN 15
54
55#define MQTT_MAX_PKT_SIZE (0x2FFFFFFF)
56#define MQTT_MAX_MAX_SUPPORTED_IN_FLIGHT (256)
57#define MQTT_MAX_SUPPORTED_IN_FLIGHT (16)
58#define MQTT_MAX_HANDLERS_PER_CONNECTION (256)
59#define MQTT_MAX_SUPPORTED_RX_TOPIC_ALIASES (128)
60#define MQTT_DEFAULT_SESSION_EXPIRY_INTERVAL (3600)
61#define MQTT_DEFAULT_KEEP_ALIVE (30)
62
63#define MQTT_MAX_SUB_IDs (128)
64
81namespace MQTT {
87
88 eResult_Mqtt_Unspecified = -Pkt::eReason_Error_Unspecified,
89 eResult_Mqtt_MalformedPkt = -Pkt::eReason_Error_MalformedPkt,
90 eResult_Mqtt_Protocol = -Pkt::eReason_Error_Protocol,
91 eResult_Mqtt_Implementation = -Pkt::eReason_Error_Implementation,
92 eResult_Mqtt_UnsupportedProtoVer = -Pkt::eReason_Error_UnsupportedProtoVer,
93 eResult_Mqtt_ClientIdInvalid = -Pkt::eReason_Error_ClientIdInvalid,
94 eResult_Mqtt_UserPassword = -Pkt::eReason_Error_UserPassword,
95 eResult_Mqtt_NotAuthorized = -Pkt::eReason_Error_NotAuthorized,
96 eResult_Mqtt_ServerUnavail = -Pkt::eReason_Error_ServerUnavail,
97 eResult_Mqtt_ServerBusy = -Pkt::eReason_Error_ServerBusy,
98 eResult_Mqtt_Banned = -Pkt::eReason_Error_Banned,
99 eResult_Mqtt_ServerShutdown = -Pkt::eReason_Error_ServerShutdown,
100 eResult_Mqtt_BadAuthMethod = -Pkt::eReason_Error_BadAuthMethod,
101 eResult_Mqtt_KATimeout = -Pkt::eReason_Error_KATimeout,
102 eResult_Mqtt_SessTakeover = -Pkt::eReason_Error_SessTakeover,
103 eResult_Mqtt_FilterInvalid = -Pkt::eReason_Error_FilterInvalid,
104 eResult_Mqtt_NameInvalid = -Pkt::eReason_Error_NameInvalid,
105 eResult_Mqtt_PktId_InUse = -Pkt::eReason_Error_PktId_InUse,
106 eResult_Mqtt_PktId_NotFound = -Pkt::eReason_Error_PktId_NotFound,
107 eResult_Mqtt_RcvMax_Exceeded = -Pkt::eReason_Error_RcvMax_Exceeded,
108 eResult_Mqtt_TopicAlias_Invalid = -Pkt::eReason_Error_TopicAlias_Invalid,
109 eResult_Mqtt_TooLarge = -Pkt::eReason_Error_TooLarge,
110 eResult_Mqtt_MsgRate = -Pkt::eReason_Error_MsgRate,
111 eResult_Mqtt_Quota = -Pkt::eReason_Error_Quota,
112 eResult_Mqtt_Admin = -Pkt::eReason_Error_Admin,
113 eResult_Mqtt_PayFmt_Invalid = -Pkt::eReason_Error_PayFmt_Invalid,
114 eResult_Mqtt_NotSupported_Retain = -Pkt::eReason_Error_NotSupported_Retain,
115 eResult_Mqtt_NotSupported_QoS = -Pkt::eReason_Error_NotSupported_QoS,
116 eResult_Mqtt_UseOther = -Pkt::eReason_Error_UseOther,
117 eResult_Mqtt_ServerMoved = -Pkt::eReason_Error_ServerMoved,
118 eResult_Mqtt_NotSupported_SharedSubs = -Pkt::eReason_Error_NotSupported_SharedSubs,
119 eResult_Mqtt_ConnRate = -Pkt::eReason_Error_ConnRate,
120 eResult_Mqtt_MaxConnTime = -Pkt::eReason_Error_MaxConnTime,
121 eResult_Mqtt_NotSupported_SubIds = -Pkt::eReason_Error_NotSupported_SubIds,
122 eResult_Mqtt_NotSupported_WildSubs = -Pkt::eReason_Error_NotSupported_WildSubs,
123 eResult_Mqtt_Transport_Error = -Pkt::eReason_Error_Transport_Error,
124 eResult_Error_NetErr = -Pkt::eReason_Error_Transport_Error,
135};
136
147typedef int (*MsgCallback_t)(MQTT::Client *mConn, int mqttFd, MQTT::PacketInfo::Msg *msg, void *ctx);
148
160
161
162}
163
164#include <mqtt/mqtt_internal.h>
165#include <mqtt/config_mqtt_obj.h>
166
167namespace MQTT {
168
175enum {
188
191};
192
207
208class mqtt_leaf;
209namespace internal {
210class WrCritObj;
211}
212
221const char * GetPacketTypeString(Pkt::eType_t pkt);
222
232
241const char * GetConnectionStatusString(int status);
242
243#define MqttEndMarker \
244 virtual int Missing_ConfigEndMarker(void *&startp) override \
245 { \
246 startp = this; \
247 return sizeof(*this); \
248 };
249
250
263class Client : public TimeOutManager{
264 friend void ::UserMain(void *pd);
265public:
279
286
295
307
308private:
309 struct leaf_list_t {
310 mqtt_leaf *head;
311 mqtt_leaf *tail;
312 };
313
314 typedef leaf_list_t leaf_queue_t;
315
316 static Client *s_clients; // global list of all clients
317 static Client *s_clientsTail; // tail of global list of all clients
318 Client *pNextClient; // next client in the global list
319 leaf_list_t regList; // Registered objects
320
321 void dequeue_active(mqtt_leaf **ppNextReq, int activeQueue,
322 uint32_t &waiting, leaf_queue_t *q);
323
324 OS_CRIT queueLock;
325
326 ParsedURI broker;
327 NBString clientId;
328 NBString username;
329 NBString password;
330protected:
331 NBString lwtTopic; // Topic Name for Last Will and Testament message
332 NBString lwtMessage; // Last Will and Testament message contents
333 NBString connMsg; // Message to Publish to LWT topic after connecting
334 NBString disconnMsg; // Message to Publish to LWT topic when intentionally disconnecting
335#ifdef NB_SSL_SUPPORTED
336 uint8_t *clientCert;
337 uint32_t certLen;
338 uint8_t *privKey;
339 uint32_t privKeyLen;
340 NbSslCtx *pSslCtx;
341#endif
342private:
343 // Registered Object message event queues
344 uint32_t pubQueueWaiting;
345 uint32_t subQueueWaiting;
346 leaf_queue_t pubQueue[MQTT_OBJ_PRIORITY_COUNT];
347 leaf_queue_t subQueue[MQTT_OBJ_PRIORITY_COUNT];
348
349 PublishRequest nextPubReq;
350 AckCbCtx nextSubAckCtx;
351
352 fd_set rd_fds;
353 fd_set wr_fds;
354 fd_set er_fds;
355
356 int connect();
357 int SendConnect();
358 // Client has messages to send?
359 inline bool ReadyToSend()
360 {
361 return mSess.txNeedSpace || pubQueueWaiting || subQueueWaiting
362 || mSess.pubReqQueueWaiting || mSess.subReqQueue.head;
363 }
364
365protected:
366 ConnectRequest connReq;
367 PublishRequest lwtMsg;
368
369 internal::Session mSess;
370 void initSessionInfo(const ParsedURI &brokerURI, bool bCleanStart, uint16_t maxKeepAlive, PublishRequest *pLwtMsg, RequestProperty *addProps);
371 virtual internal::eClientState_t SetState_Rx(internal::eClientState_t newState);
372 virtual internal::eClientState_t SetState_Tx(internal::eClientState_t newState);
373
374 void RegisterClient();
375 void DeregisterClient();
376
377 void InterpolateLeafTopics();
378
379 void readyConnMsgsFromConfig(config_MqttClient &clientCfg,
380 config_MqttLWT *lwtCfg, RequestProperty *addProps);
381 Client(config_MqttClient &clientCfg,
382 config_MqttLWT *lwtCfg = NULL, RequestProperty *addProps = NULL,
383 bool ConnectOnStartup = true);
384public:
400 Client(const char *brokerURI, const char *pClientId, uint16_t maxKeepAlive = MQTT_DEFAULT_KEEP_ALIVE,
401 bool bCleanStart = true, PublishRequest *lwtMsg = NULL,
402 const char *pConnMsg = NULL, const char *pDisconnMsg = NULL,
403 const char *pUsername = NULL, const char *pPassword = NULL,
404 RequestProperty *addProps = NULL, bool ConnectOnStartup = true);
420 Client(const ParsedURI *brokerURI, const char *pClientId, uint16_t maxKeepAlive = MQTT_DEFAULT_KEEP_ALIVE,
421 bool bCleanStart = true, PublishRequest *lwtMsg = NULL,
422 const char *pConnMsg = NULL, const char *pDisconnMsg = NULL,
423 const char *pUsername = NULL, const char *pPassword = NULL,
424 RequestProperty *addProps = NULL, bool ConnectOnStartup = true);
425
436 int Connect(bool bWaitForConnection, const char *pNewBrokerURI,
437 ConnAckCb_t notifyCb = NULL, void *notifyCtx = NULL);
438
449 int Connect(bool bWaitForConnection = true, const ParsedURI *pNewBrokerURI = NULL,
450 ConnAckCb_t notifyCb = NULL, void *notifyCtx = NULL);
451
464 void SetConnectNotify(ConnAckCb_t notifyCb, void *notifyCtx);
465
466 /*
467 * @brief Get the current configured value for various connection limits.
468 *
469 * @param limit The limit type to get the value of.
470 *
471 * @returns The value of the requested connection limit;
472 * */
473 uint32_t GetLimit(eSessionLimit limit);
474
475 /*
476 * @brief Set the value for various connection limits.
477 *
478 * @param limit The limit type to get the value of.
479 *
480 * @returns Whether setting the limit was successful or not.
481 * */
482 bool SetLimit(eSessionLimit limit, uint32_t value);
483
498 int SetRateLimit(eRateLimitType type, uint8_t bucketMax, uint8_t fillCount,
499 uint8_t fillTicks, eRateLimitAdjustMethod adjMethod,
500 uint8_t adjCount);
511 int SetRateLimit_Publish(int reqPerSecond);
512
523 int SetRateLimit_Subscribe(int reqPerSecond);
524
533
545 inline void SetClientCert(uint8_t *cert, uint32_t len, uint8_t *privkey, uint32_t privlen)
546 {
547#ifdef NB_SSL_SUPPORTED
548 clientCert = cert;
549 certLen = len;
550 privKey = privkey;
551 privKeyLen = privlen;
552#endif
553 }
554
566 inline void GetClientCert(uint8_t **cert, uint32_t *len, uint8_t **privkey, uint32_t *privlen)
567 {
568#ifdef NB_SSL_SUPPORTED
569 *cert = clientCert;
570 *len = certLen;
571 *privkey = privKey;
572 *privlen = privKeyLen;
573#else
574 *cert = NULL;
575 *len = 0;
576 *privkey = NULL;
577 *privlen = 0;
578#endif
579 }
580
591
602
613
623
638 int Publish(const char *topic, uint8_t *pData, uint32_t len, int prio, TickTimeout &t, uint8_t qos = 0);
639
653 int Publish(const char *topic, const char *pStr, int prio, TickTimeout &t, uint8_t qos = 0);
654
666 int Publish(PublishRequest *req, int prio, TickTimeout &t);
667
678 int QueuePublish(PublishRequest *req, int *prio);
679
692 int Subscribe(TopicHandler &handler, int *handlerIdx, TickTimeout &t, uint8_t subOpts = Pkt::eSubOpt_NoLocal);
693
705 int Subscribe(SubscribeRequest *req, int *handlerIdx, TickTimeout &t);
706
716 int QueueSubscribe(SubUnsubQueueMsg *qmsg);
717
729 int Unsubscribe(int handlerIdx, TickTimeout &t, const char *topicFilter = NULL);
730
741 int Unsubscribe(const char *topicFilter, TickTimeout &t);
742
752 int QueueUnsubscribe(SubUnsubQueueMsg *qmsg);
753
764 int RegisterTopicHandler(TopicHandler *newHandler, int *handlerIdx);
765
776
786 int RemoveTopicHandler(int handlerIdx);
787
796 void RegisterMqttObj(mqtt_leaf &leaf, uint32_t interval=0);
797
805 void RemoveObj(mqtt_leaf &leaf);
806
815
824
825 int AddToSelectSet(fd_set &rd_set, fd_set &wr_set, fd_set &er_set);
826 TickTimeout ProcessSelectResult(fd_set &rd_set, fd_set &wr_set, fd_set &er_set);
827
828 const ParsedURI & getBrokerURI() { return broker; }
829
830protected:
831 static volatile OS_TCB *TaskTcb;
832 static OS_CRIT s_ListCrit; // Critical to protect global static list values
833 static OS_SEM s_TaskWakeSem; // Explicit task wake signalling semaphore
834 static void Task(void *);
835 friend class internal::WrCritObj;
836 friend struct internal::Session;
837
838public:
844 static void StartTask(uint8_t taskPrio = MQTT_TASK_PRIO);
845
851 static inline Client *GetFirstClient() { return s_clients; }
852};
853
860class ConfiguredClient : public config_MqttClient, public Client {
861// config_MqttClient clientCfg;
862 config_MqttLWT clientCfgLWT{*this,"LWT","Last Will and Testament message configuration"};
863 MqttEndMarker;
864#ifdef NB_SSL_SUPPORTED
865 NbSslCtx sslConCtx;
866#endif
867 void init(RequestProperty *addProps);
868
869 virtual internal::eClientState_t SetState_Tx(internal::eClientState_t newState) override;
870public:
880 ConfiguredClient(config_obj &owner = sys, const char* name = NULL,
881 const char *desc = "Mqtt client connection configuration",
882 RequestProperty *addProps = NULL, bool ConnectOnStartup = true);
883
884 virtual void CommitTestedValue(uint32_t permission_mask) override;
885};
886
893typedef void(LeafCallBack)(mqtt_leaf *p, void *pextra);
894
895enum ValueTestResult
896{
897 eOk,
898 eBad
899};
900
906class mqtt_leaf : public TimeOutElement{
907public:
911 eObj_State_PubReady = 0x00,
912 eObj_State_PubPendTimer = 0x01,
913 eObj_State_PubQueued = 0x02,
914 eObj_State_PubNeedAck = 0x03,
915
916 eObj_State_SubNone = 0x00,
917 eObj_State_SubSendSub = 0x10,
918 eObj_State_SubNeedAck = 0x20,
919 eObj_State_SubReady = 0x30,
920 eObj_State_SubSendUnsub = 0x40,
921 eObj_State_SubUnsubNeedAck = 0x50,
922
923 eObj_State_PubState_MASK = 0x0F,
924 eObj_State_SubState_MASK = 0xF0,
925 };
926
927private:
928 OS_SEM *pSemDone;
929 Client *mClient;
930 mqtt_leaf *pParent;
931 mqtt_leaf *pSibling;
932 mqtt_leaf *pNextLeaf;
933
934 mqtt_leaf *pNextPubReq;
935 AckCbCtx pubAckCtx;
936 mqtt_leaf *pNextSubReq;
937 AckCbCtx subAckCtx;
938
939 uint16_t subHandlerId;
940 uint8_t state;
941 uint8_t priority;
942
943 static OS_CRIT s_needClientCrit;
944 static mqtt_leaf *s_needClient;
945
946protected:
949 uint16_t mFlags;
950
958 mqtt_leaf(const char *topic, Client *mClient, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
959
968 mqtt_leaf(mqtt_leaf &parent, const char *topic, Client *mClient, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
969
970 /*
971 * @brief Set the Client this object is registered with.
972 *
973 * @param *client Pointer to the Client to register with.
974 *
975 * @returns eResult_t return code
976 * */
977// int SetClient(Client *client);
978
979 /*
980 * @brief Get the Client this object is registered with.
981 *
982 * @returns Pointer to the Client this oject is registered with
983 * */
984// Client *GetClient();
985
992
1000 virtual mqtt_leaf *AddChild(mqtt_leaf *child);
1001
1008
1015 void ForEachLeaf(LeafCallBack *p, void *pd);
1016
1023
1032
1041
1050
1059
1065 int Assign();
1066
1072 uint8_t PubState() { return state & eObj_State_PubState_MASK; }
1073
1079 uint8_t SubState() { return state & eObj_State_SubState_MASK; }
1080
1086 virtual void SetPubState(uint8_t newState);
1087
1093 virtual void SetSubState(uint8_t newState);
1094
1103 virtual int ParseFd(int mqttFd) = 0;
1104
1113 int HandleSubAck(int mqttFd, PacketInfo::Msg *msg);
1114
1123 int HandleUnsubAck(int mqttFd, PacketInfo::Msg *msg);
1124
1133 int HandlePubAck(int mqttFd, PacketInfo::Msg *msg);
1134public:
1140
1145
1153 bool NameMatch(const char *cp);
1154
1164 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) = 0;
1165
1173 virtual int GetPubTopicName(NBString &s);
1174
1183
1192 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg);
1193
1202
1217 int Publish(int waitForCompletion = -1);
1218
1230 void SetPublishInterval(uint32_t intervalPeriodTicks);
1231
1238
1246
1252 virtual void SetFlags(uint16_t newFlags);
1253
1259 virtual void ClearFlags(uint16_t delFlags);
1260
1266 inline uint16_t GetFlags() { return mFlags; }
1267
1273 inline int getPriority() { return priority; }
1274
1285 static int MqttRxPublish(Client *mClient, int mqttFd, PacketInfo::Msg *msg, void *ctx);
1286
1296 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) = 0;
1297
1306 virtual int RenderToFd(eObj_Serialize_t form, int fd) = 0;
1307 virtual void TimeElementEvent() override;
1308
1309 virtual int Missing_ConfigEndMarker(void *&startp) = 0;
1310private:
1311 struct leaf_queue_t {
1312 mqtt_leaf *head;
1313 mqtt_leaf *tail;
1314 };
1315 static int puback_cb(Client *mSess, void *ctx, PacketInfo::PublishAck *ack);
1316 static int suback_cb(Client *mSess, void *ctx, PacketInfo::PublishAck *ack);
1317
1318 static void dequeue_active(mqtt_leaf **ppNextReq, int activeQueue,
1319 uint32_t &waiting, leaf_queue_t *q);
1320 friend class Client;
1321 friend class mqtt_obj;
1322 friend void mqttParseFd(mqtt_leaf *pl, void *pd);
1323};
1324
1329class mqtt_obj : public mqtt_leaf {
1330 mqtt_leaf *pChildren;
1331protected:
1339 mqtt_obj(const char *topic, Client *mClient, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1348 mqtt_obj(mqtt_leaf &parent, const char *topic, Client *mClient, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1354
1362 mqtt_leaf *FindChild(const char *topic);
1363
1369 virtual mqtt_leaf *GetChildren() override;
1370
1378 virtual mqtt_leaf *AddChild(mqtt_leaf *child) override;
1379
1385 virtual mqtt_leaf *RemoveFirstChild() override;
1386
1392 virtual void SetPubState(uint8_t newState) override;
1393
1399 virtual void SetSubState(uint8_t newState) override;
1400
1409 virtual int ParseFd(int mqttFd) override;
1410
1418 virtual int GetSubTopicFilter(NBString &s) override;
1419
1428 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
1429
1438public:
1439
1440 virtual int Missing_ConfigEndMarker(void *&startp) override
1441 {
1442 startp = this;
1443 return sizeof(*this);
1444 };
1445
1455 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
1456
1466 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
1467
1476 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
1477};
1478
1483class mqtt_int : public mqtt_leaf {
1484private:
1485 int32_t val;
1486protected:
1495 virtual int ParseFd(int mqttFd) override;
1496
1497public:
1506 mqtt_int(int val, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1514 mqtt_int(const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1524 mqtt_int(mqtt_leaf &parent, int val, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1533 mqtt_int(mqtt_leaf &parent, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1534
1544
1551 inline operator int() const { return val; }
1557 mqtt_int &operator++() { ++val; Assign(); return *this; }
1563 int32_t operator++(int) { int32_t ret = val++; Assign(); return ret; }
1569 mqtt_int &operator--() { --val; Assign(); return *this; }
1575 int32_t operator--(int) { int32_t ret = val--; Assign(); return ret; }
1576
1586 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
1595 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
1605 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
1614 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
1615
1616 // This is named so error messages make sense to user, old name was GetExtent
1617 virtual int Missing_ConfigEndMarker(void *&startp) override
1618 {
1619 startp = this;
1620 return sizeof(*this);
1621 };
1622};
1623
1628class mqtt_uint : public mqtt_leaf {
1629private:
1630 uint32_t val;
1631protected:
1640 virtual int ParseFd(int mqttFd) override;
1641
1642public:
1651 mqtt_uint(uint32_t val, const char *topic, Client *client, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1659 mqtt_uint(const char *topic, Client *client, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1669 mqtt_uint(mqtt_leaf &parent, uint32_t val, const char *topic, Client *client, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1678 mqtt_uint(mqtt_leaf &parent, const char *topic, Client *client, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1679
1688 mqtt_uint &operator=(uint32_t i);
1695 inline operator unsigned() const { return val; }
1701 mqtt_uint &operator++() { ++val; Assign(); return *this; }
1707 uint32_t operator++(int) { uint32_t ret = val++; Assign(); return ret; }
1713 mqtt_uint &operator--() { --val; Assign(); return *this; }
1719 uint32_t operator--(int) { uint32_t ret = val--; Assign(); return ret; }
1720
1730 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
1739 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
1749 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
1758 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
1759
1760 virtual int Missing_ConfigEndMarker(void *&startp) override
1761 {
1762 startp = this;
1763 return sizeof(*this);
1764 };
1765};
1766
1771class mqtt_float : public mqtt_leaf {
1772private:
1773 double val;
1774 uint8_t serPrecision;
1775 char serStrFormat;
1776protected:
1785 virtual int ParseFd(int mqttFd) override;
1786
1787public:
1796 mqtt_float(double val, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1804 mqtt_float(const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1814 mqtt_float(mqtt_leaf &parent, double val, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1823 mqtt_float(mqtt_leaf &parent, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
1824
1840 inline operator double() const { return val; }
1841
1849 void SetStringFormat(char formatChar, uint8_t precision)
1850 {
1851 switch (formatChar)
1852 {
1853 case 'f':
1854 case 'F':
1855 case 'e':
1856 case 'E':
1857 case 'g':
1858 case 'G':
1859 case 'a':
1860 case 'A':
1861 serStrFormat = formatChar;
1862 break;
1863 default:
1864 break;
1865 }
1866 serPrecision = precision;
1867 }
1868
1878 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
1887 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
1897 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
1906 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
1907
1908 virtual int Missing_ConfigEndMarker(void *&startp) override
1909 {
1910 startp = this;
1911 return sizeof(*this);
1912 };
1913};
1914
1919class mqtt_string : public mqtt_leaf {
1920 NBString val;
1921protected:
1930 virtual int ParseFd(int mqttFd) override;
1931
1932public:
1941 mqtt_string(const char *val, const char *topic, Client *mClient = NULL, uint16_t flags = 0);
1950 mqtt_string(const NBString &val, const char *topic, Client *mClient = NULL, uint16_t flags = 0);
1958 mqtt_string(const char *topic, Client *mClient = NULL, uint16_t flags = 0);
1968 mqtt_string(mqtt_leaf &parent, const char *val, const char *topic, Client *mClient = NULL, uint16_t flags = 0);
1978 mqtt_string(mqtt_leaf &parent, const NBString &val, const char *topic, Client *mClient = NULL, uint16_t flags = 0);
1987 mqtt_string(mqtt_leaf &parent, const char *topic, Client *mClient = NULL, uint16_t flags = 0);
1988
2006 mqtt_string &operator=(const char *s);
2007
2014 inline operator NBString() const { return val; }
2021 inline const char operator[](size_t pos) const { return val[pos]; }
2027 inline char &operator[](size_t pos) { return val.posRef(pos); }
2028
2038 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
2047 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
2057 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
2066 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
2067
2068 virtual int Missing_ConfigEndMarker(void *&startp) override
2069 {
2070 startp = this;
2071 return sizeof(*this);
2072 };
2073};
2074
2079class mqtt_bool : public mqtt_leaf {
2080private:
2081 bool val;
2082protected:
2091 virtual int ParseFd(int mqttFd) override;
2092
2093public:
2102 mqtt_bool(bool val, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
2110 mqtt_bool(const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
2120 mqtt_bool(mqtt_leaf &parent, bool val, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
2129 mqtt_bool(mqtt_leaf &parent, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
2130
2146 inline operator bool() const { return val; }
2153 bool operator!() const { return !val; }
2154
2164 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
2173 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
2183 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
2192 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
2193
2194 virtual int Missing_ConfigEndMarker(void *&startp) override
2195 {
2196 startp = this;
2197 return sizeof(*this);
2198 };
2199};
2200
2205class mqtt_IO : public mqtt_leaf {
2206private:
2207 FastIO pin;
2208 int fixDir;
2209 MqttEndMarker;
2210
2211protected:
2220 virtual int ParseFd(int mqttFd) override;
2221public:
2230 mqtt_IO(PinIO ioPin, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
2240 mqtt_IO(mqtt_leaf &parent, PinIO ioPin, const char *topic, Client *mClient = NULL, uint16_t flags = (eObj_Flag_PubOnWrite | eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal));
2241
2247 virtual void SetFlags(uint16_t newFlags) override;
2253 virtual void ClearFlags(uint16_t delFlags) override;
2254
2262 int SetFixedDirection(int direction);
2263
2272 mqtt_IO &operator=(bool val);
2279 inline operator bool() { return pin; }
2286 bool operator!() { return !pin; }
2287
2297 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
2306 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
2316 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
2325 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
2326
2334 static void PinNotify(int port_num, int pin, void *ctx);
2335};
2336
2341class mqtt_IO_Input : public mqtt_IO {
2342public:
2343 using mqtt_IO::operator=;
2352 mqtt_IO_Input(PinIO ioPin, const char *topic, Client *client = NULL, uint16_t flags = 0)
2353 : mqtt_IO(ioPin, topic, client, flags | eObj_Flag_PubOnWrite)
2354 {SetFixedDirection(-1);}
2364 mqtt_IO_Input(mqtt_leaf &parent, PinIO ioPin, const char *topic, Client *client = NULL, uint16_t flags = 0)
2365 : mqtt_IO(parent, ioPin, topic, client, flags | eObj_Flag_PubOnWrite)
2366 {SetFixedDirection(-1);}
2367};
2368
2373class mqtt_IO_Output : public mqtt_IO {
2374public:
2375 using mqtt_IO::operator=;
2384 mqtt_IO_Output(PinIO ioPin, const char *topic, Client *client = NULL, uint16_t flags = 0)
2385 : mqtt_IO(ioPin, topic, client, flags | (eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal))
2386 {SetFixedDirection(1);}
2396 mqtt_IO_Output(mqtt_leaf &parent, PinIO ioPin, const char *topic, Client *client = NULL, uint16_t flags = 0)
2397 : mqtt_IO(parent, ioPin, topic, client, flags | (eObj_Flag_Subscribe | eObj_Flag_Sub_NoLocal))
2398 {SetFixedDirection(1);}
2399};
2400
2405class ConfigExposer : public mqtt_leaf {
2406public:
2415private:
2416 config_leaf *pLeaf;
2417 config_leaf *pendingPubLeaf;
2418
2419 uint32_t renderFlags;
2420protected:
2429 virtual int ParseFd(int mqttFd) override;
2430
2431public:
2441 ConfigExposer(config_leaf &leaf, const char *topicRoot, Client *mClient = NULL, uint16_t initFlags = 0, uint32_t renderFlags = 0);
2452 ConfigExposer(mqtt_leaf &parent, config_leaf &leaf, const char *topicRoot, Client *mClient = NULL, uint16_t initFlags = 0, uint32_t renderFlags = 0);
2453// MqttConfigExposer(const char *topicRoot, Session *mClient);
2454// MqttConfigExposer(const char *topicRoot, Session *mClient);
2455
2463 virtual int GetPubTopicName(NBString &s) override;
2471 virtual int GetSubTopicFilter(NBString &s) override;
2472
2482 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
2491 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
2509 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
2518 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
2519
2520 virtual int Missing_ConfigEndMarker(void *&startp) override
2521 {
2522 startp = this;
2523 return sizeof(*this);
2524 };
2525};
2526
2527typedef int (*SubHandlerCb)(int mqttFd, const char *pathExt, uint32_t msgLen);
2528
2533class SubHandler : public mqtt_leaf {
2534 SubHandlerCb handler;
2535 MqttEndMarker;
2536protected:
2546 virtual int ParseFd(int mqttFd) override;
2557 virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override;
2567 virtual int RenderToFd(eObj_Serialize_t form, int fd) override;
2568public:
2578 SubHandler(SubHandlerCb handler, const char * topicFilter, Client *mClient = NULL, uint16_t flags = 0);
2589 virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override;
2599 virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override;
2600
2601};
2602
2605class PropMarker {
2606 uint32_t markers[8];
2607 int num;
2608public:
2609 PropMarker()
2610 : markers{0,0,0,0,0,0,0,0}, num(0)
2611 {
2612 }
2613
2614 PropMarker(uint32_t val_0, uint32_t val_1, uint32_t val_2, uint32_t val_3,
2615 uint32_t val_4, uint32_t val_5, uint32_t val_6, uint32_t val_7)
2616 : markers{val_0, val_1, val_2, val_3, val_4, val_5, val_6, val_7}, num(0)
2617 {
2618 for (int i = 0; i < 8; i++)
2619 for (uint32_t v = 1; v; v <<= 1)
2620 if (markers[i]&v)
2621 num++;
2622 }
2623
2624 inline void reset() { for(int i = 0; i < 8; i++) markers[i] = 0; }
2625
2626 inline void set(int prop)
2627 {
2628 prop--;
2629 num += ((markers[prop>>5] & (1UL << (prop&0x1F))) == 0);
2630 markers[prop>>5] |= 1UL << (prop&0x1F);
2631 }
2632 inline void clr(int prop)
2633 {
2634 prop--;
2635 num -= ((markers[prop>>5] & (1UL << (prop&0x1F))) != 0);
2636 markers[prop>>5] &= ~(1UL << (prop&0x1F));
2637 }
2638 inline bool isset(int prop) { prop--; return ((markers[prop>>5] & (1UL << (prop&0x1F))) != 0); }
2639 inline int count() { return num; }
2640 void show();
2641};
2642
2643
2644
2645}
2646#endif /* ----- #ifndef __MQTT_API_H ----- */
2647
Advanced low-level MQTT Client for interacting with Mqtt Brokers. The client handles all network comm...
Definition mqtt.h:263
int Unsubscribe(const char *topicFilter, TickTimeout &t)
Unsubscribe and deregister a TopicHandler.
int RemoveTopicHandler(int handlerIdx)
Remove/deregister a TopicHandler from the Client by index.
static void StartTask(uint8_t taskPrio=MQTT_TASK_PRIO)
Start the Client Task.
int Subscribe(TopicHandler &handler, int *handlerIdx, TickTimeout &t, uint8_t subOpts=Pkt::eSubOpt_NoLocal)
Register a TopicHandler and subscribe its Topic on the Broker.
eConnectionStatus GetConnectionStatus()
Get the current state of the Client's connection to the Broker.
eConnectionStatus
Connection state values.
Definition mqtt.h:298
@ eConnStat_InProgress
Connection to broker in progress.
Definition mqtt.h:302
@ eConnStat_No_Broker_Configured
Error, no broker configured to be used.
Definition mqtt.h:300
@ eConnStat_Refused
Connection refused by broker.
Definition mqtt.h:304
@ eConnStat_Error
General error with client connection.
Definition mqtt.h:299
@ eConnStat_Established
Connection with broker established.
Definition mqtt.h:303
@ eConnStat_Resolving
Currently resolving broker address.
Definition mqtt.h:301
void RegisterMqttObj(mqtt_leaf &leaf, uint32_t interval=0)
Register an MqttObj with the Client.
eRateLimitAdjustMethod
How to adjust rate limit buckets when modifying the current rate limit.
Definition mqtt.h:289
@ eRateLimitAdj_Add
Add the adjustment value to the current token count.
Definition mqtt.h:292
@ eRateLimitAdj_Subtract
Subtract the adjustment value from the current token count.
Definition mqtt.h:293
@ eRateLimitAdj_Set
Set the current limit token count to the adjustment value.
Definition mqtt.h:291
@ eRateLimitAdj_None
Do not modify the current limit token count.
Definition mqtt.h:290
Client(const char *brokerURI, const char *pClientId, uint16_t maxKeepAlive=MQTT_DEFAULT_KEEP_ALIVE, bool bCleanStart=true, PublishRequest *lwtMsg=NULL, const char *pConnMsg=NULL, const char *pDisconnMsg=NULL, const char *pUsername=NULL, const char *pPassword=NULL, RequestProperty *addProps=NULL, bool ConnectOnStartup=true)
Constructor. This version takes a raw string for the broker URI.
int SendNextSubReq()
Send the next queued SubUnSub Request.
static Client * GetFirstClient()
Start the Client Task.
Definition mqtt.h:851
int RemoveTopicHandler(TopicHandler *handler)
Remove/deregister a TopicHandler from the Client by reference.
void SetConnectNotify(ConnAckCb_t notifyCb, void *notifyCtx)
Set the connection notification callback and it's context information.
void SetClientCert(uint8_t *cert, uint32_t len, uint8_t *privkey, uint32_t privlen)
Set the Client Certificate and Private Key to use when connecting to a Broker via TLS.
Definition mqtt.h:545
int QueueSubscribe(SubUnsubQueueMsg *qmsg)
Register a TopicHandler and subscribe its Topic on the Broker.
void RemoveObj(mqtt_leaf &leaf)
Deregister/remove an MqttObj from the Client.
int QueueUnsubscribe(SubUnsubQueueMsg *qmsg)
Queue unsubscribing and deregistering a TopicHandler.
int QueuePublish(mqtt_leaf &leaf)
Queue an MqttObj to be published.
int QueueSubscribe(mqtt_leaf &leaf)
Queue an MqttObj to subscribe.
eRateLimitType
Rate limit types for Client messaging.
Definition mqtt.h:282
@ eRateLimit_Subscribe
Limit for Subscribe requests per second.
Definition mqtt.h:284
@ eRateLimit_Publish
Limit for Publish requests per second.
Definition mqtt.h:283
int QueueAllSubscriptions()
Queue all Client's registered MqttObjs to be subscribed and published according to the object's opera...
Client(const ParsedURI *brokerURI, const char *pClientId, uint16_t maxKeepAlive=MQTT_DEFAULT_KEEP_ALIVE, bool bCleanStart=true, PublishRequest *lwtMsg=NULL, const char *pConnMsg=NULL, const char *pDisconnMsg=NULL, const char *pUsername=NULL, const char *pPassword=NULL, RequestProperty *addProps=NULL, bool ConnectOnStartup=true)
Constructor. This version takes a ParsedURI object for the broker URI.
int Unsubscribe(int handlerIdx, TickTimeout &t, const char *topicFilter=NULL)
Unsubscribe and deregister a TopicHandler.
int Subscribe(SubscribeRequest *req, int *handlerIdx, TickTimeout &t)
Register a TopicHandler (via fully specified SubscribeRequest) and subscribe its Topic on the Broker.
int QueuePublish(PublishRequest *req, int *prio)
Queue a publish message from a fully defined request.
int Publish(PublishRequest *req, int prio, TickTimeout &t)
Publish a fully defined request.
int SetRateLimit(eRateLimitType type, uint8_t bucketMax, uint8_t fillCount, uint8_t fillTicks, eRateLimitAdjustMethod adjMethod, uint8_t adjCount)
Set the value for a given rate limit.
int RegisterTopicHandler(TopicHandler *newHandler, int *handlerIdx)
Register a TopicHandler with the Client.
int Connect(bool bWaitForConnection, const char *pNewBrokerURI, ConnAckCb_t notifyCb=NULL, void *notifyCtx=NULL)
Begin the process of Connecting the client to the Broker.
int Disconnect()
Disconnect the Client from the Broker.
int SendNextPubReq()
Send the next queued Publish Request.
int SetRateLimit_Publish(int reqPerSecond)
Set the Publish rate limit. This method automatically determines the fillCount and fillTicks to use f...
int QueueUnsubscribe(mqtt_leaf &leaf)
Queue an MqttObj to unsubscribe.
int Publish(const char *topic, uint8_t *pData, uint32_t len, int prio, TickTimeout &t, uint8_t qos=0)
Publish a binary payload message.
eSessionLimit
Limit types for the Client interactions with the Broker.
Definition mqtt.h:268
@ eLimit_SubAliases
Maximum number of subscription aliases.
Definition mqtt.h:274
@ eLimit_InFlight_Rx
Maximum number of outstanding rx messages with QoS > 0.
Definition mqtt.h:272
@ eLimit_Size_Rx
Maximum transmit message size allowed.
Definition mqtt.h:270
@ eLimit_Subscriptions
Maximum number of topic subscriptions.
Definition mqtt.h:273
@ eLimit_QoS
Maximum QoS for messages.
Definition mqtt.h:276
@ eLimit_PublishAliases
Maximum number of Publish topic name aliases.
Definition mqtt.h:275
@ eLimit_Size_Tx
Maximum receive message size accepted.
Definition mqtt.h:269
@ eLimit_InFlight_Tx
Maximum number of outstanding tx messages with QoS > 0.
Definition mqtt.h:271
@ eLimit_SessionExpirary
Maximum time for Session before expiring.
Definition mqtt.h:277
int Connect(bool bWaitForConnection=true, const ParsedURI *pNewBrokerURI=NULL, ConnAckCb_t notifyCb=NULL, void *notifyCtx=NULL)
Begin the process of Connecting the client to the Broker.
int Publish(const char *topic, const char *pStr, int prio, TickTimeout &t, uint8_t qos=0)
Publish a message.
void GetClientCert(uint8_t **cert, uint32_t *len, uint8_t **privkey, uint32_t *privlen)
Set the Client Certificate and Private Key to use when connecting to a Broker via TLS.
Definition mqtt.h:566
int SetRateLimit_Subscribe(int reqPerSecond)
Set the Subscribe rate limit. This method automatically determines the fillCount and fillTicks to use...
Easy MqttObj class for automatically publishing and subscribing NetBurner Config system objects to/fr...
Definition mqtt.h:2405
virtual int GetSubTopicFilter(NBString &s) override
Get the Subscription Topic Filter this object Subscribes to.
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
Handle a message sent by the Broker triggered by this object's Subscription.
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
Render this object to an output socket.
virtual int ParseFd(int mqttFd) override
Parse the data from a file descriptor according to this object's current default serialization method...
ConfigExposer(config_leaf &leaf, const char *topicRoot, Client *mClient=NULL, uint16_t initFlags=0, uint32_t renderFlags=0)
Constructor for a standalone ConfigExposer object.
virtual int GetRenderLength(eObj_Serialize_t form=eObj_Serialize_CURRENT_FORM) override
the number of bytes used to serialize this object in a particular format.
virtual int GetPubTopicName(NBString &s) override
Get the Topic Name this object Publishes to.
ConfigExposer(mqtt_leaf &parent, config_leaf &leaf, const char *topicRoot, Client *mClient=NULL, uint16_t initFlags=0, uint32_t renderFlags=0)
Constructor for a ConfigExposer object that has a parent.
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
whether the current index of a JSON dataset is valid for this object, or assign the value at the curr...
eRenderFlag_t
Rendering options for MQTT output of Config objects.
Definition mqtt.h:2410
@ eRender_ModifiedOnly
Only render modified leaves of the branch.
Definition mqtt.h:2412
@ eRender_Hidden
Hide this branch from renders of the object.
Definition mqtt.h:2411
@ eRender_Pretty
Do Pretty Print rendering.
Definition mqtt.h:2413
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
Render this object to an output buffer.
Easy MQTT Client wrapper for interacting with MQTT brokers. The client handles all network communicat...
Definition mqtt.h:860
ConfiguredClient(config_obj &owner=sys, const char *name=NULL, const char *desc="Mqtt client connection configuration", RequestProperty *addProps=NULL, bool ConnectOnStartup=true)
ConfiguredClient constructor.
Easy class for registering a callback function that receives messages on an MQTT topic and handles th...
Definition mqtt.h:2533
virtual int ParseFd(int mqttFd) override
SubHandler::ParseFd Parse the data from a file descriptor according to this object's current default ...
SubHandler(SubHandlerCb handler, const char *topicFilter, Client *mClient=NULL, uint16_t flags=0)
SubHandler Constructor for a standalone SubHandler object.
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
SubHandler::TestOrSetValue Test whether the current index of a JSON dataset is valid for this object,...
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
SubHandler::RenderToFd Render this object to an output socket.
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
SubHandler::SubscribeEvent Handle a message sent by the Broker triggered by this object's Subscriptio...
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
SubHandler::RenderToBuffer Render this object to an output buffer.
MqttObj connecting hardware GPIO pins to an Mqtt Broker. This class defaults the pin to an Input stat...
Definition mqtt.h:2341
mqtt_IO_Input(mqtt_leaf &parent, PinIO ioPin, const char *topic, Client *client=NULL, uint16_t flags=0)
Constructor for a mqtt_IO_Input object that has a parent.
Definition mqtt.h:2364
mqtt_IO_Input(PinIO ioPin, const char *topic, Client *client=NULL, uint16_t flags=0)
Constructor for a standalone mqtt_IO_Input object.
Definition mqtt.h:2352
MqttObj connecting hardware GPIO pins to an Mqtt Broker. This class defaults the pin to an Output sta...
Definition mqtt.h:2373
mqtt_IO_Output(PinIO ioPin, const char *topic, Client *client=NULL, uint16_t flags=0)
Constructor for a standalone mqtt_IO_Output object.
Definition mqtt.h:2384
mqtt_IO_Output(mqtt_leaf &parent, PinIO ioPin, const char *topic, Client *client=NULL, uint16_t flags=0)
Constructor for a mqtt_IO_Output object that has a parent.
Definition mqtt.h:2396
Easy MqttObj class for automatically publishing and subscribing hardware GPIO pins to/from an MQTT to...
Definition mqtt.h:2205
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
whether the current index of a JSON dataset is valid for this object, or assign the value at the curr...
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
Render this object to an output socket.
mqtt_IO(mqtt_leaf &parent, PinIO ioPin, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a mqtt_IO object that has a parent.
int SetFixedDirection(int direction)
Set a fixed direction for the GPIO pin.
virtual void ClearFlags(uint16_t delFlags) override
behavioral flags from this object
static void PinNotify(int port_num, int pin, void *ctx)
Static notification function for pin state changes.
mqtt_IO & operator=(bool val)
Assignment operator for mqtt_IO. Assigns the value to the hardware GPIO, then performs any post assig...
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
Handle a message sent by the Broker triggered by this object's Subscription.
virtual int ParseFd(int mqttFd) override
the data from a file descriptor according to this object's current default serialization method and a...
bool operator!()
Boolean Not operator for mqtt_IO. Returns the negation of the current state of the underlying GPIO.
Definition mqtt.h:2286
virtual void SetFlags(uint16_t newFlags) override
additional behavioral flags for this object
mqtt_IO(PinIO ioPin, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_IO object.
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
Render this object to an output buffer.
Easy MqttObj class for automatically publishing and subscribing boolean values to/from an MQTT topic....
Definition mqtt.h:2079
bool operator!() const
Boolean Not operator for mqtt_bool. Returns the negated value of the object as an boolean.
Definition mqtt.h:2153
mqtt_bool(const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_bool object.
virtual int ParseFd(int mqttFd) override
the data from a file descriptor according to this object's current default serialization method and a...
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
Render this object to an output socket.
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
whether the current index of a JSON dataset is valid for this object, or assign the value at the curr...
mqtt_bool(bool val, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_bool object.
mqtt_bool & operator=(bool i)
Assignment operator for mqtt_bool. Assigns the value to the object, then performs any post assignment...
mqtt_bool(mqtt_leaf &parent, bool val, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a mqtt_bool object that has a parent.
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
Handle a message sent by the Broker triggered by this object's Subscription.
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
Render this object to an output buffer.
mqtt_bool(mqtt_leaf &parent, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a mqtt_bool object that has a parent.
Easy MqttObj class for automatically publishing and subscribing floating point values to/from an MQTT...
Definition mqtt.h:1771
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
Render this object to an output buffer.
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
Render this object to an output socket.
mqtt_float(mqtt_leaf &parent, double val, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a mqtt_float object that has a parent.
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
Handle a message sent by the Broker triggered by this object's Subscription.
mqtt_float(const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_float object.
virtual int ParseFd(int mqttFd) override
the data from a file descriptor according to this object's current default serialization method and a...
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
whether the current index of a JSON dataset is valid for this object, or assign the value at the curr...
mqtt_float(mqtt_leaf &parent, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a mqtt_float object that has a parent.
void SetStringFormat(char formatChar, uint8_t precision)
the printf style format char to use when serializing this object in a string form.
Definition mqtt.h:1849
mqtt_float & operator=(double f)
Assignment operator for mqtt_float. Assigns the value to the object, then performs any post assignmen...
mqtt_float(double val, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_float object.
Easy MqttObj class for automatically publishing and subscribing unsigned integer values to/from an MQ...
Definition mqtt.h:1483
int32_t operator--(int)
Postdecrement the object.
Definition mqtt.h:1575
virtual int ParseFd(int mqttFd) override
the data from a file descriptor according to this object's current default serialization method and a...
mqtt_int & operator=(int i)
Assignment operator for mqtt_int. Assigns the value to the object, then performs any post assignment ...
mqtt_int(mqtt_leaf &parent, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_int object.
mqtt_int(int val, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_int object.
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
whether the current index of a JSON dataset is valid for this object, or assign the value at the curr...
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
Render this object to an output socket.
mqtt_int & operator--()
Predecrement the object.
Definition mqtt.h:1569
mqtt_int & operator++()
Preincrement the object.
Definition mqtt.h:1557
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
Render this object to an output buffer.
mqtt_int(const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_int object.
mqtt_int(mqtt_leaf &parent, int val, const char *topic, Client *mClient=NULL, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_int object.
int32_t operator++(int)
Postincrement the object.
Definition mqtt.h:1563
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
Handle a message sent by the Broker triggered by this object's Subscription.
Base class for all Mqtt Objects (MqttObj). Mqtt Objects provide a seamless bridge/synchronization to ...
Definition mqtt.h:906
bool MatchId(ParsedJsonDataSet &pjs)
Determine whether the JSON dataset's current index matches this object's name.
int QueuePublish()
Queue this object to be Published via the registered Client.
virtual void ClearFlags(uint16_t delFlags)
Clear behavioral flags from this object.
uint16_t GetFlags()
Get the behavioral flags set for this object.
Definition mqtt.h:1266
mqtt_leaf(const char *topic, Client *mClient, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for mqtt_leaf objects.
static int MqttRxPublish(Client *mClient, int mqttFd, PacketInfo::Msg *msg, void *ctx)
Static message handler for Publish messages received by the registered Client.
uint16_t mFlags
Behavioral flags.
Definition mqtt.h:949
int HandleSubAck(int mqttFd, PacketInfo::Msg *msg)
Handle a Subscribe Acknowledge message from the broker for our Subscribe request.
virtual int RenderToFd(eObj_Serialize_t form, int fd)=0
Render this object to an output socket.
virtual mqtt_leaf * GetChildren()
Get the first child of this object.
virtual void SetSerializationForm(eObj_Serialize_t form)
Set the default serialization format for this object.
virtual void SetFlags(uint16_t newFlags)
Set additional behavioral flags for this object.
NBInterpolatedString topicName
Topic name or additional branch.
Definition mqtt.h:947
void SetPublishInterval(uint32_t intervalPeriodTicks)
Sets or clears an automatic publishing interval for this MQTT object.
void RemoveFromTree()
Remove this object from it's parent tree.
virtual int GetSubTopicFilter(NBString &s)
Get the Subscription Topic Filter this object Subscribes to.
int Assign()
Perform post assignemnt operations.
int QueueUnsubscribe()
Queue this object to be Unsubscribed via the registered Client.
mqtt_leaf(mqtt_leaf &parent, const char *topic, Client *mClient, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for mqtt_leaf objects.
virtual void SetPubState(uint8_t newState)
Set the Publish state.
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg)
Handle a message sent by the Broker triggered by this object's Subscription.
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal)=0
Test whether the current index of a JSON dataset is valid for this object, or assign the value at the...
void ForEachLeaf(LeafCallBack *p, void *pd)
Call a function on each element of the MqttObj tree with this object as the root.
virtual void SetSubState(uint8_t newState)
Set the Subscribe state.
int Publish(int waitForCompletion=-1)
Publishes the current MQTT object, optionally waiting for completion.
~mqtt_leaf()
~mqtt_leaf Destructor for base mqtt_leaf
int HandlePubAck(int mqttFd, PacketInfo::Msg *msg)
Handle an Publish Acknowledge message from the broker for our Publish request.
virtual mqtt_leaf * RemoveFirstChild()
Remove the first child from this object.
virtual int ParseFd(int mqttFd)=0
Parse the data from a file descriptor according to this object's current default serialization method...
eObj_Serialize_t publishForm
Default serialization form.
Definition mqtt.h:948
eObj_Serialize_t GetSerializationForm()
Get the default serialization format for this object.
Definition mqtt.h:1244
virtual int GetRenderLength(eObj_Serialize_t form=eObj_Serialize_CURRENT_FORM)
Get the number of bytes used to serialize this object in a particular format.
virtual mqtt_leaf * AddChild(mqtt_leaf *child)
Add an MqttObj as a child to this object.
int HandleUnsubAck(int mqttFd, PacketInfo::Msg *msg)
Handle an Unsubscribe Acknowledge message from the broker for our Unsubscribe request.
bool NameMatch(const char *cp)
Determine whether a given name matches this object.
int getPriority()
Get the message priority for this object.
Definition mqtt.h:1273
eObj_State_t
Mqtt Object Publication/Subscription States.
Definition mqtt.h:910
uint8_t PubState()
Get the Publish state.
Definition mqtt.h:1072
virtual int GetPubTopicName(NBString &s)
Get the Topic Name this object Publishes to.
void RootParse(ParsedJsonDataSet &pjs)
Assign to this object tree from a JSON dataset.
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen)=0
Render this object to an output buffer.
uint8_t SubState()
Get the Subscribe state of this object.
Definition mqtt.h:1079
int QueueSubscribe()
Queue this object to be Subscribed via the registered Client.
Base class for easy MQTT Objects (MqttObj). mqtt_obj are comprised of higher order parent objects tha...
Definition mqtt.h:1329
virtual mqtt_leaf * AddChild(mqtt_leaf *child) override
an MqttObj as a child to this object.
virtual void SetPubState(uint8_t newState) override
the Publish state
virtual void SetSubState(uint8_t newState) override
the Subscribe state
mqtt_leaf * FindChild(const char *topic)
the child object that is registered for the given Topic Name.
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
Handle a message sent by the Broker triggered by this object's Subscription.
mqtt_obj(mqtt_leaf &parent, const char *topic, Client *mClient, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for an mqtt_obj with a known parent object.
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
Render this object to an output socket.
mqtt_obj(const char *topic, Client *mClient, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_obj object.
virtual int GetSubTopicFilter(NBString &s) override
the Subscription Topic Filter this object Subscribes to.
virtual mqtt_leaf * GetChildren() override
the first child of this object.
~mqtt_obj()
~mqtt_obj Destructor for base mqtt_obj
virtual int GetRenderLength(eObj_Serialize_t form=eObj_Serialize_CURRENT_FORM) override
the number of bytes used to serialize this object in a particular format.
virtual mqtt_leaf * RemoveFirstChild() override
Remove the first child from this object.
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
whether the current index of a JSON dataset is valid for this object, or assign the value at the curr...
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
Render this object to an output buffer.
virtual int ParseFd(int mqttFd) override
the data from a file descriptor according to this object's current default serialization method and a...
Easy MqttObj class for automatically publishing and subscribing string values to/from an MQTT topic....
Definition mqtt.h:1919
mqtt_string & operator=(const NBString &s)
Assignment operator for mqtt_string. Assigns the value to the object, then performs any post assignme...
mqtt_string(const char *topic, Client *mClient=NULL, uint16_t flags=0)
Constructor for a standalone mqtt_string object.
char & operator[](size_t pos)
operator that returns a reference to the character at the given position.
Definition mqtt.h:2027
mqtt_string(mqtt_leaf &parent, const char *topic, Client *mClient=NULL, uint16_t flags=0)
Constructor for a mqtt_string object that has a parent.
mqtt_string(mqtt_leaf &parent, const NBString &val, const char *topic, Client *mClient=NULL, uint16_t flags=0)
Constructor for a mqtt_string object that has a parent.
mqtt_string(const char *val, const char *topic, Client *mClient=NULL, uint16_t flags=0)
Constructor for a standalone mqtt_string object.
virtual int ParseFd(int mqttFd) override
the data from a file descriptor according to this object's current default serialization method and a...
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
Test whether the current index of a JSON dataset is valid for this object, or assign the value at the...
mqtt_string(mqtt_leaf &parent, const char *val, const char *topic, Client *mClient=NULL, uint16_t flags=0)
Constructor for a mqtt_string object that has a parent.
mqtt_string(const NBString &val, const char *topic, Client *mClient=NULL, uint16_t flags=0)
Constructor for a standalone mqtt_string object.
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
Render this object to an output buffer.
mqtt_string & operator=(const char *s)
Assignment operator for mqtt_string. Assigns the value to the object, then performs any post assignme...
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
Render this object to an output socket.
const char operator[](size_t pos) const
operator that returns the const char value of the character an the index. Operates on const objects.
Definition mqtt.h:2021
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
Handle a message sent by the Broker triggered by this object's Subscription.
Easy MqttObj class for automatically publishing and subscribing unsigned integer values to/from an MQ...
Definition mqtt.h:1628
uint32_t operator--(int)
Postdecrement the object.
Definition mqtt.h:1719
virtual int RenderToFd(eObj_Serialize_t form, int fd) override
Render this object to an output socket.
mqtt_uint(mqtt_leaf &parent, uint32_t val, const char *topic, Client *client, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a mqtt_uint object that has a parent.
uint32_t operator++(int)
Postincrement the object.
Definition mqtt.h:1707
mqtt_uint(const char *topic, Client *client, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_uint object.
mqtt_uint & operator++()
Preincrement the object.
Definition mqtt.h:1701
virtual int RenderToBuffer(eObj_Serialize_t form, uint8_t *buf, int buflen) override
Render this object to an output buffer.
mqtt_uint(mqtt_leaf &parent, const char *topic, Client *client, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a mqtt_uint object that has a parent.
mqtt_uint & operator=(uint32_t i)
Assignment operator for mqtt_uint. Assigns the value to the object, then performs any post assignment...
virtual int ParseFd(int mqttFd) override
the data from a file descriptor according to this object's current default serialization method and a...
virtual int SubscribeEvent(int mqttFd, PacketInfo::Msg *msg) override
Handle a message sent by the Broker triggered by this object's Subscription.
mqtt_uint & operator--()
Predecrement the object.
Definition mqtt.h:1713
mqtt_uint(uint32_t val, const char *topic, Client *client, uint16_t flags=(eObj_Flag_PubOnWrite|eObj_Flag_Subscribe|eObj_Flag_Sub_NoLocal))
Constructor for a standalone mqtt_uint object.
virtual ValueTestResult TestOrSetValue(ParsedJsonDataSet &pjs, bool setVal) override
whether the current index of a JSON dataset is valid for this object, or assign the value at the curr...
A wrapper for NBString::Interpolate() ideal for easy access to ephemeral values.
Definition nbstring.h:655
Lightweight alternative to C++ CString class.
Definition nbstring.h:118
A class to create, read, and modify a JSON object.
Definition json_lexer.h:535
Parsed Uniform Resource Identifier Class (URI)
Definition http_funcs.h:62
GPIO Pin Class.
Definition coldfire/cpu/MCF5441X/include/cpu_pins.h:15
TickTimeout objects are used to facilitate sequential function calls with timeout parameters that nee...
Definition nbrtos.h:168
Base class used to create configuration objects.
Definition config_obj.h:320
Configuration object, Filesystem Bulk Storage header file.
Configuration object header file.
NetBurner System Constants.
#define MQTT_TASK_PRIO
Definition constants.h:163
#define MQTT_OBJ_PRIORITY_COUNT
Definition mqtt.h:51
#define MQTT_DEFAULT_KEEP_ALIVE
Definition mqtt.h:61
void init()
System initialization. Ideally called at the beginning of all applications, since the easiest Recover...
JSON HTTP functions.
NetBurner JSON Lexer. See the JSON Lexer page for complete documentation.
void UserMain(void *pd)
Main function.
Definition PlatformSpecific/SAME70/MODM7AE70/ADC_Simple/src/main.cpp:42
MQTT Namespace.
Definition mqtt.h:81
int(* MsgCallback_t)(MQTT::Client *mConn, int mqttFd, MQTT::PacketInfo::Msg *msg, void *ctx)
Function signature for a user-implemented callback function to receive messages from a subscription.
Definition mqtt.h:147
const char * GetPacketTypeString(Pkt::eType_t pkt)
Get the name of a specific eType_t protocol packet type.
const char * GetReturnCodeString(MQTT::eResult_t result)
Get the name of a specific API eResult_t return code.
@ eObj_Flag_DynTopicName
<++>
Definition mqtt.h:190
@ eObj_Flag_PubQoS_ExactlyOnce
Publish using QoS == At Most Once.
Definition mqtt.h:178
@ eObj_Flag_Sub_Retained_Never
Never receive Retained messages, unless connected and subscribed when they are sent.
Definition mqtt.h:187
@ eObj_Flag_PubRetain
Publish with Retain set.
Definition mqtt.h:179
@ eObj_Flag_Sub_QoS_ExactlyOnce
Receive Publish messages at QoS == At Most Once.
Definition mqtt.h:184
@ eObj_Flag_PubQoS_AtLeastOnce
Publish using QoS == At Least Once.
Definition mqtt.h:177
@ eObj_Flag_Sub_Retained_IfNew
When subscribing/connecting, only receive the Retained Publish, if it is new since last subscribed/co...
Definition mqtt.h:186
@ eObj_Flag_Sub_QoS_AtLeastOnce
Receive Publish messages at QoS == At Least Once.
Definition mqtt.h:183
@ eObj_Flag_Sub_HandlerOnly
<++>
Definition mqtt.h:181
@ eObj_Flag_PubOnWrite
Publish object whenever it is written to.
Definition mqtt.h:176
@ eObj_Flag_WaitForPub
Assigning to the object blocks until new value has been published.
Definition mqtt.h:189
@ eObj_Flag_Sub_NoLocal
Do not Receive Local Publish Messages.
Definition mqtt.h:185
@ eObj_Flag_Subscribe
Automatically subscribe to the objects Topic.
Definition mqtt.h:180
@ eObj_Flag_Sub_IncludeLocal
Receive Publish messages sent by the object's client (aka, receive an Echo)
Definition mqtt.h:182
eResult_t
MQTT library return codes.
Definition mqtt.h:85
@ eResult_Mqtt_PayFmt_Invalid
Payload Format error (malformed message)
Definition mqtt.h:113
@ eResult_Mqtt_NotSupported_SubIds
Broker does not support Subscription IDs.
Definition mqtt.h:121
@ eResult_Mqtt_NotSupported_QoS
Requested QoS level not supported for prior Publish Message.
Definition mqtt.h:115
@ eResult_Mqtt_SessTakeover
Session has been taken over by another connection.
Definition mqtt.h:102
@ eResult_Mqtt_NotSupported_SharedSubs
Broker does not support Shared Subscriptions.
Definition mqtt.h:118
@ eResult_Mqtt_TopicAlias_Invalid
Requested Topic Alias is invalid/unknown.
Definition mqtt.h:108
@ eResult_Mqtt_NotSupported_Retain
Retain not supported for prior Publish Message.
Definition mqtt.h:114
@ eResult_Error_Malformed
Malformed argument.
Definition mqtt.h:130
@ eResult_Mqtt_MalformedPkt
Malformed Mqtt msg was sent/received.
Definition mqtt.h:89
@ eResult_Mqtt_NotSupported_WildSubs
Broker does not support Wildcard Subscriptions.
Definition mqtt.h:122
@ eResult_Mqtt_TooLarge
Message Size too large.
Definition mqtt.h:109
@ eResult_Error_NetErr
General network layer error.
Definition mqtt.h:124
@ eResult_Mqtt_Protocol
Unsupported or unknown protocol.
Definition mqtt.h:90
@ eResult_Success
No error, completed successfully.
Definition mqtt.h:86
@ eResult_Mqtt_UnsupportedProtoVer
Unsupported MQTT protocol version.
Definition mqtt.h:92
@ eResult_Mqtt_UserPassword
Invalid Username/password.
Definition mqtt.h:94
@ eResult_Mqtt_NameInvalid
Submitted Topic Name is invalid.
Definition mqtt.h:104
@ eResult_Mqtt_Banned
Client is banned by the broker.
Definition mqtt.h:98
@ eResult_Mqtt_ServerUnavail
Broker unavailable.
Definition mqtt.h:96
@ eResult_Error_Timeout
Operation timed out.
Definition mqtt.h:131
@ eResult_Mqtt_NotAuthorized
Client not authorized.
Definition mqtt.h:95
@ eResult_Mqtt_Admin
General Administrative error.
Definition mqtt.h:112
@ eResult_Socket_TryAgain
Client Network Socket error, try again.
Definition mqtt.h:125
@ eResult_Mqtt_KATimeout
Keep Alive Timeout exceeded.
Definition mqtt.h:101
@ eResult_Mqtt_Quota
Exceeded client message quota.
Definition mqtt.h:111
@ eResult_Mqtt_ClientIdInvalid
Broker refusing current Client ID.
Definition mqtt.h:93
@ eResult_Error_InvalidURI
Provided Broker address URI is invalid.
Definition mqtt.h:128
@ eResult_Mqtt_PktId_NotFound
Broker has no outstanding packet with the requested ID.
Definition mqtt.h:106
@ eResult_Error_NoSuchConn
No such connection.
Definition mqtt.h:133
@ eResult_Mqtt_ServerMoved
Broker Permanently Moved to new address.
Definition mqtt.h:117
@ eResult_Error_BadArg
General Bad Argument.
Definition mqtt.h:134
@ eResult_Mqtt_MsgRate
Exceeded client rate limit.
Definition mqtt.h:110
@ eResult_Mqtt_Implementation
Feature/option not implemented.
Definition mqtt.h:91
@ eResult_Error_BadProp
Argument contains malformed Message Property.
Definition mqtt.h:132
@ eResult_Cont_Auth
<++>
Definition mqtt.h:127
@ eResult_Mqtt_PktId_InUse
Broker has an outstanding Reliable QOS Packet with the same ID (sending Subscribe when a Publish with...
Definition mqtt.h:105
@ eResult_Mqtt_ConnRate
Exceeded Connection Rate Limit.
Definition mqtt.h:119
@ eResult_Mqtt_FilterInvalid
A submitted request filter is invalid.
Definition mqtt.h:103
@ eResult_Mqtt_RcvMax_Exceeded
<++>
Definition mqtt.h:107
@ eResult_Mqtt_UseOther
Client should connect to specified Other Broker (equivalent to HTTP 3xx redirect)
Definition mqtt.h:116
@ eResult_Mqtt_BadAuthMethod
Broker does not support the requested authentication method.
Definition mqtt.h:100
@ eResult_Mqtt_ServerShutdown
Broker is shutting down.
Definition mqtt.h:99
@ eResult_Mqtt_Unspecified
Unknown/Unspecified error.
Definition mqtt.h:88
@ eResult_Mqtt_Transport_Error
Transport layer error.
Definition mqtt.h:123
@ eResult_Socket_NeedDNS
Broker address failed to resolve DNS.
Definition mqtt.h:126
@ eResult_Error_NoneAvail
Required resource exhausted, none available.
Definition mqtt.h:129
@ eResult_Mqtt_ServerBusy
Broker is unable to process message at this time.
Definition mqtt.h:97
@ eResult_Mqtt_MaxConnTime
Exceeded Maximum Connection Time limit.
Definition mqtt.h:120
const char * GetConnectionStatusString(int status)
Get the name of a specific GetConnectionStatus return code.
eObj_Serialize_t
MqttObj Serialization Formats.
Definition mqtt.h:196
@ eObj_Serialize_MqttString
Serialize as a MQTT Protocol level string.
Definition mqtt.h:201
@ eObj_Serialize_LittleEndian
Serialize as binary, Little Endian ordering.
Definition mqtt.h:203
@ eObj_Serialize_BigEndian
Serialize as binary, Big Endian ordering.
Definition mqtt.h:202
@ eObj_Serialize_Disabled
Do not serialize, used to disable serialization of branches in complex structures.
Definition mqtt.h:197
@ eObj_Serialize_NativeEndian
Serialize as binary, host native ordering.
Definition mqtt.h:204
@ eObj_Serialize_String
Serialize as a null terminated string.
Definition mqtt.h:198
@ eObj_Serialize_CURRENT_FORM
Serialize as the object's current defined form (only valid if the object has a currently assigned for...
Definition mqtt.h:205
@ eObj_Serialize_JSON_ValOnly
Serialize as a JSON value.
Definition mqtt.h:200
@ eObj_Serialize_JSON
Serialize as a JSON name:value pair.
Definition mqtt.h:199
PacketInfo::Msg message data structure.
Definition mqtt_msg_reqs.h:70
Structure used to specify details for a Publish call.
Definition mqtt_msg_reqs.h:207
Structure used to specify details for a Subscribe call.
Definition mqtt_msg_reqs.h:286
TopicHandler context definition.
Definition mqtt.h:155
MsgCallback_t handleMsg
Handler method to call.
Definition mqtt.h:157
NBString topicFilter
Filter used to describe which topics this handler covers.
Definition mqtt.h:156
void * ctx
User provided extra data passed to the handler method.
Definition mqtt.h:158
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at ...
Definition nbrtos.h:1110
Semaphores are used to control access to shared resources or or to communicate between tasks in a mul...
Definition nbrtos.h:411