In the above case, I would expect packet_id returned from MQTT_PublishToResend() is 3. However, it turns out to be 0 which is MQTT_PACKET_ID_INVALID. I am not sure this is expected or a bug.
I find the cause of this comes from the following line https://github.com/FreeRTOS/coreMQTT/blob/main/source/core_mqtt_state.c#L572 while updating states. This lines deletes the state entry by just marking the packet id invalid without resetting all other fields, which makes MQTT_PublishToResend() confused and return unexpected values.
HI, I found this issue occurs in the following scenario.
The following is pseudo code.
In the above case, I would expect
packet_id
returned fromMQTT_PublishToResend()
is 3. However, it turns out to be 0 which isMQTT_PACKET_ID_INVALID
. I am not sure this is expected or a bug.I find the cause of this comes from the following line https://github.com/FreeRTOS/coreMQTT/blob/main/source/core_mqtt_state.c#L572 while updating states. This lines deletes the state entry by just marking the packet id invalid without resetting all other fields, which makes
MQTT_PublishToResend()
confused and return unexpected values.If this is a bug, I would suggest replace the line https://github.com/FreeRTOS/coreMQTT/blob/main/source/core_mqtt_state.c#L572 with the following.
Thank you!