FreeRTOS / coreMQTT-Agent

Implements an MQTT agent (or daemon) task for simple MQTT connection sharing among different threads of execution.
MIT License
29 stars 32 forks source link

Incoming callback context not used #72

Closed boraozgen closed 2 years ago

boraozgen commented 2 years ago

The incoming callback context parameter passed to MQTTAgent_Init gets stored but not used afterwards. Should be removed or passed to the callback.

https://github.com/FreeRTOS/coreMQTT-Agent/blob/8df94cec1b05eca9862a66705685617ba178bcb0/source/core_mqtt_agent.c#L986

alfred2g commented 2 years ago

Hello, this callback is actually used, when we receive the callback from mqtt init. as the current implementation assumes

 pMqttAgentContext->pIncomingCallbackContext

is the first element in the MQTTAgentContext_t structure, and a cast is performed where the callback is received.

the transformation is done here: https://github.com/FreeRTOS/coreMQTT-Agent/blob/8df94cec1b05eca9862a66705685617ba178bcb0/source/core_mqtt_agent.c#L622 it is not perfect and we should use a different way to do that like using member of.

boraozgen commented 2 years ago

As far as I see, the callback itself is used but not pIncomingCallbackContext. I suppose as pAgentContext is passed with the callback, it is expected that the users should extract pIncomingCallbackContext themselves.

archigup commented 2 years ago

Hi, we are aware of the issue with the agent callback and are looking into it. As you mentioned, users of the library can currently get pIncomingCallbackContext in the callback by getting it from the pAgentContext.