Using AT commands to connect to an MQTT broker

I am using P822601 board (with nRF9160 chip).
Sample project "Serial lte modem" (SDK 1.8).
I'm trying to connect to a test mqtt broker (mosquitto) using AT commands via LTE Link Monitor, but with no success.
Using the "MQTT_AT_commands.rst" document, I similarly prepared a command to connect:

AT#XMQTTCON=1,"mqtt.mosquitto.org","SJ","SJ75747723","test.mosquitto.org",1883

But the result for the command is always the same: ERROR.
I'm not sure about the sequence of AT commands needed to work correctly with MQTT.
1) Could you please indicate the necessary sequence of commands required for the correct configuration and work with MQTT.

2)  The SIM card (iBASIS eSIM) used can be deactivated for some reason?



  • Hello Stas,

    1) Could you please indicate the necessary sequence of commands required for the correct configuration and work with MQTT.

    I have tested this myself with a nRF9160 DK and the Serial LTE modem application in NCS v1.8.0 and it works as expected, see log below:

    *** Booting Zephyr OS build v2.7.0-ncs1  ***
    Ready
    [00:00:00.205,871] <inf> slm: Serial LTE Modem
    [00:00:00.234,954] <inf> slm_at_host: at_host init done
    
    AT+CEREG=5
    OK
    
    AT+CFUN=1
    OK
    
    +CEREG: 2,"76C1","03113C00",7
    +CEREG: 1,"76C1","03113C00",7,,,"00001010","11000001"
    
    AT#XMQTTCON=1,"MyMQTT-Client-ID","","","test.mosquitto.org",1883
    OK
    #XMQTTEVT: 0,0
    
    AT#XMQTTCON=0
    #XMQTTEVT: 1,0
    OK
    
    [00:01:15.500,396] <err> slm_mqtt: POLLNVAL
    [00:01:15.500,427] <inf> slm_mqtt: MQTT thread terminated

    Port 1883 of test.mosquitto.org is “MQTT, unencrypted, unauthenticated”, so no username and passwort needed. For more information, see https://test.mosquitto.org/. I’m not sure if “mqtt.mosquitto.org” is a good idea for a client-id, nor if it is accepted by the server.

    2)  The SIM card (iBASIS eSIM) used can be deactivated for some reason?

    I’m not sure if I understand this question. Can you elaborate?

    Regards,

    Markus

Related