Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Callback functions are used by the µC/MQTT-client stack. Their purpose is to notify the upper application of certain activities occurring in the µC/MQTT-client core.

Each particular callback for every event is set with MQTTc_ConnSetParam and is optional. The p_arg parameter passed in every callback is also set via MQTTc_ConnSetParam with the MQTTc_PARAM_TYPE_CALLBACK_ARG_PTR type.

No blocking calls (delays, pending on an OS object, etc.) or long operations should ever be done in any of these callbacks. These callbacks are executed from the MQTTc stack internal task and if it is delayed or blocked, the whole MQTTc stack will be delayed/blocked, too, preventing the reception or transmission of any message on any connection.

On Complete Callbacks

The following callbacks  are of type MQTTc_CMPL_CALLBACK. Even though they are optional, they are necessary to know that a particular message has been completely sent, in order to re-use it for another message. The generic complete callback may be used to emulate all other callbacks in this category.

On Error Callback

This callback is of type MQTTc_ERR_CALLBACK. Even though it is optional, it is recommended to have it, to know if a problem occurs.

On PUBLISH message received callback

This callback is of type MQTTc_PUBLISH_RX_CALLBACK. This callback is required only if the application expects to receive data from the broker. If not, it will never be called.

  • No labels