1, message classes QOS
Normally, all subscriptions set to 0, you can, and then talk about what grade the news with it!
When sending data it will be carrying a message class:
假设是0
So this is not really news sent MQTT server (Broker), and do not know if the device more, really can not really guarantee to the server a.
假设是1
So after a client sends a message of it, the server is a look at the message level 1, it will send a message back to the client a reply message. After the client sends a message actually finished inside will start a time-out operation, if there is no reply within how much time it will Zaifayici
假设是2
This is the message we must reach it MQTT server. This is very demanding, but also more take up memory
2, publish / subscribe messaging
Generally include the following
- Publish / subscribe topic
- News
- Return mark (default 0)
- [1] See news rating
- The need to preserve message server [below] speak together with your doctor
- Identification message (usually less than, the default will be 1)
3, will (will)
I assume the phone and a device corresponds to subscribe to a topic and post a topic, and I will be able to communicate this device up, but I know how this equipment is down? Of course the information they can send to the device, if you do not respond, it shows off the line.
But then, MQTT server provides a way to set up the equipment I suppose the message will be offline will release the theme aaaaa, if the device is dropped, the server will give clients subscribed aaaaa sent offline.
[Note: If the server within 1.5 times the time heartbeat packet time you set, no heartbeat packet to think you're cutting out.
4, Heartbeat
MQTT predetermined, after completing transmission connection protocol , the heartbeat packet data is transmittedC0 00
Sent: Heartbeat time connection protocol inside (you can send in advance), then the server replies D0 00
MQTT C library that record
- Official data returned to determine which library
Use MQTTPacket_read(数据解析完存到的数组,数组长度,提取数据函数)
, the most important is the function to extract the data transport_getdata
, the format of this function can not be changed, this is the official format.
Wherein the local data storage Usart1ReadBuff received network modules need to be modified according to actual.