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.

Compiler/CC3220SF: Not able to transmit more than 32kb of data over mqtt.

Part Number: CC3220SF

Tool/software: TI C/C++ Compiler

Hello 

I am using CC3220sf for one of our projects and need to transmit around 60-70kb of data in a single packet over wifi using MQTT. However I am not able to transmit more than 32kb of data in a single packet. Since its going to be a battery operated device, every wifi transmission amounts to power consumption. 

Upon inspection it was found that there is a restriction on buffer size in MQTT libraries of the SDK. The size was initially hardcoded to 1024 bytes. I tried changing the value to 65k by recompiling the libraries. It complies fine and in the memory allocation window in CCS I can verify the increase in size as well. But when I try to publish data more than 32kb, the MQTT publish fails with error codes of  -1 or -7.

I am using  simplelink_cc32xx_sdk_3_30_01_02  and CCS Version: 9.2.0.00013.

Any advice would be highly appreciated.

Thanks

  • Yes, the MQTT library is currently limited to 32KB messages.

    The library tries to send the entire message in one socket send command. The limitation is on the sl_Send command.

    Regarding the power consumption, please note that the MQTT message will anyway get fragmented to smaller WiFi frames (per Wi-Fi MTU  ~ 1460B), so if you are able to split the your MQTT payload to 2 messages the difference will basically be the extra MQTT header. 

    Br,

    Kobi

  • Hello 

    Thanks a lot for clarification on that.

    I am facing one more issue with MQTT-not sure whether to create another thread for the issue or not.  My device needs to go in hibernate mode at regular intervals of time. Upon wakeup I am trying to do a auto/fast connection with the access point which works I guess, as I am able to get the IP address . However when I try to connect the MQTT client with the broker, the application gets stuck in infinite loop.

    The similar behavior is there even when a reconnect attempt is made  after a MQTTClient_DISCONNECT_CB_EVENT is received. To make MQTT connect with broker I need to re-establish the Wi-fi connection, as-in the first time after power-on, which takes relatively long time to connect with the access-point. 

    Could you provide some idea on this as well or are aware of any such behavior?

    Thanks and Regards

    Aditya 

  • Hi,

    Are you disconnecting from the server before going to hibernate?

    If you will not disconnect (before going to hibernate) and the MQTT keep alive interval is longer than the hibernate interval, than the server will keep the previous connection and trigger a disconnection upon the new connection.

    When you get the MQTTClient_DISCONNECT_CB_EVENT, are  you trying to call connect from the event callback or are you signalling another thread to call the Connect? Please make sure the 2nd option is used.

    Br,

    Kobi

  • Hello,

    I tried the iteration you suggested. I am disconnecting from server and deleting the Client before going to hibernate(getting the MQTTClient_DISCONNECT_CB_EVENT). After reboot, my steps are as follows:

    1. sl_Start(0, 0, 0),
    2. wait till IP is acquired
    3. Fetch IP and MAC-address
    4. sl_stop(),
    5. sl_start(NULL,NULL,NULL)
    6. and then proceed forward with making connection with the broker. When "MQTTClient_connect" is called, I am getting -2022 error code in return which is for SL_RET_CODE_DEVICE_STAT_IN_PROGRESS, along with MQTTClient_DISCONNECT_CB_EVENT.

    I have not initialized any keep alive interval. I read back its default value and its coming as 0. Also MQTTClient_connect gets called in a separate thread and not from the callback.

    Am I missing something here?

    Thanks

    Aditya

  • Are you calling sl_WlanRxStatStart() anywhere in your code? (this is the only reason for getting the -2022 error code).

    When you call disconnect, please wait till the MQTTClient_run() returns (this will happen following the MQTTClient_DISCONNECT_CB_EVENT) before going to hibernate.

    Why do you need state 4 & 5 ?

  • Hello

    I am not calling sl_WlanRxStatStart() anywhere in my application. Maybe the sl stack calls it internally somewhere? 

    And MQTTClient_run() is also returning before going to hibernate.

    Regarding step 4 and 5, that is just an observation which I was testing as I saw this being done, in few of the example codes, following step 3, to see whether that would make a difference.

    Regards

    Aditya  

  • Please try to debug inside the MQTTClient_run() call to find the exact point of failure. You can find the mqtt_client sources under source/ti/net/mqtt/ and you can add them to your project with more log messages (you will need to add the mqtt headers folder to the project properties / include options). 

    Another option to debug this is using the NWP logs (please check chapter 20.1 in http://www.ti.com/lit/ug/swru455j/swru455j.pdf?ts=1588609495378 for details.

    Br,

    Kobi