Closed SwamidasSilabs closed 1 year ago
Hello @SwamidasSilabs! To help. me in my investigation can you please provide which version of the SDK you are using? A specific commit hash/id for that release is even more helpful.
I took a look at the latest version of the code with the _aws_iot_mqtt_internal_yield
function (v3.0.1) and I believe I found how the call to handle the data received is to work.
Overall the function trace looks like...
aws_iot_mqtt_yield
(line) which in turn calls_aws_iot_mqtt_internal_yield
(line) in turn callingaws_iot_mqtt_internal_cycle_read
(line) which calls_aws_iot_mqtt_internal_handle_publish
(line) which calls_aws_iot_mqtt_internal_deliver_message
(line) which calls a registered message handler provided by the applicationThe message handlers are set when subscribing to an MQTT topic.
Have you set up a message handler for the MQTT topic which you are expecting to receive data on?
Hi @kstribrnAmzn
Thanks for your reply, I have registered a message handler and the handler is getting triggered when the data arrives.
I have one more doubt here, Can't we receive the data without registering the message handler, You can assume like a synchronous receive.
Thanks, Swamidas
Can't we receive the data without registering the message handler, You can assume like a synchronous receive.
MQTT is not a synchronous request/response protocol and the receive path is asynchronous. Once you have subscribed to a topic, data on that topic can arrive anytime. Therefore, you need to register a handler for receiving data.
Another question for you - I see that you are using V3 of the SDK. Is there a reason to not use the latest version?
Thanks @aggarg
I have registered the message handler and am able to process the data.
Great. I am closing this issue. Feel free to reopen or create a new one if you need anything else.
Hi Team,
I am facing one issue with the _aws_iot_mqtt_internal_yield function, Here is my test case. My module is the client and has called aws_iot_mqtt_yield with a timeout of 1000 milliseconds. The _aws_iot_mqtt_internal_yield has a do-while that loops till the 1000 milliseconds time expires irrespective of whether the data is received. The 1st loop has received the data from the server whereas the 2nd loop hasn't, and it comes out with a timeout error, how can I consume or use the data received in the 1st loop?