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.
MQTTNetwork.h
00001 #ifndef _MQTTNETWORK_H_ 00002 #define _MQTTNETWORK_H_ 00003 00004 #include "EthernetInterface.h" 00005 #include "TCPSocket.h" 00006 00007 class MQTTNetwork 00008 { 00009 public: 00010 MQTTNetwork(EthernetInterface* aNetwork) : 00011 network(aNetwork), 00012 socket(new TCPSocket) 00013 {} 00014 00015 ~ MQTTNetwork() { delete socket; } 00016 int read(unsigned char* buffer, int len, int timeout) { return socket->recv(buffer, len); } 00017 int write(unsigned char* buffer, int len, int timeout) { return socket->send(buffer, len); } 00018 int connect(const char* hostname, uint16_t port) 00019 { 00020 SocketAddress addr; 00021 00022 socket->open(network); 00023 addr.set_ip_address(hostname); 00024 addr.set_port(port); 00025 return socket->connect(addr); 00026 } 00027 int disconnect() { return socket->close(); } 00028 private: 00029 EthernetInterface* network; 00030 TCPSocket* socket; 00031 }; 00032 #endif // _MQTTNETWORK_H_
Generated on Tue Jul 12 2022 23:30:50 by
1.7.2