MQTT in IDFv5 - where is user_context?
Posted: Wed Jan 25, 2023 6:31 am
Hi,
I'm looking at porting an mqtt client implementation from IDFv4 to IDFv5, but I've run into what seems to be a big issue.
Previously*, it was possible to set a "user context" pointer when initialising the client, and that pointer would then be handed back in each event. This followed the typical pattern for event driven libraries in C, where the caller is free to associate whatever context with a session and have it accessible at the time of handling the event.
In IDFv5**, I cannot find any support for this. Is it really intentional that such a fundamental aspect of the library has been changed/removed? I'm looking at a significant rewrite of the client code here if that's the case. By the looks of it I would have to establish and maintain an external esp_mqtt_client_handle_t to user context data structure in order to achieve what the old `user_context` field did. Obviously, I'd prefer to not have to do that.
Thanks in advance.
*) See https://docs.espressif.com/projects/esp ... parameters
**) See https://docs.espressif.com/projects/esp ... figuration
I'm looking at porting an mqtt client implementation from IDFv4 to IDFv5, but I've run into what seems to be a big issue.
Previously*, it was possible to set a "user context" pointer when initialising the client, and that pointer would then be handed back in each event. This followed the typical pattern for event driven libraries in C, where the caller is free to associate whatever context with a session and have it accessible at the time of handling the event.
In IDFv5**, I cannot find any support for this. Is it really intentional that such a fundamental aspect of the library has been changed/removed? I'm looking at a significant rewrite of the client code here if that's the case. By the looks of it I would have to establish and maintain an external esp_mqtt_client_handle_t to user context data structure in order to achieve what the old `user_context` field did. Obviously, I'd prefer to not have to do that.
Thanks in advance.
*) See https://docs.espressif.com/projects/esp ... parameters
**) See https://docs.espressif.com/projects/esp ... figuration