版本:eclipse-paho-mqtt-c-1.3.12
开发工具:QT
问题1、其他都正常,唯独无法收到订阅消息
原因:
MQTTClient_setCallbacks函数必须在MQTTClient_connect前调用
问题2、MQTTClient_messageArrived回调函数异常,多次收到重复内容。
原因:
MQTTClient_messageArrived回调函数返回了0
函数返回值说明:
1:成功
2:失败,会再次回调
return This function must return 0 or 1 indicating whether or not
* the message has been safely received by the client application. <br>
* Returning 1 indicates that the message has been successfully handled.
* To free the message storage, ::MQTTClient_freeMessage must be called.
* To free the topic name storage, ::MQTTClient_free must be called.<br>
* Returning 0 indicates that there was a problem. In this
* case, the client library will reinvoke MQTTClient_messageArrived() to
* attempt to deliver the message to the application again.
* Do not free the message and topic storage when returning 0, otherwise
* the redelivery will fail.