Modified MQTT for Mbed OS.

Dependencies:   FP MQTTPacket

Dependents:   mbed-os-mqtt door_lock co657_IoT nucleo-f429zi-mbed-os-mqtt

Fork of MQTT by MQTT

Files at this revision

API Documentation at this revision

Comitter:
azazeal88
Date:
Tue Nov 01 22:13:41 2016 +0000
Parent:
46:e335fcc1a663
Child:
48:83e45fa35cc8
Commit message:
Updated for Mbed OS

Changed in this revision

MQTTEthernet.h Show annotated file Show diff for this revision Revisions of this file
MQTTSocket.h Show annotated file Show diff for this revision Revisions of this file
--- a/MQTTEthernet.h	Tue Aug 18 09:57:19 2015 +0000
+++ b/MQTTEthernet.h	Tue Nov 01 22:13:41 2016 +0000
@@ -11,7 +11,6 @@
 public:    
     MQTTEthernet()
     {
-        eth.init();                          // Use DHCP
         eth.connect();
     }
     
@@ -20,9 +19,14 @@
         return eth;
     }
     
+    const char * get_ip_address()
+    {
+        return eth.get_ip_address();
+    }
+    
     void reconnect()
     {
-        eth.connect();  // nothing I've tried actually works to reconnect 
+        eth.connect(); 
     }
     
 private:
--- a/MQTTSocket.h	Tue Aug 18 09:57:19 2015 +0000
+++ b/MQTTSocket.h	Tue Nov 01 22:13:41 2016 +0000
@@ -2,26 +2,28 @@
 #define MQTTSOCKET_H
 
 #include "MQTTmbed.h"
-#include "TCPSocketConnection.h"
+#include "TCPSocket.h"
 
 class MQTTSocket
 {
 public:    
+
+    int open(EthernetInterface& eth){
+        return mysock.open(&eth);
+    }    
+
     int connect(char* hostname, int port, int timeout=1000)
     {
-        mysock.set_blocking(false, timeout);    // 1 second Timeout 
         return mysock.connect(hostname, port);
     }
 
     int read(unsigned char* buffer, int len, int timeout)
     {
-        mysock.set_blocking(false, timeout);  
-        return mysock.receive((char*)buffer, len);
+        return mysock.recv((char*)buffer, len);
     }
     
     int write(unsigned char* buffer, int len, int timeout)
     {
-        mysock.set_blocking(false, timeout);  
         return mysock.send((char*)buffer, len);
     }
     
@@ -32,7 +34,7 @@
     
 private:
 
-    TCPSocketConnection mysock; 
+    TCPSocket mysock; 
     
 };