MQTTAsync_message(3)

πŸ’– MQTTAsync_message(3) πŸ’–

okay bestie, welcome to the Library Functions Manual page for MQTTAsync_message β€” yes that's the section 3 vibe, we're in the C library pages now, no cap. pull up a chair, grab a strawberry πŸ“, and let's talk structs.


✨ NAME ✨

MQTTAsync_message β€” the struct that holds a message's payload + all its lil attributes πŸ’…


🌸 SYNOPSIS 🌸

#include <MQTTAsync.h>

πŸŽ€ Data Fields

char struct_id [4]
int struct_version
int payloadlen
void * payload
int qos
int retained
int dup
int msgid
MQTTProperties properties

πŸ¦‹ DETAILED DESCRIPTION πŸ¦‹

So this is a structure representing the payload and attributes of an MQTT message. literally the whole message bundle, glowing, iconic.

🚨 IMPORTANT: the message topic is NOT part of this structure. like, the topic is not here, bestie. it lives elsewhere. go look at MQTTAsync_publishMessage(), MQTTAsync_publish(), MQTTAsync_receive(), MQTTAsync_freeMessage() and MQTTAsync_messageArrived() for that. iykyk.

πŸ‘‘ FIELD DOCUMENTATION πŸ‘‘

πŸ’œ char struct_id[4]

The eyecatcher for this structure. must be MQTM. that's it, that's the vibe check. if it's not MQTM, something is Wrongβ„’.

πŸ’œ int struct_version

The version number of this structure. Must be 0 or 1. 0 indicates no message properties. so if you want properties (see below πŸ‘€) you need version 1.

πŸ’œ int payloadlen

The length of the MQTT message payload in bytes. just the number, the count, the receipts on how long the payload is. πŸ“

πŸ’œ void* payload

A pointer to the payload of the MQTT message. it points. that's its job. 🫢

πŸ’œ int qos

The quality of service (QoS) assigned to the message. there are three levels of QoS and yes we're listing all of them:

  • QoS0 β€” Fire and forget πŸ”₯ the message may not be delivered. no promises. she said what she said.
  • QoS1 β€” At least once ✨ the message will be delivered, but may be delivered more than once in some circumstances. (so, duplicates possible β€” noted, remember that for dup later πŸ‘€)
  • QoS2 β€” Once and one only πŸ’… the message will be delivered exactly once. main character guarantee, periodt.

πŸ’œ int retained

The retained flag serves two purposes depending on whether the message it is associated with is being published or received. plot twist: one flag, two jobs.

retained = true β€” for messages being published, a true setting indicates that the MQTT server should retain a copy of the message. The message will then be transmitted to new subscribers to a topic that matches the message topic. For subscribers registering a new subscription, the flag being true indicates that the received message is not a new one, but one that has been retained by the MQTT server. 🧚

retained = false β€” for publishers, this indicates that this message should not be retained by the MQTT server. For subscribers, a false setting indicates this is a normal message, received as a result of it being published to the server. 🌈

πŸ’œ int dup

The dup flag indicates whether or not this message is a duplicate. It is only meaningful when receiving QoS1 messages. When true, the client application should take appropriate action to deal with the duplicate message.

⚠️ This is an output parameter only. don't write to it, bestie, it won't do anything for you. πŸ™ˆ

πŸ’œ int msgid

The message identifier is reserved for internal use by the MQTT client and server. It is an output parameter only β€” writing to it will serve no purpose. It contains the MQTT message id of an incoming publish message. so like, it's giving "look but don't touch" energy. πŸ’€

πŸ’œ MQTTProperties properties

The MQTT V5 properties associated with the message. fancy, modern, elevated. ⭐


🌟 AUTHOR 🌟

Generated automatically by Doxygen for the Paho Asynchronous MQTT C Client Library from the source code. (doxygen did the typing, i just did the makeup πŸ’„)


and that's the whole page, babe πŸŽ€ Paho Asynchronous MQTT C Client Library, dated Tue Jun 2 2026 00:00:00, page MQTTAsync_message(3) β€” you're all caught up, go forth and publish slay πŸ’…βœ¨πŸ”₯

πŸ“¦ where this page comes from