I'm trying to implement a MQTT-client based on the embedded variant of Paho. This is what my code looks like (pseudocode of the relevant parts):
struct mqtt_inst_data *instData;
MQTTPacket_connectData data="">
MQTTString topic=MQTTString_initializer;
-> open TCP/IP connection here
data.clientID.cstring=id;#else
data.cleansession=1;
len = MQTTSerialize_connect(buf,MAX_BUFLEN,&data); /* 1 */
topic.cstring=(char*)topicData->c_str();
strncpy(payload,payData->c_str(),200);
payloadlen=strlen(payload);
len+=MQTTSerialize_publish(buf+len,MAX_BUFLEN-len,0,3,0,0,topic,(unsigned char*)payload,payloadlen); /* 2 */
len+=MQTTSerialize_disconnect(buf+len,MAX_BUFLEN-len); /* 3 */
-> send data "buf" with length "len" here
-> close TCP/IP connection
1538382438: New connection from 192.168.188.1 on port 1883.
1538382446: New client connected from 192.168.188.1 as C85B76DF5FF6 (c1, k60).
1538382446: No will message specified.
1538382446: Sending CONNACK to C85B76DF5FF6 (0, 0)
1538382446: Invalid QoS in PUBLISH from C85B76DF5FF6, disconnecting.
1538382446: Socket error on client C85B76DF5FF6, disconnecting.
Where/how do I have to set this QoS stuff exactly? MQTTPacket_connectData has a sub-structure MQTTPacket_willOptions which itself contains a member "qos" - but what do I have to do with this structure exactly? Or is this error caused by some other problem?