--- libaitmqtt/inc/aitmqtt.h 2022/09/14 17:37:13 1.3.4.10 +++ libaitmqtt/inc/aitmqtt.h 2022/09/15 15:04:44 1.3.4.13 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitmqtt.h,v 1.3.4.10 2022/09/14 17:37:13 misho Exp $ +* $Id: aitmqtt.h,v 1.3.4.13 2022/09/15 15:04:44 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -238,7 +238,7 @@ typedef struct { /* MQTT structures */ typedef struct { - unsigned char sub_ret; + unsigned char sub_qos; mqtt_msg_t sub_topic; mqtt_msg_t sub_value; } mqtt_subscr_t; @@ -470,47 +470,37 @@ mqtt_msg_t *mqtt_msgPUBCOMP(unsigned short msgID); /* * mqtt_msgSUBSCRIBE() Create SUBSCRIBE message * - * @buf = Message buffer * @Topics = MQTT subscription topics * @msgID = MessageID - * @Dup = Duplicate message - * @QOS = QoS - * return: -1 error or >-1 message size for send + * return: NULL error or allocated SUBSCRIBE message */ -int -mqtt_msgSUBSCRIBE(mqtt_msg_t * __restrict buf, mqtt_subscr_t * __restrict Topics, - unsigned short msgID, unsigned char Dup, unsigned char QOS); +mqtt_msg_t *mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, unsigned short msgID); /* * mqtt_msgSUBACK() Create SUBACK message * - * @buf = Message buffer * @Topics = MQTT subscription topics * @msgID = MessageID - * return: -1 error or >-1 message size for send + * return: NULL error or allocated SUBACK message */ -int mqtt_msgSUBACK(mqtt_msg_t * __restrict buf, mqtt_subscr_t * __restrict Topics, - unsigned short msgID); +mqtt_msg_t *mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, unsigned short msgID); /* * mqtt_msgUNSUBSCRIBE() Create UNSUBSCRIBE message * - * @buf = Message buffer * @Topics = MQTT subscription topics * @msgID = MessageID * @Dup = Duplicate message * @QOS = QoS - * return: -1 error or >-1 message size for send + * return: NULL error or allocated UNSUBSCRIBE message */ -int -mqtt_msgUNSUBSCRIBE(mqtt_msg_t * __restrict buf, mqtt_subscr_t * __restrict Topics, +mqtt_msg_t *mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, unsigned short msgID, unsigned char Dup, unsigned char QOS); /* * mqtt_msgUNSUBACK() Create UNSUBACK message * - * @buf = Message buffer * @msgID = MessageID - * return: -1 error or >-1 message size for send + * return: NULL error or allocated UNSUBACK message */ -int mqtt_msgUNSUBACK(mqtt_msg_t * __restrict buf, unsigned short msgID); +mqtt_msg_t *mqtt_msgUNSUBACK(unsigned short msgID); /*** RECEIVER FUNCTIONS ***/ @@ -526,8 +516,8 @@ int mqtt_msgUNSUBACK(mqtt_msg_t * __restrict buf, unsi * @userLen = Username length * @psPass = Password for Username, only if csUser is set * @passLen = Password length - * @psWillTopic = Will Topic if !=NULL Will Flags set into message and must be free() - * @psWillMessage = Will Message, may be NULL if !NULL must be free() after use! + * @psWillTopic = Will Topic if !=NULL Will Flags set into message and must be e_free() + * @psWillMessage = Will Message, may be NULL if !NULL must be e_free() after use! * return: .reserved == 1 is error or == 0 connection flags & msg ok */ mqtthdr_connack_t mqtt_readCONNECT(mqtt_msg_t * __restrict buf, unsigned short *KASec, @@ -619,7 +609,7 @@ int mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, un * * @buf = Message buffer * @msgID = MessageID - * @subqos = Subscribes QoS, must be free after use with free() + * @subqos = Subscribes QoS, must be free after use with e_free() * return: -1 error or >-1 readed subscribes QoS elements */ int mqtt_readSUBACK(mqtt_msg_t * __restrict buf, unsigned short *msgID, unsigned char **subqos);