MQTT Client example program. Ethernet connection is via an ENC28J60 module.

Dependencies:   UIPEthernet MQTTClient

Revision:
13:6b2f125cc9b8
Parent:
12:3af0ae09bd01
Child:
14:b2c96d7b4335
--- a/main.cpp	Tue Sep 03 13:45:22 2019 +0000
+++ b/main.cpp	Sat Sep 07 18:14:51 2019 +0000
@@ -19,13 +19,14 @@
 #define GATEWAY     "192.168.1.1"
 #define NETMASK     "255.255.255.0"
 #define SERVER_IP   "192.168.1.31"              // IP address of your MQTT broker. Change to match your case.
+#define MQTT_PORT   1883
 
 // MAC address must unique within the connected network! Change it as needed.
-const uint8_t   MAC[6] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x06 };
+const uint8_t   MAC[6] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
 UipEthernet     net(MAC, D11, D12, D13, D10);   // mac, mosi, miso, sck, cs
 void            onMqttMessage(char* topic, uint8_t* payload, unsigned int length);  // ISR (callback) to handle arrived MQTT messages.
 TcpClient       client;
-MQTTClient      mqttClient(SERVER_IP, 1883, onMqttMessage, client);
+MQTTClient      mqttClient(SERVER_IP, MQTT_PORT, onMqttMessage, client);
 char            message_buff[MQTT_MAX_PACKET_SIZE];                                 // buffer to store received messages
 
 /**