MQTT can't get the full data for subscribed topics

Hi, 

I'm using nRF9160, NCS2.2.0, and using serial_lte_modem sample.

Recently, I have developed a program for MQTT, and I encountered the following phenomenon.

1. nRF9160 subscribed to a topic.

2. I send some data to the topic.

3. When the size of this data exceeds 670 Bytes, nRF9160 only read a part of this data, and the rest of this data is unreadable.

I debug the code to locate the following problem:

In file slm_at_mqtt.c, path: ${NCS_ROOT}/nrf/applications/serial_lte_modem/src/mqtt_c/slm_at_mqtt.c:92

do {
		ret = mqtt_read_publish_payload(c, rsp_buf, sizeof(rsp_buf));
		if (ret > 0) {
			data_send(rsp_buf, ret);
			size_read += ret;
		}
	} while (ret >= 0 && size_read < evt->param.publish.message.payload.len);

Firstly, I calll mqtt_read_publish_payload() to get this data, the 'ret' return 570, it is means i get 570Bytes from MQTT, but I send size is 670 Bytes.

Then, continue reading data, but the 'ret' return a negative error code(-11).

Finally, the MQTT disconnect.

How do I get the rest of this data?

Best Regards,

Yang Hu

Parents Reply
  • Hi Hakon,

    I use serial-lte-modem sample to record some modem trace.

    1. NCS version: V2.2.0

    2. nRF9160 modem version: V1.3.2

    3. Board: nrf9160dk_nrf9160_ns

    In the serial-lte-modem sample,  I modified nrf9160dk_nrf9160_ns.conf

    CONFIG_SLM_CONNECT_UART_0=y
    CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2
    CONFIG_UART_0_NRF_HW_ASYNC=y
    CONFIG_SLM_WAKEUP_PIN=6
    CONFIG_SLM_INDICATE_PIN=2
    CONFIG_CONSOLE=y
    CONFIG_SLM_EXTERNAL_XTAL=y
    CONFIG_SLM_LOG_LEVEL_DBG=y
    CONFIG_SLM_TWI=n
    CONFIG_MODEM_KEY_MGMT=y
    CONFIG_SLM_MQTTC_MESSAGE_BUFFER_LEN=1024
    CONFIG_NRF_MODEM_LIB_TRACE_ENABLED=y
    CONFIG_SLM_MQTTC_MESSAGE_BUFFER_LEN=1024
    CONFIG_NRF_MODEM_LIB_TRACE_ENABLED=y

    I carried out several tests, here are the modem trace files:

    serial-lte-modem modem trace.zip

Children
Related