This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

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
  • Hi!

    Thanks for reaching out. The "#XMQTTEVT: 9,0" response is a MQTT_EVT_PINGRESP event, originating from the connection regurarly pinging the broker. Hence, it should be unrelated to the issue you are facing. On that note, are you able to read out the log over the RTT interface? That could give more insight into what's actually happening. Please replace CONFIG_SLM_LOG_LEVEL_INF=y with CONFIG_SLM_LOG_LEVEL_DBG=y in the prj.conf.

    I will report the JSON issue to the developers. What error are you getting?

    Best regards,
    Carl Richard

Reply
  • Hi!

    Thanks for reaching out. The "#XMQTTEVT: 9,0" response is a MQTT_EVT_PINGRESP event, originating from the connection regurarly pinging the broker. Hence, it should be unrelated to the issue you are facing. On that note, are you able to read out the log over the RTT interface? That could give more insight into what's actually happening. Please replace CONFIG_SLM_LOG_LEVEL_INF=y with CONFIG_SLM_LOG_LEVEL_DBG=y in the prj.conf.

    I will report the JSON issue to the developers. What error are you getting?

    Best regards,
    Carl Richard

Children
No Data
Related