sensor web server

Dependencies:   EthernetNetIf HTTPServer mbed

Revision:
0:803d8094260a
diff -r 000000000000 -r 803d8094260a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 18 11:24:12 2012 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HTTPServer.h"
+
+#include "SensorHandler.h"
+
+EthernetNetIf ethif( IpAddr(192,168,1,102), // IP
+                     IpAddr(255,255,255,0), // Subnet mask
+                     IpAddr(192,168,1,1),   // Gateway
+                     IpAddr(192,168,1,1) ); // DNS
+HTTPServer server;
+DigitalOut led1(LED1);  // for alive check
+
+int main(void)
+{
+    // EthernetNetIf setup
+    if( ethif.setup() )
+    {
+        return 1;
+    }
+
+    // Set web root path handler
+    server.addHandler<SensorHandler>("/");
+    
+    // Set http port
+    server.bind(80);
+
+    Timer tm;
+    tm.start();
+    while(1)
+    {
+        Net::poll();
+        if( 1.0 < tm.read() )
+        {
+            led1 = !led1;   // high->low, low->high
+            tm.start();
+        }
+    }
+}
\ No newline at end of file