test

Dependencies:   EthernetNetIf mbed

Fork of HTTPServer by Donatien Garnier

Committer:
y_notsu
Date:
Wed Jan 23 12:39:09 2013 +0000
Revision:
7:4e8f5ce9c0f3
Child:
8:2b1867fdf78f
Networking test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
y_notsu 7:4e8f5ce9c0f3 1 #include "mbed.h"
y_notsu 7:4e8f5ce9c0f3 2 #include "EthernetNetIf.h"
y_notsu 7:4e8f5ce9c0f3 3 #include "HTTPServer.h"
y_notsu 7:4e8f5ce9c0f3 4
y_notsu 7:4e8f5ce9c0f3 5 EthernetNetIf eth;
y_notsu 7:4e8f5ce9c0f3 6 HTTPServer svr;
y_notsu 7:4e8f5ce9c0f3 7
y_notsu 7:4e8f5ce9c0f3 8 DigitalOut led1(LED1);
y_notsu 7:4e8f5ce9c0f3 9
y_notsu 7:4e8f5ce9c0f3 10 int main() {
y_notsu 7:4e8f5ce9c0f3 11 printf("Setting up...\n");
y_notsu 7:4e8f5ce9c0f3 12 EthernetErr ethErr = eth.setup();
y_notsu 7:4e8f5ce9c0f3 13 if(ethErr)
y_notsu 7:4e8f5ce9c0f3 14 {
y_notsu 7:4e8f5ce9c0f3 15 printf("Error %d in setup.\n", ethErr);
y_notsu 7:4e8f5ce9c0f3 16 return -1;
y_notsu 7:4e8f5ce9c0f3 17 }
y_notsu 7:4e8f5ce9c0f3 18 printf("Setup OK\n");
y_notsu 7:4e8f5ce9c0f3 19
y_notsu 7:4e8f5ce9c0f3 20 svr.addHandler<SimpleHandler>("/"); //Default handler
y_notsu 7:4e8f5ce9c0f3 21 svr.bind(80);
y_notsu 7:4e8f5ce9c0f3 22
y_notsu 7:4e8f5ce9c0f3 23 printf("Listening...\n");
y_notsu 7:4e8f5ce9c0f3 24
y_notsu 7:4e8f5ce9c0f3 25 Timer tm;
y_notsu 7:4e8f5ce9c0f3 26 tm.start();
y_notsu 7:4e8f5ce9c0f3 27 //Listen indefinitely
y_notsu 7:4e8f5ce9c0f3 28 while(true)
y_notsu 7:4e8f5ce9c0f3 29 {
y_notsu 7:4e8f5ce9c0f3 30 Net::poll();
y_notsu 7:4e8f5ce9c0f3 31 if(tm.read()>.5)
y_notsu 7:4e8f5ce9c0f3 32 {
y_notsu 7:4e8f5ce9c0f3 33 led1=!led1; //Show that we are alive
y_notsu 7:4e8f5ce9c0f3 34 tm.start();
y_notsu 7:4e8f5ce9c0f3 35 }
y_notsu 7:4e8f5ce9c0f3 36 }
y_notsu 7:4e8f5ce9c0f3 37
y_notsu 7:4e8f5ce9c0f3 38 return 0;
y_notsu 7:4e8f5ce9c0f3 39 }