NetBurner 3.5.6
PDF Version
MQTT Namespace Reference

MQTT Namespace. More...

Namespaces

namespace  PacketInfo
 MQTT PacketInfo Namespace.
 

Classes

class  Client
 Advanced low-level MQTT Client for interacting with Mqtt Brokers. The client handles all network communications with the Broker and handles local message queueing and dispatching to topic handlers. More...
 
class  ConfigExposer
 Easy MqttObj class for automatically publishing and subscribing NetBurner Config system objects to/from an MQTT topic. Use like a normal ConfigObj. More...
 
class  ConfiguredClient
 Easy MQTT Client wrapper for interacting with MQTT brokers. The client handles all network communications with the Broker and handles local message queueing and dispatching to topic handlers. Adds ConfigObj for automatically configuring all Client settings via the Config System. More...
 
struct  ConnectRequest
 Structure used to specify details for a Publish call. More...
 
class  mqtt_bool
 Easy MqttObj class for automatically publishing and subscribing boolean values to/from an MQTT topic. Use like a normal bool. More...
 
class  mqtt_float
 Easy MqttObj class for automatically publishing and subscribing floating point values to/from an MQTT topic. Use like a normal double. More...
 
class  mqtt_int
 Easy MqttObj class for automatically publishing and subscribing unsigned integer values to/from an MQTT topic. Use like a normal int32_t. More...
 
class  mqtt_IO
 Easy MqttObj class for automatically publishing and subscribing hardware GPIO pins to/from an MQTT topic. Use like a normal PinIO. More...
 
class  mqtt_IO_Input
 MqttObj connecting hardware GPIO pins to an Mqtt Broker. This class defaults the pin to an Input state. More...
 
class  mqtt_IO_Output
 MqttObj connecting hardware GPIO pins to an Mqtt Broker. This class defaults the pin to an Output state. More...
 
class  mqtt_leaf
 Base class for all Mqtt Objects (MqttObj). Mqtt Objects provide a seamless bridge/synchronization to communicate information through an MQTT Broker via a Client object. More...
 
class  mqtt_obj
 Base class for easy MQTT Objects (MqttObj). mqtt_obj are comprised of higher order parent objects that contain registered child objects. More...
 
class  mqtt_string
 Easy MqttObj class for automatically publishing and subscribing string values to/from an MQTT topic. Use like a normal NBString. More...
 
class  mqtt_uint
 Easy MqttObj class for automatically publishing and subscribing unsigned integer values to/from an MQTT topic. Use like a normal uint32_t. More...
 
struct  PublishRequest
 Structure used to specify details for a Publish call. More...
 
class  SubHandler
 Easy class for registering a callback function that receives messages on an MQTT topic and handles them appropriately. Behaves similarly to HttpResponseHandler. More...
 
struct  SubscribeFilter
 Structure used to specify a topic filter for subscriptions. More...
 
struct  SubscribeFilter_NbStr
 Structure used to specify a topic filter for subscriptions. More...
 
struct  SubscribeRequest
 Structure used to specify details for a Subscribe call. More...
 
struct  TopicHandler
 TopicHandler context definition. More...
 

Typedefs

typedef 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.
 

Enumerations

enum  eResult_t {
  eResult_Success = 0 , eResult_Mqtt_Unspecified = -Pkt::eReason_Error_Unspecified , eResult_Mqtt_MalformedPkt = -Pkt::eReason_Error_MalformedPkt , eResult_Mqtt_Protocol = -Pkt::eReason_Error_Protocol ,
  eResult_Mqtt_Implementation = -Pkt::eReason_Error_Implementation , eResult_Mqtt_UnsupportedProtoVer = -Pkt::eReason_Error_UnsupportedProtoVer , eResult_Mqtt_ClientIdInvalid = -Pkt::eReason_Error_ClientIdInvalid , eResult_Mqtt_UserPassword = -Pkt::eReason_Error_UserPassword ,
  eResult_Mqtt_NotAuthorized = -Pkt::eReason_Error_NotAuthorized , eResult_Mqtt_ServerUnavail = -Pkt::eReason_Error_ServerUnavail , eResult_Mqtt_ServerBusy = -Pkt::eReason_Error_ServerBusy , eResult_Mqtt_Banned = -Pkt::eReason_Error_Banned ,
  eResult_Mqtt_ServerShutdown = -Pkt::eReason_Error_ServerShutdown , eResult_Mqtt_BadAuthMethod = -Pkt::eReason_Error_BadAuthMethod , eResult_Mqtt_KATimeout = -Pkt::eReason_Error_KATimeout , eResult_Mqtt_SessTakeover = -Pkt::eReason_Error_SessTakeover ,
  eResult_Mqtt_FilterInvalid = -Pkt::eReason_Error_FilterInvalid , eResult_Mqtt_NameInvalid = -Pkt::eReason_Error_NameInvalid , eResult_Mqtt_PktId_InUse = -Pkt::eReason_Error_PktId_InUse , eResult_Mqtt_PktId_NotFound = -Pkt::eReason_Error_PktId_NotFound ,
  eResult_Mqtt_RcvMax_Exceeded = -Pkt::eReason_Error_RcvMax_Exceeded , eResult_Mqtt_TopicAlias_Invalid = -Pkt::eReason_Error_TopicAlias_Invalid , eResult_Mqtt_TooLarge = -Pkt::eReason_Error_TooLarge , eResult_Mqtt_MsgRate = -Pkt::eReason_Error_MsgRate ,
  eResult_Mqtt_Quota = -Pkt::eReason_Error_Quota , eResult_Mqtt_Admin = -Pkt::eReason_Error_Admin , eResult_Mqtt_PayFmt_Invalid = -Pkt::eReason_Error_PayFmt_Invalid , eResult_Mqtt_NotSupported_Retain = -Pkt::eReason_Error_NotSupported_Retain ,
  eResult_Mqtt_NotSupported_QoS = -Pkt::eReason_Error_NotSupported_QoS , eResult_Mqtt_UseOther = -Pkt::eReason_Error_UseOther , eResult_Mqtt_ServerMoved = -Pkt::eReason_Error_ServerMoved , eResult_Mqtt_NotSupported_SharedSubs = -Pkt::eReason_Error_NotSupported_SharedSubs ,
  eResult_Mqtt_ConnRate = -Pkt::eReason_Error_ConnRate , eResult_Mqtt_MaxConnTime = -Pkt::eReason_Error_MaxConnTime , eResult_Mqtt_NotSupported_SubIds = -Pkt::eReason_Error_NotSupported_SubIds , eResult_Mqtt_NotSupported_WildSubs = -Pkt::eReason_Error_NotSupported_WildSubs ,
  eResult_Mqtt_Transport_Error = -Pkt::eReason_Error_Transport_Error , eResult_Error_NetErr = -Pkt::eReason_Error_Transport_Error , eResult_Socket_TryAgain = -256 , eResult_Socket_NeedDNS = -257 ,
  eResult_Cont_Auth = -258 , eResult_Error_InvalidURI = -259 , eResult_Error_NoneAvail = -260 , eResult_Error_Malformed = -261 ,
  eResult_Error_Timeout = -262 , eResult_Error_BadProp = -263 , eResult_Error_NoSuchConn = -264 , eResult_Error_BadArg = -265
}
 MQTT library return codes. More...
 
enum  {
  eObj_Flag_PubOnWrite = 0x0001 , eObj_Flag_PubQoS_AtLeastOnce = 0x0002 , eObj_Flag_PubQoS_ExactlyOnce = 0x0004 , eObj_Flag_PubRetain = 0x0008 ,
  eObj_Flag_Subscribe = 0x0010 , eObj_Flag_Sub_HandlerOnly = 0x0020 , eObj_Flag_Sub_IncludeLocal = 0x0040 , eObj_Flag_Sub_QoS_AtLeastOnce = 0x0080 ,
  eObj_Flag_Sub_QoS_ExactlyOnce = 0x0100 , eObj_Flag_Sub_NoLocal = 0x0200 , eObj_Flag_Sub_Retained_IfNew = 0x0400 , eObj_Flag_Sub_Retained_Never = 0x0800 ,
  eObj_Flag_WaitForPub = 0x1000 , eObj_Flag_DynTopicName = 0x2000
}
 MqttObj Control Flags. More...
 
enum  eObj_Serialize_t {
  eObj_Serialize_Disabled = 0x00 , eObj_Serialize_String = 0x01 , eObj_Serialize_JSON = 0x02 , eObj_Serialize_JSON_ValOnly = 0x04 ,
  eObj_Serialize_MqttString = 0x08 , eObj_Serialize_BigEndian = 0x10 , eObj_Serialize_LittleEndian = 0x20 , eObj_Serialize_NativeEndian = 0x40 ,
  eObj_Serialize_CURRENT_FORM = 0x80
}
 MqttObj Serialization Formats. More...
 

Functions

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.
 
const char * GetConnectionStatusString (int status)
 Get the name of a specific GetConnectionStatus return code.
 

Detailed Description

MQTT Namespace.

#include <mqtt/mqtt.h>

Client or ConfiguredClient are the base classes to use MQTT.

SubHandler and TopicHandler are event callbacks for the Client.

ConfigExposer and the mqtt_* classes are "magic" classes that automatically handle pub/sub of the associated object to/from the specified MQTT topic.

Topic Names are also handled as an NBInterpolatedString and so can be dynamically assigned to NetBurner Config System values using specially formatting strings.

See the MQTT examples folder for more details.

Typedef Documentation

◆ MsgCallback_t

typedef int(* MQTT::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.

Parameters
*mConnPointer to the Mqtt Client that received the message
mqttFdThe file descriptor for the socket the message was received on
*msgPointer to the message struct
*ctxA void pointer passed into the register function. Can be used to reference objects or other data
See also
TopicHandler, RegisterTopicHandler

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

MqttObj Control Flags.

Describes how the object should behave in relation to the Client and normal code.

Enumerator
eObj_Flag_PubOnWrite 

Publish object whenever it is written to.

eObj_Flag_PubQoS_AtLeastOnce 

Publish using QoS == At Least Once.

eObj_Flag_PubQoS_ExactlyOnce 

Publish using QoS == At Most Once.

eObj_Flag_PubRetain 

Publish with Retain set.

eObj_Flag_Subscribe 

Automatically subscribe to the objects Topic.

eObj_Flag_Sub_HandlerOnly 

<++>

eObj_Flag_Sub_IncludeLocal 

Receive Publish messages sent by the object's client (aka, receive an Echo)

eObj_Flag_Sub_QoS_AtLeastOnce 

Receive Publish messages at QoS == At Least Once.

eObj_Flag_Sub_QoS_ExactlyOnce 

Receive Publish messages at QoS == At Most Once.

eObj_Flag_Sub_NoLocal 

Do not Receive Local Publish Messages.

eObj_Flag_Sub_Retained_IfNew 

When subscribing/connecting, only receive the Retained Publish, if it is new since last subscribed/connected.

eObj_Flag_Sub_Retained_Never 

Never receive Retained messages, unless connected and subscribed when they are sent.

eObj_Flag_WaitForPub 

Assigning to the object blocks until new value has been published.

eObj_Flag_DynTopicName 

<++>

◆ eObj_Serialize_t

MqttObj Serialization Formats.

Enumerator
eObj_Serialize_Disabled 

Do not serialize, used to disable serialization of branches in complex structures.

eObj_Serialize_String 

Serialize as a null terminated string.

eObj_Serialize_JSON 

Serialize as a JSON name:value pair.

eObj_Serialize_JSON_ValOnly 

Serialize as a JSON value.

eObj_Serialize_MqttString 

Serialize as a MQTT Protocol level string.

eObj_Serialize_BigEndian 

Serialize as binary, Big Endian ordering.

eObj_Serialize_LittleEndian 

Serialize as binary, Little Endian ordering.

eObj_Serialize_NativeEndian 

Serialize as binary, host native ordering.

eObj_Serialize_CURRENT_FORM 

Serialize as the object's current defined form (only valid if the object has a currently assigned format)

◆ eResult_t

MQTT library return codes.

Enumerator
eResult_Success 

No error, completed successfully.

eResult_Mqtt_Unspecified 

Unknown/Unspecified error.

eResult_Mqtt_MalformedPkt 

Malformed Mqtt msg was sent/received.

eResult_Mqtt_Protocol 

Unsupported or unknown protocol.

eResult_Mqtt_Implementation 

Feature/option not implemented.

eResult_Mqtt_UnsupportedProtoVer 

Unsupported MQTT protocol version.

eResult_Mqtt_ClientIdInvalid 

Broker refusing current Client ID.

eResult_Mqtt_UserPassword 

Invalid Username/password.

eResult_Mqtt_NotAuthorized 

Client not authorized.

eResult_Mqtt_ServerUnavail 

Broker unavailable.

eResult_Mqtt_ServerBusy 

Broker is unable to process message at this time.

eResult_Mqtt_Banned 

Client is banned by the broker.

eResult_Mqtt_ServerShutdown 

Broker is shutting down.

eResult_Mqtt_BadAuthMethod 

Broker does not support the requested authentication method.

eResult_Mqtt_KATimeout 

Keep Alive Timeout exceeded.

eResult_Mqtt_SessTakeover 

Session has been taken over by another connection.

eResult_Mqtt_FilterInvalid 

A submitted request filter is invalid.

eResult_Mqtt_NameInvalid 

Submitted Topic Name is invalid.

eResult_Mqtt_PktId_InUse 

Broker has an outstanding Reliable QOS Packet with the same ID (sending Subscribe when a Publish with the same ID is in progress, etc.)

eResult_Mqtt_PktId_NotFound 

Broker has no outstanding packet with the requested ID.

eResult_Mqtt_RcvMax_Exceeded 

<++>

eResult_Mqtt_TopicAlias_Invalid 

Requested Topic Alias is invalid/unknown.

eResult_Mqtt_TooLarge 

Message Size too large.

eResult_Mqtt_MsgRate 

Exceeded client rate limit.

eResult_Mqtt_Quota 

Exceeded client message quota.

eResult_Mqtt_Admin 

General Administrative error.

eResult_Mqtt_PayFmt_Invalid 

Payload Format error (malformed message)

eResult_Mqtt_NotSupported_Retain 

Retain not supported for prior Publish Message.

eResult_Mqtt_NotSupported_QoS 

Requested QoS level not supported for prior Publish Message.

eResult_Mqtt_UseOther 

Client should connect to specified Other Broker (equivalent to HTTP 3xx redirect)

eResult_Mqtt_ServerMoved 

Broker Permanently Moved to new address.

eResult_Mqtt_NotSupported_SharedSubs 

Broker does not support Shared Subscriptions.

eResult_Mqtt_ConnRate 

Exceeded Connection Rate Limit.

eResult_Mqtt_MaxConnTime 

Exceeded Maximum Connection Time limit.

eResult_Mqtt_NotSupported_SubIds 

Broker does not support Subscription IDs.

eResult_Mqtt_NotSupported_WildSubs 

Broker does not support Wildcard Subscriptions.

eResult_Mqtt_Transport_Error 

Transport layer error.

eResult_Error_NetErr 

General network layer error.

eResult_Socket_TryAgain 

Client Network Socket error, try again.

eResult_Socket_NeedDNS 

Broker address failed to resolve DNS.

eResult_Cont_Auth 

<++>

eResult_Error_InvalidURI 

Provided Broker address URI is invalid.

eResult_Error_NoneAvail 

Required resource exhausted, none available.

eResult_Error_Malformed 

Malformed argument.

eResult_Error_Timeout 

Operation timed out.

eResult_Error_BadProp 

Argument contains malformed Message Property.

eResult_Error_NoSuchConn 

No such connection.

eResult_Error_BadArg 

General Bad Argument.

Function Documentation

◆ GetConnectionStatusString()

const char * MQTT::GetConnectionStatusString ( int status)

Get the name of a specific GetConnectionStatus return code.

Parameters
statusThe integer output from GetConnectionStatus()
Returns
A pointer to the string containing the return code name.
See also
Client::Connect, Client::Disconnect, Client::GetConnectionStatus

◆ GetPacketTypeString()

const char * MQTT::GetPacketTypeString ( Pkt::eType_t pkt)

Get the name of a specific eType_t protocol packet type.

Parameters
pktThe protocol packet type to get the name of.
Returns
A pointer to the string containing the packet type name.
See also
GetReturnCodeString

◆ GetReturnCodeString()

const char * MQTT::GetReturnCodeString ( MQTT::eResult_t result)

Get the name of a specific API eResult_t return code.

Parameters
resultThe return code to get the name of.
Returns
A pointer to the string containing the return code name.
See also
GetReturnCodeString