Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

LAUNCHXL-CC3235SF: MQTT publish function hangs

Part Number: LAUNCHXL-CC3235SF
Other Parts Discussed in Thread: CC3235SF

Tool/software:

Hi 

We're using the latest SDK and running the MQTT client example, and it looks great when triggering the publish function via a button.

In order to check the stability, we use a 3 second period timer to trigger the publishing  function, Sometime (randomly) the publishing function hangs and does not return, and application reecives the "MQTT_EVENT_SERVER_DISCONNECT" event. we would like to know whether any limition on MQTT library. we also upload the patch for you reference.

--- C:\ti\simplelink_cc32xx_sdk_7_10_00_13\examples\rtos\CC3235SF_LAUNCHXL\demos\mqtt_client\mqtt_client_app.c
+++ C:\Users\97111701\workspace_v12_2_3\mqtt_client_CC3235SF_LAUNCHXL_tirtos7_ticlang\mqtt_client_app.c
@@ -112,7 +112,7 @@
 
 #ifndef MQTT_SECURE_CLIENT
 #define MQTT_CONNECTION_FLAGS           MQTTCLIENT_NETCONN_URL
-#define MQTT_CONNECTION_ADDRESS         "broker.hivemq.com" //"mqtt.eclipse.org"
+#define MQTT_CONNECTION_ADDRESS         "192.168.0.101"//"test.mosquitto.org"//"172.16.120.28"//"broker.hivemq.com" //"mqtt.eclipse.org"
 #define MQTT_CONNECTION_PORT_NUMBER     1883
 #else
 #define MQTT_CONNECTION_FLAGS           MQTTCLIENT_NETCONN_IP4 | MQTTCLIENT_NETCONN_SEC
@@ -134,6 +134,8 @@
 /* If ClientId isn't set, the MAC address of the device will be copied into  */
 /* the ClientID parameter.                                                   */
 char ClientId[13] = "clientId123";
+
+timer_t g_timer;
 
 enum{
     APP_MQTT_PUBLISH,
@@ -377,11 +379,11 @@
     if(ret < 0){
         LOG_ERROR("msg queue send error %d", ret);
     }
-    queueElement.event = APP_OTA_TRIGGER;
-    ret = mq_send(appQueue, (const char*)&queueElement, sizeof(struct msgQueue), 0);
-    if(ret < 0){
-        LOG_ERROR("msg queue send error %d", ret);
-    }
+//    queueElement.event = APP_OTA_TRIGGER;
+//    ret = mq_send(appQueue, (const char*)&queueElement, sizeof(struct msgQueue), 0);
+//    if(ret < 0){
+//        LOG_ERROR("msg queue send error %d", ret);
+//    }
 }
 
 void pushButtonConnectionHandler(uint_least8_t index)
@@ -715,6 +717,39 @@
     }
 }
 
+
+
+void TimerPeriodicIntHandler(sigval val)
+{
+    int ret;
+    struct msgQueue queueElement;
+
+    queueElement.event = APP_MQTT_PUBLISH;
+    ret = mq_send(appQueue, (const char*)&queueElement, sizeof(struct msgQueue), 0);
+    if(ret < 0){
+        LOG_ERROR("msg queue send error %d", ret);
+    }
+}
+
+void MqttTimerPubStart()
+{
+    struct itimerspec value;
+    sigevent sev;
+
+    /* Create Timer                                                          */
+    sev.sigev_notify = SIGEV_SIGNAL;
+    sev.sigev_notify_function = &TimerPeriodicIntHandler;
+    timer_create(CLOCK_MONOTONIC, &sev, &g_timer);
+
+    /* start timer                                                           */
+    value.it_interval.tv_sec = 3;
+    value.it_interval.tv_nsec = 0;//100 * 1000000;
+    value.it_value.tv_sec = 3;
+    value.it_value.tv_nsec = 0;//100 * 1000000;
+
+    timer_settime(g_timer, 0, &value, NULL);
+}
+
 void mainThread(void * args)
 {
     int32_t ret;
@@ -812,7 +847,7 @@
     /* Loop attempt to establish AP Connection */
     while(conn_Failure != 0)
     {
-        conn_Failure = SlNetConn_start(SLNETCONN_SERVICE_LVL_INTERNET, SlNetConnEventHandler, SLNETCONN_TIMEOUT, 0);
+        conn_Failure = SlNetConn_start(SLNETCONN_SERVICE_LVL_IP, SlNetConnEventHandler, SLNETCONN_TIMEOUT, 0);
         LOG_INFO("failed to Connect to AP: Error Code: %d. Retrying...",conn_Failure);
     }
 
@@ -847,7 +882,7 @@
     }
 
     do {
-        ret = SlNetConn_waitForConnection(SLNETCONN_SERVICE_LVL_INTERNET, SLNETCONN_TIMEOUT);
+        ret = SlNetConn_waitForConnection(SLNETCONN_SERVICE_LVL_IP, SLNETCONN_TIMEOUT);
     } while(ret != 0);
     LOG_INFO("Wi-Fi connection is UP");
 
@@ -863,6 +898,9 @@
         LOG_INFO("MQTT connection is UP");
 
         GPIO_enableInt(CONFIG_GPIO_BUTTON_0);
+
+        /* Start Timer to PUBLISH */
+        MqttTimerPubStart();
 
         while(1){
 

 

Environment : local network (no internet).

                       Mosquitto broker  <-> AP <-> CC3235SFLP

Software :  simplelink_cc32xx_sdk_7_10_00_13 ,  CCS 12.2

Hardware : CC3235SF LP

Thanks.

BR

Trevor

  • Hi,

    There is no limitation that I know.

    From experience, these brokers sometimes hand due to load (especially in non-secured mode).

    What I would do to double check is to use a second LP and set it into an MQTT server (broker) and test those locally.

    Regards,

    Shlomi

  • Hi Shlomi, 

    Thanks for your suggestion, when we get the sencod LP we will try to use two LPs for testing

    Do you have any error handling suggestions regarding MQTT_IF_Publish() not returning?

    Thanks.

    BR

    Trevor

  • Hi,

    Unfortunately I do not see any debug messages to open internally.

    I would maybe start with opening the Wi-Fi layer debugging at wifi_settings.h.

    It has WIFI_IF_DEBUG_LEVEL set to E_INFO which means any message that is E_INFO and above is printed.

    Maybe try to set it to the lower level E_TRACE, recompile, link and see if you get more meaningful messages.

    Shlomi