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
    MQTT_MSG_AUTH,
#endif
    MQTT_MSG_WAIT,
    MQTT_MSG_WRITE,
    MQTT_MSG_WRITE_PAYLOAD,
    MQTT_MSG_READ,
    MQTT_MSG_READ_PAYLOAD,
} 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?

Share

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 support@wolfssl.com

Thanks,
Eric

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.
https://thingspeak.com/


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.

Thanks,
JasP

Share

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 support@wolfssl.com anytime.

It looks like this is a good example of connecting an MQTT client to the ThingSpeak broker:
https://www.mathworks.com/help/thingspe … p8266.html

From there we know the broker is "mqtt.thingspeak.com"; 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?

Thanks,
Eric @ wolfSSL Support

Edit:
Here is an even better discussion of using an MQTT client with ThingSpeak:
https://www.mathworks.com/help/thingspe … 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.


Best,
JazP

Share

Re: Is there any reference about MQTT struct?

Hi JazP,

Yes, please open a support ticket.

Thanks,
Eric @ wolfSSL Support