Internet Piano for WIZwiki-W7500

Dependencies:   SDFileSystem WIZnetInterface httpServer mbed

Fork of httpServer-WIZwiki-W7500 by WIZnet

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 //#define DHCP
00008 
00009 #ifdef TARGET_WIZWIKI_W7500
00010     SDFileSystem local(SD_MOSI, SD_MISO, SD_CLK, SD_SEL, "local");//PB_3, PB_2, PB_1, PB_0
00011 #else
00012     LocalFileSystem local("local");
00013     //or TODO:
00014 #endif
00015 
00016 #ifdef TARGET_WIZWIKI_W7500
00017     uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
00018 #endif
00019 
00020 EthernetInterface eth;
00021 HTTPServer  svr;
00022 char ip_addr[] = "192.168.240.97";
00023 char subnet_mask[] = "255.255.255.0";
00024 char gateway_addr[] = "192.168.240.1";
00025 
00026 //#define DHCP //If uncomment, W7500 runs DHCP
00027 
00028 int main()
00029 {
00030     printf("Wait a second...\r\n");
00031     HTTPFsRequestHandler::mount("/local/", "/");
00032     svr.addHandler<HTTPFsRequestHandler>("/");
00033 
00034 #ifdef TARGET_WIZWIKI_W7500
00035     
00036     #ifdef DHCP
00037         eth.init(mac_addr); //Use DHCP
00038     #else
00039         eth.init(mac_addr, ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
00040     #endif
00041 
00042 #else
00043 
00044     #ifdef DHCP
00045         eth.init(); //Use DHCP
00046     #else
00047         eth.init(ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
00048     #endif
00049 
00050 #endif
00051 
00052 
00053 
00054     eth.connect();
00055     printf("Server IP Address is %s\r\n", eth.getIPAddress());
00056 
00057     if (!svr.start(80, &eth)) {
00058 
00059         error("Server not starting !");
00060         exit(0);
00061     }
00062 
00063     while(1) {
00064         svr.poll();
00065         wait(0.2);
00066     }
00067     
00068 }
00069