winwet w7500 / Mbed 2 deprecated Internet_Piano_v2

Dependencies:   SDFileSystem WIZnetInterface httpServer mbed

Fork of HTTPWebServer-WIZwiki-W750023 by ajeet prajapati

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 "FsHandler.h"
00004 #include "HTTPServer.h"
00005 #include "SDFileSystem.h"
00006 
00007 #if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
00008     //Choose one of file system.
00009     SDFileSystem local(SD_MOSI, SD_MISO, SD_CLK, SD_SEL, "local");//PB_3, PB_2, PB_1, PB_0
00010     //LocalFileSystem local("local");
00011 #endif
00012 
00013 #if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
00014     uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0xFF, 0xFF, 0x02};
00015 #endif
00016 
00017 // Declare Ethernet Class
00018 EthernetInterface eth;
00019 
00020 // Declare HTTP Server Class
00021 HTTPServer  svr;
00022 
00023 // Set Server Network
00024 char ip_addr[] = "192.168.0.112";
00025 char subnet_mask[] = "255.255.255.0";
00026 char gateway_addr[] = "192.168.0.1";
00027 
00028 
00029 int main()
00030 {
00031  //   HTTPFsRequestHandler::mount_eth(&eth);
00032     HTTPFsRequestHandler::mount("/local/", "/");
00033     svr.addHandler<HTTPFsRequestHandler>("/");
00034 
00035 #if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
00036     
00037     #ifdef DHCP
00038         eth.init(mac_addr); //Use DHCP
00039     #else
00040         eth.init(mac_addr, ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
00041     #endif
00042 
00043 #else
00044 
00045     #ifdef DHCP
00046         eth.init(); //Use DHCP
00047     #else
00048         eth.init(ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
00049     #endif
00050 
00051 #endif
00052 
00053     printf("Check Ethernet Link\r\n");
00054     while(1) //Wait link up
00055     {
00056         if(eth.link() == true) 
00057             break;
00058     }
00059     printf("Link up\r\n");
00060 
00061     eth.connect();
00062     printf("Server IP Address is %s\r\n", eth.getIPAddress());
00063 
00064     if (!svr.start(80, &eth)) {
00065 
00066         error("Server not starting !");
00067         exit(0);
00068     }
00069 
00070     while(1) {
00071         svr.poll();
00072     }
00073     
00074 }
00075