Committer:
TP
Date:
Mon Jun 13 19:06:09 2011 +0000
Revision:
0:a4a5adb694e5
Child:
1:fae5b4e9987e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TP 0:a4a5adb694e5 1 #include "mbed.h"
TP 0:a4a5adb694e5 2 #include "EthernetNetIf.h"
TP 0:a4a5adb694e5 3 #include "HttpServer.h"
TP 0:a4a5adb694e5 4 #include "TextLCD.h"
TP 0:a4a5adb694e5 5
TP 0:a4a5adb694e5 6 DigitalOut led1(LED1, "led1");
TP 0:a4a5adb694e5 7 DigitalOut led2(LED2, "led2");
TP 0:a4a5adb694e5 8 DigitalOut led3(LED3, "led3");
TP 0:a4a5adb694e5 9 DigitalOut led4(LED4, "led4");
TP 0:a4a5adb694e5 10
TP 0:a4a5adb694e5 11 LocalFileSystem fs("webfs");
TP 0:a4a5adb694e5 12
TP 0:a4a5adb694e5 13 DigitalOut rw(p25);
TP 0:a4a5adb694e5 14 TextLCD lcd(p26,p24,p23,p22,p20,p19, TextLCD::LCD20x4);
TP 0:a4a5adb694e5 15
TP 0:a4a5adb694e5 16
TP 0:a4a5adb694e5 17 EthernetNetIf eth;
TP 0:a4a5adb694e5 18 HttpServer svr;
TP 0:a4a5adb694e5 19
TP 0:a4a5adb694e5 20 int main() {
TP 0:a4a5adb694e5 21 rw = 0;
TP 0:a4a5adb694e5 22
TP 0:a4a5adb694e5 23 Base::add_rpc_class<DigitalOut>();
TP 0:a4a5adb694e5 24 lcd.cls();
TP 0:a4a5adb694e5 25 lcd.printf("Setting up..");
TP 0:a4a5adb694e5 26 EthernetErr ethErr = eth.setup();
TP 0:a4a5adb694e5 27 if(ethErr)
TP 0:a4a5adb694e5 28 {
TP 0:a4a5adb694e5 29 lcd.printf("Error %d\n", ethErr);
TP 0:a4a5adb694e5 30 return -1;
TP 0:a4a5adb694e5 31 }
TP 0:a4a5adb694e5 32 lcd.printf("OK\n");
TP 0:a4a5adb694e5 33
TP 0:a4a5adb694e5 34 svr.addHandler<SimpleHandler>("/hello");
TP 0:a4a5adb694e5 35 svr.addHandler<RpcHandler>("/rpc");
TP 0:a4a5adb694e5 36 svr.addHandler<FSHandler>(""); //Default handler
TP 0:a4a5adb694e5 37 //Example : Access to mbed.htm : http://a.b.c.d/webfs/demo.htm
TP 0:a4a5adb694e5 38 //Zet demo.htm in de root van de mbed.
TP 0:a4a5adb694e5 39 svr.bind(80);
TP 0:a4a5adb694e5 40
TP 0:a4a5adb694e5 41 lcd.printf("Listening..see:\nhttp://a.b.c.d/webfs/demo.htm");
TP 0:a4a5adb694e5 42
TP 0:a4a5adb694e5 43 Timer tm;
TP 0:a4a5adb694e5 44 tm.start();
TP 0:a4a5adb694e5 45 //Listen indefinitely
TP 0:a4a5adb694e5 46 while(true)
TP 0:a4a5adb694e5 47 {
TP 0:a4a5adb694e5 48 Net::poll();
TP 0:a4a5adb694e5 49 if(tm.read()>.5)
TP 0:a4a5adb694e5 50 {
TP 0:a4a5adb694e5 51 led1=!led1; //Show that we are alive
TP 0:a4a5adb694e5 52 tm.start();
TP 0:a4a5adb694e5 53 }
TP 0:a4a5adb694e5 54 }
TP 0:a4a5adb694e5 55
TP 0:a4a5adb694e5 56 return 0;
TP 0:a4a5adb694e5 57
TP 0:a4a5adb694e5 58 }