Skip to content

Latest commit

 

History

History
107 lines (86 loc) · 3.59 KB

GUID-C83AB35B-80E7-47A9-BE31-AA8721DEFC14.md

File metadata and controls

107 lines (86 loc) · 3.59 KB

MQTT System Service Interface

This section describes the MQTT System Service Interface

MQTT Service Status Enum

States involved in the operation of the MQTT state machine.

typedef enum 
{
    SYS_RNWF_MQTT_CONFIG,               /**<Configure the MQTT Broker parameters*/
    SYS_RNWF_MQTT_CONNECT,              /**<Connect to the MQTT Broker */
    SYS_RNWF_MQTT_RECONNECT,            /**<Request reconnect to the MQTT Cloud*/
    SYS_RNWF_MQTT_DISCONNECT,           /**<Trigger Disconnect from MQTT Broker*/
    SYS_RNWF_MQTT_SUBSCRIBE_QOS0,       /**<Subscribe to QoS0 Topics */
    SYS_RNWF_MQTT_SUBSCRIBE_QOS1,       /**<Subscribe to QoS1 Topics */
    SYS_RNWF_MQTT_SUBSCRIBE_QOS2,       /**<Subscribe to QoS2 Topics */
    SYS_RNWF_MQTT_PUBLISH,              /**<Publis to MQTT Broker*/
    SYS_RNWF_MQTT_SET_CALLBACK,         /**<Configure the MQTT Application Callback*/              
}SYS_RNWF_MQTT_SERVICE_t;

MQTT Event Enum

Events involved in the operation of the MQTT state machine

typedef enum
{
    SYS_RNWF_MQTT_CONNECTED,    /**<Connected to MQTT broker event */
    SYS_RNWF_MQTT_DISCONNECTED, /**<Disconnected from MQTT broker event*/   
    SYS_RNWF_MQTT_SUBCRIBE_MSG,  /**<Event to report received MQTT message*/   
}SYS_RNWF_MQTT_EVENT_t;

MQTT Message Configuration Struct

Defines the configuration parameters required to establish connection with MQTT Broker

typedef struct 
{
    const char *url;            /**<MQTT Broker/Server URL */    
    uint16_t port;              /**<MQTT Broker/Server Port */
    const char *clientid;
    const char *username;       /**<MQTT User Name Credential */
    const char *password;       /**<MQTT Password Credential */ 
    uint8_t     tls_idx;
    uint8_t     *tls_conf;
}SYS_RNWF_MQTT_CFG_t;

MQTT Message Enum

typedef enum
{
    SYS_RNWF_NEW_MSG,        /**New message*/ 
    SYS_RNWF_DUP_MSG         /**Duplicate message*/ 
}SYS_RNWF_MQTT_MSG_t;

MQTT QoS Enum

typedef enum
{
    SYS_RNWF_MQTT_QOS0,      /**<No-Ack, Best effort delivery(No Guarantee)*/          
    SYS_RNWF_MQTT_QOS1,      /**<Pub-Ack, sent untill PUBACK from broker(possible duplicates) */
    SYS_RNWF_MQTT_QOS2,      /**<Highest service, no duplicate with guarantee */          
}SYS_RNWF_MQTT_QOS_t;

MQTT Publish Retain Enum

Sets whether the published message is retained at the broker or
not.

typedef enum
{
    SYS_RNWF_NO_RETAIN,          /**<Publish message is not saved at broker */
    SYS_RNWF_RETAIN,             /**<Publish message is saved at broker */
}SYS_RNWF_MQTT_RETAIN_t;

MQTT Frame Struct

typedef struct
{
    SYS_RNWF_MQTT_MSG_t isNew;          /**<Indicates message is new or duplicate */
    SYS_RNWF_MQTT_QOS_t qos;            /**<QoS type for the message ::RNWF_MQTT_QOS_t */
    SYS_RNWF_MQTT_RETAIN_t isRetain;    /**<Retain flag for the publish message */
    const uint8_t *topic;           /**<Publish topic for the message */
    const uint8_t *message;         /**<Indicates message is new or duplicate */               
}SYS_RNWF_MQTT_FRAME_t;