Greetings,
I encountered another bug while developing a Fleet Provisioning (FP) application which runs on the Renesas RX65N MCU.
In rare occassions (~1 out of 500 attempts), the following ASSERTION failure (or similar) occurs.
ASSERTION FAILED: globalSubscribePacketIdentifier == usPacketIdentifier FILE C:/ws/iot-reference-rx/Demos/common/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_h
(Note: The ASSERTION failure may also happen with globalUnsubscribePacketIdentifier == usPacketIdentifier)
I referred the reference code provided in this repo: FreeRTOS-Plus/Demo/../../mqtt_pkcs11_demo_helpers.c
This is my baseline code where I encountered the issue: mqtt_pkcs11_demo_helpers.c
After investigation, I found that the ASSERTION fails when the ACK packet is received out of sequence, maybe due to timing issue or network jitter.
(i.e: Device sends an Unsubscribe command, but received a prior SUBACK packet instead)
Request
-
I believe the mqtt-agent is asynchronous, it does not wait for ACK before executing the next command.
Based on this logic, I decided to remove the 2 failing configASSERT checks.
→Is this acceptable? -
Additionally, I implemented a logic to return error in case no packet is received/processed within the timeout period.
→Does this align with the original design policy?
I attached my modified code for reference: mqtt_pkcs11_demo_helpers.c (51.9 KB)
Thank you.