Mohamad Nazrin Napiah / Mbed 2 deprecated HttpServer

Dependencies:   C12832_lcd EthernetInterface HttpServer mbed-rpc mbed-rtos mbed

Dependents:   HttpServer

Fork of HttpServerSample by Yasushi TAUCHI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EthernetInterface.h"
00003 #include "HTTPServer.h"
00004 #include "C12832_lcd.h" // Include for LCD code
00005 
00006 C12832_LCD lcd; //Initialize LCD Screen
00007 
00008 
00009 EthernetInterface eth;
00010 
00011     static const char*          mbedIp       = "192.168.137.2";  //IP
00012     static const char*          mbedMask     = "255.255.255.0";  // Mask
00013     static const char*          mbedGateway  = "192.168.137.1";    //Gateway
00014    
00015 int main()
00016 {
00017     printf("********* PROGRAM START ***********\r\n");
00018     printf("EthernetInterface Setting up...\r\n");
00019     //if(eth.init()!=0) {                             //for DHCP Server
00020         if(eth.init(mbedIp,mbedMask,mbedGateway)!=0) { //for Static IP Address
00021         printf("EthernetInterface Initialize Error \r\n");
00022         return -1;
00023     }
00024     if(eth.connect()!=0) {
00025         printf("EthernetInterface Connect Error \r\n");
00026         return -1;
00027     }
00028     printf("IP Address is %s\r\n", eth.getIPAddress());
00029     printf("NetMask is %s\r\n", eth.getNetworkMask());
00030     printf("Gateway Address is %s\r\n", eth.getGateway());
00031     printf("Ethernet Setup OK\r\n");
00032 
00033     HTTPServerAddHandler<SimpleHandler>("/"); //Default handler
00034     lcd.locate(0,0);
00035     lcd.printf("IP:%s",eth.getIPAddress());
00036     HTTPServerStart(80);
00037 }
00038 
00039