keuzeproject
Dependencies: mbed HTTPServer RemoteIR mbed-rtos SDFileSystem EthernetInterface mbed-rpc
HTTPServerHelloWorld.cpp@0:5630d7e58a0b, 2010-06-14 (annotated)
- Committer:
- donatien
- Date:
- Mon Jun 14 10:26:12 2010 +0000
- Revision:
- 0:5630d7e58a0b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:5630d7e58a0b | 1 | #include "mbed.h" |
donatien | 0:5630d7e58a0b | 2 | #include "EthernetNetIf.h" |
donatien | 0:5630d7e58a0b | 3 | #include "HTTPServer.h" |
donatien | 0:5630d7e58a0b | 4 | |
donatien | 0:5630d7e58a0b | 5 | EthernetNetIf eth; |
donatien | 0:5630d7e58a0b | 6 | HTTPServer svr; |
donatien | 0:5630d7e58a0b | 7 | |
donatien | 0:5630d7e58a0b | 8 | DigitalOut led1(LED1); |
donatien | 0:5630d7e58a0b | 9 | |
donatien | 0:5630d7e58a0b | 10 | int main() { |
donatien | 0:5630d7e58a0b | 11 | printf("Setting up...\n"); |
donatien | 0:5630d7e58a0b | 12 | EthernetErr ethErr = eth.setup(); |
donatien | 0:5630d7e58a0b | 13 | if(ethErr) |
donatien | 0:5630d7e58a0b | 14 | { |
donatien | 0:5630d7e58a0b | 15 | printf("Error %d in setup.\n", ethErr); |
donatien | 0:5630d7e58a0b | 16 | return -1; |
donatien | 0:5630d7e58a0b | 17 | } |
donatien | 0:5630d7e58a0b | 18 | printf("Setup OK\n"); |
donatien | 0:5630d7e58a0b | 19 | |
donatien | 0:5630d7e58a0b | 20 | svr.addHandler<SimpleHandler>("/"); //Default handler |
donatien | 0:5630d7e58a0b | 21 | svr.bind(80); |
donatien | 0:5630d7e58a0b | 22 | |
donatien | 0:5630d7e58a0b | 23 | printf("Listening...\n"); |
donatien | 0:5630d7e58a0b | 24 | |
donatien | 0:5630d7e58a0b | 25 | Timer tm; |
donatien | 0:5630d7e58a0b | 26 | tm.start(); |
donatien | 0:5630d7e58a0b | 27 | //Listen indefinitely |
donatien | 0:5630d7e58a0b | 28 | while(true) |
donatien | 0:5630d7e58a0b | 29 | { |
donatien | 0:5630d7e58a0b | 30 | Net::poll(); |
donatien | 0:5630d7e58a0b | 31 | if(tm.read()>.5) |
donatien | 0:5630d7e58a0b | 32 | { |
donatien | 0:5630d7e58a0b | 33 | led1=!led1; //Show that we are alive |
donatien | 0:5630d7e58a0b | 34 | tm.start(); |
donatien | 0:5630d7e58a0b | 35 | } |
donatien | 0:5630d7e58a0b | 36 | } |
donatien | 0:5630d7e58a0b | 37 | |
donatien | 0:5630d7e58a0b | 38 | return 0; |
donatien | 0:5630d7e58a0b | 39 | } |