--- mqtt/inc/Attic/aitmqtt.h 2011/11/21 12:16:11 1.1.1.1.2.6 +++ mqtt/inc/Attic/aitmqtt.h 2011/11/21 14:51:23 1.1.1.1.2.9 @@ -114,7 +114,12 @@ typedef struct { username:1; } __packed mqtthdr_connflgs_t; +typedef struct { + unsigned char reserved; + unsigned char retcode; +} __packed mqtthdr_connack_t; + /* MQTT Message buffer */ typedef struct { @@ -196,7 +201,59 @@ inline mqtthdr_var_t *mqtt_str2var(const unsigned char int mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const char *csConnID, const char *csUser, const char *csPass, const char *csWillTopic, const char *csWillMessage, - char ClrSess, char WillQOS, char WillRetain); + unsigned char ClrSess, unsigned char WillQOS, unsigned char WillRetain); +/* + * mqtt_msgCONNACK() Create CONNACK message + * + * @buf = Message buffer + * @retcode = Return code + * return: -1 error or >-1 message size for send + */ +int mqtt_msgCONNACK(mqtt_msg_t * __restrict buf, unsigned char retcode); +/* + * mqtt_msgPUBLISH() Create PUBLISH message + * + * @buf = Message buffer + * @csTopic = Publish topic + * @msgID = MessageID >0, if QOS != MQTT_QOS_ONCE + * @Dup = Duplicate message + * @QOS = QoS + * return: -1 error or >-1 message size for send + */ +int mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const char *csTopic, + unsigned short msgID, unsigned char Dup, unsigned char QOS); +/* + * mqtt_msgPUBACK() Create PUBACK message + * + * @buf = Message buffer + * @msgID = MessageID + * return: -1 error or >-1 message size for send + */ +inline int mqtt_msgPUBACK(mqtt_msg_t * __restrict buf, unsigned short msgID); +/* + * mqtt_msgPUBREC() Create PUBREC message + * + * @buf = Message buffer + * @msgID = MessageID + * return: -1 error or >-1 message size for send + */ +inline int mqtt_msgPUBREC(mqtt_msg_t * __restrict buf, unsigned short msgID); +/* + * mqtt_msgPUBREL() Create PUBREL message + * + * @buf = Message buffer + * @msgID = MessageID + * return: -1 error or >-1 message size for send + */ +inline int mqtt_msgPUBREL(mqtt_msg_t * __restrict buf, unsigned short msgID); +/* + * mqtt_msgPUBCOMP() Create PUBCOMP message + * + * @buf = Message buffer + * @msgID = MessageID + * return: -1 error or >-1 message size for send + */ +inline int mqtt_msgPUBCOMP(mqtt_msg_t * __restrict buf, unsigned short msgID); #endif