nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
mqtt_helper.h File Reference
#include <stdio.h>
#include <zephyr/net/mqtt.h>

Go to the source code of this file.

Data Structures

struct  mqtt_helper_buf
 
struct  mqtt_helper_cfg
 
struct  mqtt_helper_conn_params
 

Typedefs

typedef bool(* mqtt_helper_on_all_events_t) (struct mqtt_client *const client, const struct mqtt_evt *const event)
 Handler invoked for events that are received from the MQTT stack. This callback handler can be used to filter incoming MQTT events before they are processed by the MQTT helper library.
 
typedef void(* mqtt_helper_on_connack_t) (enum mqtt_conn_return_code return_code, bool session_present)
 
typedef void(* mqtt_helper_on_disconnect_t) (int result)
 
typedef void(* mqtt_helper_on_publish_t) (struct mqtt_helper_buf topic_buf, struct mqtt_helper_buf payload_buf)
 
typedef void(* mqtt_helper_on_puback_t) (uint16_t message_id, int result)
 
typedef void(* mqtt_helper_on_suback_t) (uint16_t message_id, int result)
 
typedef void(* mqtt_helper_on_pingresp_t) (void)
 
typedef void(* mqtt_helper_on_error_t) (enum mqtt_helper_error error)
 

Enumerations

enum  mqtt_state {
  MQTT_STATE_UNINIT , MQTT_STATE_DISCONNECTED , MQTT_STATE_TRANSPORT_CONNECTING , MQTT_STATE_CONNECTING ,
  MQTT_STATE_TRANSPORT_CONNECTED , MQTT_STATE_CONNECTED , MQTT_STATE_DISCONNECTING , MQTT_STATE_COUNT
}
 
enum  mqtt_helper_error { MQTT_HELPER_ERROR_MSG_SIZE }
 

Functions

int mqtt_helper_init (struct mqtt_helper_cfg *cfg)
 Initialize the MQTT helper.
 
int mqtt_helper_connect (struct mqtt_helper_conn_params *conn_params)
 Connect to an MQTT broker.
 
int mqtt_helper_disconnect (void)
 Disconnect from the MQTT broker.
 
int mqtt_helper_subscribe (struct mqtt_subscription_list *sub_list)
 Subscribe to MQTT topics.
 
int mqtt_helper_publish (const struct mqtt_publish_param *param)
 Publish an MQTT message.
 
int mqtt_helper_deinit (void)
 Deinitialize library. Must be called when all MQTT operations are done to release resources and allow for a new client. The client must be in a disconnected state.