Initial port of the Arduino MQTT Client: http://knolleary.net/arduino-client-for-mqtt/ Updated with larger timeout and buffer sizes

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_mqtt_endpoint_nxp

Fork of MQTT by Joerg Wende

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Mon Jun 30 22:17:23 2014 +0000
Parent:
8:40326dd71c95
Commit message:
updates for ublox cellular modem enablement

Changed in this revision

PubSubClient.cpp Show annotated file Show diff for this revision Revisions of this file
PubSubClient.h Show annotated file Show diff for this revision Revisions of this file
--- a/PubSubClient.cpp	Mon Apr 07 03:47:16 2014 +0000
+++ b/PubSubClient.cpp	Mon Jun 30 22:17:23 2014 +0000
@@ -109,7 +109,11 @@
             while ((len=readPacket(llen))==0) {
                 unsigned long t = millis();
                 if (t-lastInActivity > MQTT_KEEPALIVE*1000UL) {
+#ifdef CELLULAR_NETWORK
+                    _client.close();
+#else
                     _client.close(true);
+#endif
                     return false;
                 }
             }
@@ -120,7 +124,11 @@
                 return true;
             }
         }
+#ifdef CELLULAR_NETWORK
+        _client.close();
+#else
         _client.close(true);
+#endif
     }
     return false;
 }
@@ -139,7 +147,11 @@
         unsigned long t = millis();
         if ((t - lastInActivity > MQTT_KEEPALIVE*1000UL) || (t - lastOutActivity > MQTT_KEEPALIVE*1000UL)) {
             if (pingOutstanding) {
+#ifdef CELLULAR_NETWORK
+                _client.close();
+#else
                 _client.close(true);
+#endif
                 return false;
             } else {
                 buffer[0] = MQTTPINGREQ;
@@ -295,7 +307,11 @@
     buffer[0] = MQTTDISCONNECT;
     buffer[1] = 0;
     _client.send(buffer,2);
+#ifdef CELLULAR_NETWORK
+    _client.close();
+#else
     _client.close(true);
+#endif
     lastInActivity = lastOutActivity = millis();
 }
 
@@ -318,6 +334,10 @@
 {
     bool rc;
     rc = (int)_client.is_connected();
+#ifdef CELLULAR_NETWORK
+    if (!rc) _client.close();
+#else
     if (!rc) _client.close(true);
+#endif
     return rc;
 }
\ No newline at end of file
--- a/PubSubClient.h	Mon Apr 07 03:47:16 2014 +0000
+++ b/PubSubClient.h	Mon Jun 30 22:17:23 2014 +0000
@@ -9,7 +9,8 @@
 #ifndef PubSubClient_h
 #define PubSubClient_h
 
-
+// Have to include so we can do different stuff with cellular stacks... ugh... 
+#include "Definitions.h"
 
 // MQTT_MAX_PACKET_SIZE : Maximum packet size
 #define MQTT_MAX_PACKET_SIZE 128