High level MQTT-SN C++ library
Dependencies: EthernetInterface FP MQTTSNPacket
MQTTSNUDP.h
00001 #if !defined(MQTTSOCKET_H) 00002 #define MQTTSOCKET_H 00003 00004 #include "MQTTmbed.h" 00005 #include "UDPSocket.h" 00006 00007 class MQTTSNUDP 00008 { 00009 public: 00010 int connect(char* hostname, int port, int timeout=1000) 00011 { 00012 mysock.init(); 00013 //mysock.set_blocking(false, timeout); // 1 second Timeout 00014 return remote.set_address((const char *)hostname, port); 00015 } 00016 00017 int read(unsigned char* buffer, int len, int timeout) 00018 { 00019 mysock.set_blocking(false, timeout); 00020 return mysock.receiveFrom(remote, (char *)buffer, len); 00021 } 00022 00023 int write(unsigned char* buffer, int len, int timeout) 00024 { 00025 mysock.set_blocking(false, timeout); 00026 return mysock.sendTo(remote, (char*)buffer, len); 00027 } 00028 00029 int disconnect() 00030 { 00031 return mysock.close(); 00032 } 00033 00034 private: 00035 00036 UDPSocket mysock; 00037 Endpoint remote; 00038 00039 }; 00040 00041 00042 00043 #endif
Generated on Fri Jul 15 2022 11:00:18 by 1.7.2