This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

MQTT-SN Old data hangs in the buffer

My problem is with examples of publishing and subscribing at the same time. I crossed them by adding a check for subscription if I did not sign I do this and register the topic id

1. When I try to send a message from the MQTT client to the sensor, the data comes fine

<info> app: data: {"value": true}

2. Next, I publish data already from the sensor itself

{
"idx" : 157,
"nvalue" : 1,
"svalue" : ""
}

In the next step, I repeat step 1, sending data from MQTT and receive a clogged buffer with the previous message

<info> app: data: {
  "state": true
}value" : 1,
"svalue" : ""
}

How can you defeat this? I think you need to clear the buffer somehow after sending the message by

mqttsn_client_publish( & m_client, m_topic_pub.topic_id, (const uint8_t *)Func(), strlen(Func()), & m_msg_id);
Related