Single instance HTTP Server using new Ethernet Interface. Blocking mode only; this improved stability, but the HTTP server must be started from a separate thread.

Dependents:   SmartLight

Fork of HTTPServer by Henry Leinen

Revision:
16:cc3f5c53d0d5
Parent:
14:011edcd33e86
Child:
17:d7186c696729
diff -r 909dcf44c3db -r cc3f5c53d0d5 HTTPServer.cpp
--- a/HTTPServer.cpp	Sat Aug 17 15:34:07 2013 +0000
+++ b/HTTPServer.cpp	Sat Aug 17 16:17:55 2013 +0000
@@ -1,16 +1,8 @@
 #include "mbed.h"
 #include "HTTPServer.h"
 #define DEBUG
-#include "debug.h"
-
-#define _DEBUG      1
+#include "hl_debug.h"
 
-#ifdef _DEBUG
-DigitalOut led1(LED1);
-DigitalOut led2(LED2);
-DigitalOut led3(LED3);
-DigitalOut led4(LED4);
-#endif
 
 
 /* Constructor */
@@ -93,7 +85,7 @@
         return false;
     }
 
-    ERR("Connected !");
+    INFO("Connected !");
     //  set into non blocking operation
     m_Svr.set_blocking(false, 100);
 
@@ -103,34 +95,15 @@
 
 int HTTPServer::poll(bool blocking)
 {
-#ifdef _DEBUG
-    led4 = 1;   //  Indicate we are waiting for a new connection
-#endif
     //  This thread basically checks if there is a new incoming connection.
     //  If so , a new HTTPConnection is created and the connection thread is started.
     TCPSocketConnection Clnt;
     if (m_Svr.accept(Clnt) < 0) {
-#ifdef _DEBUG
-        led4 = 0;
-        led3 = 1;   //  ERROR
-        led2 = 0;
-        led1 = 0;
-#endif
         return -1;
     }
 
     //   a new connection was received
     INFO("Client (IP=%s) is connected !\n", Clnt.get_address());
-#ifdef _DEBUG
-    led4 = 0;
-    led3 = 0;
-    led2 = 0;
-#endif
-
-#ifdef _DEBUG
-    led3 = 1;
-    led2 = 1;
-#endif
     HTTPConnection con(Clnt);
     int c = con.poll();
     if (c == 0) {
@@ -141,11 +114,6 @@
     if (c == -1) {
 //        break;
     }
-#ifdef _DEBUG
-    led2 = 0;
-    led3 = 0;
-#endif
-
 
     INFO("Leaving polling thread");
     return 0;