Annotation of mqtt/inc/aitmqtt.h, revision 1.1.1.1.2.1
1.1 misho 1: #ifndef __AITMQTT_H
2: #define __AITMQTT_H
3:
4:
1.1.1.1.2.1! misho 5: struct mqtthdr {
! 6: unsigned char mqtt_retain : 1,
! 7: mqtt_qos : 2,
! 8: mqtt_dup : 1,
! 9: mqtt_type : 4;
! 10: unsigned char mqtt_len;
! 11: };
! 12:
! 13: #define MQTT_TYPE_UNKNOWN 0 /* reserved */
! 14: #define MQTT_TYPE_CONNECT 1 /* client request to connect to server */
! 15: #define MQTT_TYPE_CONNACK 2 /* connect acknowledgment */
! 16: #define MQTT_TYPE_PUBLISH 3 /* publish message */
! 17: #define MQTT_TYPE_PUBACK 4 /* publish acknowledgment */
! 18: #define MQTT_TYPE_PUBREC 5 /* publish received (assured delivery part 1) */
! 19: #define MQTT_TYPE_PUBREL 6 /* publish release (assured delivery part 2) */
! 20: #define MQTT_TYPE_PUBCOMP 7 /* publish complete (assured delivery part 3) */
! 21: #define MQTT_TYPE_SUBSCRIBE 8 /* client subscribe request */
! 22: #define MQTT_TYPE_SUBACK 9 /* subscribe acknowledgment */
! 23: #define MQTT_TYPE_UNSUBSCRIBE 10 /* client unsubscribe request */
! 24: #define MQTT_TYPE_UNSUBACK 11 /* unsubscribe acknowledgment */
! 25: #define MQTT_TYPE_PINGREQ 12 /* PING request */
! 26: #define MQTT_TYPE_PINGRESP 13 /* PING response */
! 27: #define MQTT_TYPE_DISCONNECT 14 /* client is disconnecting */
! 28: #define MQTT_TYPE_RESERVED 15 /* reserved */
! 29:
! 30: #define MQTT_FLAG_DUP 1 /* This flag is set when the client or server attempts to re-deliver
! 31: a PUBLISH, PUBREL, SUBSCRIBE or UNSUBSCRIBE message.
! 32: This applies to messages where the value of QoS is greater than
! 33: zero (0), and an acknowledgment is required.
! 34: When the DUP bit is set, the variable header includes a Message ID.
! 35:
! 36: The recipient should treat this flag as a hint as to whether
! 37: the message may have been previously received.
! 38: It should not be relied on to detect duplicates. */
! 39:
! 40: #define MQTT_QOS_ONCE 0 /* At most once, Fire and Forget, <=1 */
! 41: #define MQTT_QOS_ACK 1 /* At least once, Acknowledged delivery, >=1 */
! 42: #define MQTT_QOS_EXACTLY 2 /* Exactly once, Assured delivery, =1 */
! 43: #define MQTT_QOS_RESERVED 3 /* reserved */
! 44:
! 45: #define MQTT_FLAG_RETAIN 1 /* This flag is only used on PUBLISH messages.
! 46:
! 47: When a client sends a PUBLISH to a server,
! 48: if the Retain flag is set (1),
! 49: the server should hold on to the message after it has been
! 50: delivered to the current subscribers.
! 51: When a new subscription is established on a topic,
! 52: the last retained message on that topic should be sent to
! 53: the subscriber with the Retain flag set.
! 54: If there is no retained message, nothing is sent
! 55: This is useful where publishers send messages on a
! 56: "report by exception" basis, where it might be some time between messages.
! 57: This allows new subscribers to instantly receive data with the retained,
! 58: or Last Known Good, value.
! 59:
! 60: When a server sends a PUBLISH to a client as a result of
! 61: a subscription that already existed when the original PUBLISH arrived,
! 62: the Retain flag should not be set, regardless of the Retain flag
! 63: of the original PUBLISH. This allows a client to distinguish messages
! 64: that are being received because they were retained and those
! 65: that are being received "live".
! 66:
! 67: Retained messages should be kept over restarts of the server.
! 68: A server may delete a retained message if it receives a message
! 69: with a zero-length payload and the Retain flag set on the same topic. */
! 70:
! 71:
1.1 misho 72: // -------------------------------------------------------
73: // mqtt_GetErrno() Get error code of last operation
74: inline int mqtt_GetErrno();
75: // mqtt_GetError() Get error text of last operation
76: inline const char *mqtt_GetError();
77: // -------------------------------------------------------
78:
79:
1.1.1.1.2.1! misho 80: /*
! 81: * mqtt_encodeLen() Encode number to MQTT length field
! 82: * @num = number for encode
! 83: * return: -1 error or >-1 length
! 84: */
! 85: inline unsigned int mqtt_encodeLen(unsigned int num);
! 86: /*
! 87: * mqtt_decodeLen() Decode length from MQTT packet
! 88: * @len = length
! 89: * return: -1 error, >-1 length of message
! 90: */
! 91: inline unsigned int mqtt_decodeLen(unsigned int len);
! 92:
! 93:
1.1 misho 94: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>