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

Setup nRF Cloud with own boards by using AT commands

We have developed our own application board with the nRF9160 on it according to the reference design.

The modem is connected to an application controller by UART (no HW Ctrl pins) and I have the same UART to connect from outside.

I wanted to know if it is possible to connect it to the nRF Cloud for test reasons (just send some packages)

For the moment I use the "Serial LTE modem" Software (removed RTS/CTS) to send AT commands from application controller.

In general I can get a connection with the LTE/NB-ioT and get an IP address.

Questions:

- Is it possible to connect to the nRF Cloud just using AT commands?

- How can I use / update a certificate (only AT)?

- How do the packages look like that must be sent (by AT)?

Thanks for helping...

Regards,

Bernd

  • Hi Øyvind,

    Because it seems that there is a more basic problem with connecting I have setup an AWS thing and try to connect it with MQTT AT commands and the FOTA example. I cannot get a connection in general.

    MQTT FOTA Sample Settings
    ■ Security tag for TLS credentials <CERT_SEC_TAG> 1000
    Custom MQTT client ID <USE_CUSTOM_CLIENT_ID> 
    ■ Client ID <CLIENT_ID> nRF9160_BMS
    ■ AWS IoT MQTT broker hostname <MQTT_BROKER_HOSTNAME> a2lfsfrs57xcmu-ats.iot.eu-central-1.amazonaws.com
    ■ AWS IoT MQTT broker port <MQTT_BROKER_PORT> 8883
    ■ MQTT message buffer size <MQTT_MESSAGE_BUFFER_SIZE> 256
    ■ MQTT payload buffer size <MQTT_PAYLOAD_BUFFER_SIZE> 256

    The FOTA returns:

    SPM: NS image at 0x20200
    
    
    
    
    SPM: NS MSP at 0x2001e248
    
    
    
    
    SPM: NS reset vector at 0x25c91
    
    
    
    
    SPM: prepare to jump to Non-Secure image.
    
    
    
    
    *** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
    
    
    
    
    MQTT AWS Jobs FOTA Sample, version: v1.0.0
    
    
    
    
    Initializing modem library
    
    
    
    
    Initialized modem library
    
    
    
    
    LTE Link Connecting ...
    
    
    
    
    LTE Link Connected!
    
    
    
    
    IPv4 Address 35.156.166.89
    
    
    client_id: nRF9160_BMS
    
    
    
    
    ERROR: mqtt_connect -111

    What could be the problem?

    Regards,

    Bernd

  • Hello Bernd,

    I'll let Øyvind confirm but what I remember, MQTT connect error -111 means connection refused.
    This could be related to wrong/missing provisioning / registration of your nRF9160 on AWS.


    I am digging into this as well now.

    Best regards,
    Kevin

  • Hello Bernd and Kevin, 

    Kevin Kotinkar said:
    MQTT connect error -111 means connection refused.
    This could be related to wrong/missing provisioning / registration of your nRF9160 on AWS.

    Yes, this is correct. 

    I'm currently trying to find some more answers from our developers as well.  

     

    Bernd said:
    MQTT FOTA Sample Settings

     Do you mean AWS FOTA sample? Are you trying to connect nRF Cloud or AWS? 

    Thanks.
    -Øyvind

  • Hello Øyvind,

    seems that the certificates are deleted / damaged if I do an over-programming with the debugger (but they are still listed with "AT%CMNG=1"?)

    I programmed first the AWS FOTA sample and then overwrite the certificates - now it connects correctly.

    client_id: nRF9160_BMS
    
    
    
    
    [mqtt_evt_handler:120] MQTT client connected!
    
    
    [mqtt_evt_handler:177] SUBACK packet id: 2112
    
    
    [mqtt_evt_handler:177] SUBACK packet id: 2114
    
    
    [mqtt_evt_handler:167] PUBACK packet id: 34934
    
    
    
    
    [mqtt_evt_handler:182] default: 9
    
    
    
    

    I used the AWS FOTA sample & AWS because I have more possibilities to setup the cloud.

    So in general the AWS and the MQTT connection works.

    Unfortunately the AWS FOTA software does not accept any MQTT AT commands and quit with error -8

    AT#XMQTTSUB="xyz",1
    
    
    
    
    E: Error while processing AT command: -8

    Can't this not be used together?

    Are the MQTT AT commands not active? Any switch to select or do I have to add this manually?

    If I go back to Serial LTE modem software, programming the certificates and using this MQTT commands it still says just error

    Do I need a TLS socket before I can connect?

    Something like "AT#XSSOCKET=1,1,1,1000,0" ?

    Assuming that the command

    "AT#XMQTTCON=1,"nRF9160_BMS","","","a2lfsfrs57xcmu-ats.iot.eu-central-1.amazonaws.com",8883,1000"

    is doing the same as the "err = mqtt_connect(&client);" there must be a difference which I do not see at the moment...

    Could you or your developers setup a connection to any AWS thing just using the ATs?

    Regards,

    Bernd

  • Hello Bernd, hello Øyvind,

    I wanted to share some of my latest results:


    1.) I am able to connect to the nRF cloud using SLM and AT Commands, at least I succeed initially. The MQTT client ID seems to be important as well, and has to match with what you configure on nRF cloud:

    My AT command is:
    (client-ID is: nrf-<IMEI of the nRF9160>)
    AT#XMQTTCON=1,"nrf-352656106651436","","","a2n7tk1kp18wix-ats.iot.us-east-1.amazonaws.com",8883,16842753

    Response is:
    #XMQTTEVT: 0,0

    I noticed that I have to publish/subscribe to the right topics in order to continue manually, will need to further investigate here.

    2.) However, if something is wrong on the input, I see for example a "#XMQTTEVT: 1,-128" response and can't work with SLM's MQTT anymore. I cannot disconnect using AT#XMQTTCON=0 or connect again. I have tested this also with a public MQTT broker without TLS. Once I disconnect the MQTT client, I cannot restart another MQTT session.
    I have to reset the nRF9160 DK in order to use the MQTT AT commands again, otherwise I always get an "ERROR".

    (I am using the SLM of NCS SDK 1.6.0)

    Are the MQTT AT commands not active?

    @Bernd - the SLM application basically wraps AT commands around the MQTT libraries, so these AT commands are specific to the application, not to the modem. Thus, wenn running the AWS FOTA application, I believe you do not have them available by default .

    Do I need a TLS socket before I can connect?

    No, I didn't need to set this up. Within SLM this is done in the background of the MQTT AT command.

    Best regards,
    Kevin

Related