Serial LTE Modem + MQTT subscribe

I have an embedded Linux platform which uses an nRF9160 connected via UART. The nRF9160 has been loaded with the serial LTE modem firmware, version 1.3.1.

I've been experimenting with the AT command for MQTT. So far, I've been able to set up the necessary credentials and connect to my AWS account. I have also been able to publish MQTT messages, only HEX and ASCII. If I send a JSON message, the firmware generates an error -- It doesn't attempt to send out LTE, it seems to just error before that. However, I've been able to encode JSON into a hex message and send that way -- AWS actually interprets this as JSON.

Today, I was attempting to demo the MQTT subscribe. When I do this, I get an unexpected response, and the connection to AWS terminates. My security profile for publish and subscribe are the same, but I can't subscribe. I am using a Linux system for this. I've provided some example output for some helper tools I've written.

root@beaglebone:~/swedar_sirius_linux/build# ./mqtt_connect 1 client-lte a3g5x5to9ttni4-ats.iot.us-west-2.amazonaws.com 8883 1984
~~~~~
OK<CR><LF>
#XMQTTEVT: 0,0<CR><LF>
~~~~~
Connected

root@beaglebone:~/swedar_sirius_linux/build# ./lte AT#XMQTTCON?
#XMQTTCON: 1,"client-lte","a3g5x5to9ttni4-ats.iot.us-west-2.amazonaws.com",8883,1984
OK

root@beaglebone:~/swedar_sirius_linux/build# ./mqtt_subscribe -t swedar-full -q 0
command = AT#XMQTTSUB="swedar-full",0
#XMQTTEVT: 9,0<CR><LF>
Timeout!
Timeout!

The `XMQTTEVT` that occurs here with this tool is not anywhere in the docs. I don't know what this means outside of it didn't work.

For this next setup, I connected the same as before, and published a message just to see it was working, then I tried the subscribe another way.

root@beaglebone:~/swedar_sirius_linux/build# ./mqtt_connect 1 client-lte a3g5x5to9ttni4-ats.iot.us-west-2.amazonaws.com 8883 1984
~~~~~
OK<CR><LF>
#XMQTTEVT: 0,0<CR><LF>
~~~~~
Connected

root@beaglebone:~/swedar_sirius_linux/build# ./mqtt_publish -t swedar-full -d test.txt -q 1
command = AT#XMQTTPUB="swedar-full",1,"Hello from Sirius!",1,0
~~~~~
OK<CR><LF>
#XMQTTEVT: 3,0<CR><LF>
~~~~~
Message acknowledged

root@beaglebone:~/swedar_sirius_linux/build# ./lte -z AT#XMQTTSUB=\"swedar-full\",0
OK
#XMQTTEVT: 1,-128

This indicates the connection is gone. What is the error code? Any idea why the subscribe command would error?

Parents
  • Hello,

    I updated the serial LTE firmware to 1.4.1 and the modem firmware to 1.2.3. I still had the same successes and the same failures with this version.

    I'm not that familiar with customizing the nRF9160 firmware. Where would I modify CONFIG_SLM_LOG_LEVEL_INF=y? I will do the mod and reflash the unit and report back any new info.

Reply
  • Hello,

    I updated the serial LTE firmware to 1.4.1 and the modem firmware to 1.2.3. I still had the same successes and the same failures with this version.

    I'm not that familiar with customizing the nRF9160 firmware. Where would I modify CONFIG_SLM_LOG_LEVEL_INF=y? I will do the mod and reflash the unit and report back any new info.

Children
  • Hi again!

    The SLM firmware has gotten quite a lot of updates in the master branch of NCS (v1.4.99-dev1), so I would recommend trying out that aswell.

    As for the logging you can navigate to the serial LTE monitor project folder (should be located at <ncs_root>/nrf/applications/serial_lte_modem) and open the file prj.conf in a text editor. Find CONFIG_SLM_LOG_LEVEL_INF and replace it with CONFIG_SLM_LOG_LEVEL_DBG. Then you must rebuild the application. If you use Segger Embedded Studio the project must be reloaded before rebuilding.

    Please inform me if you face any difficulities!

    Best regards,
    Carl Richard

  • Hello,

    I tried out the v1.4.990-dev1 today. Commands like #XFTP and #XMQTTCON are now consistently just reporting ERROR which isn't helpful. In the last version v1.4.1, I noticed the connect command now required a username and password, so I added that. It would connect ok all the time.

    I didn't notice any new characters when I enter commands with the CONFIG_SLM_LOG_LEVEL_DBG line. I can tell the modem version with AT+CGMR. Is there a command to get back the 1.4.99? I'm programming our boards nRF9160 via a JTAG using the debug out on the nRF9160-dk board.

  • Hi!

    My apologies. To use MQTT with SLM on v1.4.990-dev1 it must be configured by adding CONFIG_SLM_MQTTC=y in the prj.conf file. Just append it at the end. 

    The debug log of the Serial LTE Modem are written to RTT over the SWD interface, as the serial interface are used only for the modem functionality. To read the log you can use the Segger RTT Viewer program while your board is connected to the nRF9160DK board with JTAG. You can read more about how you can use the RTT viewer here.

    Best regards,
    Carl Richard

Related