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...
#include <mqtt.h>
Inherits TimeOutElement.
Inherited by MQTT::ConfigExposer, MQTT::SubHandler, MQTT::mqtt_IO, MQTT::mqtt_bool, MQTT::mqtt_float, MQTT::mqtt_int, MQTT::mqtt_obj, MQTT::mqtt_string, and MQTT::mqtt_uint.
|
enum | eObj_State_t |
| Mqtt Object Publication/Subscription States.
|
|
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.
◆ mqtt_leaf() [1/2]
Constructor for mqtt_leaf objects.
- Parameters
-
*topic | Mqtt Topic Name to use for Publish/Subcribe. |
*mClient | Pointer to Client to register with. If NULL, it will be registered with the first created Client. |
flags | Behavioral flags to set on the created object |
◆ mqtt_leaf() [2/2]
Constructor for mqtt_leaf objects.
- Parameters
-
&parent | Reference to parent object. |
*topic | Additional Topic Name for the leaf, added as another level in the topic path after the parent objects topic (parent='/foo', this='/foo/bar'). |
*mClient | Pointer to Client to register with. If NULL, it will be registered with the first created Client. |
flags | Behavioral flags to set on the created object |
◆ AddChild()
Add an MqttObj as a child to this object.
- Parameters
-
*child | Pointer to the child object to add |
- Returns
- Pointer to the first child of this object
Reimplemented in MQTT::mqtt_obj.
◆ Assign()
int MQTT::mqtt_leaf::Assign |
( |
| ) |
|
|
protected |
Perform post assignemnt operations.
- Returns
- eResult_t return code
◆ ClearFlags()
virtual void MQTT::mqtt_leaf::ClearFlags |
( |
uint16_t | delFlags | ) |
|
|
virtual |
Clear behavioral flags from this object.
- Parameters
-
delFlags | The flags to be cleared from this object |
Reimplemented in MQTT::mqtt_IO.
◆ ForEachLeaf()
void MQTT::mqtt_leaf::ForEachLeaf |
( |
LeafCallBack * | p, |
|
|
void * | pd ) |
|
protected |
Call a function on each element of the MqttObj tree with this object as the root.
- Parameters
-
*p | Pointer to the function to be executed on each element of the tree |
*pd | Pointer to extra data to pass to the function being called |
◆ GetChildren()
virtual mqtt_leaf * MQTT::mqtt_leaf::GetChildren |
( |
| ) |
|
|
protectedvirtual |
Get the first child of this object.
- Returns
- Pointer to the first child of this object
Reimplemented in MQTT::mqtt_obj.
◆ GetFlags()
uint16_t MQTT::mqtt_leaf::GetFlags |
( |
| ) |
|
|
inline |
Get the behavioral flags set for this object.
- Returns
- The flags to set for this object
◆ getPriority()
int MQTT::mqtt_leaf::getPriority |
( |
| ) |
|
|
inline |
Get the message priority for this object.
- Returns
- The message priority for this object.
◆ GetPubTopicName()
virtual int MQTT::mqtt_leaf::GetPubTopicName |
( |
NBString & | s | ) |
|
|
virtual |
Get the Topic Name this object Publishes to.
- Parameters
-
&s | The NBString to copy the Topic Name into |
- Returns
- eResult_t return code
Reimplemented in MQTT::ConfigExposer.
◆ GetRenderLength()
Get the number of bytes used to serialize this object in a particular format.
- Parameters
-
form | Serialization format to use |
- Returns
- Length of serialized data
Reimplemented in MQTT::ConfigExposer, and MQTT::mqtt_obj.
◆ GetSerializationForm()
Get the default serialization format for this object.
- Returns
- eObj_Serialize_t Serialization format in use
◆ GetSubTopicFilter()
virtual int MQTT::mqtt_leaf::GetSubTopicFilter |
( |
NBString & | s | ) |
|
|
virtual |
Get the Subscription Topic Filter this object Subscribes to.
- Parameters
-
&s | The NBString to copy the Subscription Topic Filter into |
- Returns
- eResult_t return code
Reimplemented in MQTT::ConfigExposer, and MQTT::mqtt_obj.
◆ HandlePubAck()
Handle an Publish Acknowledge message from the broker for our Publish request.
- Parameters
-
mqttFd | File descriptor to read additional message data from |
*msg | Pointer to message struct containing the Publish Acknowledgement |
- Returns
- eResult_t return code
◆ HandleSubAck()
Handle a Subscribe Acknowledge message from the broker for our Subscribe request.
- Parameters
-
mqttFd | File descriptor to read additional message data from |
*msg | Pointer to message struct containing the Subscribe Acknowledgement |
- Returns
- eResult_t return code
◆ HandleUnsubAck()
Handle an Unsubscribe Acknowledge message from the broker for our Unsubscribe request.
- Parameters
-
mqttFd | File descriptor to read additional message data from |
*msg | Pointer to message struct containing the Unsubscribe Acknowledgement |
- Returns
- eResult_t return code
◆ MatchId()
Determine whether the JSON dataset's current index matches this object's name.
- Parameters
-
&pjs | Reference to the JSON dataset to be assigned from |
- Returns
- Whether the JSON dataset's current index matches this object's name.
◆ MqttRxPublish()
static int MQTT::mqtt_leaf::MqttRxPublish |
( |
Client * | mClient, |
|
|
int | mqttFd, |
|
|
PacketInfo::Msg * | msg, |
|
|
void * | ctx ) |
|
static |
Static message handler for Publish messages received by the registered Client.
- Parameters
-
*mClient | Pointer to the Client that received the message |
mqttFd | File Descriptor to read any additional data from |
*msg | Pointer to the structure containing the received message |
*ctx | Pointer to the leaf this message is for |
- Returns
- The message priority for this object.
◆ NameMatch()
bool MQTT::mqtt_leaf::NameMatch |
( |
const char * | cp | ) |
|
Determine whether a given name matches this object.
- Parameters
-
- Returns
- Whether the given name matches this object
◆ ParseFd()
virtual int MQTT::mqtt_leaf::ParseFd |
( |
int | mqttFd | ) |
|
|
protectedpure virtual |
◆ Publish()
int MQTT::mqtt_leaf::Publish |
( |
int | waitForCompletion = -1 | ) |
|
Publishes the current MQTT object, optionally waiting for completion.
This method queues the object for publication via MQTT. If waitForCompletion
is greater than 0, or if the object is configured to wait (eObj_Flag_WaitForPub
), the function will block until the publish operation is complete.
- Parameters
-
waitForCompletion | Set to 1 to block until the publish is done. |
- Returns
- eResult_Success on successful queuing and (if applicable) completion; error codes may propagate from
QueuePublish()
.
- See also
- QueuePublish
◆ PubState()
uint8_t MQTT::mqtt_leaf::PubState |
( |
| ) |
|
|
inlineprotected |
Get the Publish state.
- Returns
- eObj_State_t state of this object
◆ QueuePublish()
int MQTT::mqtt_leaf::QueuePublish |
( |
| ) |
|
|
protected |
Queue this object to be Published via the registered Client.
- Returns
- eResult_t return code
- See also
- Client::Publish
◆ QueueSubscribe()
int MQTT::mqtt_leaf::QueueSubscribe |
( |
| ) |
|
|
protected |
Queue this object to be Subscribed via the registered Client.
- Returns
- eResult_t return code
- See also
- Client::Subscribe
◆ QueueUnsubscribe()
int MQTT::mqtt_leaf::QueueUnsubscribe |
( |
| ) |
|
|
protected |
◆ RemoveFirstChild()
virtual mqtt_leaf * MQTT::mqtt_leaf::RemoveFirstChild |
( |
| ) |
|
|
protectedvirtual |
Remove the first child from this object.
- Returns
- Pointer to the new first child of this object
Reimplemented in MQTT::mqtt_obj.
◆ RenderToBuffer()
virtual int MQTT::mqtt_leaf::RenderToBuffer |
( |
eObj_Serialize_t | form, |
|
|
uint8_t * | buf, |
|
|
int | buflen ) |
|
pure virtual |
◆ RenderToFd()
◆ RootParse()
Assign to this object tree from a JSON dataset.
- Parameters
-
&pjs | Reference to the JSON dataset to be assigned from |
◆ SetFlags()
virtual void MQTT::mqtt_leaf::SetFlags |
( |
uint16_t | newFlags | ) |
|
|
virtual |
Set additional behavioral flags for this object.
- Parameters
-
newFlags | The set of new flags to be set |
Reimplemented in MQTT::mqtt_IO.
◆ SetPublishInterval()
void MQTT::mqtt_leaf::SetPublishInterval |
( |
uint32_t | intervalPeriodTicks | ) |
|
Sets or clears an automatic publishing interval for this MQTT object.
If a non-zero interval is specified, the object will be automatically published at the given interval (in system ticks). If the interval is zero, the automatic publishing is disabled by deregistering the object from the client's scheduler.
- Parameters
-
intervalPeriodTicks | The interval period in system ticks. A value of zero disables periodic publishing. |
- Note
- This operation has no effect if the MQTT client (
mClient
) is not initialized.
◆ SetPubState()
virtual void MQTT::mqtt_leaf::SetPubState |
( |
uint8_t | newState | ) |
|
|
protectedvirtual |
Set the Publish state.
- Parameters
-
newState | The new Publish state for this object |
Reimplemented in MQTT::mqtt_obj.
◆ SetSerializationForm()
Set the default serialization format for this object.
- Parameters
-
form | Serialization format to use |
◆ SetSubState()
virtual void MQTT::mqtt_leaf::SetSubState |
( |
uint8_t | newState | ) |
|
|
protectedvirtual |
Set the Subscribe state.
- Parameters
-
newState | The new Subscribe state for this object |
Reimplemented in MQTT::mqtt_obj.
◆ SubscribeEvent()
virtual int MQTT::mqtt_leaf::SubscribeEvent |
( |
int | mqttFd, |
|
|
PacketInfo::Msg * | msg ) |
|
virtual |
◆ SubState()
uint8_t MQTT::mqtt_leaf::SubState |
( |
| ) |
|
|
inlineprotected |
Get the Subscribe state of this object.
- Returns
- eObj_State_t state
◆ TestOrSetValue()
virtual ValueTestResult MQTT::mqtt_leaf::TestOrSetValue |
( |
ParsedJsonDataSet & | pjs, |
|
|
bool | setVal ) |
|
pure virtual |
Test 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
-
&pjs | The JSON dataset to use |
setVal | true: 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
Implemented in MQTT::ConfigExposer, MQTT::mqtt_bool, MQTT::mqtt_float, MQTT::mqtt_int, MQTT::mqtt_IO, MQTT::mqtt_obj, MQTT::mqtt_string, MQTT::mqtt_uint, and MQTT::SubHandler.
The documentation for this class was generated from the following file: