This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220SF-LAUNCHXL: MQTT Library does not connect to broker

Part Number: CC3220SF-LAUNCHXL

I'm trying to connect to the MQTT broker test.mosquitto.org and I get:

Connection to broker failed, Error code: -1

Here is my cpu info:

         *************************************************

         CC3220 Wi-Fi Thermostat Ver: v2.038

         *************************************************

         CHIP: 0x30000019
         MAC:  2.0.0.0
         PHY:  2.2.0.0
         NWP:  3.0.1.4
         ROM:  0
         HOST: 3.0.1.39
         MAC address: 98:84:e3:f5:fe:0b

  • Updated service pack:

    *************************************************

    CC3220 Wi-Fi Thermostat Ver: v2.039

    *************************************************

    CHIP: 0x30000019
    MAC: 2.0.0.0
    PHY: 2.2.0.6
    NWP: 3.9.0.6
    ROM: 0
    HOST: 3.0.1.39
    MAC address: 98:84:e3:f5:fe:0b

    *************************************************

    Error coded persists. Tried another MQTT test server.

    [MQTT Thread] Creating MQTT client...URL: iot.eclipse.org, Port: 1883
    [MQTT Thread] MQTT Client library initialized successfully
    [MQTT Thread] MqttClient::MQTT_CLIENT_CONNECTING_TO_BROKER...MQTTClient_connect():Connection to broker failed, Error code: -1
  • Hi Raymond,

    Are you using a provided example? Please try the MQTT Client example in the SDK.

    If you are trying to connect to test.mosquitto.org, you also have not updated your structure correctly since according to your terminal you are attempting to connect to iot.eclipse.org.

    Best regards,
    Sarah
  • I am working with the WIFI Thermostat SDK code and just enabled the MQTT option.
    Version simplelink_cc32xx_sdk_2_30_00_05
    The error message is the same with either address.
  • Wifi Thermostat version TIDM1020_wifi_thermostat_3.0
  • Is there a way to import the MQTT code into the workspace?
  • Hi Raymond,

    That version of the Wi-Fi Thermostat is implemented for connection to AWS using the AWS plugin.

    You can import the MQTT client example from the CC32xx SDK into Code Composer Studio from the top menu bar by selecting Projects -> Import CCS Project. Please see the Wi-Fi MQTT SimpleLink Academy for complete instructions: dev.ti.com/.../node

    Best regards,
    Sarah
  • Correction I am trying to implement TIDM1020_wifi_thermostat_2.0
  • The link given does not explain how to bring the \source\net\mqtt source into the workspace
  • or how do I edit the MQTT source and rebuild it
  • My issue is the MQTT library is not connecting to port 1883 of the test.mosquitto.org or iot.eclipse.org MQTT server (broker). The MQTT library was rebuilt and debug support was removed. So I decided to put the debug support back in. I read the docs and it said to cd (change to the directory) to the mqtt directory and type gmake. It did not work. Looking at the directory I noticed that they did a conversion from Gen1 to Gen2. Gen 1 apparently uses a gmake makefile where Gen 2 uses the new XDC tools build platform. Looking further into this it looks like they developed the code under Linux. I am using Windows. I tried using the XDC tool to rebuild the build system and it came out horribly wrong. I'm going to install an Ubuntu VM and reattempt the build.

    Using:

    simplelink_cc32xx_sdk_2_30_00_05

    TIDM1020_wifi_thermostat_2.0

  • Hi Raymond,

    You will need to update mqtt_client_task.c in the Wi-Fi thermostat code. Undefine SECURE_CLIENT in line 77 since 1883 is a non-secure port. You will also need to update the SERVER_ADDRESS.

    Again, the best way to test a basic MQTT client is the example in the SDK. The default example is already set up to connect to the Eclipse broker. Have you tried this yet?

    If you would like to debug the MQTT library source, the easiest way is to add the source files to your CCS project. You can left click on your project name and add files there.

    Best regards,
    Sarah

  • These are the parameters I have set in my file:
    /* Operate Lib in MQTT 3.1 mode. */
    #define MQTT_3_1_1 false
    #define MQTT_3_1 true

    #define WILL_TOPIC "Client"
    #define WILL_MSG "Client Stopped"
    #define WILL_QOS MQTT_QOS_2
    #define WILL_RETAIN false

    //#define SECURE_CLIENT

    /* Defining Broker IP address and port Number */
    //#define SERVER_ADDRESS "{orgID}.messaging.internetofthings.ibmcloud.com"
    //#define SERVER_ADDRESS "test.mosquitto.org"
    #define SERVER_ADDRESS "iot.eclipse.org"
    #define PORT_NUMBER 1883
    #define SECURED_PORT_NUMBER 8883
    #define LOOPBACK_PORT 1882

    the other project I have noticed differences in the mqtt_client_task file and I will review them.
    The MQTT library is the same for both projects.
  • I built the demo mqtt_client and it works. That tells me the MQTT library is functional. So I will compare the two client task files and determine the difference as to why the thermostat code cannot connect.
    Thank you for your support.