AT commands sequense for SIM7600 to connect to IoT Hub over MQTT?

Selvin Furtado 20 Reputation points
2023-03-31T18:31:01.94+00:00

Have tried the following sequence of AT commands, the connection keeps closing. Please tell me where I'm going wrong.

23:22:08.825 -> AT

23:22:08.825 -> OK

23:23:05.805 -> AT+CSQ

23:23:05.805 -> +CSQ: 20,99

23:23:05.805 ->

23:23:05.805 -> OK

23:24:40.356 -> AT+CREG?

23:24:40.356 -> +CREG: 0,1

23:24:40.356 ->

23:24:40.356 -> OK

23:27:11.411 -> AT+CGREG?

23:27:11.411 -> +CGREG: 0,1

23:27:11.411 ->

23:27:11.411 -> OK

23:29:45.275 -> AT+CGSOCKCONT=1,"IP","www"

23:29:45.320 -> OK

23:29:59.902 -> AT+CGPADDR

23:29:59.902 -> +CGPADDR: 1,0.0.0.0

23:29:59.902 -> +CGPADDR: 2,36.2.129.0.103.113.245.137.0.0.0.11.32.62.58.1

23:29:59.902 -> +CGPADDR: 3,0.0.0.0,0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0

23:29:59.902 ->

23:29:59.902 -> OK

23:33:44.184 -> AT+CGACT?

23:33:44.184 -> +CGACT: 1,0

23:33:44.184 -> +CGACT: 2,1

23:33:44.184 -> +CGACT: 3,0

23:33:44.184 ->

23:33:44.184 -> OK

23:36:47.204 -> AT+CSSLCFG="sslversion",0,4

23:36:47.204 -> OK

23:38:29.182 -> AT+CSSLCFG="authmode",0,1

23:38:29.182 -> OK

23:38:44.781 -> AT+CCERTLIST

23:38:44.781 -> +CCERTLIST: "BaltimoreCyberTrustRoot.crt.pem"

23:38:44.827 ->

23:38:44.827 -> OK

23:38:58.324 -> AT+CSSLCFG="cacert",0,"BaltimoreCyberTrustRoot.crt.pem"

23:38:58.369 -> OK

23:40:03.615 -> AT+NETOPEN

23:40:03.655 -> OK

23:40:03.882 ->

23:40:03.882 -> +NETOPEN: 0

23:40:54.885 -> AT+NETOPEN?

23:40:54.885 -> +NETOPEN: 1

23:40:54.885 ->

23:40:54.885 -> OK

23:41:42.751 -> AT+CMQTTSTART

23:41:42.797 -> +CMQTTSTART: 0

23:41:42.797 ->

23:41:42.797 -> OK

23:41:54.708 -> AT+CMQTTACCQ=0, "DemoDevice01"

23:41:54.755 -> OK

23:44:20.600 -> AT+CMQTTSSLCFG=0,0

23:44:20.600 -> OK

23:46:15.902 -> AT+CMQTTWILLTOPIC=0,38

23:46:15.948 -> >devices/DemoDevice01/messages/events/

23:46:50.072 -> OK

23:47:37.671 -> AT+CMQTTWILLMSG=0,17,1

23:47:37.671 -> >SIMCOM Connected!

23:47:47.848 -> OK

23:48:55.344 -> AT+CMQTTCONNECT=0,"tcp://#####.azure-devices.net:8883",90,1,"aunoaiothubprod.azure-devices.net/DemoDevice01/?api-version=2018-06-30","SharedAccessSignature sr=#####.azure-devices.net%2Fdevices%2FDemoDevice01&sig=#####&se=1687198367"

23:48:55.344 -> OK

23:48:56.668 ->

23:48:56.668 -> +CMQTTCONNECT: 0,6

23:48:56.668 ->

23:48:56.668 -> +CMQTTCONNLOST: 0,1

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,176 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 32,011 Reputation points MVP
    2023-03-31T22:15:17.9733333+00:00

    Hello @Selvin Furtado ,

    I have no experience with these AT commands for this specific module but please check out this high-level introduction to the MQTT topics of the Azure IoT Hub.

    The full example (written in C#) is seen on GitHub.

    There it occurs to me more recent API is used:

    var user_name = $"{settings.hostName}/{settings.clientId}/?api-version=2021-04-12";
    
    

    I recommend testing with the C# version first so you learn about the MQTT interface first before proceeding to the AT commands.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


4 additional answers

Sort by: Most helpful
  1. Anders Nordberg Lauritsen 26 Reputation points
    2024-08-22T08:20:10.3966667+00:00

    I have just been working the exact same problem, but with a SIM7670. Only difference it that I use X509 certs for auth instead of symmetric keys. The commands are more or less the same, so the issues might also be. What made it work for my solution was:

    The SIM7670 modem use MQTT 3.1 as default protocol. IoTHub requires MQTT 3.1.1, so to change the protocol I needed to call:

    AT+CMQTTCFG="version",0,4

    The call must be after the +CMQTTACCQ command, but before the +CMQTTCONNECT.

    I also think that SNI must be enabled, but I am not 100% sure that this was an issue:

    AT+CSSLCFG="enableSNI",0,1

    1 person found this answer helpful.

  2. Sedat SALMAN 13,740 Reputation points
    2023-03-31T20:21:49.5933333+00:00

    The reason code for disconnection is 1, which usually indicates that the connection was closed by the server.

    the reason can be

    • Incorrect MQTT credentials
    • Verify that the SSL/TLS configuration is correct, including the certificate used
    • The keep-alive timeout (90 seconds in your case) might be too short.
    • nsure that your IoT Hub instance does not have any restrictions, such as a device limit or throttling, which could cause the connection to be closed.
    • nsure that your IoT Hub instance does not have any restrictions, such as a device limit or throttling, which could cause the connection to be closed.

  3. Noushad 0 Reputation points
    2024-07-18T13:37:45.46+00:00

    @Selvin Furtado

    I am facing the same problem. Have you solved this problem now?

    my console output mentioned below:

    [17:58:29.820]OUT¡ú¡óAT+CSSLCFG="sslversion",0,3

    ¡õ

    [17:58:29.836]IN¡û¡ô

    OK

    [17:58:37.559]OUT¡ú¡óAT+CSSLCFG="authmode",0,1

    ¡õ

    [17:58:37.573]IN¡û¡ô

    OK

    [17:58:44.517]OUT¡ú¡ó AT+CSSLCFG="cacert",0,"server_ca.pem"

    ¡õ

    [17:58:44.532]IN¡û¡ô

    OK

    [17:58:57.005]OUT¡ú¡óAT+CMQTTSTART

    ¡õ

    [17:58:57.026]IN¡û¡ô

    +CMQTTSTART: 0

    OK

    [17:59:08.927]OUT¡ú¡óAT+CMQTTACCQ=0,"adapter3_test",0,4

    ¡õ

    [17:59:08.941]IN¡û¡ô

    OK

    [17:59:20.166]OUT¡ú¡óAT+CMQTTSSLCFG=0,0

    ¡õ

    [17:59:20.178]IN¡û¡ô

    OK

    [17:59:26.350]OUT¡ú¡óAT+CMQTTWILLTOPIC=0,29

    ¡õ

    [17:59:26.361]IN¡û¡ô

    [17:59:33.391]OUT¡ú¡ódevices/adapter3_test/messages/events/

    ¡õ

    [17:59:33.405]IN¡û¡ô

    OK

    [17:59:40.623]OUT¡ú¡óAT+CMQTTWILLMSG=0,17,1

    ¡õ

    [17:59:40.635]IN¡û¡ô

    [17:59:47.583]OUT¡ú¡ósimcomwillmessage

    ¡õ

    [17:59:47.596]IN¡û¡ô

    OK

    [17:59:59.130]OUT¡ú¡óAT+CMQTTCONNECT=0,"tcp://on*******######.azure-devices.net:8883",900,0,"one#######b.azure-devices.net/adapter3_test/?api-version=2021-04-12","SharedAccessSignature sr=onese####.azure-devices.net%2Fdevices%2Fadapter3_test&sig=Bigz8E##############d1%2Bpi%2BFMkjc%3D&se=1735626676"

    ¡õ

    [17:59:59.171]IN¡û¡ô

    OK

    [18:00:02.969]IN¡û¡ô

    +CMQTTCONNECT: 0,6

    +CMQTTCONNLOST: 0,1

    I would sincerely appreciate assistance from someone.

    0 comments No comments

  4. Altay 0 Reputation points
    2024-08-14T14:00:51.5933333+00:00

    I'm having the exactly the same issue. Anyone able to solve this? A help would be really appreciated.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.