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.
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
| MQTTClient.h | Show annotated file Show diff for this revision Revisions of this file |
| MQTTNetwork.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
{
--- /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