Prusa MINI Firmware overview
MQTT client
Collaboration diagram for MQTT client:

Modules

 Options
 

Classes

struct  mqtt_connect_client_info_t
 

Macros

#define MQTT_PORT   1883
 
#define mqtt_subscribe(client, topic, qos, cb, arg)   mqtt_sub_unsub(client, topic, qos, cb, arg, 1)
 
#define mqtt_unsubscribe(client, topic, cb, arg)   mqtt_sub_unsub(client, topic, 0, cb, arg, 0)
 

Typedefs

typedef void(* mqtt_connection_cb_t) (mqtt_client_t *client, void *arg, mqtt_connection_status_t status)
 
typedef void(* mqtt_incoming_data_cb_t) (void *arg, const u8_t *data, u16_t len, u8_t flags)
 
typedef void(* mqtt_incoming_publish_cb_t) (void *arg, const char *topic, u32_t tot_len)
 
typedef void(* mqtt_request_cb_t) (void *arg, err_t err)
 

Enumerations

enum  mqtt_connection_status_t {
  MQTT_CONNECT_ACCEPTED = 0, MQTT_CONNECT_REFUSED_PROTOCOL_VERSION = 1, MQTT_CONNECT_REFUSED_IDENTIFIER = 2, MQTT_CONNECT_REFUSED_SERVER = 3,
  MQTT_CONNECT_REFUSED_USERNAME_PASS = 4, MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_ = 5, MQTT_CONNECT_DISCONNECTED = 256, MQTT_CONNECT_TIMEOUT = 257
}
 
enum  { MQTT_DATA_FLAG_LAST = 1 }
 

Detailed Description

 

Macro Definition Documentation

◆ MQTT_PORT

#define MQTT_PORT   1883

Default MQTT port

◆ mqtt_subscribe

#define mqtt_subscribe (   client,
  topic,
  qos,
  cb,
  arg 
)    mqtt_sub_unsub(client, topic, qos, cb, arg, 1)

Subscribe to topic

◆ mqtt_unsubscribe

#define mqtt_unsubscribe (   client,
  topic,
  cb,
  arg 
)    mqtt_sub_unsub(client, topic, 0, cb, arg, 0)

Unsubscribe to topic

Typedef Documentation

◆ mqtt_connection_cb_t

typedef void(* mqtt_connection_cb_t) (mqtt_client_t *client, void *arg, mqtt_connection_status_t status)

Function prototype for mqtt connection status callback. Called when client has connected to the server after initiating a mqtt connection attempt by calling mqtt_connect() or when connection is closed by server or an error

Parameters
clientMQTT client itself
argAdditional argument to pass to the callback function
statusConnect result code or disconnection notification
See also
mqtt_connection_status_t

◆ mqtt_incoming_data_cb_t

typedef void(* mqtt_incoming_data_cb_t) (void *arg, const u8_t *data, u16_t len, u8_t flags)

Function prototype for MQTT incoming publish data callback function. Called when data arrives to a subscribed topic

See also
mqtt_subscribe
Parameters
argAdditional argument to pass to the callback function
dataUser data, pointed object, data may not be referenced after callback return, NULL is passed when all publish data are delivered
lenLength of publish data fragment
flagsMQTT_DATA_FLAG_LAST set when this call contains the last part of data from publish message

◆ mqtt_incoming_publish_cb_t

typedef void(* mqtt_incoming_publish_cb_t) (void *arg, const char *topic, u32_t tot_len)

Function prototype for MQTT incoming publish function. Called when an incoming publish arrives to a subscribed topic

See also
mqtt_subscribe
Parameters
argAdditional argument to pass to the callback function
topicZero terminated Topic text string, topic may not be referenced after callback return
tot_lenTotal length of publish data, if set to 0 (no publish payload) data callback will not be invoked

◆ mqtt_request_cb_t

typedef void(* mqtt_request_cb_t) (void *arg, err_t err)

Function prototype for mqtt request callback. Called when a subscribe, unsubscribe or publish request has completed

Parameters
argPointer to user data supplied when invoking request
errERR_OK on success ERR_TIMEOUT if no response was received within timeout, ERR_ABRT if (un)subscribe was denied

Enumeration Type Documentation

◆ mqtt_connection_status_t

Connection status codes

Enumerator
MQTT_CONNECT_ACCEPTED 
MQTT_CONNECT_REFUSED_PROTOCOL_VERSION 
MQTT_CONNECT_REFUSED_IDENTIFIER 
MQTT_CONNECT_REFUSED_SERVER 
MQTT_CONNECT_REFUSED_USERNAME_PASS 
MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_ 
MQTT_CONNECT_DISCONNECTED 
MQTT_CONNECT_TIMEOUT 

◆ anonymous enum

anonymous enum

Data callback flags

Enumerator
MQTT_DATA_FLAG_LAST 

Flag set when last fragment of data arrives in data callback

108  {
109  /** Flag set when last fragment of data arrives in data callback */
111 };
MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_
Definition: mqtt.h:86
MQTT_CONNECT_REFUSED_IDENTIFIER
Definition: mqtt.h:83
MQTT_CONNECT_REFUSED_USERNAME_PASS
Definition: mqtt.h:85
MQTT_CONNECT_TIMEOUT
Definition: mqtt.h:88
MQTT_CONNECT_REFUSED_PROTOCOL_VERSION
Definition: mqtt.h:82
MQTT_CONNECT_REFUSED_SERVER
Definition: mqtt.h:84
MQTT_CONNECT_ACCEPTED
Definition: mqtt.h:81
mqtt_connection_status_t
mqtt_connection_status_t
Definition: mqtt.h:79
MQTT_DATA_FLAG_LAST
Definition: mqtt.h:110
MQTT_CONNECT_DISCONNECTED
Definition: mqtt.h:87