Microchip® Advanced Software Framework

Quick start guide for MQTT service

Copyright (C) 2017 Microchip Technology Inc.

and its subsidiaries (Microchip). All rights reserved.

You are permitted to use the software and its derivatives with Microchip products.

SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL OR EQUITABLE THEORY FOR ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, OR OTHER SIMILAR COSTS. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP AND ITS LICENSORS LIABILITY WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU PAID DIRECTLY TO MICROCHIP TO USE THIS SOFTWARE. MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS.

THIRD PARTY SOFTWARE: Notwithstanding anything to the contrary, any third party software accompanying this software is subject to the terms and conditions of the third party’s license agreement or open source software license. To the extent required by third party or open source licenses covering such third party software, the terms of such license will apply in lieu of the terms provided herein. To the extent the terms of such third party licenses prohibit any of the restrictions described herein, such restrictions will not apply to such third party software. THIRD PARTY SOFTWARE IS SUBJECT TO THE FOREGOING WARRANTY DISCLAIMER AND LIMIT ON LIABILITY PROVIDED IN THE PARAGRAPH ABOVE.

This is the quick start guide for the how to configure and use the MQTT service.

Basic operations of MQTT

MQTT is formed by the following operations.

  1. Connect
  2. Publish
  3. Subscribe
  4. Unsubscribe
  5. Disconnect

Before performing this operations, must call mqtt_init function.

Connect

  1. Connect operation is required for the other operations.
  2. Connect operation is consist of following 2 functions.
    * mqtt_connect : This function preforms the connect to MQTT broker server.
    * mqtt_connect_broker : This function preforms the authenticate and configure options to the MQTT broker server.
    *
  3. After mqtt_connect operation has completed MQTT_CALLBACK_SOCK_CONNECTED event will produced. It means server was found and connected.
  4. After that you should call mqtt_connect_broker function and configure this MQTT connection. After this operation finished, MQTT_CALLBACK_CONNECTED event will produced.

Publish

  1. Publish operation perform the send message to all of subscribers that share the same topic.
  2. Publish operation is consist of following function.
    * mqtt_publish : This function preforms the publish message to the subscribers
    *

Subscribe

  1. Subscribe operation is used to get the message on a particular topic when it is generated.
  2. Subscribe operation is consist of following function.
    * mqtt_subscribe : This function preforms the subscription of the topic.
    *

Disconnect

  1. Disconnect operation is used to disconnect from the MQTT broker server.
  2. Disconnect operation is consist of following function.
    * mqtt_unsubscribe : This function preforms the unsubscribe topic.
    *

Unsubscribe

  1. Unsubscribe operation is used to cancel a subscription of the specific topic.
  2. Unsubscribe operation is consist of following function.
    * mqtt_disconnect : This function preforms the disconnection from the broker server.
    *