4.1.8.6.2 MQTT System Service Interface

MQTT Service Status EnumStates involved in the operation of the MQTT state machine.
typedefenum 
{
    SYS_WINCS_MQTT_CONFIG,               /**<Configure the MQTT Broker parameters*/ 
    SYS_WINCS_MQTT_USER_PROP_SET,         /* Set user property*/
    SYS_WINCS_MQTT_LWT_CONFIG,            /**<Configure the MQTT Broker parameters*/
    SYS_WINCS_MQTT_CONNECT,              /**<Connect to the MQTT Broker */
    SYS_WINCS_MQTT_RECONNECT,            /**<Request reconnect to the MQTT Cloud*/
    SYS_WINCS_MQTT_DISCONNECT,           /**<Trigger Disconnect from MQTT Broker*/
    SYS_WINCS_MQTT_SUBS_TOPIC,           /**<Subscribe to QOS Topics **/
    SYS_WINCS_MQTT_PUBLISH,              /**<Publis to MQTT Broker*/
    SYS_WINCS_MQTT_SET_CALLBACK,         /**<Configure the MQTT Application Callback*/ 
    SYS_WINCS_MQTT_UNSUBSCRIBE,          /**<UNSubscribe to Topic */ 
    SYS_WINCS_MQTT_SET_SRVC_CALLBACK,    /**<Configure the MQTT Application Callback*/
    SYS_WINCS_MQTT_GET_CALLBACK,         /*< Get Callback Function data*/
}SYS_WINCS_MQTT_SERVICE_t;
MQTT Event Enum Events involved in the operation of the MQTT state machine
typedefenum
{
    SYS_WINCS_MQTT_CONNECTED,    /**<Connected to MQTT broker event */
    SYS_WINCS_MQTT_DISCONNECTED, /**<Disconnected from MQTT broker event*/   
    SYS_WINCS_MQTT_SUBCRIBE_MSG,  /**<Event to report received MQTT message*/          
    SYS_WINCS_MQTT_SUBCRIBE_ACK, /*Subscribe MQTT ACK*/
    SYS_WINCS_MQTT_PUBLISH_ACK,  /*MQTT Publish ACK*/  
    SYS_WINCS_MQTT_PUBLISH_MSG_RECV,  /*MQTT Publish acknowledgement and completion received. */
    SYS_WINCS_MQTT_UNSUBSCRIBED,  /*MQTT A topic has been un-subscribed.*/      
    SYS_WINCS_MQTT_DPS_STATUS,    /*MQTT DPS Status*/
    SYS_WINCS_MQTT_ERROR,         /*MQTT ERROR*/
}SYS_WINCS_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 Enable */
    bool                            tlsIdx;

    /**< Azure DPS */
    uint8_t                         azureDps;

    /**< TLS Configuration */
    SYS_WINCS_NET_TLS_SOC_PARAMS   *tlsConf; 

    /**< Protocol version */
    SYS_WINCS_MQTT_PROTO_VER        protoVer;

    /**< MQTT Clean session flag */
    bool                            cleanSession;

    /**< MQTT keep alive time */
    uint16_t                        keepAliveTime;

    /**< MQTT connection session expiry interval */
    uint16_t                         sessionExpiryInterval;

    /**< TLS handle */
    uint8_t                           tlsHandle;


} SYS_WINCS_MQTT_CFG_t;
MQTT_LWT_CFG_t structure
typedef struct
{
    /* Topic name for the LWT message. */
    const char                     *topicName; 

    /* Content of the LWT message. */
    const char                     *message;

    /* Message is a duplicate of a previous one. */
    bool                            isDuplicate;

    /* QoS level of message. */
    SYS_WINCS_MQTT_QOS_t            qos;

    /* Flag indicating if message is to be, or has been, retained. */
    bool                            retain;
<#if SYS_WINCS_MQTT_PUBLISH == true>   
    /* MQTT publish properties */
    SYS_WINCS_MQTT_PUB_PROP         publishProp;
</#if> 
    /* Protocol version */
    SYS_WINCS_MQTT_PROTO_VER        protoVer;

} SYS_WINCS_MQTT_LWT_CFG_t;

MQTT QoS Enum
typedef enum
{
    SYS_WINCS_MQTT_QOS0 = WDRV_WINC_MQTT_QOS_0,      /**<No-Ack, Best effort delivery(No Guarantee)*/          
    SYS_WINCS_MQTT_QOS1 = WDRV_WINC_MQTT_QOS_1,      /**<Pub-Ack, sent untill PUBACK from broker(possible duplicates) */
    SYS_WINCS_MQTT_QOS2 = WDRV_WINC_MQTT_QOS_2,      /**<Highest service, no duplicate with guarantee */          
}SYS_WINCS_MQTT_QOS_t;

MQTT Frame Struct
typedef struct
{
    SYS_WINCS_MQTT_PROTO_VER protoVer;   /* Protocol version */
    bool isNew;                       /**<Indicates message is new or duplicate */
    SYS_WINCS_MQTT_QOS_t qos;         /**<QoS type for the message ::WINCS_MQTT_QOS_t */
    bool isRetain;                    /**<Retain flag for the publish message */
    char *topic;           /**<Publish topic for the message */
    const char *message;         /**<Indicates message is new or duplicate */    
    SYS_WINCS_MQTT_SUB_PROP subscribeProp;   /* Subscription Identifier*/
    SYS_WINCS_MQTT_PUB_PROP publishProp;     /* MQTT publish properties*/ 
           
}SYS_WINCS_MQTT_FRAME_t;

MQTT_CONN_ACK_PROP structure

typedef struct
{
    /* Session expiry interval. */
    uint32_t                        sessionExpiryInterval;

    /* Maximum packet size. */
    uint32_t                        maxPacketSize;

    /* Receive maximum. */
    uint16_t                        receiveMax;

    /* Topic alias max. */
    uint16_t                        topicAliasMax;

    /* Flag indicating retain available property. */
    bool                            retainAvailable;

    /* Flag indicating if wildcard subscriptions are supported. */
    bool                            wildcardSubsAvailable;

    /* Flag indicating if subscription IDs are available. */
    bool                            subIDsAvailable;

    /* Flag indicating if shared subscriptions are supported. */
    bool                            sharedSubsAvailable;

    /* Max QoS settings. */
    uint8_t                         maxQoS;

    /* Assigned client ID. */
    uint8_t                         assignedClientId[SYS_WINCS_MQTT_CONN_MAX_ASSIGNED_CLIENT_ID+1];

} SYS_WINC_MQTT_CONN_ACK_PROP;