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

Parents
  • 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

Reply
  • 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

Children
  • "I see for example a "#XMQTTEVT: 1,-128" response and can't work with SLM's MQTT anymore"

    MQTT event type: MQTT_EVT_DISCONNECT, result: -128 (ENOTCONN)

    MQTT client lose connection to the broker.

    "I have tested this also with a public MQTT broker without TLS. Once I disconnect the MQTT client, I cannot restart another MQTT session"

    Please wait to test MQTT in NCSv1.7.0 in which re-connect to MQTT broker is now possible.

    Or you can try SLM in NCS master now.

Related