MQTTClient_willOptions(3)

πŸ’– MQTTClient_willOptions πŸ’–

okay bestie, welcome to section 3 of the Library Functions Manual, and today we're unpacking MQTTClient_willOptions β€” the struct that holds your client's whole last words situation. yes, literally. it's giving dramatic goodbye note but make it MQTT. πŸ¦‹


✨ SYNOPSIS ✨

#include <MQTTClient.h>

🌸 Data Fields

char struct_id[4]
int struct_version
const char * topicName
const char * message
int retained
int qos
struct {
   int len
   const void * data
} payload

πŸ’… Detailed Description πŸ’…

so MQTTClient_willOptions defines the MQTT "Last Will and Testament" (LWT) settings for the client. no cap, that's the actual name. 😭

here's the tea: if a client unexpectedly loses its connection to the server, the server goes ahead and publishes the LWT message to the LWT topic on behalf of the client. iconic behavior honestly. that way, every other client subscribed to the LWT topic gets notified that this client has dipped. πŸ‘‹

to turn the LWT function on for a specific client, you pass a valid pointer to an MQTTClient_willOptions structure inside the MQTTClient_connectOptions structure β€” the one used in the MQTTClient_connect() call that connects the client to the server. 🫢

and if you don't want LWT at all? the pointer to MQTTClient_willOptions can just be set to NULL. simple as that. no will, no testament, no drama.


πŸŽ€ Field Documentation πŸŽ€

🌈 char struct_id[4]

the eyecatcher for this structure. must be MQTW. it's basically the struct's little name tag so everyone knows who it is at the function party. ✨

πŸ¦‹ int struct_version

the version number of this structure. must be 0 or 1. 0 means there is no binary payload option. choose wisely bestie. πŸ’…

πŸ‘‘ const char* topicName

the LWT topic to which the LWT message will be published. that's where your final message lands. 🎯

πŸ’œ const char* message

the LWT payload in string form.

πŸ“ int retained

the retained flag for the LWT message (see MQTTClient_message.retained).

⭐ int qos

the quality of service setting for the LWT message (see MQTTClient_message.qos and Quality of service).

🧚 int len

binary payload length.

🌸 const void* data

binary payload data.

πŸ’– struct { ... } payload

the LWT payload in binary form. this is only checked and used if the message option is NULL. lowkey important. don't sleep on it. πŸ™ˆ


🌷 Author 🌷

Generated automatically by Doxygen for Paho MQTT C Client Library from the source code.


okay that's the whole vibe check, you're officially a will-options expert now πŸ’…βœ¨ this was MQTTClient_willOptions(3), from the Paho MQTT C Client Library, dated Tue Jun 2 2026 00:00:00. go forth and configure your last will, bestie πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from