BG96 can't connect to AWS iot core +QMTOPEN: 0,3 ever

Hello I follow the “example of MQTT Operation with SSL” into document “BG96_MQTT_App_note_v1.1.pdf” but it don’t works

well my problem is that ever I do:
AT+QMTOPEN=,<aws_host>,8883

+QMTOPEN 0,3 means:
+QMTOPEN <TCPConnectID>, <err_code>

from documentation: errr_code is 3

  • Check whether the inputted user name and password are correct. NOT APPLY
  • Make sure the client ID is not used. NOT APPLY because i have a variable tcpConnectID
  • Reopen MQTT connection and try to send CONNECT packet to server again. OPEN again when same result…

Also I added the full trace of commands with a posible error at documentation of “Quectel_MQTT_Application_Note_V1.1.pdf” at AT+QSSLCFG=“ignorelocaltime”,1


// boot
resp: RDY (RDY)
AT0
resp: ATE0
resp: OK (ATE0)

AT+CMEE=2
resp: OK (AT+CMEE=2)

AT+COPS=2
resp: OK (COPS=2)

AT+QGPS=1
resp: +QGPS: 0 OK (QGPS?)
resp: ERROR (QGPS)

/////////////////////////////////
// certs upload
resp: OK (QFDEL)
resp: +CME ERROR: Fail to list the file (QFLST)
resp: CONNECT
resp: +QFUPL: 1758,384a
resp: OK (QFUPL)

resp: OK (QFDEL)
resp: +CME ERROR: Fail to list the file (QFLST)
resp: CONNECT
resp: +QFUPL: 1220,3504
resp: OK (QFUPL)

resp: OK (QFDEL)
resp: +CME ERROR: Fail to list the file (QFLST)
resp: CONNECT
resp: +QFUPL: 1675,45d
resp: OK (QFUPL)


/////////////////////////////////
// start gps
AT+QGPS?
resp: +QGPS: 1 OK (GPS?)
resp: APP RDY (APP RDY)


/////////////////////////////////
// GSM 
AT+CPIN?
resp: +CPIN: READY (CPIN)

AT+QCFG="band",00000000F,80000,80000,1
resp OK (QCFG)

AT+QCF="nwscanmode",0,1
resp OK (nwscanmode)

AT+QCFG="nwscanseq",030201,1
resp OK (nwscanseq)

AT+QCFG="iotopmode",2,1
resp OK (iotopmode)

AT+CFUN=1
resp OK (CFUN)

AT+CGDCONT=1,"IP","wlapn.com"
resp OK (CGDCONT)

AT+COPS=0,2
resp OK (COPS)

AT+CEREG?
resp +CEREG: 0,4 OK

AT+CSQ=?
resp +CSQ: (0-31,99),(0-7,99) OK

AT+CGATT?
resp +CGATT: 0 OK

AT+COPS=?
resp +COPS: (1,"Orange SP","ESPRT","21403",0),(1,"Movistar","Movistar","21407",0),(1,"vodafone ES","voda ES","21401",9)


/////////////////////////////////
//// SSL configuration

//AT+QMTCFG="ssl",<TCPConnectID>,<sslenable>,<ssl_ctx_id>
AT+QMTCFG="ssl",0,1,2
resp: OK (mqttssl)

// IMPORTANT:
// TCPConnectID = 0
// ssl_ctx_id = 2


AT+QSSLCFG="cacert",2,"ca.pem"
resp: OK (cacert)

AT+QSSLCFG="clientcert",2,"cc.crt"
resp: OK (clientcrt)

AT+QSSLCFG="clientkey",2,"ck.pem"
resp: OK (clientkey)

AT+QSSLCFG="seclevel",2,2
resp: OK (seclevel)

AT+QSSLCFG="sslversion",2,4
resp: OK (sslversion)

AT+QSSLCFG="ciphersuite",2,0xffff
resp: OK (ciphersuite)


// ALTERNATIVE BOTH TESTED WITHOUT SUCCESS
[
// SAME THAT PDF MQTT (is right?)
//AT+QSSLCFG="ignorelocaltime",<ssl_ctx_id>,<ignoretlime>
> if <ignoreltime> is omitted, query whether the validity check for certification is ignored for
> the specified SSL context 
// POSIBLE ERROR IT SHOULD BE 2 ?
AT+QSSLCFG="ignorelocaltime",1
resp: +QSSLCFG: "ignorelocaltime",1,1 OK (ignorelocaltime)



// SAME PDF SSL
//AT+QSSLCFG="ignorelocaltime",<ssl_ctx_id>,<ignoreltime>
> if <ignoreltime> is not omitted, set whether or not to ignore
> certification validity check for the specified SSL context
AT+QSSLCFG="ignorelocaltime",2,1
]

//AT+QMTCFG="version",<TCPConnectID>,<MQTT_VERSION>
AT+QMTCFG="version",0,4
resp: OK (mqttversion)

//AT+QMTOPEN=<TCPConnectID>,<host>,<port>
AT+QMTOPEN=0,<aws>,8883
resp: OK +QMTOPEN: 0,3 (qmtopen,1)

resp: OK +QMTOPEN: 0,3 (qmtopen,2)
resp: OK +QMTOPEN: 0,3 (qmtopen,3)
resp: OK +QMTOPEN: 0,3 (qmtopen,4)
resp: OK +QMTOPEN: 0,3 (qmtopen,5)
resp: OK +QMTOPEN: 0,3 (qmtopen,6)
resp: OK +QMTOPEN: 0,3 (qmtopen,7)
resp: OK +QMTOPEN: 0,3 (qmtopen,8)
resp: OK +QMTOPEN: 0,3 (qmtopen,9)
resp: OK +QMTOPEN: 0,3 (qmtopen,10)
resp: OK +QMTOPEN: 0,3 (qmtopen,11)
resp: OK +QMTOPEN: 0,3 (qmtopen,12)
resp: OK +QMTOPEN: 0,3 (qmtopen,13)
resp: OK +QMTOPEN: 0,3 (qmtopen,14)
resp: OK +QMTOPEN: 0,3 (qmtopen,15)
resp: OK +QMTOPEN: 0,3 (qmtopen,16)
resp: OK +QMTOPEN: 0,3 (qmtopen,17)
resp: OK +QMTOPEN: 0,3 (qmtopen,18)
resp: OK +QMTOPEN: 0,3 (qmtopen,19)
resp: OK +QMTOPEN: 0,3 (qmtopen,20)
resp: OK +QMTOPEN: 0,3 (qmtopen,21)
resp: OK +QMTOPEN: 0,3 (qmtopen,22)
resp: OK +QMTOPEN: 0,3 (qmtopen,23)
resp: OK +QMTOPEN: 0,3 (qmtopen,24)
resp: OK +QMTOPEN: 0,3 (qmtopen,25)
resp: OK +QMTOPEN: 0,3 (qmtopen,26)
resp: OK +QMTOPEN: 0,3 (qmtopen,27)
resp: OK +QMTOPEN: 0,3 (qmtopen,28)
resp: OK +QMTOPEN: 0,3 (qmtopen,29)
resp: OK +QMTOPEN: 0,3 (qmtopen,30)
resp: OK +QMTOPEN: 0,3 (qmtopen,31)
resp: OK +QMTOPEN: 0,3 (qmtopen,32)
resp: OK +QMTOPEN: 0,3 (qmtopen,33)
resp: OK +QMTOPEN: 0,3 (qmtopen,34)
resp: OK +QMTOPEN: 0,3 (qmtopen,35)
resp: OK +QMTOPEN: 0,3 (qmtopen,36)
resp: OK +QMTOPEN: 0,-1 (qmtopen,37)
resp: OK +QMTOPEN: 0,-1 (qmtopen,38)
resp: OK +QMTOPEN: 0,-1 (qmtopen,39)
resp: OK +QMTOPEN: 0,-1 (qmtopen,40)
resp: OK +QMTOPEN: 0,-1 (qmtopen,41)

Thanks in advanced

Hi stbnrivas

The error code means failed to activate PDP,please try to activate the PDP context by AT+QIACT= and AT+QIACT?.
please refer to the detailed process in section 1.1 in the attachment.
Quectel_BG96_TCP(IP)_Application_Note_V1.2.pdf (727.5 KB)
If the problem persists,please contact our local FAE to get the log tool and they will help to analyze the reason.

B&R

Thanks so much Puck,

just for to be sure, I’m trying to connect through MQTT, Do I need activate the PDP context as I would use TCP? only to said that into document “BG96_MQTT_App_note_v1.1.pdf” don’t appear

AT+QICSGP=<contextID>,<context_type>,<APN>,<username>,<password> //configure a context id cid
AT+QIACT=<contextID> 

Also I don’t how to link contextID with AT+QMT commands because this only speak about TCPConnectID and ssl_ctx_id for ssl.

I found a AT+QMTCFG=“pdpcid” that not appear in example for AWS Iot core but I will give a try…

again thanks

I’m back with more questions:

  1. why into the detailed process in section 1.1 “Quectel_BG96_TCP(IP)_Application_Note_V1.2.pdf” don’t use AT+COPS? TCP/IP don’t need?

  2. into MQTT with SSL have 4 things to configure: Network, TCP, SSL and MQTT… it will useful a state diagram like it has into TCP document. There are some like that?

  3. I’m checking about the ids again…

  • <tcpconnectID> used into QMTOPEN, QMTCONN, QMTSUB, QMTPUB
  • <pdp_cid> used into CGDCONT
  • <sslctxID> used into QSSLCFG
  • <contextID> used into AT+QICSGP

Hi @stbnrivas

please refer to the following answers.

Q1. why into the detailed process in section 1.1 “Quectel_BG96_TCP(IP)_Application_Note_V1.2.pdf” don’t use AT+COPS? TCP/IP don’t need?
just make sure the network is working
image
AT+ COPS is often used for manual network registration.

Q2. into MQTT with SSL have 4 things to configure: Network, TCP, SSL and MQTT… it will useful a state diagram like it has into TCP document. There are some like that?
please refer to the attachment.
Quectel_BG95&BG77&BG600L_Series_MQTT_Application_Note_V1.1.pdf (617.9 KB)

Q3. I’m checking about the ids again…

thanks again Puck

I would like focus into Answer 3 I in theory (pdf doc) there only var TCP_CON_ID but I splitted TCP_CON_ID in two variables TCP_CON_ID and MQTT_CON_ID

#define TCP_CON_ID  0
#define MQTT_CON_ID 0
#define SSL_CTX_ID  2


// first use of this:
AT+QMTCFG="ssl",<TCP_CON_ID>,1,<SSL_CTX_ID>

... 
AT+QMTCFG="will",<TCP_CON_ID>
AT+QMTCFG="timeout",<TCP_CON_ID>


AT+QSSLCFG="cacert",<SSL_CTX_ID>,"ca.pem"
AT+QSSLCFG="clientcert",<SSL_CTX_ID>,"cc.crt"
AT+QSSLCFG="clientkey",<SSL_CTX_ID>,"ck.key"
AT+QSSLCFG="seclevel",<SSL_CTX_ID>,2
AT+QSSLCFG="sslversion",<SSL_CTX_ID>,4
AT+QSSLCFG="ciphersuite",<SSL_CTX_ID>,0xffff

AT+QMTOPEN=<MQTT_CON_ID>,"aaaaaaaaaaaaaa.iot.eu-west-1.amazonaws.com",8883
AT+QMTCONN=<MQTT_CON_ID>,"thing-name"
AT+QMTSUB=<MQTT_CON_ID>,?,"$topic",1

well if I use
#define TCP_CON_ID 0
#define MQTT_CON_ID 0

mi logs are:

...
resp: +QSSLCFG: "ignorelocaltime",1,1 OK (ignorelocaltime)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,1)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,2)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,3)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,4)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,5)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,6)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,7)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,8)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,9)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,10)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,11)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,12)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,13)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,14)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,15)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,16)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,17)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,18)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,19)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,20)
resp: OK +QMTOPEN: 0,-1 (QMTOPEN,21)
resp: OK +QMTOPEN: 0,4 (QMTOPEN,22)

But if I use:

#define TCP_CON_ID 0
#define MQTT_CON_ID 1

resp: +QSSLCFG: "ignorelocaltime",1,1 OK (ignorelocaltime)
resp: OK +QMTOPEN: 1,0 (QMTOPEN,1)
//  its open!! tcpconnID=1 status=0 which means no error
resp: OK +QMTSTAT: 1,1 (QMTCONN)
resp: OK +QMTOPEN: 1,0 (QMTOPEN,1)
resp: OK +QMTSTAT: 1,1 (QMTCONN)
resp: OK +QMTOPEN: 1,0 (QMTOPEN,1)
resp: OK +QMTSTAT: 1,1 (QMTCONN)
resp: OK +QMTOPEN: 1,0 (QMTOPEN,1)

but QMTCONN fails with tcpconnID=1 and error_code=1 which means connection is closed or reset by peer event with retry as documentation said

any advice? again thanks so much puck

1 Like