Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FP MQTTPacket
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 Wed Jul 13 2022 03:44:46 by
1.7.2
