MQTT lib for WISEAgent

Dependencies:   FP MQTTPacket

Dependents:   MQTT_G_SENSOR

Fork of MQTT by MQTT

Files at this revision

API Documentation at this revision

Comitter:
ericliang
Date:
Wed Aug 12 02:38:46 2015 +0000
Parent:
44:c299463ae853
Child:
46:55dd947a124e
Commit message:
Modify MQTT lib for WISEAgent

Changed in this revision

MQTTAsync.h Show annotated file Show diff for this revision Revisions of this file
MQTTClient.h Show annotated file Show diff for this revision Revisions of this file
MQTTEthernet.h Show annotated file Show diff for this revision Revisions of this file
MQTTPacket.lib Show annotated file Show diff for this revision Revisions of this file
--- a/MQTTAsync.h	Mon Oct 06 11:41:05 2014 +0000
+++ b/MQTTAsync.h	Wed Aug 12 02:38:46 2015 +0000
@@ -21,6 +21,8 @@
 #include "MQTTPacket.h"
 #include "stdio.h"
 
+
+
 namespace MQTT
 {
 
@@ -62,7 +64,7 @@
 		
 	limits()
 	{
-		MAX_MQTT_PACKET_SIZE = 100;
+		MAX_MQTT_PACKET_SIZE = ADV_MAX_PACKET_SIZE;		
 		MAX_MESSAGE_HANDLERS = 5;
 		MAX_CONCURRENT_OPERATIONS = 1; // 1 indicates single-threaded mode - set to >1 for multithreaded mode
 		command_timeout_ms = 30000;
@@ -203,6 +205,7 @@
 	this->ping_outstanding = 0;
 	   
 	// How to make these memory allocations portable?  I was hoping to avoid the heap
+	printf("size=%d\n",limits.MAX_MQTT_PACKET_SIZE);
 	buf = new char[limits.MAX_MQTT_PACKET_SIZE];
 	readbuf = new char[limits.MAX_MQTT_PACKET_SIZE];
 	this->operations = new struct Operations[limits.MAX_CONCURRENT_OPERATIONS];
@@ -553,7 +556,7 @@
 
 	if (message->qos == QOS1 || message->qos == QOS2)
 		message->id = packetid.getNext();
-    
+
 	int len = MQTTSerialize_publish(buf, limits.MAX_MQTT_PACKET_SIZE, 0, message->qos, message->retained, message->id, topic, (char*)message->payload, message->payloadlen);
     int rc = sendPacket(len, atimer.left_ms()); // send the subscribe packet
 	if (rc != len) 
--- a/MQTTClient.h	Mon Oct 06 11:41:05 2014 +0000
+++ b/MQTTClient.h	Wed Aug 12 02:38:46 2015 +0000
@@ -88,7 +88,7 @@
  * @param Network a network class which supports send, receive
  * @param Timer a timer class with the methods:
  */
-template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE = 100, int MAX_MESSAGE_HANDLERS = 5>
+template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE = ADV_MAX_PACKET_SIZE, int MAX_MESSAGE_HANDLERS = 5>
 class Client
 {
 
@@ -804,6 +804,7 @@
 template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE, int b>
 int MQTT::Client<Network, Timer, MAX_MQTT_PACKET_SIZE, b>::publish(const char* topicName, void* payload, size_t payloadlen, unsigned short& id, enum QoS qos, bool retained)
 {
+    printf("eric 1\n");
     int rc = FAILURE;
     Timer timer = Timer(command_timeout_ms);
     MQTTString topicString = MQTTString_initializer;
@@ -818,9 +819,10 @@
     if (qos == QOS1 || qos == QOS2)
         id = packetid.getNext();
 #endif
-
+printf("eric 2\n");
     len = MQTTSerialize_publish(sendbuf, MAX_MQTT_PACKET_SIZE, 0, qos, retained, id,
               topicString, (unsigned char*)payload, payloadlen);
+              printf("eric 3 len=%d\n",len);
     if (len <= 0)
         goto exit;
         
@@ -845,7 +847,7 @@
 
 template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE, int b>
 int MQTT::Client<Network, Timer, MAX_MQTT_PACKET_SIZE, b>::publish(const char* topicName, void* payload, size_t payloadlen, enum QoS qos, bool retained)
-{
+{    
     unsigned short id = 0;  // dummy - not used for anything
     return publish(topicName, payload, payloadlen, id, qos, retained);
 }
--- a/MQTTEthernet.h	Mon Oct 06 11:41:05 2014 +0000
+++ b/MQTTEthernet.h	Wed Aug 12 02:38:46 2015 +0000
@@ -25,6 +25,7 @@
         eth.connect();  // nothing I've tried actually works to reconnect 
     }
     
+    
 private:
 
     EthernetInterface eth;
--- a/MQTTPacket.lib	Mon Oct 06 11:41:05 2014 +0000
+++ b/MQTTPacket.lib	Wed Aug 12 02:38:46 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/mqtt/code/MQTTPacket/#bf36e077e7b8
+http://mbed.org/teams/mqtt/code/MQTTPacket/#18bc6c007ce2