TI's MQTT Demo with freertos CM4F

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

mqtt_client_ctx_cbs Struct Reference

mqtt_client_ctx_cbs Struct Reference
[The Client Library API(s)]

Callbacks to be invoked by MQTT Client library onto Client application. More...

#include <mqtt_client.h>

Data Fields

bool(* publish_rx )(void *app, bool dup, enum mqtt_qos qos, bool retain, struct mqtt_packet *mqp)
 Provides a PUBLISH message from server to the client application.
void(* ack_notify )(void *app, uint8_t msg_type, uint16_t msg_id, uint8_t *buf, uint32_t len)
 Notifies the client application about an ACK or a response from the server.
void(* disconn_cb )(void *app, int32_t cause)
 Notifies the client application about the termination of connection with the server.

Detailed Description

Callbacks to be invoked by MQTT Client library onto Client application.

Definition at line 718 of file mqtt_client.h.


Field Documentation

void(* ack_notify)(void *app, uint8_t msg_type, uint16_t msg_id, uint8_t *buf, uint32_t len)

Notifies the client application about an ACK or a response from the server.

Following are the messages that are notified by the client LIB to the application.

CONNACK, PINGRSP, PUBACK, PUBCOMP, SUBACK, UNSUBACK

Parameters:
[in]appapplication to which this ACK message is targeted
See also:
mqtt_client_ctx_create
Parameters:
[in]msg_typeType of the MQTT messsage
[in]msg_idtransaction identity of the message
[in]bufrefers to contents of message and depends on msg_type
[in]lenlength of the buf
Returns:
none
Note:
The size of the buf parameter i.e len is non-zero for the SUBACK and CONNACK messages. For SUBACK the buf carries an array of QOS responses provided by the server. For CONNACK, the buf carries variable header contents. Helper macro VHB_CONNACK_RC( ) and VHB_CONNACK_SP( ) can be used to access contents provided by the server. For all other messages, the value of len parameter is zero.
The parameter msg_id is not relevant for the messages CONNACK and PINGRSP and is set to zero.

Definition at line 782 of file mqtt_client.h.

void(* disconn_cb)(void *app, int32_t cause)

Notifies the client application about the termination of connection with the server.

After servicing this callback, the application can destroy associated context if it no longer required

Parameters:
[in]appapplication whose connection got terminated
See also:
mqtt_client_ctx_create
Parameters:
[in]causereason that created disconnection (LIBRARY Generated Error Codes)

Definition at line 793 of file mqtt_client.h.

bool(* publish_rx)(void *app, bool dup, enum mqtt_qos qos, bool retain, struct mqtt_packet *mqp)

Provides a PUBLISH message from server to the client application.

The application can utilize the associated set of helper macros to get references to the topic and the data information contained in the message. Helper Macros for RX PUBLISH

Depending upon the QoS level of the message, the MQTT client library shall dispatch the correponding acknowlegement (PUBACK or PUBREC) to the server, thereby, relieving application of this support.

If the application completes the processing of the packet within the implementation of this callback routine, then a value of 'true' must be returned to the client LIB 'context'. The library, in this case, does not handover the packet to application and instead, frees it up on return from this routine.

If the application intends to defer the processing of the PUBLISH message to a different execution task, then it must takeover the owernship of the packet by returning a value of 'false' to the client LIB 'context. In this arrangement, the client LIB 'context' hands over the packet to the application. The responsibility of storing, managing and eventually freeing up the packet back to the pool, now, lies with the app.

Parameters:
[in]appapplication to which this PUBLISH message is targeted
See also:
mqtt_client_ctx_create
Parameters:
[in]dupasserted to indicate a DUPLICATE PUBLISH
[in]qosquality of Service of the PUBLISH message
[in]retainAsserted to indicate message at new subscription
[in]mqpPacket Buffer that holds the PUBLISH message
Returns:
true to indicate that processing of the packet has been completed and it can freed-up and returned back to the pool by the library. Otherwise, false.

Definition at line 754 of file mqtt_client.h.