Here is an example of setting up and posting data using MQTT.
NOTE 1: Authentication is via username, password.
NOTE 2: In these example commands, change server details, username password, pub topic, subtopic to match your server setup.
NOTE 3: Press Enter after each +set, +push command.
Wait for startup to finish.
+notify,event:init,result:0,firmware:v1.0.8
+notify,carrier:connecting
+notify,carrier:connected
+notify,imei:123451234512345
+notify,event:coap,init:1
Setup device ID
+set,devid:1234AAAB
Expect this response
+rsp,devid:1234AAAB
Setup server address (This is the MQTT broker address)
+set,server_address:postman.cloudmqtt.com
Expect this response
+rsp,server_address:postman.cloudmqtt.com
Setup server port (to match your MQTT server)
+set,server_port:8883
Expect this response
+rsp,server_port:8883
Setup username
+set,user:hrkvpcik
Expect this response
+rsp,user:hrkvpcik
Setup password
+set,pw:nvywp1OGX3R
Expect this response
+rsp,pw:nvywp1OGX3R
Setup publish topic.
+set,pubtopic:sensor/1234AAAB/cellular_uplink_raw
Expect this response
+rsp,pubtopic:sensor/1234AAAB/cellular_uplink_raw
Setup subscribe topic. This is optional of you only want to test publishing from device to MQTT server.
+set,subtopic:sensor/124AAAB/
Expect this response
+rsp,subtopic:sensor/124AAAB/#
Setup protocol as MQTT
+set,proto:mqtt
Expect this response
+rsp,proto:mqtt
Expect to see a notify message for mqtt initialization completion
+notify,event:mqtt,init:1
Device is now ready to be enabled to connect to MQTT server
Enable device to connect to server
+set,enabled:1
Expect this response
+rsp,enabled:1
Upon successfully connecting, device will send notify messages like these
+notify,event:mqtt,connecting:1,host:postman.cloudmqtt.com,devid:1234AAAB,user:hrkvpcik,pw:nvywp1OGX3R
+notify,event:mqtt,connected:1
You can send your data by "pushing" it to a queue. For testing, just use the first queue: queue1
the data payload here is temp:1,humid:2
+push,queue1,temp:1,humid:2
Expect response like this. result:0 is success.
+rsp,result:0,mark:1
+notify,mqtt:pub,topic:sensor/1234AAAB/cellular_uplink_raw,data:temp:1,humid:2,error:0
+notify,mqtt:pub,mark:1,id:55544
+notify,mqtt:puback,id:55544
If you send a message to the sub topic, device will send these notify messages
+notify,mqtt:sub,topic1:sensor/124AAAB/#
+notify,mqtt:subevent,qos:1,topic:sensor/124AAAB/down,payload:howdy
Device will report mqtt server pings like this
+notify,mqtt:ping
+notify,mqtt:ping
Comments
0 comments
Please sign in to leave a comment.