iot_water_monitor_v2
Dependencies: easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code
MQTTNetwork.h
00001 #ifndef _MQTTNETWORK_H_ 00002 #define _MQTTNETWORK_H_ 00003 00004 #include "NetworkInterface.h" 00005 00006 class MQTTNetwork { 00007 public: 00008 MQTTNetwork(NetworkInterface* aNetwork) : network(aNetwork) { 00009 socket = new TCPSocket(); 00010 } 00011 00012 ~MQTTNetwork() { 00013 delete socket; 00014 } 00015 00016 int read(unsigned char* buffer, int len, int timeout) { 00017 socket->set_timeout(timeout); 00018 return socket->recv(buffer, len); 00019 } 00020 00021 int write(unsigned char* buffer, int len, int timeout) { 00022 socket->set_timeout(timeout); 00023 return socket->send(buffer, len); 00024 } 00025 00026 int connect(const char* hostname, int port) { 00027 socket->open(network); 00028 return socket->connect(hostname, port); 00029 } 00030 00031 int disconnect() { 00032 return socket->close(); 00033 } 00034 00035 private: 00036 NetworkInterface* network; 00037 TCPSocket* socket; 00038 }; 00039 00040 #endif // _MQTTNETWORK_H_
Generated on Tue Jul 12 2022 20:06:04 by 1.7.2