Hi Forum,
I am using wolfMQTT and MPLABX Harmony 3 with the NET-GLUE (https://github.com/Microchip-MPLAB-Harm … net_glue.h)
Using these configuration values :
#define APP_MQTT_MAX_PUBLISH_MESSAGE_SIZE 1024
#define APP_MQTT_TX_BUFF_SIZE 2048
#define APP_MQTT_RX_BUFF_SIZE 2048
#define APP_MQTT_DEFAULT_QOS MQTT_QOS_0
The message to publish is a JSON string which is passed / filled to the mqtt context object publish buffer using snprintf :
snprintf(mqttCtx->publishMessage, APP_MQTT_MAX_PUBLISH_MESSAGE_SIZE + 1, MQTT_HW_TOPIC_PAYLOAD_TEMPLATE,
field1,
field2,
...
...
fieldN);
Total length json string is about 298 characters.
To publish the message I execute :
resCode = MqttClient_Publish(&mqttCtx->mqttClient, &mqttCtx->mqttPublish);
if (resCode == MQTT_CODE_CONTINUE)
{
break;
}
The message is published successfully but the receiving broker receives randomly some messages incomplete.
Most of the time the message has LAST character missing or an extra null character at the END.
Is correct to fill "mqttCtx->publishMessage" buffer using snprintf or am I doing something wrong?
Any help is appreciated it.
Thanks