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

Dependencies:   UIPEthernet MQTTClient

Revision:
16:2c61673000e8
Parent:
15:da8fef967438
--- a/main.cpp	Thu Sep 12 22:01:55 2019 +0000
+++ b/main.cpp	Fri Jun 05 15:47:42 2020 +0000
@@ -59,7 +59,7 @@
  */
 int main(void)
 {
-    const int       MAX_TRIES = 5;
+    const int       MAX_TRIES = 1;
     const time_t    INTERVAL = 5;
     int             i = 0;
     bool            connected = false;
@@ -75,15 +75,17 @@
         return -1;
     }
 
-    // Show the network address
-    const char*     ip = net.get_ip_address();
-    const char*     netmask = net.get_netmask();
-    const char*     gateway = net.get_gateway();
-    printf("IP address: %s\n", ip ? ip : "None");
-    printf("Netmask: %s\n", netmask ? netmask : "None");
-    printf("Gateway: %s\n", gateway ? gateway : "None");
+    // Show the network address   
+    SocketAddress   addr;
+    net.get_ip_address(&addr);
+    printf("IP address: %s\n", addr.get_ip_address() ? addr.get_ip_address() : "None");
+    net.get_netmask(&addr);
+    printf("Netmask: %s\n", addr.get_ip_address() ? addr.get_ip_address() : "None");
+    net.get_gateway(&addr);
+    printf("Gateway: %s\n", addr.get_ip_address() ? addr.get_ip_address() : "None");
 
-    printf("Connecting to the MQTT broker ...  ");
+
+    printf("Connecting to the MQTT broker ...\r\n");
     do {
         wait(1.0);
         connected = mqttClient.connect("myMQTTHelloClient");