My Modify MQTTPacket Packet size 100 -> 400
Fork of MQTTPacket by
Revision 14:c2052aee81de, committed 2014-08-01
- Comitter:
- Ian Craggs
- Date:
- Fri Aug 01 15:34:04 2014 +0100
- Parent:
- 13:5e60cd1a52e7
- Child:
- 15:f0ae0b8d4418
- Commit message:
- Change C types to better fit MQTT types, and match MQTT-SN library
Changed in this revision
--- a/MQTTConnect.h Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTConnect.h Fri Aug 01 15:34:04 2014 +0100
@@ -69,7 +69,7 @@
* The quality of service setting for the LWT message (see
* MQTTAsync_message.qos and @ref qos).
*/
- int qos;
+ char qos;
} MQTTPacket_willOptions;
@@ -84,9 +84,9 @@
int struct_version;
/** Version of MQTT to be used. 3 = 3.1 4 = 3.1.1
*/
- int MQTTVersion;
+ unsigned char MQTTVersion;
MQTTString clientID;
- int keepAliveInterval;
+ unsigned short keepAliveInterval;
unsigned char cleansession;
unsigned char willFlag;
MQTTPacket_willOptions will;
@@ -97,13 +97,13 @@
#define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \
MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} }
-int MQTTSerialize_connect(char* buf, int buflen, MQTTPacket_connectData* options);
-int MQTTDeserialize_connect(MQTTPacket_connectData* data, char* buf, int len);
+int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options);
+int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len);
-int MQTTSerialize_connack(char* buf, int buflen, int connack_rc);
-int MQTTDeserialize_connack(int* connack_rc, char* buf, int buflen);
+int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc);
+int MQTTDeserialize_connack(unsigned char* connack_rc, unsigned char* buf, int buflen);
-int MQTTSerialize_disconnect(char* buf, int buflen);
-int MQTTSerialize_pingreq(char* buf, int buflen);
+int MQTTSerialize_disconnect(unsigned char* buf, int buflen);
+int MQTTSerialize_pingreq(unsigned char* buf, int buflen);
#endif /* MQTTCONNECT_H_ */
--- a/MQTTConnectClient.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTConnectClient.c Fri Aug 01 15:34:04 2014 +0100
@@ -55,9 +55,9 @@
* @param options the options to be used to build the connect packet
* @return serialized length, or error if 0
*/
-int MQTTSerialize_connect(char* buf, int buflen, MQTTPacket_connectData* options)
+int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options)
{
- char *ptr = buf;
+ unsigned char *ptr = buf;
MQTTHeader header;
MQTTConnectFlags flags;
int len = 0;
@@ -128,11 +128,11 @@
* @param len the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
-int MQTTDeserialize_connack(int* connack_rc, char* buf, int buflen)
+int MQTTDeserialize_connack(unsigned char* connack_rc, unsigned char* buf, int buflen)
{
MQTTHeader header;
- char* curdata = buf;
- char* enddata = NULL;
+ unsigned char* curdata = buf;
+ unsigned char* enddata = NULL;
int rc = 0;
int mylen;
int compression;
@@ -148,7 +148,6 @@
goto exit;
compression = readChar(&curdata);
- compression = compression; // hush compiler warnings
*connack_rc = readChar(&curdata);
rc = 1;
@@ -163,14 +162,14 @@
* Serializes a 0-length packet into the supplied buffer, ready for writing to a socket
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
- * @param type the message type
+ * @param packettype the message type
* @return serialized length, or error if 0
*/
-int MQTTSerialize_zero(char* buf, int buflen, int type)
+int MQTTSerialize_zero(unsigned char* buf, int buflen, unsigned char packettype)
{
MQTTHeader header;
int rc = -1;
- char *ptr = buf;
+ unsigned char *ptr = buf;
FUNC_ENTRY;
if (buflen < 2)
@@ -179,7 +178,7 @@
goto exit;
}
header.byte = 0;
- header.bits.type = type;
+ header.bits.type = packettype;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, 0); /* write remaining length */
@@ -196,7 +195,7 @@
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
* @return serialized length, or error if 0
*/
-int MQTTSerialize_disconnect(char* buf, int buflen)
+int MQTTSerialize_disconnect(unsigned char* buf, int buflen)
{
return MQTTSerialize_zero(buf, buflen, DISCONNECT);
}
@@ -208,7 +207,7 @@
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
* @return serialized length, or error if 0
*/
-int MQTTSerialize_pingreq(char* buf, int buflen)
+int MQTTSerialize_pingreq(unsigned char* buf, int buflen)
{
return MQTTSerialize_zero(buf, buflen, PINGREQ);
}
--- a/MQTTConnectServer.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTConnectServer.c Fri Aug 01 15:34:04 2014 +0100
@@ -48,12 +48,12 @@
* @param len the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
-int MQTTDeserialize_connect(MQTTPacket_connectData* data, char* buf, int len)
+int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len)
{
MQTTHeader header;
MQTTConnectFlags flags;
- char* curdata = buf;
- char* enddata = &buf[len];
+ unsigned char* curdata = buf;
+ unsigned char* enddata = &buf[len];
int rc = 0;
MQTTString Protocol;
int version;
@@ -61,7 +61,6 @@
FUNC_ENTRY;
header.byte = readChar(&curdata);
- header.byte = header.byte; // hush compiler warnings
curdata += MQTTPacket_decodeBuf(curdata, &mylen); /* read remaining length */
@@ -114,11 +113,11 @@
* @param connack_rc the integer connack return code to be used
* @return serialized length, or error if 0
*/
-int MQTTSerialize_connack(char* buf, int buflen, int connack_rc)
+int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc)
{
MQTTHeader header;
int rc = 0;
- char *ptr = buf;
+ unsigned char *ptr = buf;
FUNC_ENTRY;
if (buflen < 2)
--- a/MQTTDeserializePublish.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTDeserializePublish.c Fri Aug 01 15:34:04 2014 +0100
@@ -33,12 +33,12 @@
* @param buflen the length in bytes of the data in the supplied buffer
* @return error code. 1 is success
*/
-int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, int* packetid, MQTTString* topicName,
- char** payload, int* payloadlen, char* buf, int buflen)
+int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
+ unsigned char** payload, int* payloadlen, unsigned char* buf, int buflen)
{
MQTTHeader header;
- char* curdata = buf;
- char* enddata = NULL;
+ unsigned char* curdata = buf;
+ unsigned char* enddata = NULL;
int rc = 0;
int mylen = 0;
@@ -70,25 +70,25 @@
/**
* Deserializes the supplied (wire) buffer into an ack
- * @param type returned integer - the MQTT packet type
+ * @param packettype returned integer - the MQTT packet type
* @param dup returned integer - the MQTT dup flag
* @param packetid returned integer - the MQTT packet identifier
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param buflen the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
-int MQTTDeserialize_ack(int* type, unsigned char* dup, int* packetid, char* buf, int buflen)
+int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen)
{
MQTTHeader header;
- char* curdata = buf;
- char* enddata = NULL;
+ unsigned char* curdata = buf;
+ unsigned char* enddata = NULL;
int rc = 0;
int mylen;
FUNC_ENTRY;
header.byte = readChar(&curdata);
*dup = header.bits.dup;
- *type = header.bits.type;
+ *packettype = header.bits.type;
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
enddata = curdata + mylen;
--- a/MQTTPacket.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTPacket.c Fri Aug 01 15:34:04 2014 +0100
@@ -25,7 +25,7 @@
* @param length the length to be encoded
* @return the number of bytes written to buffer
*/
-int MQTTPacket_encode(char* buf, int length)
+int MQTTPacket_encode(unsigned char* buf, int length)
{
int rc = 0;
@@ -50,9 +50,9 @@
* @param value the decoded length returned
* @return the number of bytes read from the socket
*/
-int MQTTPacket_decode(int (*getcharfn)(char*, int), int* value)
+int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value)
{
- char c;
+ unsigned char c;
int multiplier = 1;
int len = 0;
#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4
@@ -97,9 +97,9 @@
}
-static char* bufptr;
+static unsigned char* bufptr;
-int bufchar(char* c, int count)
+int bufchar(unsigned char* c, int count)
{
int i;
@@ -109,7 +109,7 @@
}
-int MQTTPacket_decodeBuf(char* buf, int* value)
+int MQTTPacket_decodeBuf(unsigned char* buf, int* value)
{
bufptr = buf;
return MQTTPacket_decode(bufchar, value);
@@ -121,10 +121,10 @@
* @param pptr pointer to the input buffer - incremented by the number of bytes used & returned
* @return the integer value calculated
*/
-int readInt(char** pptr)
+int readInt(unsigned char** pptr)
{
- char* ptr = *pptr;
- int len = 256*((unsigned char)(*ptr)) + (unsigned char)(*(ptr+1));
+ unsigned char* ptr = *pptr;
+ int len = 256*(*ptr) + (*(ptr+1));
*pptr += 2;
return len;
}
@@ -135,7 +135,7 @@
* @param pptr pointer to the input buffer - incremented by the number of bytes used & returned
* @return the character read
*/
-char readChar(char** pptr)
+char readChar(unsigned char** pptr)
{
char c = **pptr;
(*pptr)++;
@@ -148,7 +148,7 @@
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
* @param c the character to write
*/
-void writeChar(char** pptr, char c)
+void writeChar(unsigned char** pptr, char c)
{
**pptr = c;
(*pptr)++;
@@ -160,11 +160,11 @@
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
* @param anInt the integer to write
*/
-void writeInt(char** pptr, int anInt)
+void writeInt(unsigned char** pptr, int anInt)
{
- **pptr = (char)(anInt / 256);
+ **pptr = (unsigned char)(anInt / 256);
(*pptr)++;
- **pptr = (char)(anInt % 256);
+ **pptr = (unsigned char)(anInt % 256);
(*pptr)++;
}
@@ -174,7 +174,7 @@
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
* @param string the C string to write
*/
-void writeCString(char** pptr, const char* string)
+void writeCString(unsigned char** pptr, const char* string)
{
int len = strlen(string);
writeInt(pptr, len);
@@ -190,7 +190,7 @@
}
-void writeMQTTString(char** pptr, MQTTString mqttstring)
+void writeMQTTString(unsigned char** pptr, MQTTString mqttstring)
{
if (mqttstring.lenstring.len > 0)
{
@@ -211,7 +211,7 @@
* @param enddata pointer to the end of the data: do not read beyond
* @return 1 if successful, 0 if not
*/
-int readMQTTLenString(MQTTString* mqttstring, char** pptr, char* enddata)
+int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata)
{
int rc = 0;
@@ -222,7 +222,7 @@
mqttstring->lenstring.len = readInt(pptr); /* increments pptr to point past length */
if (&(*pptr)[mqttstring->lenstring.len] <= enddata)
{
- mqttstring->lenstring.data = *pptr;
+ mqttstring->lenstring.data = (char*)*pptr;
*pptr += mqttstring->lenstring.len;
rc = 1;
}
@@ -285,7 +285,7 @@
* @param getfn pointer to a function which will read any number of bytes from the needed source
* @return integer MQTT packet type, or -1 on error
*/
-int MQTTPacket_read(char* buf, int buflen, int (*getfn)(char*, int))
+int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int))
{
int rc = -1;
MQTTHeader header;
--- a/MQTTPacket.h Fri Aug 01 13:08:46 2014 +0100 +++ b/MQTTPacket.h Fri Aug 01 15:34:04 2014 +0100 @@ -81,26 +81,25 @@ #include "MQTTSubscribe.h" #include "MQTTUnsubscribe.h" -int MQTTSerialize_ack(char* buf, int buflen, int type, unsigned char dup, int packetid); -int MQTTDeserialize_ack(int* type, unsigned char* dup, int* packetid, char* buf, int buflen); +int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid); +int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen); int MQTTPacket_len(int rem_len); int MQTTPacket_equals(MQTTString* a, char* b); -int MQTTPacket_encode(char* buf, int length); -int MQTTPacket_decode(int (*getcharfn)(char*, int), int* value); -int MQTTPacket_decodeBuf(char* buf, int* value); +int MQTTPacket_encode(unsigned char* buf, int length); +int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value); +int MQTTPacket_decodeBuf(unsigned char* buf, int* value); -int readInt(char** pptr); -char readChar(char** pptr); -void writeChar(char** pptr, char c); -void writeInt(char** pptr, int anInt); -int readMQTTLenString(MQTTString* mqttstring, char** pptr, char* enddata); -void writeCString(char** pptr, const char* string); -void writeMQTTString(char** pptr, MQTTString mqttstring); -int MQTTPacket_read(char* buf, int buflen, int (*getfn)(char*, int)); +int readInt(unsigned char** pptr); +char readChar(unsigned char** pptr); +void writeChar(unsigned char** pptr, char c); +void writeInt(unsigned char** pptr, int anInt); +int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata); +void writeCString(unsigned char** pptr, const char* string); +void writeMQTTString(unsigned char** pptr, MQTTString mqttstring); -int MQTTPacket_read(char* buf, int buflen, int (*getfn)(char*, int)); +int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int)); #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */ }
--- a/MQTTPublish.h Fri Aug 01 13:08:46 2014 +0100 +++ b/MQTTPublish.h Fri Aug 01 15:34:04 2014 +0100 @@ -17,14 +17,14 @@ #ifndef MQTTPUBLISH_H_ #define MQTTPUBLISH_H_ -int MQTTSerialize_publish(char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, int packetid, MQTTString topicName, - char* payload, int payloadlen); +int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, + MQTTString topicName, unsigned char* payload, int payloadlen); -int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, int* packetid, MQTTString* topicName, - char** payload, int* payloadlen, char* buf, int len); +int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName, + unsigned char** payload, int* payloadlen, unsigned char* buf, int len); -int MQTTSerialize_puback(char* buf, int buflen, int packetid); -int MQTTSerialize_pubrel(char* buf, int buflen, unsigned char dup, int packetid); -int MQTTSerialize_pubcomp(char* buf, int buflen, int packetid); +int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid); +int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid); +int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid); #endif /* MQTTPUBLISH_H_ */
--- a/MQTTSerializePublish.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTSerializePublish.c Fri Aug 01 15:34:04 2014 +0100
@@ -51,10 +51,10 @@
* @param payloadlen integer - the length of the MQTT payload
* @return the length of the serialized data. <= 0 indicates error
*/
-int MQTTSerialize_publish(char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, int packetid,
- MQTTString topicName, char* payload, int payloadlen)
+int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
+ MQTTString topicName, unsigned char* payload, int payloadlen)
{
- char *ptr = buf;
+ unsigned char *ptr = buf;
MQTTHeader header;
int rem_len = 0;
int rc = 0;
@@ -95,16 +95,16 @@
* Serializes the ack packet into the supplied buffer.
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
- * @param type integer - the MQTT packet type
- * @param dup integer - the MQTT dup flag
- * @param packetid integer - the MQTT packet identifier
+ * @param type the MQTT packet type
+ * @param dup the MQTT dup flag
+ * @param packetid the MQTT packet identifier
* @return serialized length, or error if 0
*/
-int MQTTSerialize_ack(char* buf, int buflen, int type, unsigned char dup, int packetid)
+int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
{
MQTTHeader header;
int rc = 0;
- char *ptr = buf;
+ unsigned char *ptr = buf;
FUNC_ENTRY;
if (buflen < 4)
@@ -112,7 +112,7 @@
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
- header.bits.type = type;
+ header.bits.type = packettype;
header.bits.dup = dup;
header.bits.qos = 0;
writeChar(&ptr, header.byte); /* write header */
@@ -133,7 +133,7 @@
* @param packetid integer - the MQTT packet identifier
* @return serialized length, or error if 0
*/
-int MQTTSerialize_puback(char* buf, int buflen, int packetid)
+int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid)
{
return MQTTSerialize_ack(buf, buflen, PUBACK, packetid, 0);
}
@@ -147,7 +147,7 @@
* @param packetid integer - the MQTT packet identifier
* @return serialized length, or error if 0
*/
-int MQTTSerialize_pubrel(char* buf, int buflen, unsigned char dup, int packetid)
+int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid)
{
return MQTTSerialize_ack(buf, buflen, PUBREL, packetid, dup);
}
@@ -160,7 +160,7 @@
* @param packetid integer - the MQTT packet identifier
* @return serialized length, or error if 0
*/
-int MQTTSerialize_pubcomp(char* buf, int buflen, int packetid)
+int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid)
{
return MQTTSerialize_ack(buf, buflen, PUBCOMP, packetid, 0);
}
--- a/MQTTSubscribe.h Fri Aug 01 13:08:46 2014 +0100 +++ b/MQTTSubscribe.h Fri Aug 01 15:34:04 2014 +0100 @@ -17,13 +17,15 @@ #ifndef MQTTSUBSCRIBE_H_ #define MQTTSUBSCRIBE_H_ -int MQTTSerialize_subscribe(char* buf, int buflen, int dup, int packetid, int count, MQTTString topicFilters[], int requestedQoSs[]); - -int MQTTDeserialize_subscribe(int* dup, int* packetid, int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], char* buf, int len); +int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, + int count, MQTTString topicFilters[], int requestedQoSs[]); -int MQTTSerialize_suback(char* buf, int buflen, int packetid, int count, int* grantedQoSs); +int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, + int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], unsigned char* buf, int len); -int MQTTDeserialize_suback(int* packetid, int maxcount, int* count, int grantedQoSs[], char* buf, int len); +int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs); + +int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int len); #endif /* MQTTSUBSCRIBE_H_ */
--- a/MQTTSubscribeClient.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTSubscribeClient.c Fri Aug 01 15:34:04 2014 +0100
@@ -47,9 +47,10 @@
* @param requestedQoSs - array of requested QoS
* @return the length of the serialized data. <= 0 indicates error
*/
-int MQTTSerialize_subscribe(char* buf, int buflen, int dup, int packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
+int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, int count,
+ MQTTString topicFilters[], int requestedQoSs[])
{
- char *ptr = buf;
+ unsigned char *ptr = buf;
MQTTHeader header;
int rem_len = 0;
int rc = 0;
@@ -96,17 +97,16 @@
* @param buflen the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
-int MQTTDeserialize_suback(int* packetid, int maxcount, int* count, int grantedQoSs[], char* buf, int buflen)
+int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int buflen)
{
MQTTHeader header;
- char* curdata = buf;
- char* enddata = NULL;
+ unsigned char* curdata = buf;
+ unsigned char* enddata = NULL;
int rc = 0;
int mylen;
FUNC_ENTRY;
header.byte = readChar(&curdata);
- header.byte = header.byte; // hush compiler warnings
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
enddata = curdata + mylen;
--- a/MQTTSubscribeServer.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTSubscribeServer.c Fri Aug 01 15:34:04 2014 +0100
@@ -32,12 +32,12 @@
* @param buflen the length in bytes of the data in the supplied buffer
* @return the length of the serialized data. <= 0 indicates error
*/
-int MQTTDeserialize_subscribe(int* dup, int* packetid, int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[],
- char* buf, int buflen)
+int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
+ int requestedQoSs[], unsigned char* buf, int buflen)
{
MQTTHeader header;
- char* curdata = buf;
- char* enddata = NULL;
+ unsigned char* curdata = buf;
+ unsigned char* enddata = NULL;
int rc = -1;
int mylen = 0;
@@ -77,11 +77,11 @@
* @param grantedQoSs - array of granted QoS
* @return the length of the serialized data. <= 0 indicates error
*/
-int MQTTSerialize_suback(char* buf, int buflen, int packetid, int count, int* grantedQoSs)
+int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs)
{
MQTTHeader header;
int rc = -1;
- char *ptr = buf;
+ unsigned char *ptr = buf;
int i;
FUNC_ENTRY;
--- a/MQTTUnsubscribe.h Fri Aug 01 13:08:46 2014 +0100 +++ b/MQTTUnsubscribe.h Fri Aug 01 15:34:04 2014 +0100 @@ -17,12 +17,14 @@ #ifndef MQTTUNSUBSCRIBE_H_ #define MQTTUNSUBSCRIBE_H_ -int MQTTSerialize_unsubscribe(char* buf, int buflen, int dup, int packetid, int count, MQTTString topicFilters[]); - -int MQTTDeserialize_unsubscribe(int* dup, int* packetid, int max_count, int* count, MQTTString topicFilters[], char* buf, int len); +int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, + int count, MQTTString topicFilters[]); -int MQTTSerialize_unsuback(char* buf, int buflen, int packetid); +int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int max_count, int* count, MQTTString topicFilters[], + unsigned char* buf, int len); -int MQTTDeserialize_unsuback(int* packetid, char* buf, int len); +int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid); + +int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int len); #endif /* MQTTUNSUBSCRIBE_H_ */
--- a/MQTTUnsubscribeClient.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTUnsubscribeClient.c Fri Aug 01 15:34:04 2014 +0100
@@ -46,9 +46,10 @@
* @param topicFilters - array of topic filter names
* @return the length of the serialized data. <= 0 indicates error
*/
-int MQTTSerialize_unsubscribe(char* buf, int buflen, int dup, int packetid, int count, MQTTString topicFilters[])
+int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
+ int count, MQTTString topicFilters[])
{
- char *ptr = buf;
+ unsigned char *ptr = buf;
MQTTHeader header;
int rem_len = 0;
int rc = -1;
@@ -88,9 +89,9 @@
* @param buflen the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
-int MQTTDeserialize_unsuback(int* packetid, char* buf, int buflen)
+int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int buflen)
{
- int type = 0;
+ unsigned char type = 0;
unsigned char dup = 0;
int rc = 0;
--- a/MQTTUnsubscribeServer.c Fri Aug 01 13:08:46 2014 +0100
+++ b/MQTTUnsubscribeServer.c Fri Aug 01 15:34:04 2014 +0100
@@ -31,11 +31,12 @@
* @param buflen the length in bytes of the data in the supplied buffer
* @return the length of the serialized data. <= 0 indicates error
*/
-int MQTTDeserialize_unsubscribe(int* dup, int* packetid, int maxcount, int* count, MQTTString topicFilters[], char* buf, int len)
+int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
+ unsigned char* buf, int len)
{
MQTTHeader header;
- char* curdata = buf;
- char* enddata = NULL;
+ unsigned char* curdata = buf;
+ unsigned char* enddata = NULL;
int rc = 0;
int mylen = 0;
@@ -70,11 +71,11 @@
* @param packetid integer - the MQTT packet identifier
* @return the length of the serialized data. <= 0 indicates error
*/
-int MQTTSerialize_unsuback(char* buf, int buflen, int packetid)
+int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid)
{
MQTTHeader header;
int rc = 0;
- char *ptr = buf;
+ unsigned char *ptr = buf;
FUNC_ENTRY;
if (buflen < 2)
