--- libaitmqtt/inc/aitmqtt.h 2012/01/27 15:12:27 1.1.1.1.2.3 +++ libaitmqtt/inc/aitmqtt.h 2012/04/26 12:33:14 1.1.1.1.2.9 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitmqtt.h,v 1.1.1.1.2.3 2012/01/27 15:12:27 misho Exp $ +* $Id: aitmqtt.h,v 1.1.1.1.2.9 2012/04/26 12:33:14 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -50,7 +50,12 @@ SUCH DAMAGE. #define MAX_CONNID 24 #define MAX_CRED 13 #define MQTTMSG_MAX 65529 +#define MQTT_DATA_MAX 268435455 +#define MQTT_PROTO_VER 3 +#define MQTT_KEEPALIVE 10 +#define MQTT_DEFAULT_MSGID 0xDEBA + /* FIXED HEADER */ struct mqtthdr { @@ -99,6 +104,9 @@ struct mqtthdr { #define MQTT_QOS_EXACTLY 2 /* Exactly once, Assured delivery, =1 */ #define MQTT_QOS_RESERVED 3 /* reserved */ +#define MQTT_QOS_DENY 0 /* Not granted QoS for SUBACK */ +#define MQTT_QOS_PASS 2 /* Granted QoS for SUBACK */ + #define MQTT_FLAG_RETAIN 1 /* This flag is only used on PUBLISH messages. When a client sends a PUBLISH to a server, @@ -229,6 +237,15 @@ inline int mqtt_msgRealloc(mqtt_msg_t * __restrict msg */ int mqtt_expandTopic(const char *csInput, char * __restrict psRegEx, int regexLen, unsigned char BOL, unsigned char EOL); +/* + * mqtt_sqlTopic() - Expanding topic to SQL search string + * + * @csInput = Input topic + * @psSQL = Output to SQL search string + * @sqlLen = Length of psSQL + * return: -1 error, 0 changed bytes + */ +int mqtt_sqlTopic(const char *csInput, char * __restrict psSQL, int sqlLen); /* * mqtt_encodeLen() Encode number to MQTT length field @@ -530,9 +547,9 @@ unsigned short mqtt_readPUBCOMP(mqtt_msg_t * __restric * @buf = Message buffer * @msgID = MessageID * @subscr = Subscriptions, must be free after use with mqtt_subFree() - * return: NULL error or !=NULL MQTT fixed header + * return: -1 error or >-1 elements into subscr */ -struct mqtthdr *mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, unsigned short *msgID, +int mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, unsigned short *msgID, mqtt_subscr_t **subscr); /* * mqtt_readSUBACK() Read SUBACK message @@ -549,9 +566,9 @@ int mqtt_readSUBACK(mqtt_msg_t * __restrict buf, unsig * @buf = Message buffer * @msgID = MessageID * @subscr = Subscriptions, must be free after use with mqtt_subFree() - * return: NULL error or !=NULL MQTT fixed header + * return: -1 error or >-1 elements into subscr */ -struct mqtthdr *mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, unsigned short *msgID, +int mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, unsigned short *msgID, mqtt_subscr_t **subscr); /* * mqtt_readUNSUBACK() Read UNSUBACK message