A simple HTTP server echoing received requests. Ethernet connection is over an ENC28J60 board. Usage: Type the server's IP address into you web browser and hit <ENTER>.

Dependencies:   UIPEthernet

Revision:
4:06fcbe983e24
Parent:
3:f3bfd257e138
Child:
5:068f4c368ab0
--- a/main.cpp	Fri Nov 27 20:48:39 2015 +0000
+++ b/main.cpp	Fri Nov 27 21:15:45 2015 +0000
@@ -9,10 +9,9 @@
 
 Serial  pc(USBTX, USBRX);
 
-#define DHCP    1   // comment out this line if you are not using DHCP
+#define DHCP    1   // comment out this line if you'd like to use static IP address
 
 // UIPEthernet is the name of a global instance of UIPEthernetClass.
-
 // Do not change the name! It is used within the UIPEthernet library.
 // Adapt the SPI pin names to your mbed platform/board if not present yet.
 #if defined(TARGET_LPC1768)
@@ -41,7 +40,6 @@
 
 const uint16_t  MY_PORT = 80;   // for HTTP connection
 EthernetServer  myServer = EthernetServer(MY_PORT);
-Serial          serial(USBTX, USBRX);
 
 /**
  * @brief
@@ -54,11 +52,11 @@
 
 #if defined(DHCP)
     pc.printf("Searching for DHCP server.\r\n");
-    pc.printf("It takes some time. Please wait..\r\n");
+    pc.printf("Please wait..\r\n");
 
     if(UIPEthernet.begin(MY_MAC) != 1) {
         pc.printf("No DHCP server found.\r\n");
-        pc.printf("Exiting application\r\n");
+        pc.printf("Exiting application.\r\n");
         return 0;
     }
 
@@ -82,8 +80,8 @@
                 char*   buf = (char*)malloc(size);
                 size = client.read((uint8_t*)buf, size);
                 if(buf[0] == 'G' && buf[1] == 'E' && buf[2] == 'T') {
-                    serial.printf("GET request received:\n\r");
-                    serial.printf(buf);
+                    pc.printf("GET request received:\n\r");
+                    pc.printf(buf);
                     char    echoHeader[256] = { };
                     sprintf
                     (
@@ -93,7 +91,7 @@
                     );
                     client.write((uint8_t*)echoHeader, strlen(echoHeader));
                     client.write((uint8_t*)buf, size);
-                    serial.printf("Echo done.\r\n");
+                    pc.printf("Echo done.\r\n");
                 }
                 free(buf);
             }