My app connects to AWS over WiFi intermittently.
Please advise if the following sequence is correct-
Is it possible to shorten reconnection time described above by calling wiced_aws_init()/wiced_aws_create_endpoint() once upon the first connection, or does it have to be called on every (re)connection
There seem to be a memory leak when calling wiced_aws_disconnect().
At the end of the function there's a call to "free(aws)".
However the parameter aws that was dynamically allocated in wiced_aws_create_endpoint(), has an internal dynamic allocation (aws->mqtt.base) taking place in aws_internal_mqtt_init() that is not freed when its parent object (aws) is being freed !
Was this reported memory leak handled in the latest SDK? Should I follow the suggested solution in the post?
Your guidelines on how to deal with this use case are highly valuable and appreciated
You can use the solution suggested in the mentioned thread. After that thread, there hasn't been a wiced release; so, you would need to fix it in your local setup for now.
If you are putting the device to sleep by suspending network activity, then you have to follow the sequence quoted above
wiced applications are a means to get you started; like the default publisher in 43xxx_Wi-Fi/apps/demo/aws/iot/pub_sub/publisher/publisher.c doesn't handle the disconnection events at all. They are by no means perfect and hence, I would recommend you to check the memory leak in case of your connection teardown and free the base object correctly.
Thanks for your prompt reply.
I understand that the wiced samples are, well, samples... and are not fully fledged apps.
I was referring to a memory leak in the underlying SDK in the file libraries/protocols/AWS/wiced_aws.c
Thanks for the beautiful explanation . What I meant earlier is that since in the default snippet, we are not handling the disconnection at all; it might have gone completely unnoticed from our side. Fair warning: there might be other memory leaks as well. I will request you to do a mallinfo in your application for finding out other such bugs.
Meanwhile, you can add line #398 in 43xxx_Wi-Fi/libraries/protocols/AWS/wiced_aws.c free(aws->mqtt.base).
Additionally, in line #290 in 43xxx_Wi-Fi/libraries/protocols/AWS/aws_mqtt.c, you can add the following three lines from wiced_mqtt_deinit
I will update the thread as and when I find any other issue.