3.2.8.7.2 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_QOS,        /**<Subscribe to QoS 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 
{    
    /**<MQTT Broker/Server URL */    
    const char *url;          
    
    /**<MQTT Service client ID*/
    const char *clientid;
    
    /**<MQTT User Name Credential */
    const char *username;       
    
    /**<MQTT Password Credential */ 
    const char *password;       
    
    /**<MQTT Broker/Server Port */
    uint16_t port;          
    
    /*MQTT TLS Index*/
    uint8_t     tls_idx;
    
    /*Azure DPS*/
    uint8_t     azure_dps;
    
    /*TLS Configuration*/
    uint8_t     *tls_conf;    

    /*MQTT Protocol Version*/
    uint8_t     protoVer;

    /*MQTT Keep Alive time */
    uint16_t     keep_alive_time;


}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;

MQTT LWT Configuration Struct

typedef struct
{
    /**<QoS type for the LWT message ::SYS_RNWF_MQTT_QOS_t */
    SYS_RNWF_MQTT_QOS_t qos;
    
    /**<Retain flag for the LWT message */
    SYS_RNWF_MQTT_RETAIN_t isRetain; 
    
    /**<Topic name of the LWT message */
    const char *topic_name; 
    
    /**<LWT message */
    const char *message;
    
}SYS_RNWF_MQTT_LWT_CFG_t;