sasa ivkovic / Mbed 2 deprecated LAN

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EthernetNetIf.h"
00003 #include "HTTPServer.h"
00004 #include "TextLCD.h"
00005 
00006 
00007 EthernetNetIf eth;  
00008 HTTPServer svr;
00009 
00010 DigitalOut led1(LED1);
00011 TextLCD lcd(p14, p15, p16, p17, p18, p19);
00012 
00013 int main() {
00014   lcd.printf("Setting up...\n");
00015   EthernetErr ethErr = eth.setup();
00016   if(ethErr)
00017   {
00018     lcd.printf("Error %d in setup.\n", ethErr);
00019     return -1;
00020   }
00021   lcd.printf("Setup OK\n");
00022   
00023   svr.addHandler<SimpleHandler>("/"); //Default handler
00024   svr.bind(80);
00025   
00026   lcd.printf("Listening...\n");
00027     
00028   Timer tm;
00029   tm.start();
00030   //Listen indefinitely
00031   while(true)
00032   {
00033     Net::poll();
00034     if(tm.read()>.5)
00035     {
00036       led1=!led1; //Show that we are alive
00037       tm.start();
00038     }
00039   }
00040   
00041  
00042 }