MQTT Native API
Extensions
Functions
int | mqttConnect(Mqtt *mq, cchar *username, cchar *password, int flags, MqttWaitFlags waitFlags) |
Establish a session with the MQTT broker. | |
cchar* | mqttGetError(struct Mqtt *mq) |
Returns an error message for error code, | |
int | mqttMsgsInQueue(Mqtt *mq) |
Get the number of messages to send in the send queue. | |
int | mqttMsgsToSend(Mqtt *mq) |
Get the number of messages in the queue. | |
int | mqttPing(Mqtt *mq) |
Ping the broker. | |
int | mqttPublish(Mqtt *mq, cvoid *msg, ssize size, int qos, MqttWaitFlags waitFlags, cchar *topic, ...) |
Publish an application message to the MQTT broker. | |
int | mqttPublishRetained(Mqtt *mq, cvoid *msg, ssize size, int qos, MqttWaitFlags waitFlags, cchar *topic, ...) |
Publish a retained message to the MQTT broker. | |
void | mqttSetMessageSize(Mqtt *mq, int size) |
Set the maximum message size. | |
int | mqttSubscribe(Mqtt *mq, MqttCallback callback, int maxQos, MqttWaitFlags waitFlags, cchar *topic, ...) |
Subscribe to a topic. | |
int | mqttUnsubscribe(Mqtt *mq, cchar *topic, MqttWaitFlags wait) |
Unsubscribe from a topic. |
Typedefs
Mqtt | An MQTT mq. |
MqttCallback | Subscription callback. |
MqttHdr | Fixed header of a packet. |
MqttResp | A struct used to deserialize/interpret an incoming packet from the broker. |
MqttRespConn | A connection response. |
MqttRespPing | The resp to a ping request. |
MqttRespPub | A publish packet received from the broker. |
MqttRespPubAck | A publish acknowledgement for messages that were published with QoS level 1. |
MqttRespPubComp | The resp to a PUBREL packet. |
MqttRespPubRec | The resp packet to a PUBLISH packet with QoS level 2. |
MqttRespPubRel | The resp to a PUBREC packet. |
MqttRespSubAck | The resp to a subscription request. |
MqttRespUnsubAck | The brokers resp to a UNSUBSCRIBE request. |
Defines
#define | MQTT_PROTOCOL_LEVEL 0x04 |
Protocol version. |
Functions
Establish a session with the MQTT broker.
- Mqtt_init must have been called.
- Parameters:
-
mq The Mqtt object. username The username to use when establishing the session with the MQTT broker. Set to NULL if a username is not required.password The password to use when establishing the session with the MQTT broker. Set to NULL if a password is not required.flags Additional MqttConnectFlags to use when establishing the connection. These flags are for forcing the session to start clean, MQTT_CONNECT_CLEAN_SESSION , the QOS level to publish thewill_message with (providedwill_message !=NULL ), MQTT_CONNECT_WILL_QOS_[0,1,2], and whether or not the broker should retain thewill_message , MQTT_CONNECT_WILL_RETAIN.waitFlags Wait flags.
- Returns:
- Zero if successful.
- API Stability:
- Evolving.
Returns an error message for error code,
- Parameters:
-
mq Mqtt object.
- Returns:
- The associated error message.
- API Stability:
- Evolving.
Get the number of messages to send in the send queue.
- Parameters:
-
mq The MQTT mq.
- Returns:
- The number of messages in the queue to send.
- API Stability:
- Evolving.
Get the number of messages in the queue.
- Parameters:
-
mq The MQTT mq.
- Returns:
- The number of messages in the queue.
- API Stability:
- Evolving.
Ping the broker.
- MqttConnect must have been called.
- Parameters:
-
mq The MQTT mq.
- Returns:
- Zero if successful.
- API Stability:
- Evolving.
Publish an application message to the MQTT broker.
- MqttConnect must have been called.
- Parameters:
-
mq The Mqtt object. msg The data to be published. size The size of application_message in bytes.qos Quality of service. 0, 1, or 2. waitFlags Wait flags. topic Printf style topic string. ... Topic args.
- Returns:
- Zero if successful.
Publish a retained message to the MQTT broker.
- MqttConnect must have been called.
- Parameters:
-
mq The Mqtt object. msg The data to be published. size The size of application_message in bytes.qos Quality of service. 0, 1, or 2. waitFlags Wait flags. topic Printf style topic string. ... Topic args.
- Returns:
- Zero if successful.
Set the maximum message size.
- Description:
- AWS supports a smaller maximum message size.
- Parameters:
-
mq The MQTT mq. size The maximum message size.
- API Stability:
- Evolving.
Subscribe to a topic.
- MqttConnect must have been called.
- Parameters:
-
mq Mqtt object. callback Function to invoke on receipt of messages. maxQos Maximum quality of service message to receive. waitFlags Wait flags. topic Printf style topic string. ... Topic args.
- Returns:
- Zero if successful.
- API Stability:
- Evolving.
Unsubscribe from a topic.
- MqttConnect must have been called.
- Parameters:
-
mq The MQTT mq. topic The name of the topic to unsubscribe from. wait Wait flags.
- Returns:
- Zero if successful.
- API Stability:
- Evolving.
Typedefs
Subscription callback.
- Parameters:
-
resp Message received structure.
- API Stability:
- Evolving.
An MQTT mq.
- All members can be manipulated via the related functions.
- Fields:
-
- API Stability:
- Evolving.
Fixed header of a packet.
- API Stability:
- Evolving.
- Fields:
-
int flags Packet control flags. int length Size in bytes.
A struct used to deserialize/interpret an incoming packet from the broker.
- API Stability:
- Evolving.
- Fields:
-
A connection response.
- API Stability:
- Evolving.
- Fields:
-
MqttConnCode code Connection return code. uchar hasSession Check if already have a session.
The resp to a ping request.
- This resp contains no members.
- Fields:
-
- API Stability:
- Evolving.
A publish packet received from the broker.
- Description:
- A publish packet is received from the broker when a mq publishes to a topic that the {local mq} is subscribed to.
- Fields:
-
cvoid * data Message. int dataSize Size of message. MqttCallback callback Message callback function. uchar dup Set to 0 on first attempt to send packet. char * fullTopic Full topic string. uint16_t id Message ID. struct Mqtt * mq Message queue. uchar qos Quality of service. uchar retain Message is retained. cvoid * topic Topic string. Not null terminated. uint16_t topicSize Size of the topic.
- API Stability:
- Evolving.
A publish acknowledgement for messages that were published with QoS level 1.
- API Stability:
- Evolving.
- Fields:
-
uint16_t id Message ID.
The resp to a PUBREL packet.
- API Stability:
- Evolving.
- Fields:
-
uint16_t id Message ID.
The resp packet to a PUBLISH packet with QoS level 2.
- API Stability:
- Evolving.
- Fields:
-
uint16_t id Message ID.
The resp to a PUBREC packet.
- API Stability:
- Evolving.
- Fields:
-
uint16_t id Message ID.
The resp to a subscription request.
- API Stability:
- Evolving.
- Fields:
-
cuchar * codes Array of return codes for subscribed topics. uint16_t id Message ID. int numCodes Size of codes.
The brokers resp to a UNSUBSCRIBE request.
- API Stability:
- Evolving.
- Fields:
-
uint16_t id Message ID.