Dependencies:
MQTTPacket
FP
Revision 60:de9d500da15f, committed 2021-03-11
- Comitter:
- dinos95
- Date:
- Thu Mar 11 15:11:33 2021 +0000
- Parent:
- 59:9cff7b6bbd01
- Commit message:
- potistiri
Changed in this revision
diff -r 9cff7b6bbd01 -r de9d500da15f MQTTClient.h
--- a/MQTTClient.h Thu Nov 02 12:12:41 2017 +0000
+++ b/MQTTClient.h Thu Mar 11 15:11:33 2021 +0000
@@ -108,7 +108,7 @@
* @param Network a network class which supports send, receive
* @param Timer a timer class with the methods:
*/
-template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE = 100, int MAX_MESSAGE_HANDLERS = 5>
+template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE = 2000, int MAX_MESSAGE_HANDLERS =10>
class Client
{
diff -r 9cff7b6bbd01 -r de9d500da15f MQTTNetwork.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTTNetwork.h Thu Mar 11 15:11:33 2021 +0000
@@ -0,0 +1,48 @@
+
+#ifndef _MQTTNETWORK_H_
+#define _MQTTNETWORK_H_
+
+
+#include "EthernetInterface.h"
+
+class MQTTNetwork {
+public:
+ MQTTNetwork(NetworkInterface* aNetwork) : network(aNetwork) {
+ socket = new TCPSocket();
+ }
+
+ ~MQTTNetwork() {
+ delete socket;
+ }
+
+ int read(unsigned char* buffer, int len, int timeout) {
+ return socket->recv(buffer, len);
+ }
+
+ int write(unsigned char* buffer, int len, int timeout) {
+ return socket->send(buffer, len);
+ }
+
+ int connect(const char* hostname, int port) {
+ /*
+ socket->open(network);
+ return socket->connect(hostname, port);
+ */
+ socket->open(network);
+ network->gethostbyname(hostname,&a);
+ a.set_port(port);
+ return socket->connect(a);
+ }
+
+ int disconnect() {
+ return socket->close();
+ }
+
+private:
+ NetworkInterface* network;
+ TCPSocket* socket;
+ SocketAddress a;
+};
+
+
+#endif // _MQTTNETWORK_H_
\ No newline at end of file