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
  • Hello,

    can you do a modem trace so I can check what's going on in the modem?

  • 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

  • Also, I run into some issues when sending the data from the serial terminal directly. How do you send 670+ bytes to the SLM?

  • If you are sending more than 256 bytes of data to the slm via the serial port, you need to enter data mode first and then exit data mode after sending the data. 

    Refer here: developer.nordicsemi.com/.../slm_data_mode.html

    And currently it is not the receiving of data from the serial port that causes the disconnection, but the receiving of data from a subscribed topic that causes the disconnection.

  • Harvey Zheng said:
    If you are sending more than 256 bytes of data to the slm via the serial port, you need to enter data mode first and then exit data mode after sending the data.

    Are you sure that you need to manually set it to data mode when using AT#XMQTTPUB? It says in the documentation that it will be set to data mode automatically when using MQTT publish.

  • When AT#XMQTTPUB does not carry a message, slm will automatically enter data mode.

    Maybe my description here is misleading. When the device subscribes to the /cgw/cmd-request/cgw/351358811068466/cmd-request topic, I used MQTTX to post data to this topic and the device is having this problem when receiving it.

    Topic: cgw/cmd-request/cgw/351358811068466/cmd-request

    Data(Hex): 24000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f000300000000000324000000090000003f0003000000000003

  • Okay, now it makes more sense. I will try to reproduce it then.

Reply Children
No Data
Related