ME910 support

Dependents:   5_Dragonfly_Cayenne_Sprint_IKS01A1

Fork of Cayenne-MQTT-mbed-MTSAS by Peter Ferland

Branch:
feature/multivalue
Revision:
22:0dbabcc6e7b2
Parent:
0:09ef59d2d0f7
--- a/src/MQTTCommon/MQTTConnectClient.c	Tue Nov 08 18:48:37 2016 -0700
+++ b/src/MQTTCommon/MQTTConnectClient.c	Wed Jan 25 10:34:16 2017 -0700
@@ -23,9 +23,9 @@
   * @param options the options to be used to build the connect packet
   * @return the length of buffer needed to contain the serialized version of the packet
   */
-int MQTTSerialize_connectLength(MQTTPacket_connectData* options)
+size_t MQTTSerialize_connectLength(MQTTPacket_connectData* options)
 {
-	int len = 0;
+	size_t len = 0;
 
 
 	if (options->MQTTVersion == 3)
@@ -52,12 +52,12 @@
   * @param options the options to be used to build the connect packet
   * @return serialized length, or error if 0
   */
-int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options)
+int MQTTSerialize_connect(unsigned char* buf, size_t buflen, MQTTPacket_connectData* options)
 {
 	unsigned char *ptr = buf;
 	MQTTHeader header = {0};
 	MQTTConnectFlags flags = {0};
-	int len = 0;
+	size_t len = 0;
 	int rc = -1;
 
 	if (MQTTPacket_len(len = MQTTSerialize_connectLength(options)) > buflen)
@@ -110,7 +110,7 @@
 	if (flags.bits.password)
 		writeMQTTString(&ptr, options->password);
 
-	rc = ptr - buf;
+	rc = (int)(ptr - buf);
 
 	exit:
 	return rc;
@@ -125,7 +125,7 @@
   * @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(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen)
+int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, size_t buflen)
 {
 	MQTTHeader header = {0};
 	unsigned char* curdata = buf;
@@ -160,7 +160,7 @@
   * @param packettype the message type
   * @return serialized length, or error if 0
   */
-int MQTTSerialize_zero(unsigned char* buf, int buflen, unsigned char packettype)
+int MQTTSerialize_zero(unsigned char* buf, size_t buflen, unsigned char packettype)
 {
 	MQTTHeader header = {0};
 	int rc = -1;
@@ -176,7 +176,7 @@
 	writeChar(&ptr, header.byte); /* write header */
 
 	ptr += MQTTPacket_encode(ptr, 0); /* write remaining length */
-	rc = ptr - buf;
+	rc = (int)(ptr - buf);
 exit:
 	return rc;
 }
@@ -188,7 +188,7 @@
   * @param buflen the length in bytes of the supplied buffer, to avoid overruns
   * @return serialized length, or error if 0
   */
-int MQTTSerialize_disconnect(unsigned char* buf, int buflen)
+int MQTTSerialize_disconnect(unsigned char* buf, size_t buflen)
 {
 	return MQTTSerialize_zero(buf, buflen, DISCONNECT_MSG);
 }
@@ -200,7 +200,7 @@
   * @param buflen the length in bytes of the supplied buffer, to avoid overruns
   * @return serialized length, or error if 0
   */
-int MQTTSerialize_pingreq(unsigned char* buf, int buflen)
+int MQTTSerialize_pingreq(unsigned char* buf, size_t buflen)
 {
 	return MQTTSerialize_zero(buf, buflen, PINGREQ_MSG);
 }