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 Children
  • I don't have access to NB-IoT. I'm trying to reproduce with LTE-M, but it's possible that the problem is specific to NB-IoT.

  • 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

Related