My Modify MQTTPacket Packet size 100 -> 400

Dependents:   MQTT

Fork of MQTTPacket by MQTT

Revision:
14:c2052aee81de
Parent:
9:3893bc7343f4
Child:
16:d0b3886ada32
--- 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);
 }