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.

BOOSTXL-CC3135: MQTT publish MAX Size failure

Part Number: BOOSTXL-CC3135
Other Parts Discussed in Thread: CC3135

Hi, 

I am trying to evaluate the MQTT example that I found under this link: 

simplelink_sdk_wifi_plugin_2_40_00_22\examples\rtos\MSP_EXP432E401Y\demos\mqtt_client, 

In this example, I modified the mqtt_client_app source file in order to publish an MQTT message with different size. 

I tried with size more than 1024 bytes, and then I understood that I must define a CFG_SL_CL_BUF_LEN user value, 

so, I  created a new definition of CFG_SL_CL_BUF_LEN with a value equal to 29000 and it seems that my change is correct, i.e.: I am able to publish buffer of 29KB. 

Next, I have to enlarge this size more and more, and this to publish a message with a maximum size 40KB. 

so I modified the CFG_SL_CL_BUF_LEN  to 40000 , and then, when I try to publish my MQTT message, it returns a failure equal to SLNETERR_BSD_SOC_ERROR. 

and when I debug the MQTT procedure, I found that this error appears in the sl_Send function, in this case : if(Len < 1) { /* ignore */ return(0); } ( sl_socket.c file, ligne 673). 

Let me explain more, the Len variable is declared as _i16 and for sizes more than 0x7FFF, it becomes negative value. 

I tried to cast this variable ( to _u16) before this check (if((_u16)Len < 1) ), and in this case, the function returns the sent size, declared also as _i16, and all of the MQTT procedure checks if it is negative. 

So as long as I sent this "negative size" ( higher than 0x7FFF), the Mqtt publish function returns failure and it closes the MQTT communication. 

So How Can I Publish MQTT messages with size more than 0x7FFF ? 

In the SlNetIfWifi_send function defined in the slnetiwifi.c file, len variable is declared as uint32_t, in this case how can I send a message with size declared as uint32_t, knowing that sl_Send supports only _i16 ? 

What is the maximum size supported in TCP socket  layer ? 

What is the maximum size supported in the MQTT client library ? 

Best Regards. 

Ghada 

  • HI Ghada,

    The sl_Send() function previously supported only sending the max payload length for the packet type you were using. Later NWP servicepack updates removed that limitation, but the issue is that the host driver interface only uses that int16 size, for backwards compatibility purposes. This is why the sl_send() size is capped the way it is.

    Since sl_Send() is capped, you could edit the SlNetIfWifi_send() function to split up an individual send into multiple smaller chunks as needed to perform sl_Send() calls on. Have you tried doing that?

    See this post of max packet payload sizes: e2e.ti.com/.../462214

    I'll need to investigate to see what is the max size in the MQTT client library, but it probably is defined by a buffer size setting.

    Regards,

    Michael

  • Hi 

    Thank you first for your response, 

    Unfortunately, the edition of the SlNetIfWifi_send() function does not resolve the problem. 

    In fact, and all of SlNetIfWifi_send, SlNetSock_send, MQTTNet_tcpSend, netSend function prototypes are declared so that the len is uint32_t and the returned value is int32_t, theses functions are defined respectively in slnetifwifi.c , slnetsock.c, mqtt_net_func.c, client_core.c files as below: 

    int32_t SlNetIfWifi_send(int16_t sd, void *sdContext, const void *buf, uint32_t len, uint32_t flags)

    int32_t SlNetSock_send(int16_t sd, const void *buf, uint32_t len, uint32_t flags)

    int32_t MQTTNet_tcpSend(int32_t comm, const uint8_t *buf, uint32_t len, void *ctx)

    static inline int32_t netSend(int32_t net, const uint8_t *buf, uint32_t len, void *ctx)

    In success send case, all of theses functions should return the size of packets that is successfully sent, 

    so if the uint32_t Len = 0x8000, the int32_t returned value will be equal to 0xFFFF8000, and the MQTT  library checks if it is negative for failure treatment. 

    Regards, 

    Ghada 

  • Hi Ghada,

    I'm not sure how the int32_t value will be a negative number when returned from those functions. 0x8000 when converted from a unsigned to signed 32 bit int will still be 0x8000. Do you mind showing some code snippets to illustrate the new issue you are running into after editing SlNetIfWifi_send()?

    Regards,

    Michael

  • Hi 

    Sorry for the late response, 

    Below a screen shot of my debug case, 

    I have just modified the sl_Send function as below, and this, to ignore just the zero length value, and to send the whole packet in only one SPI transmit, 

    if(Len == 0) /* (Len < 1) */
    {
    /* ignore */
    return(0);
    }

    and below the result which shows that the returned value is negative number (0xFFFF8000) : 

    as you can see, in the Watch tab, the value of len = 0x00008000, contrariwise, the value of the retVal = 0xFFFF8000 and it is treated as an error code in the mqtt library.

    Note that I am using IAR embedded Workbench (version 8.22.1) and I am interfacing the CC3135 Boost-XL module with an STM32 micro-controller. 

    I am not sure that the modification of the  SlNetIfWifi_send will solve my issue, the returned value is always defined as int32_t, and it will be automatically converted to negative value. In addition, for throughput purpose, it is better to send data in one shot and not with capped manner. 

    Regards, 

    Ghada 

  • Hi 

    It's been more than a week that I have not received any feedback from you or from TI support.

    Can you help me please ? 

    Regards, 

    Ghada