Internet piano practice for india academy

Dependencies:   SDFileSystem WIZnetInterface httpServer mbed

Fork of Internet-Piano_WIZwiki-W7500 by IOP

Piano Index Page

Committer:
justinkim
Date:
Fri Jul 10 05:36:36 2015 +0000
Revision:
18:c4c6427f857d
Parent:
16:495d07b9cff8
mbed-src -> mbed library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
justinkim 8:f837e0d255e8 1 #include "mbed.h"
justinkim 8:f837e0d255e8 2 #include "EthernetInterface.h"
hjjeon 14:9202a7785974 3 #include "FsHandler.h"
hjjeon 14:9202a7785974 4 #include "HTTPServer.h"
hjjeon 14:9202a7785974 5 #include "SDFileSystem.h"
hjjeon 9:a63ff95c354b 6
justinkim 16:495d07b9cff8 7 //#define DHCP
justinkim 16:495d07b9cff8 8
hjjeon 14:9202a7785974 9 #ifdef TARGET_WIZWIKI_W7500
hjjeon 14:9202a7785974 10 SDFileSystem local(SD_MOSI, SD_MISO, SD_CLK, SD_SEL, "local");//PB_3, PB_2, PB_1, PB_0
hjjeon 14:9202a7785974 11 #else
hjjeon 14:9202a7785974 12 LocalFileSystem local("local");
hjjeon 14:9202a7785974 13 //or TODO:
hjjeon 14:9202a7785974 14 #endif
hjjeon 9:a63ff95c354b 15
hjjeon 14:9202a7785974 16 #ifdef TARGET_WIZWIKI_W7500
hjjeon 14:9202a7785974 17 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
hjjeon 14:9202a7785974 18 #endif
hjjeon 14:9202a7785974 19
hjjeon 14:9202a7785974 20 EthernetInterface eth;
hjjeon 14:9202a7785974 21 HTTPServer svr;
justinkim 16:495d07b9cff8 22 char ip_addr[] = "192.168.240.111";
hjjeon 14:9202a7785974 23 char subnet_mask[] = "255.255.255.0";
justinkim 16:495d07b9cff8 24 char gateway_addr[] = "192.168.240.1";
hjjeon 14:9202a7785974 25
hjjeon 15:0091888ada99 26 //#define DHCP //If uncomment, W7500 runs DHCP
hjjeon 14:9202a7785974 27
hjjeon 14:9202a7785974 28 int main()
justinkim 8:f837e0d255e8 29 {
justinkim 8:f837e0d255e8 30 printf("Wait a second...\r\n");
hjjeon 14:9202a7785974 31 HTTPFsRequestHandler::mount("/local/", "/");
hjjeon 14:9202a7785974 32 svr.addHandler<HTTPFsRequestHandler>("/");
hjjeon 14:9202a7785974 33
hjjeon 14:9202a7785974 34 #ifdef TARGET_WIZWIKI_W7500
hjjeon 14:9202a7785974 35
hjjeon 14:9202a7785974 36 #ifdef DHCP
hjjeon 14:9202a7785974 37 eth.init(mac_addr); //Use DHCP
hjjeon 14:9202a7785974 38 #else
hjjeon 14:9202a7785974 39 eth.init(mac_addr, ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
hjjeon 14:9202a7785974 40 #endif
hjjeon 14:9202a7785974 41
hjjeon 14:9202a7785974 42 #else
hjjeon 14:9202a7785974 43
hjjeon 14:9202a7785974 44 #ifdef DHCP
hjjeon 14:9202a7785974 45 eth.init(); //Use DHCP
hjjeon 14:9202a7785974 46 #else
hjjeon 14:9202a7785974 47 eth.init(ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
hjjeon 14:9202a7785974 48 #endif
hjjeon 14:9202a7785974 49
hjjeon 14:9202a7785974 50 #endif
hjjeon 14:9202a7785974 51
hjjeon 14:9202a7785974 52
hjjeon 14:9202a7785974 53
justinkim 8:f837e0d255e8 54 eth.connect();
justinkim 8:f837e0d255e8 55 printf("Server IP Address is %s\r\n", eth.getIPAddress());
hjjeon 14:9202a7785974 56
hjjeon 14:9202a7785974 57 if (!svr.start(80, &eth)) {
hjjeon 14:9202a7785974 58
hjjeon 14:9202a7785974 59 error("Server not starting !");
hjjeon 14:9202a7785974 60 exit(0);
hjjeon 14:9202a7785974 61 }
hjjeon 14:9202a7785974 62
hjjeon 14:9202a7785974 63 while(1) {
hjjeon 14:9202a7785974 64 svr.poll();
hjjeon 14:9202a7785974 65 wait(0.2);
hjjeon 14:9202a7785974 66 }
hjjeon 12:d1e2995ca5f6 67
justinkim 8:f837e0d255e8 68 }
justinkim 8:f837e0d255e8 69