High level MQTT-SN C++ library

Dependencies:   EthernetInterface FP MQTTSNPacket

Dependents:   HelloMQTTSN

Revision:
0:ae83cacd60d2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTTSNUDP.h	Thu Feb 26 16:01:40 2015 +0000
@@ -0,0 +1,43 @@
+#if !defined(MQTTSOCKET_H)
+#define MQTTSOCKET_H
+
+#include "MQTTmbed.h"
+#include "UDPSocket.h"
+
+class MQTTSNUDP
+{
+public:    
+    int connect(char* hostname, int port, int timeout=1000)
+    {
+        mysock.init();
+        //mysock.set_blocking(false, timeout);    // 1 second Timeout 
+        return remote.set_address((const char *)hostname, port);
+    }
+
+    int read(unsigned char* buffer, int len, int timeout)
+    {
+        mysock.set_blocking(false, timeout);  
+        return mysock.receiveFrom(remote, (char *)buffer, len);
+    }
+    
+    int write(unsigned char* buffer, int len, int timeout)
+    {
+        mysock.set_blocking(false, timeout);  
+        return mysock.sendTo(remote, (char*)buffer, len);
+    }
+    
+    int disconnect()
+    {
+        return mysock.close();
+    }
+    
+private:
+
+    UDPSocket mysock;
+    Endpoint remote;
+    
+};
+
+
+
+#endif