mqtt就是tcp通信,首先连接服务器,然后发出连接命令,成功返回后,订阅话题,在主循环间隔时间内发送保持命令。
 
连接MQTT服务器的 mqtt.lewei50.com 1883
client_ID afe8c****25747f49a3db2f6b7f69fa7_01
connection Timeout 30 Keep Alive Interval 60
发布话题:
topic
/lw/u/afe8c****25747f49a3db2f6b7f69fa7_01
[
{
"Name":"T1",
"Value":"10.2"
},
{
"Name":"H1",
"Value":"80.3"
}
]
订阅话题:
/lw/c/afe8c****25747f49a3db2f6b7f69fa7_01
{"f":"writeSerial","p1":"A1B","p2":"C377650D"}
硬件接收到服务器的回复后,
要回复响应信息
/lw/r/afe8c****25747f49a3db2f6b7f69fa7_01
{
"successful": true,
"message": "writeSerial"
}