An API for using MQTT over multiple transports
Dependents: EthW5500 EthW5500 wmx_laser wmx_laser_copy ... more
Fork of MQTT by
MQTTSocket.h
00001 #if !defined(MQTTSOCKET_H) 00002 #define MQTTSOCKET_H 00003 00004 #include "MQTTmbed.h" 00005 #include "TCPSocketConnection.h" 00006 00007 class MQTTSocket 00008 { 00009 public: 00010 int connect(char* hostname, int port, int timeout=1000) 00011 { 00012 mysock.set_blocking(false, timeout); // 1 second Timeout 00013 return mysock.connect(hostname, port); 00014 } 00015 00016 int read(unsigned char* buffer, int len, int timeout) 00017 { 00018 mysock.set_blocking(false, timeout); 00019 return mysock.receive((char*)buffer, len); 00020 } 00021 00022 int write(unsigned char* buffer, int len, int timeout) 00023 { 00024 mysock.set_blocking(false, timeout); 00025 return mysock.send((char*)buffer, len); 00026 } 00027 00028 int disconnect() 00029 { 00030 return mysock.close(); 00031 } 00032 00033 private: 00034 00035 TCPSocketConnection mysock; 00036 00037 }; 00038 00039 00040 00041 #endif
Generated on Tue Jul 12 2022 17:25:25 by 1.7.2