Internet piano with Updated SDFileSystem

Dependencies:   SDFileSystem WIZnetInterface httpServer mbed

Fork of HTTPWebServer-WIZwiki-W750023 by ajeet prajapati

Committer:
wiznetw7500
Date:
Tue Nov 28 08:55:18 2017 +0000
Revision:
26:de82526f4cb3
Parent:
25:db437ab10b04
Internet piano with Updated SDFileSystem

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
irinakim 23:17bcb0c6105c 7 #if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
hjjeon 17:be86c9b2cbda 8 //Choose one of file system.
hjjeon 14:9202a7785974 9 SDFileSystem local(SD_MOSI, SD_MISO, SD_CLK, SD_SEL, "local");//PB_3, PB_2, PB_1, PB_0
hjjeon 17:be86c9b2cbda 10 //LocalFileSystem local("local");
hjjeon 14:9202a7785974 11 #endif
hjjeon 9:a63ff95c354b 12
irinakim 23:17bcb0c6105c 13 #if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
joon874 24:64dfb6c4994b 14 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0xFF, 0xFF, 0x02};
hjjeon 14:9202a7785974 15 #endif
hjjeon 14:9202a7785974 16
joon874 24:64dfb6c4994b 17 // Declare Ethernet Class
hjjeon 14:9202a7785974 18 EthernetInterface eth;
joon874 24:64dfb6c4994b 19
joon874 24:64dfb6c4994b 20 // Declare HTTP Server Class
hjjeon 14:9202a7785974 21 HTTPServer svr;
joon874 24:64dfb6c4994b 22
joon874 24:64dfb6c4994b 23 // Set Server Network
wiznetw7500 26:de82526f4cb3 24 char ip_addr[] = "192.168.0.112";
hjjeon 14:9202a7785974 25 char subnet_mask[] = "255.255.255.0";
ajeet3004 25:db437ab10b04 26 char gateway_addr[] = "192.168.0.1";
hjjeon 14:9202a7785974 27
hjjeon 14:9202a7785974 28
hjjeon 14:9202a7785974 29 int main()
justinkim 8:f837e0d255e8 30 {
wiznetw7500 26:de82526f4cb3 31 // HTTPFsRequestHandler::mount_eth(&eth);
hjjeon 14:9202a7785974 32 HTTPFsRequestHandler::mount("/local/", "/");
hjjeon 14:9202a7785974 33 svr.addHandler<HTTPFsRequestHandler>("/");
hjjeon 14:9202a7785974 34
irinakim 23:17bcb0c6105c 35 #if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
hjjeon 14:9202a7785974 36
hjjeon 14:9202a7785974 37 #ifdef DHCP
hjjeon 14:9202a7785974 38 eth.init(mac_addr); //Use DHCP
hjjeon 14:9202a7785974 39 #else
hjjeon 14:9202a7785974 40 eth.init(mac_addr, ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
hjjeon 14:9202a7785974 41 #endif
hjjeon 14:9202a7785974 42
hjjeon 14:9202a7785974 43 #else
hjjeon 14:9202a7785974 44
hjjeon 14:9202a7785974 45 #ifdef DHCP
hjjeon 14:9202a7785974 46 eth.init(); //Use DHCP
hjjeon 14:9202a7785974 47 #else
hjjeon 14:9202a7785974 48 eth.init(ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
hjjeon 14:9202a7785974 49 #endif
hjjeon 14:9202a7785974 50
hjjeon 14:9202a7785974 51 #endif
hjjeon 14:9202a7785974 52
hjjeon 18:5d96484995cf 53 printf("Check Ethernet Link\r\n");
hjjeon 18:5d96484995cf 54 while(1) //Wait link up
hjjeon 18:5d96484995cf 55 {
hjjeon 18:5d96484995cf 56 if(eth.link() == true)
hjjeon 18:5d96484995cf 57 break;
hjjeon 18:5d96484995cf 58 }
hjjeon 18:5d96484995cf 59 printf("Link up\r\n");
hjjeon 14:9202a7785974 60
justinkim 8:f837e0d255e8 61 eth.connect();
justinkim 8:f837e0d255e8 62 printf("Server IP Address is %s\r\n", eth.getIPAddress());
hjjeon 14:9202a7785974 63
hjjeon 14:9202a7785974 64 if (!svr.start(80, &eth)) {
hjjeon 14:9202a7785974 65
hjjeon 14:9202a7785974 66 error("Server not starting !");
hjjeon 14:9202a7785974 67 exit(0);
hjjeon 14:9202a7785974 68 }
hjjeon 14:9202a7785974 69
hjjeon 14:9202a7785974 70 while(1) {
hjjeon 14:9202a7785974 71 svr.poll();
hjjeon 14:9202a7785974 72 }
hjjeon 12:d1e2995ca5f6 73
justinkim 8:f837e0d255e8 74 }
justinkim 8:f837e0d255e8 75