Jack Hansdampf / Mbed OS WebSwitch_ENC28J60_GSOE

Dependencies:   UIPEthernet_GSOE

Revision:
14:810ac368dd6e
Parent:
12:7c46dcf6f7e2
Child:
15:9beb9b99695d
--- a/main.cpp	Tue Sep 03 09:34:17 2019 +0000
+++ b/main.cpp	Sat Sep 07 17:53:02 2019 +0000
@@ -8,6 +8,7 @@
 
 //#define DEBUG
 
+// Static IP address must be unique and compatible with your network.
 #define IP      "192.168.1.35"
 #define GATEWAY "192.168.1.1"
 #define NETMASK "255.255.255.0"
@@ -215,9 +216,11 @@
 {
     printf("Starting ...\r\n");
 
-    // IP address must be unique and compatible with your network.
     //net.set_network(IP, NETMASK, GATEWAY);  // include this for using static IP address
-    net.connect();
+    if (net.connect(30) != 0) { // 'connect' timeout in seconds (defaults to 60 sec)
+        printf("Unable to connet.\r\n");
+        return -1;
+    }
 
     // Show the network address
     const char*     ip = net.get_ip_address();
@@ -227,9 +230,9 @@
     printf("IP address: %s\r\n", ip ? ip : "None");
     printf("Netmask: %s\r\n", netmask ? netmask : "None");
     printf("Gateway: %s\r\n\r\n", gateway ? gateway : "None");
-    printf("------------------------------------------------------\r\n");
-    printf("Usage: Type %s/%s/ into your web browser and hit ENTER\r\n", net.get_ip_address(), PASSWORD.c_str());
-    printf("------------------------------------------------------\r\n");
+    printf("------------------------------------------------------------------\r\n");
+    printf("Usage: Type %s/%s/ into your web browser and hit ENTER\r\n", ip, PASSWORD.c_str());
+    printf("------------------------------------------------------------------\r\n");
 
     /* Open the server on ethernet stack */
     server.open(&net);
@@ -237,8 +240,8 @@
     /* Bind the HTTP port (TCP 80) to the server */
     server.bind(PORT);
 
-    /* Can handle 5 simultaneous connections */
-    server.listen(5);
+    /* Can handle 4 simultaneous connections */
+    server.listen(4);
 
     while (true) {
         client = server.accept();