MQTT Client: mqtt_client_ctx_cbs Struct Reference

Message Queuing Telemetry Transport Protocol

mqtt_client_ctx_cbs Struct Reference

#include <mqtt_client.h>

List of all members.

Public Attributes

bool(* publish_rx )(void *app, bool dup, enum mqtt_qos qos, bool retain, struct mqtt_packet *mqp)
void(* ack_notify )(void *app, u8 msg_type, u16 msg_id, u8 *buf, u32 len)
void(* disconn_cb )(void *app, i32 cause)

Detailed Description

Callbacks to be invoked by MQTT Client library onto Client application

Member Data Documentation

void(* mqtt_client_ctx_cbs::ack_notify)(void *app, u8 msg_type, u16 msg_id, u8 *buf, u32 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.


[in]appapplication to which this ACK message is targeted
See also:
[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
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.
void(* mqtt_client_ctx_cbs::disconn_cb)(void *app, i32 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

[in]appapplication whose connection got terminated
See also:
[in]causereason that created disconnection (LIBRARY Generated Error Codes)
bool(* mqtt_client_ctx_cbs::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.

[in]appapplication to which this PUBLISH message is targeted
See also:
[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
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.

The documentation for this struct was generated from the following file:
Generated on Mon Nov 17 2014 12:11:04 for MQTT Client by  doxygen 1.7.4