Embedded Wireless Framework
Data Structures | Typedefs | Enumerations | Functions
Adapter MQTT API

MQTT functions for connecting, disconnecting. publishing and subscribing. More...

Data Structures

struct  ewf_socket_mqtt
 The MQTT socket structure definition. More...
 
struct  _ewf_adapter_mqtt_message
 The MQTT Message structure definition. More...
 
struct  _ewf_adapter_api_mqtt
 

Typedefs

typedef struct ewf_socket_mqtt ewf_socket_mqtt
 
typedef enum _ewf_adapter_mqtt_qos ewf_adapter_mqtt_qos
 
typedef struct _ewf_adapter_mqtt_message ewf_adapter_mqtt_message
 
typedef ewf_result(* ewf_adapter_mqtt_state_callback) (ewf_socket_mqtt *socket_ptr, const char *state_cstr, const char *param_cstr)
 A function pointer type for MQTT basic API state callbacks. More...
 
typedef ewf_result(* ewf_adapter_mqtt_message_callback) (ewf_socket_mqtt *socket_ptr, const char *topic_str, ewf_adapter_mqtt_message *message_ptr)
 A function pointer type for MQTT message callbacks. More...
 
typedef struct _ewf_adapter_api_mqtt ewf_adapter_api_mqtt
 

Enumerations

enum  _ewf_adapter_mqtt_qos { ewf_adapter_mqtt_qos_0 = 0 , ewf_adapter_mqtt_qos_1 = 1 , ewf_adapter_mqtt_qos_2 = 2 , ewf_adapter_mqtt_qos_error = -1 }
 The MQTT QoS enumeration definition.
 

Functions

ewf_result ewf_adapter_mqtt_open (ewf_adapter *adapter_ptr, ewf_socket_mqtt *socket_ptr)
 Open an MQTT socket. More...
 
ewf_result ewf_adapter_mqtt_close (ewf_socket_mqtt *socket_ptr)
 Close an MQTT socket. More...
 
ewf_result ewf_adapter_mqtt_set_tls_configuration (ewf_socket_mqtt *socket_ptr, uint32_t tls_configuration_id)
 Set the TLS context for the socket. More...
 
ewf_result ewf_adapter_mqtt_connect (ewf_socket_mqtt *socket_ptr, const char *server_str, uint32_t port, const char *clientid_str, const char *username_str, const char *password_str)
 Connect to an MQTT server. More...
 
ewf_result ewf_adapter_mqtt_disconnect (ewf_socket_mqtt *socket_ptr)
 Disconnect from an MQTT server. More...
 
ewf_result ewf_adapter_mqtt_publish_string (ewf_socket_mqtt *socket_ptr, const char *topic_str, const char *message_str)
 Publish a message to to a topic. More...
 
ewf_result ewf_adapter_mqtt_publish_buffer (ewf_socket_mqtt *socket_ptr, const char *topic_str, const uint8_t *message_ptr, uint32_t message_size)
 Publish a message to to a topic. More...
 
ewf_result ewf_adapter_mqtt_publish_message (ewf_socket_mqtt *socket_ptr, const char *topic_str, const ewf_adapter_mqtt_message *message_ptr)
 Publish a message to to a topic. More...
 
ewf_result ewf_adapter_mqtt_subscribe (ewf_socket_mqtt *socket_ptr, const char *topic_str, ewf_adapter_mqtt_qos qos)
 Subscribe to a topic. More...
 
ewf_result ewf_adapter_mqtt_subscribe_with_result (ewf_socket_mqtt *socket_ptr, const char *topic_str, ewf_adapter_mqtt_qos *qos_ptr)
 Subscribe to a topic. More...
 
ewf_result ewf_adapter_mqtt_unsubscribe (ewf_socket_mqtt *socket_ptr, const char *topic_str)
 Unsubscribe from a topic. More...
 
ewf_result ewf_adapter_mqtt_state_callback_set (ewf_socket_mqtt *socket_ptr, ewf_adapter_mqtt_state_callback callback)
 Register a callback for state changes. More...
 
ewf_result ewf_adapter_mqtt_message_callback_set (ewf_socket_mqtt *socket_ptr, ewf_adapter_mqtt_message_callback callback)
 Register a callback for subscribed messages. More...
 

Detailed Description

MQTT functions for connecting, disconnecting. publishing and subscribing.

Typedef Documentation

◆ ewf_adapter_api_mqtt

@breif the MQTT API type

◆ ewf_adapter_mqtt_message_callback

typedef ewf_result(* ewf_adapter_mqtt_message_callback) (ewf_socket_mqtt *socket_ptr, const char *topic_str, ewf_adapter_mqtt_message *message_ptr)

A function pointer type for MQTT message callbacks.

Parameters
[in]adapter_ptra pointer to an adapter structure
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_state_callback

typedef ewf_result(* ewf_adapter_mqtt_state_callback) (ewf_socket_mqtt *socket_ptr, const char *state_cstr, const char *param_cstr)

A function pointer type for MQTT basic API state callbacks.

Parameters
[in]adapter_ptra pointer to an adapter structure
[in]state_cstra pointer to the state string
[in]param_cstra pointer to the state param string
Returns
ewf_result success and error conditions

Function Documentation

◆ ewf_adapter_mqtt_close()

ewf_result ewf_adapter_mqtt_close ( ewf_socket_mqtt socket_ptr)

Close an MQTT socket.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_connect()

ewf_result ewf_adapter_mqtt_connect ( ewf_socket_mqtt socket_ptr,
const char *  server_str,
uint32_t  port,
const char *  clientid_str,
const char *  username_str,
const char *  password_str 
)

Connect to an MQTT server.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_disconnect()

ewf_result ewf_adapter_mqtt_disconnect ( ewf_socket_mqtt socket_ptr)

Disconnect from an MQTT server.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_message_callback_set()

ewf_result ewf_adapter_mqtt_message_callback_set ( ewf_socket_mqtt socket_ptr,
ewf_adapter_mqtt_message_callback  callback 
)

Register a callback for subscribed messages.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
[in]callbacka pointer to the callback
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_open()

ewf_result ewf_adapter_mqtt_open ( ewf_adapter adapter_ptr,
ewf_socket_mqtt socket_ptr 
)

Open an MQTT socket.

Parameters
[in]adapter_ptra pointer to an adapter structure
[in,out]socketa pointer to a variable that will hold the MQTT socket
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_publish_buffer()

ewf_result ewf_adapter_mqtt_publish_buffer ( ewf_socket_mqtt socket_ptr,
const char *  topic_str,
const uint8_t *  message_ptr,
uint32_t  message_size 
)

Publish a message to to a topic.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_publish_message()

ewf_result ewf_adapter_mqtt_publish_message ( ewf_socket_mqtt socket_ptr,
const char *  topic_str,
const ewf_adapter_mqtt_message message_ptr 
)

Publish a message to to a topic.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_publish_string()

ewf_result ewf_adapter_mqtt_publish_string ( ewf_socket_mqtt socket_ptr,
const char *  topic_str,
const char *  message_str 
)

Publish a message to to a topic.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_set_tls_configuration()

ewf_result ewf_adapter_mqtt_set_tls_configuration ( ewf_socket_mqtt socket_ptr,
uint32_t  tls_configuration_id 
)

Set the TLS context for the socket.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_state_callback_set()

ewf_result ewf_adapter_mqtt_state_callback_set ( ewf_socket_mqtt socket_ptr,
ewf_adapter_mqtt_state_callback  callback 
)

Register a callback for state changes.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
[in]callbacka pointer to the callback
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_subscribe()

ewf_result ewf_adapter_mqtt_subscribe ( ewf_socket_mqtt socket_ptr,
const char *  topic_str,
ewf_adapter_mqtt_qos  qos 
)

Subscribe to a topic.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
[in]topic_stra pointer to a topic string to subscribe to
[in]qosa requested QoS
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_subscribe_with_result()

ewf_result ewf_adapter_mqtt_subscribe_with_result ( ewf_socket_mqtt socket_ptr,
const char *  topic_str,
ewf_adapter_mqtt_qos *  qos_ptr 
)

Subscribe to a topic.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
[in]topic_stra pointer to a topic string to subscribe to
[in,out]qos_ptra pointer to a requested QoS, on exit the granted QoS
Returns
ewf_result success and error conditions

◆ ewf_adapter_mqtt_unsubscribe()

ewf_result ewf_adapter_mqtt_unsubscribe ( ewf_socket_mqtt socket_ptr,
const char *  topic_str 
)

Unsubscribe from a topic.

Parameters
[in]socket_ptra pointer to an MQTT socket structure
Returns
ewf_result success and error conditions