Hello.
I am running a simple MQTT client on the QBG96 module (I have been following the instructions in the “Quectel_BG96_MQTT_Application_Note_V1.0.pdf”).
I am connecting to mosquitto.org (which is a simple public MQTT test broker that I’ve used for development numerous times without any issues).
The connection to mosquitto is unencrypted so I am using port 1883 - there is NO username, password, or special certificates required to connect to it either.
I am entering the series of commands through tera-term (cuitting and pasting from a text document)
I seem to be having a major timing issue - After I submit the “AT+QMTCONN” command, within a few seconds, the connection appears to be terminated - here is the output of the entire setup:
RDY
AT+CFUN=1
OK
AT+QCSQ
+QCSQ: “CAT-M1”,-42,-71,166,-13
OK
AT+CEREG?
+CEREG: 0,1
OK
AT+COPS?
+COPS: 0,0,“Verizon Wireless”,8
OK
AT+QIACT=1
OK
AT+QIACT?
+QIACT: 1,1,1,“100.75.83.231”
OK
AT+QMTCFG=“aliauth”,0
+QMTCFG: “aliauth”,"","",""
OK
AT+QMTOPEN=0,“test.mosquitto .org”,1883
OK
+QMTOPEN: 0,0
AT+QMTCONN=0,“mosquitto”
OK
+QMTCONN: 0,0,0
+QMTCONN: 0,1
+QMTSTAT: 0,3
(NOTE: After the +QMTCONN: 0,1 response arrives, any AT+QMT command I attempt to send results in ERROR)
So, I started over and IMMEDIATELY after sending the AT+QMTCONN=0,“mosquitto” (within 1 second), I then subscribe to a topic successfully and managed to receive one message from the broker:
AT+QMTCFG=“aliauth”,0
+QMTCFG: “aliauth”,"","",""
OK
AT+QMTOPEN=0,“test.mosquitto .org”,1883
OK
+QMTOPEN: 0,0
AT+QMTCONN=0,“mosquitto”
OK
+QMTCONN: 0,0,0
AT+QMTSUB=0,1,“my_topic”,0
OK
+QMTSUB: 0,1,0,0
+QMTRECV: 0,0,“my_topic”,“Hey Now”
+QMTCONN: 0,1
+QMTSTAT: 0,3
(NOTE: The received message was just “Hey Now”)
But, again after a few seconds, the connection dies (hence the +QMTCONN: 0,1 status)
My questions:
Q1. Is it my responsibility to keep the connection alive or is this handled inside the modem itself?
Q2. If it IS my responsibility to keep the connection alive, How do I do it?
Q3. Is there a timeout value to set to keep this connection alive?
NOTE: In my testing, I tried various “keepalive” times and none of them made a difference.
AT+QMTCFG=“keepalive”,0,60
AT+QMTCFG=“keepalive”,0,500
AT+QMTCFG=“keepalive”,0,1000
AT+QMTCFG=“keepalive”,0,3600
For reference, here is the sequence of commands I am sending:
// Turn on cellular functionality
AT+CFUN=1
// Check the received signal strength
AT+QCSQ
// Query network registration status (0,1=Registered, on home network, 0,5=Registered, roaming) other - not connected
AT+CEREG?
// Query network technology and carrier:
AT+COPS?
// Activate PDP context
AT+QIACT=1
// Confirm PDP context was activated
AT+QIACT?
// Configure MQTT session
AT+QMTCFG=“aliauth”,0
// Open the mosquitto client
AT+QMTOPEN=0,“test.mosquitto .org”,1883
// Connect to the client.
AT+QMTCONN=0,“mosquitto”
// Subscribe to a topic
AT+QMTSUB=0,1,“my_topic”,0
Thanks in advance for your help!
Dave…