An API for using MQTT over multiple transports for mbed OS 5
Fork of MQTT by
MQTTSocket.h
- Committer:
- JPlenert
- Date:
- 2017-01-30
- Revision:
- 47:a38f394916ff
- Parent:
- 43:21da1f744243
File content as of revision 47:a38f394916ff:
#if !defined(MQTTSOCKET_H) #define MQTTSOCKET_H #include "MQTTmbed.h" #include <TCPSocket.h> class MQTTSocket { public: MQTTSocket(EthernetInterface ð) { mysock.open(ð); } int connect(char* hostname, int port, int timeout=1000) { mysock.set_timeout(timeout); return mysock.connect(hostname, port); } int read(unsigned char* buffer, int len, int timeout) { mysock.set_timeout(timeout); return mysock.recv((void*)buffer, len); } int write(unsigned char* buffer, int len, int timeout) { mysock.set_timeout(timeout); return mysock.send((char*)buffer, len); } int disconnect() { return mysock.close(); } private: TCPSocket mysock; }; #endif