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/MQTTSerializePublish.c	Tue Nov 08 18:48:37 2016 -0700
+++ b/src/MQTTCommon/MQTTSerializePublish.c	Wed Jan 25 10:34:16 2017 -0700
@@ -27,9 +27,9 @@
   * @param payloadlen the length of the payload to be sent
   * @return the length of buffer needed to contain the serialized version of the packet
   */
-int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen)
+size_t MQTTSerialize_publishLength(int qos, MQTTString topicName, size_t payloadlen)
 {
-	int len = 0;
+	size_t len = 0;
 
 	len += 2 + MQTTstrlen(topicName) + payloadlen;
 	if (qos > 0)
@@ -51,12 +51,12 @@
   * @param payloadlen integer - the length of the MQTT payload
   * @return the length of the serialized data.  <= 0 indicates error
   */
-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 MQTTSerialize_publish(unsigned char* buf, size_t buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
+		MQTTString topicName, unsigned char* payload, size_t payloadlen)
 {
 	unsigned char *ptr = buf;
 	MQTTHeader header = {0};
-	int rem_len = 0;
+	size_t rem_len = 0;
 	int rc = 0;
 
 	if (MQTTPacket_len(rem_len = MQTTSerialize_publishLength(qos, topicName, payloadlen)) > buflen)
@@ -81,7 +81,7 @@
 	memcpy(ptr, payload, payloadlen);
 	ptr += payloadlen;
 
-	rc = ptr - buf;
+	rc = (int)(ptr - buf);
 
 exit:
 	return rc;
@@ -98,7 +98,7 @@
   * @param packetid the MQTT packet identifier
   * @return serialized length, or error if 0
   */
-int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
+int MQTTSerialize_ack(unsigned char* buf, size_t buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
 {
 	MQTTHeader header = {0};
 	int rc = 0;
@@ -116,7 +116,7 @@
 
 	ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
 	writeInt(&ptr, packetid);
-	rc = ptr - buf;
+	rc = (int)(ptr - buf);
 exit:
 	return rc;
 }
@@ -129,7 +129,7 @@
   * @param packetid integer - the MQTT packet identifier
   * @return serialized length, or error if 0
   */
-int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid)
+int MQTTSerialize_puback(unsigned char* buf, size_t buflen, unsigned short packetid)
 {
 	return MQTTSerialize_ack(buf, buflen, PUBACK_MSG, 0, packetid);
 }
@@ -143,7 +143,7 @@
   * @param packetid integer - the MQTT packet identifier
   * @return serialized length, or error if 0
   */
-int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid)
+int MQTTSerialize_pubrel(unsigned char* buf, size_t buflen, unsigned char dup, unsigned short packetid)
 {
 	return MQTTSerialize_ack(buf, buflen, PUBREL_MSG, dup, packetid);
 }
@@ -156,7 +156,7 @@
   * @param packetid integer - the MQTT packet identifier
   * @return serialized length, or error if 0
   */
-int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid)
+int MQTTSerialize_pubcomp(unsigned char* buf, size_t buflen, unsigned short packetid)
 {
 	return MQTTSerialize_ack(buf, buflen, PUBCOMP_MSG, 0, packetid);
 }