Developer documentation for the utilities used to implement the MQTT-C client.
More...
|
enum | MQTTQueuedMessageState { MQTT_QUEUED_UNSENT,
MQTT_QUEUED_AWAITING_ACK,
MQTT_QUEUED_COMPLETE
} |
| An enumeration of queued message states.
|
|
Developer documentation for the utilities used to implement the MQTT-C client.
- Note
- To deserialize a packet from a buffer use mqtt_unpack_response (it's the only function you need).
◆ mqtt_mq_get
#define mqtt_mq_get |
( |
|
mq_ptr, |
|
|
|
index |
|
) |
| (((struct mqtt_queued_message*) ((mq_ptr)->mem_end)) - 1 - index) |
◆ __mqtt_next_pid()
uint16_t __mqtt_next_pid |
( |
struct mqtt_client * |
client | ) |
|
Generate a new next packet ID.Packet ID's are generated using a max-length LFSR.
- Parameters
-
- Returns
- The new packet ID that should be used.
◆ __mqtt_puback()
ssize_t __mqtt_puback |
( |
struct mqtt_client * |
client, |
|
|
uint16_t |
packet_id |
|
) |
| |
Acknowledge an ingree publish with QOS==1.
- Parameters
-
[in,out] | client | The MQTT client. |
[in] | packet_id | The packet ID of the ingress publish being acknowledged. |
- Returns
MQTT_OK
upon success, an MQTTErrors otherwise.
◆ __mqtt_pubcomp()
ssize_t __mqtt_pubcomp |
( |
struct mqtt_client * |
client, |
|
|
uint16_t |
packet_id |
|
) |
| |
Acknowledge an ingree PUBREL packet.
- Parameters
-
[in,out] | client | The MQTT client. |
[in] | packet_id | The packet ID of the ingress PUBREL being acknowledged. |
- Returns
MQTT_OK
upon success, an MQTTErrors otherwise.
◆ __mqtt_pubrec()
ssize_t __mqtt_pubrec |
( |
struct mqtt_client * |
client, |
|
|
uint16_t |
packet_id |
|
) |
| |
Acknowledge an ingree publish with QOS==2.
- Parameters
-
[in,out] | client | The MQTT client. |
[in] | packet_id | The packet ID of the ingress publish being acknowledged. |
- Returns
MQTT_OK
upon success, an MQTTErrors otherwise.
◆ __mqtt_pubrel()
ssize_t __mqtt_pubrel |
( |
struct mqtt_client * |
client, |
|
|
uint16_t |
packet_id |
|
) |
| |
Acknowledge an ingree PUBREC packet.
- Parameters
-
[in,out] | client | The MQTT client. |
[in] | packet_id | The packet ID of the ingress PUBREC being acknowledged. |
- Returns
MQTT_OK
upon success, an MQTTErrors otherwise.
◆ __mqtt_recv()
Handles ingress client traffic.
- Parameters
-
- Returns
- MQTT_OK upon success, an MQTTErrors otherwise.
◆ __mqtt_send()
Handles egress client traffic.
- Parameters
-
- Returns
- MQTT_OK upon success, an MQTTErrors otherwise.
◆ mqtt_mq_clean()
Clear as many messages from the front of the queue as possible.
- Note
- Calls to this function are the only way to remove messages from the queue.
- Parameters
-
◆ mqtt_mq_find()
Find a message in the message queue.
- Parameters
-
| mq | The message queue. |
[in] | control_type | The control type of the message you want to find. |
[in] | packet_id | The packet ID of the message you want to find. Set to NULL if you don't want to specify a packet ID. |
- Returns
- The found message.
NULL
if the message was not found.
◆ mqtt_mq_init()
Initialize a message queue.
- Parameters
-
[out] | mq | The message queue to initialize. |
[in] | buf | The buffer for this message queue. |
[in] | bufsz | The number of bytes in the buffer. |
◆ mqtt_mq_register()
Register a message that was just added to the buffer.
- Note
- This function should be called immediately following a call to a packer function that returned a positive value. The positive value (number of bytes packed) should be passed to this function.
- Parameters
-
| mq | The message queue. |
[in] | nbytes | The number of bytes that were just packed. |
- Note
- This function will step mqtt_message_queue::curr and update mqtt_message_queue::curr_sz.
- Returns
- The newly added struct mqtt_queued_message.