Topic: Correct MqttClient_WaitMessage() use

If you visit this documentation page, the MqttClient_WaitMessage() function prototype only shows 2 parameters, but the example below it shows 3: … i4qultver2

I am looking to read the incoming message.


Re: Correct MqttClient_WaitMessage() use

Hello kackle123

The web doc is out date from the code. There are two API

int MqttClient_WaitMessage_ex(MqttClient *client, MqttObject* msg,
        int timeout_ms)
    return MqttClient_WaitType(client, msg, MQTT_PACKET_TYPE_ANY, 0,
int MqttClient_WaitMessage(MqttClient *client, int timeout_ms)
    if (client == NULL)
        return MQTT_CODE_ERROR_BAD_ARG;
    return MqttClient_WaitMessage_ex(client, &client->msg, timeout_ms);

As you can see, `MqttClient_WaitMessage` does take 2 parameters.

Are you trying to read an incoming publish, whose topic you have already subscribed? You should try setting up a publish callback. Here is an example: … ient.c#L58

Eric @ wolfSSL Support

Re: Correct MqttClient_WaitMessage() use

Thank you!  It's tough on those who are inexperienced to have incorrect documentation.  I'll take a look at the callback, too.  Hopefully that documentation is okay. smile