An API for using MQTT over multiple transports for mbed OS 5
Fork of MQTT by
Revision 47:a38f394916ff, committed 2017-01-30
- Comitter:
- JPlenert
- Date:
- Mon Jan 30 19:26:31 2017 +0000
- Parent:
- 46:e335fcc1a663
- Commit message:
- Needed changed for mbed OS 5
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 |
diff -r e335fcc1a663 -r a38f394916ff MQTTEthernet.h --- a/MQTTEthernet.h Tue Aug 18 09:57:19 2015 +0000 +++ b/MQTTEthernet.h Mon Jan 30 19:26:31 2017 +0000 @@ -1,4 +1,3 @@ - #if !defined(MQTTETHERNET_H) #define MQTTETHERNET_H @@ -9,10 +8,8 @@ class MQTTEthernet : public MQTTSocket { public: - MQTTEthernet() + MQTTEthernet(EthernetInterface ði) : eth(ethi), MQTTSocket(ethi) { - eth.init(); // Use DHCP - eth.connect(); } EthernetInterface& getEth() @@ -27,9 +24,9 @@ private: - EthernetInterface eth; + EthernetInterface ð }; -#endif +#endif \ No newline at end of file
diff -r e335fcc1a663 -r a38f394916ff MQTTSocket.h --- a/MQTTSocket.h Tue Aug 18 09:57:19 2015 +0000 +++ b/MQTTSocket.h Mon Jan 30 19:26:31 2017 +0000 @@ -2,26 +2,31 @@ #define MQTTSOCKET_H #include "MQTTmbed.h" -#include "TCPSocketConnection.h" +#include <TCPSocket.h> class MQTTSocket { -public: +public: + MQTTSocket(EthernetInterface ð) + { + mysock.open(ð); + } + int connect(char* hostname, int port, int timeout=1000) { - mysock.set_blocking(false, timeout); // 1 second Timeout + mysock.set_timeout(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); + mysock.set_timeout(timeout); + return mysock.recv((void*)buffer, len); } int write(unsigned char* buffer, int len, int timeout) { - mysock.set_blocking(false, timeout); + mysock.set_timeout(timeout); return mysock.send((char*)buffer, len); } @@ -32,7 +37,7 @@ private: - TCPSocketConnection mysock; + TCPSocket mysock; };