Topic: Is there any reference about MQTT struct?

Hi, I really appreciate providing such helpful libraries.
I have already read MQTT user manual but couldn't find what I was looking for.

I'd like to know what does each struct parameter stand for. For example, struct "MqttConnect" has many parameters.
I have less knowledge about MQTT but I could understand what is "MqttConnect.keep_alive_sec".
But I couldn't understand what is "MqttConnect.stat".

Of course I dug into source code and found a hint in "mqtt_packet.h" as below.

typedef enum _MqttMsgStat {
    MQTT_MSG_BEGIN = 0, /* must be zero, so memset will setup state */
#ifdef WOLFMQTT_V5
} MqttMsgStat;

Well... what is "MqttMsgStat"...? I just would like to publish a message to broker but... which one should I select?

Not only this parameter, I couldn't understand "ack.flags", "ack.return_code" and so on.
It might be a basic of MQTT but it would be helpful there is a reference. Do you have any idea or resource?


Re: Is there any reference about MQTT struct?

Hello @JazP

Thanks for contacting wolfSSL Support. The `stat` structure element is used internally by the command API. It preserves the current state of the command processing. This functionality is used by the non-blocking configuration option, when the API could return `MQTT_CODE_CONTINUE` to indicate an incomplete command.

If you are reusing the structure for a subsequent call (for example calling publish twice in a row with the same structure), you would need to reset the stat to 0 (MQTT_MSG_BEGIN).

Could you tell us a bit more about your use case? Feel free to contact us at


Edit to add info about the "ack" - The ack packet is a response from the broker to indicate the status of the requested command.

Re: Is there any reference about MQTT struct?

Hi Eric, I really appreciate your kind support. I could understand what is 'stat' and 'ack'.
In my application, I'm using following structs.
- MqttClient
- MqttNet
- MqttConnect
- MqttPublish

In the case of 'MqttNet', a function returned an error with no specifying mqtt connect callback. I understood it was required.
If I understand correctly, MqttClient is handled by each Mqtt functions so we don't have to set any value.

I'd like to understand which parameter should be set a value in my code. For example, 'MqttConnect.username' is required(?) but 'MqttConnect.ack.stat' is not?

As my personal project, I'm trying to publish my data to Thingspeak. My application doesn't work well as I expected.

I don't understand the support policy well but requesting a direct support via email is allowed?
Should I purchase any service?
My code is on Github so I can share it with you. Any feedback to my code is really helpful.



Re: Is there any reference about MQTT struct?

Hi JasP

We support all users of wolfSSL libraries! You can open a support ticket by emailing anytime.

It looks like this is a good example of connecting an MQTT client to the ThingSpeak broker: … p8266.html

From there we know the broker is ""; clientID is random; the username and password will come from your ThingSpeak account settings.

It does not appear to use a secure connection, so TLS can be disabled in the wolfMQTT configuration. This is likely the source of the MqttNet callback error you saw.

Are you building for an embedded platform? Have you tried running our existing examples?

Eric @ wolfSSL Support

Here is an even better discussion of using an MQTT client with ThingSpeak: … asics.html

Re: Is there any reference about MQTT struct?

Hi Eric, thanks for your reply. Yes, I'm referring both examples Thingworks and wolfMQTT.
Actually, I haven't tried wolf mqtt example with no modification.
This is because the code is running on embedded platform but not arduino.

Can... can I open a support ticket? I hesitate to post my not working code on this community.
I don't ask you doing a debug instead of me. I just want a comment if there is a mistake or lack of configuration.

If it will work as I expected, I will share my code on this forum.



Re: Is there any reference about MQTT struct?

Hi JazP,

Yes, please open a support ticket.

Eric @ wolfSSL Support