--- mqtt/inc/Attic/aitmqtt.h 2011/11/18 17:23:59 1.1.1.1.2.5 +++ mqtt/inc/Attic/aitmqtt.h 2011/11/21 15:27:26 1.1.1.1.2.11 @@ -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 { @@ -178,6 +183,81 @@ inline char mqtt_sizeLen(unsigned int len); * return: NULL error or != ok variable, must be free after use! */ inline mqtthdr_var_t *mqtt_str2var(const unsigned char *csStr, unsigned short strLen); + +/* + * mqtt_msgCONNECT() Create CONNECT message + * + * @buf = Message buffer + * @csConnID = ConnectID + * @csUser = Username if !=NULL + * @csPass = Password for Username, only if csUser is set + * @csWillTopic = Will Topic if !=NULL Will Flags set into message + * @csWillMessage = Will Message, may be NULL + * @ClrSess = Clear Session subscriptions after disconnect + * @WillQOS = Will QOS if csWillTopic is set + * @WillRetain = Will Retain Will Message if csWillTopic is set + * return: -1 error or >-1 message size for send + */ +int mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const char *csConnID, + const char *csUser, const char *csPass, + const char *csWillTopic, const char *csWillMessage, + 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 + * @Retain = Retain message + * @pData = Publish data into topic + * @datlen = Publish data length + * 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, unsigned char Retain, + const void *pData, unsigned short datlen); +/* + * 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