Periodic Connect and Disconnect MQTT


I need to publish and subscribe with MQTT protocol in MC60. I have periodic connect and disconnect to mqtt broker. for example, after 10 times trying, once i can connect and publish. I test it in AT-Command mode and OpenCPU mode. after open a network for mqtt client with AT+QMTOPEN, periodic i can’t connect to mqtt broker with AT+QMTCONN and returns ERROR.
Please help to solve this problem.

Did you successfully connect to the MQTT server during the test?
If not, I recommend using MQtt.fx for server state testing.
Or you upload a log of your test failures

Thanks for the Reply.

Both Yes and No. for more details, i can connect to the MQTT server with MQtt.fx and publish a data. but in AT-command test with a terminal like QCOM, i can sometimes open and connect to mqtt.

I realized that there is a delay to replying (AT+QMTOPEN) command for Opening MQTT-network and replying (AT+QMTCONN) command for connecting to MQTT-server and this delay to replying from Core cause Closing MQTT-network. because other AT-command run without delay and reply. I attached my test log in blow. (811 Bytes)

Logs with failure problems are displayed as follows

+CGREG: 0,2

Logs with failure problems are displayed as follows.
In addition, the execution time between AT+QMTOPEN and AT+QMTCONN is about 10 seconds. Perform AT+QMTCONN as soon as possible after AT+QMTOPEN is executed

After sending (AT+QMTOPEN), it reply OK and as I understand it, if i send (AT+QMTCONN) before receiving (+QMTOPEN: 0,0) , it return (+CME ERROR: 3518) to me and i can’t run (AT+QMTCONN) command and then it return (+QMTOPEN: 0,4) that means is MQTT closed.

The problem is exactly that If i run fast (AT+QMTCONN) after (AT+QMTOPEN) and receiving OK, it return (+CME ERROR: 3518) because MQTT-network not opened yet ((+QMTOPEN: 0,0) not arrived yet) and if i don’t run (AT+QMTCONN) before 10 seconds the MQTT-network closes.
What do you recommend?

+CME ERROR: 3518
+CME ERROR: 3518
+QMTCONN: 0,0,0

yes,You are right to understand
But why is ERROR3518 so strange

However, what is your suggestion to solve this problem?

I suggest you to find this error on the MQTT server platform. At present, your connection is normal, and you can also ignore this error

Thanks for the Reply herbert.pan

I have another question about MQTT in OpenCPU. How can i receive coming response(return data) after sending Ql_RIL_SendATCmd(AT+QMTSUB) in RIL_MQTT_QMTSUB?
after receive OK, how can i get coming data (like a key status) from MQTT-server? should i handle it(receiving data) in ATResponse_Handler? do you have any example or recommended solution?

Like this data:



+QMTSUB: 0,1,0,0

+QMTRECV: 0,0,v1/devices/me/rpc/request/58,{“method”:“checkStatus”}

+QMTRECV: 0,0,v1/devices/me/rpc/request/59,{“method”:“setValue”,“params”:true}

I am not familiar with openCPU, but I think there must be RIL about MQTT subscriptions

1 Like