# MQTT demo Source: [https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html) This demo provides a reference implementation and showcases how to use the coreMQTT API. Developers can run this demo to understand and implement the MQTT communication quickly. This demo is compatible with MQTT protocol v3.1.1. The source code is based on coreMQTT v2.1.0. ## MQTT demo contents Source: [https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html) The content of the MQTT demo is as follows: >-- mqtt_demo | >-- BUILD.gn // Build script | >-- prj.conf // Config of the demo | >-- README.md | >-- src | >-- mqtt_main.c // Part of the demo code | >-- mqtt_demo.c // Part of the demo code | >-- mqtt_demo.h // Config AP SSID | | >-- mqtt_demo_basic_tls // Demo of MQTT over one way authentication | | >-- core_mqtt_config.h // Config coreMQTT parameters | | >-- demo_config.h // Config port, host address and certificates | | >-- mqtt_demo_basic_tls.c // Part of the demo code | | >-- mqtt_demo_mutual_auth // Demo of MQTT over mutual way authentication | | >-- core_mqtt_config.h // Config coreMQTT parameters | | >-- demo_config.h // Config port, host address and certificates | | >-- mqtt_demo_mutual_auth.c // Part of the demo code | | >-- mqtt_demo_plaintext // Demo of MQTT over TCP | | >-- core_mqtt_config.h // Config coreMQTT parameters | | >-- demo_config.h // Config port, host address | | >-- mqtt_demo_plaintext.c // Part of the demo codeCopy to clipboard ## Configure MQTT demo Source: [https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html) Before building the MQTT demo, configure the following three files in advance: - prj.conf - mqtt\_demo.h - demo\_config.h ### Configure transport layer interface Configure the transport layer interface in the prj.conf file. The MQTT demo supports three transport layer interfaces. The following table lists these three interfaces and the corresponding enabling parameters. Table : Supported transport layer interfaces and parameters | Interface | Parameter | | --- | --- | | TCP | CONFIG\_MQTT\_PLAINTEXT\_DEMO | | SSL one-way authentication | CONFIG\_MQTT\_BASIC\_TLS\_DEMO | | SSL mutual authentication | CONFIG\_MQTT\_MUTUAL\_AUTH\_DEMO | Only one interface can be active for the demo. That is, you must set only one of these parameters to `y`. For example, the following configuration configures the MQTT demo to run via the TCP interface: CONFIG_MQTT_PLAINTEXT_DEMO = yCopy to clipboard ### Configure parameters for Wi-Fi connection Configure the AP SSID by defining the value of the `WLAN_AP_SSID` parameter in the mqtt\_demo.h file. For example, the following configuration instructs the station to connect to the AP that has “D-Link\_DIR-816” as the SSID: #define WLAN_AP_SSID "D-Link_DIR-816"Copy to clipboard ### Configure parameters for MQTT connection Configure the MQTT connection parameters in the demo\_config.h file for the selected transport layer interface. Different transport layer interfaces require different number of MQTT connection parameters: - **TCP:** Configure the following parameters in mqtt\_demo\_plaintext\demo\_config.h: - BROKER\_ENDPOINT: IP address of the broker - BROKER\_PORT: MQTT listening port number of broker over TCP, default 1883 For example, the following configuration instructs the station to connect to the MQTT broker at 192.168.0.122:1883. #define BROKER_ENDPOINT "192.168.0.122" #define BROKER_PORT ( 1883 )Copy to clipboard - **SSL one-way authentication:** Configure the following parameters in mqtt\_demo\_basic\_tls\demo\_config.h: - BROKER\_ENDPOINT: IP address of the broker - BROKER\_PORT: MQTT listening port number of broker over SSL, default 8883 - ROOT\_CA\_CERT\_PATH: Path of broker's root CA certificate For example, the following configuration instructs the station to connect to the MQTT broker at 192.168.0.122:8883, and `/lfs/ca.crt` is the certificate path flashed to the station. #define BROKER_ENDPOINT "192.168.0.122" #define BROKER_PORT ( 8883 ) #define ROOT_CA_CERT_PATH "/lfs/ca.crt"Copy to clipboard - **SSL mutual authentication:** Configure the following parameters in the mqtt\_demo\_mutual\_auth\demo\_config.h file: - BROKER\_ENDPOINT: IP address of the broker. - BROKER\_PORT: MQTT listening port number of broker over SSL, default 8883. - ROOT\_CA\_CERT\_PATH: Path of the broker's root CA certificate. - CLIENT\_CERT\_PATH: Path of the client certificate. - CLIENT\_PRIVATE\_KEY\_PATH: Path of the private key. For example, the following configuration instructs the station to connect to the MQTT broker at 192.168.0.122:8883, and /lfs/ca.crt, /lfs/client.crt, and /lfs/client.key are the certificate paths flashed to the station. #define BROKER_ENDPOINT "192.168.0.122" #define BROKER_PORT ( 8883 ) #define ROOT_CA_CERT_PATH "/lfs/ca.crt" #define CLIENT_CERT_PATH "/lfs/client.crt" #define CLIENT_PRIVATE_KEY_PATH "/lfs/client.key"Copy to clipboard ## Build and flash MQTT demo Source: [https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html) After completing the configuration in [Configure MQTT demo](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html#configure_mqtt_demo), follow the instructions in this section to build and flash the MQTT demo: ### Generating certificates Source: [https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html) Refer to the following website for how to generate CA, server, and client certificates: [https://mosquitto.org/man/mosquitto-tls-7.html](https://mosquitto.org/man/mosquitto-tls-7.html) ### Build and flash MQTT demo for the selected interface Source: [https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html) Depending on the selected transport layer interface, follow the corresponding instructions to build and flash the MQTT demo. **TCP:** 1. Enter the project root directory. 2. Build the MQTT demo by using the following command: python build.py -i FERMION_MQTT_DEMO -b qcc730v2_evb11_hostless -o output\qcc730v2_evb11_hostlessCopy to clipboard 3. Enter the .\tools\nvm\_programmer folder, and then flash the MQTT demo image by using the following command: python nvm_programmer.py -s ch347 -f ..\..\..\output\qcc730v2_evb11_hostless\FERMION_MQTT_DEMO\DEBUG\bin\FERMION_MQTT_DEMO_HASHED.elf -P -A --resetCopy to clipboard **SSL one-way authentication:** 1. Install littlefs-tools for python by using the following command: pip install littlefs-toolsCopy to clipboard 2. Enter the project root directory, and then use the following command to create a folder called `mycert`: mkdir .\tools\fs_tools\mycertCopy to clipboard 3. Copy the ca.crt file generated in [Generating certificates](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html#generating_certificates) to the .\tools\fs\_tools\mycert folder. 4. Enter the .\tools\fs\_tools folder, and then generate the lfs image by using the following command: python lfsimg.py -s mycertCopy to clipboard 5. Enter the project root directory, and then build the MQTT demo by using the following command: python build.py -i FERMION_MQTT_DEMO -b qcc730v2_evb11_hostless -o output\qcc730v2_evb11_hostlessCopy to clipboard 6. Enter the .\tools\nvm\_programmer\script folder, and then flash the MQTT demo image by using the following command: python nvm_programmer.py -s ch347 -f ..\..\..\output\qcc730v2_evb11_hostless\FERMION_MQTT_DEMO\DEBUG\bin\FERMION_MQTT_DEMO_HASHED.elf -P -A --resetCopy to clipboard 7. Flash the certificate: python nvm_programmer.py -s ch347 -f ..\..\fs_tools\lfsimg.bin -b 0x3000 -n flash --resetCopy to clipboard **SSL mutual authentication:** 1. Install littlefs-tools for python by using the following command: pip install littlefs-toolsCopy to clipboard 2. Enter the project root directory, and then use the following command to create a folder called `mycert`: mkdir .\tools\fs_tools\mycertCopy to clipboard 3. Copy the ca.crt, client.crt, and client.key files generated in [Generating certificates](https://docs.qualcomm.com/doc/80-Y8730-2/topic/mqtt_demo.html#generating_certificates) to the .\tools\fs\_tools\mycert folder. 4. Enter the .\tools\fs\_tools folder, and then generate the lfs image by using the following command: python lfsimg.py -s mycertCopy to clipboard 5. Enter the project root directory, and then build the MQTT demo by using the following command: python build.py -i FERMION_MQTT_DEMO -b qcc730v2_evb11_hostless -o output\qcc730v2_evb11_hostlessCopy to clipboard 6. Enter the .\tools\nvm\_programmer folder, and then flash the MQTT demo image by using the following command: python nvm_programmer.py -s ch347 -f ..\..\output\qcc730v2_evb11_hostless\FERMION_MQTT_DEMO\DEBUG\bin\FERMION_MQTT_DEMO_HASHED.elf -P -A --resetCopy to clipboard 7. Flash the certificates: python nvm_programmer.py -s ch347 -f ..\fs_tools\lfsimg.bin -b 0x3000 -n flash --resetCopy to clipboard Last Published: Jun 03, 2026 [Previous Topic QCLI sub-group: RTT](https://docs.qualcomm.com/bundle/publicresource/80-Y8730-2/topics/qcli_sub_group_rtt.md) [Next Topic Power test demo](https://docs.qualcomm.com/bundle/publicresource/80-Y8730-2/topics/power_test_demo.md)