NetBurner 3.5.6
PDF Version
MQTT::ConfigExposer Class Reference

Easy MqttObj class for automatically publishing and subscribing NetBurner Config system objects to/from an MQTT topic. Use like a normal ConfigObj. More...

#include <mqtt.h>

Inherits MQTT::mqtt_leaf.

Public Types

enum  eRenderFlag_t { eRender_Hidden , eRender_ModifiedOnly , eRender_Pretty }
 Rendering options for MQTT output of Config objects. More...
 
- Public Types inherited from MQTT::mqtt_leaf
enum  eObj_State_t
 Mqtt Object Publication/Subscription States.
 

Public Member Functions

 ConfigExposer (config_leaf &leaf, const char *topicRoot, Client *mClient=NULL, uint16_t initFlags=0, uint32_t renderFlags=0)
 Constructor for a standalone ConfigExposer object.
 
 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 int GetPubTopicName (NBString &s) override
 Get the Topic Name this object Publishes to.
 
virtual int GetSubTopicFilter (NBString &s) override
 Get the Subscription Topic Filter this object Subscribes to.
 
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 current index of the dataset to this object.
 
virtual int SubscribeEvent (int mqttFd, PacketInfo::Msg *msg) override
 Handle a message sent by the Broker triggered by this object's Subscription.
 
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 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.
 
- Public Member Functions inherited from MQTT::mqtt_leaf
 ~mqtt_leaf ()
 ~mqtt_leaf Destructor for base mqtt_leaf
 
void RemoveFromTree ()
 Remove this object from it's parent tree.
 
bool NameMatch (const char *cp)
 Determine whether a given name matches this object.
 
int Publish (int waitForCompletion=-1)
 Publishes the current MQTT object, optionally waiting for completion.
 
void SetPublishInterval (uint32_t intervalPeriodTicks)
 Sets or clears an automatic publishing interval for this MQTT object.
 
virtual void SetSerializationForm (eObj_Serialize_t form)
 Set the default serialization format for this object.
 
eObj_Serialize_t GetSerializationForm ()
 Get the default serialization format for this object.
 
virtual void SetFlags (uint16_t newFlags)
 Set additional behavioral flags for this object.
 
virtual void ClearFlags (uint16_t delFlags)
 Clear behavioral flags from this object.
 
uint16_t GetFlags ()
 Get the behavioral flags set for this object.
 
int getPriority ()
 Get the message priority for this object.
 

Protected Member Functions

virtual int ParseFd (int mqttFd) override
 Parse the data from a file descriptor according to this object's current default serialization method and assign the value.
 
- Protected Member Functions inherited from MQTT::mqtt_leaf
 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.
 
 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 mqtt_leafGetChildren ()
 Get the first child of this object.
 
virtual mqtt_leafAddChild (mqtt_leaf *child)
 Add an MqttObj as a child to this object.
 
virtual mqtt_leafRemoveFirstChild ()
 Remove the first child from this object.
 
void ForEachLeaf (LeafCallBack *p, void *pd)
 Call a function on each element of the MqttObj tree with this object as the root.
 
void RootParse (ParsedJsonDataSet &pjs)
 Assign to this object tree from a JSON dataset.
 
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.
 
int QueueSubscribe ()
 Queue this object to be Subscribed via the registered Client.
 
int QueueUnsubscribe ()
 Queue this object to be Unsubscribed via the registered Client.
 
int Assign ()
 Perform post assignemnt operations.
 
uint8_t PubState ()
 Get the Publish state.
 
uint8_t SubState ()
 Get the Subscribe state of this object.
 
virtual void SetPubState (uint8_t newState)
 Set the Publish state.
 
virtual void SetSubState (uint8_t newState)
 Set the Subscribe state.
 
int HandleSubAck (int mqttFd, PacketInfo::Msg *msg)
 Handle a Subscribe Acknowledge message from the broker for our Subscribe request.
 
int HandleUnsubAck (int mqttFd, PacketInfo::Msg *msg)
 Handle an Unsubscribe Acknowledge message from the broker for our Unsubscribe request.
 
int HandlePubAck (int mqttFd, PacketInfo::Msg *msg)
 Handle an Publish Acknowledge message from the broker for our Publish request.
 

Additional Inherited Members

- Static Public Member Functions inherited from MQTT::mqtt_leaf
static int MqttRxPublish (Client *mClient, int mqttFd, PacketInfo::Msg *msg, void *ctx)
 Static message handler for Publish messages received by the registered Client.
 
- Protected Attributes inherited from MQTT::mqtt_leaf
NBInterpolatedString topicName
 Topic name or additional branch.
 
eObj_Serialize_t publishForm
 Default serialization form.
 
uint16_t mFlags
 Behavioral flags.
 

Detailed Description

Easy MqttObj class for automatically publishing and subscribing NetBurner Config system objects to/from an MQTT topic. Use like a normal ConfigObj.

Member Enumeration Documentation

◆ eRenderFlag_t

Rendering options for MQTT output of Config objects.

Enumerator
eRender_Hidden 

Hide this branch from renders of the object.

eRender_ModifiedOnly 

Only render modified leaves of the branch.

eRender_Pretty 

Do Pretty Print rendering.

Constructor & Destructor Documentation

◆ ConfigExposer() [1/2]

MQTT::ConfigExposer::ConfigExposer ( config_leaf & leaf,
const char * topicRoot,
Client * mClient = NULL,
uint16_t initFlags = 0,
uint32_t renderFlags = 0 )

Constructor for a standalone ConfigExposer object.

Parameters
&leafReference to the ConfigObject branch being exposed
*topicRootMqtt Topic Name to use as the base for Publish/Subcribe.
*mClientPointer to Client to register with. If NULL, it will be registered with the first created Client.
initFlagsBehavioral flags to set on the created object
renderFlagsRendering flags to set for the exposed ConfigObj

◆ ConfigExposer() [2/2]

MQTT::ConfigExposer::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.

Parameters
&parentReference to parent MqttObj
&leafReference to the ConfigObject branch being exposed
*topicRootMqtt Topic Name to use as the base for Publish/Subcribe.
*mClientPointer to Client to register with. If NULL, it will be registered with the first created Client.
initFlagsBehavioral flags to set on the created object
renderFlagsRendering flags to set for the exposed ConfigObj

Member Function Documentation

◆ GetPubTopicName()

virtual int MQTT::ConfigExposer::GetPubTopicName ( NBString & s)
overridevirtual

Get the Topic Name this object Publishes to.

Parameters
&sThe NBString to copy the Topic Name into
Returns
eResult_t return code

Reimplemented from MQTT::mqtt_leaf.

◆ GetRenderLength()

virtual int MQTT::ConfigExposer::GetRenderLength ( eObj_Serialize_t form = eObj_Serialize_CURRENT_FORM)
overridevirtual

the number of bytes used to serialize this object in a particular format.

Parameters
formSerialization format to use
Returns
Length of serialized data

Reimplemented from MQTT::mqtt_leaf.

◆ GetSubTopicFilter()

virtual int MQTT::ConfigExposer::GetSubTopicFilter ( NBString & s)
overridevirtual

Get the Subscription Topic Filter this object Subscribes to.

Parameters
&sThe NBString to copy the Subscription Topic Filter into
Returns
eResult_t return code

Reimplemented from MQTT::mqtt_leaf.

◆ ParseFd()

virtual int MQTT::ConfigExposer::ParseFd ( int mqttFd)
overrideprotectedvirtual

Parse the data from a file descriptor according to this object's current default serialization method and assign the value.

Parameters
mqttFdFile descriptor to read from.
Returns
eResult_t return code

Implements MQTT::mqtt_leaf.

◆ RenderToBuffer()

virtual int MQTT::ConfigExposer::RenderToBuffer ( eObj_Serialize_t form,
uint8_t * buf,
int buflen )
overridevirtual

Render this object to an output buffer.

Parameters
formSerialization format to render as
*bufPointer to output buffer
buflenSize of the output buffer
Returns
Length of the rendered data

Implements MQTT::mqtt_leaf.

◆ RenderToFd()

virtual int MQTT::ConfigExposer::RenderToFd ( eObj_Serialize_t form,
int fd )
overridevirtual

Render this object to an output socket.

Parameters
formSerialization format to render as
fdFile descriptor to render to
Returns
Length of the rendered data

Implements MQTT::mqtt_leaf.

◆ SubscribeEvent()

virtual int MQTT::ConfigExposer::SubscribeEvent ( int mqttFd,
PacketInfo::Msg * msg )
overridevirtual

Handle a message sent by the Broker triggered by this object's Subscription.

Parameters
mqttFdFile Descriptor to read any additional message data from
*msgPointer to message received from the Broker
Returns
eResult_t return code

Reimplemented from MQTT::mqtt_leaf.

◆ TestOrSetValue()

virtual ValueTestResult MQTT::ConfigExposer::TestOrSetValue ( ParsedJsonDataSet & pjs,
bool setVal )
overridevirtual

whether the current index of a JSON dataset is valid for this object, or assign the value at the current index of the dataset to this object.

Parameters
&pjsThe JSON dataset to use
setValtrue: Assign from the value at the current index, false: test if current index is valid for this object
Returns
ValueTestResult indicating the validity of the current index

Implements MQTT::mqtt_leaf.


The documentation for this class was generated from the following file: