Internet piano with Updated SDFileSystem
Dependencies: SDFileSystem WIZnetInterface httpServer mbed
Fork of HTTPWebServer-WIZwiki-W750023 by
main.cpp@21:a5e91b90d7a3, 2015-10-19 (annotated)
- Committer:
- irinakim
- Date:
- Mon Oct 19 00:40:45 2015 +0000
- Revision:
- 21:a5e91b90d7a3
- Parent:
- 19:0ea7e7a9ebae
- Child:
- 23:17bcb0c6105c
modify ip address;
Who changed what in which revision?
User | Revision | Line number | New 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 | |
hjjeon | 14:9202a7785974 | 7 | #ifdef TARGET_WIZWIKI_W7500 |
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 | |
hjjeon | 14:9202a7785974 | 13 | #ifdef TARGET_WIZWIKI_W7500 |
hjjeon | 14:9202a7785974 | 14 | uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02}; |
hjjeon | 14:9202a7785974 | 15 | #endif |
hjjeon | 14:9202a7785974 | 16 | |
hjjeon | 14:9202a7785974 | 17 | EthernetInterface eth; |
hjjeon | 14:9202a7785974 | 18 | HTTPServer svr; |
irinakim | 21:a5e91b90d7a3 | 19 | char ip_addr[] = "192.168.240.111"; |
hjjeon | 14:9202a7785974 | 20 | char subnet_mask[] = "255.255.255.0"; |
irinakim | 21:a5e91b90d7a3 | 21 | char gateway_addr[] = "192.168.240.1"; |
hjjeon | 14:9202a7785974 | 22 | |
hjjeon | 15:0091888ada99 | 23 | //#define DHCP //If uncomment, W7500 runs DHCP |
hjjeon | 14:9202a7785974 | 24 | |
hjjeon | 14:9202a7785974 | 25 | int main() |
justinkim | 8:f837e0d255e8 | 26 | { |
justinkim | 19:0ea7e7a9ebae | 27 | HTTPFsRequestHandler::mount_eth(ð); |
hjjeon | 14:9202a7785974 | 28 | HTTPFsRequestHandler::mount("/local/", "/"); |
hjjeon | 14:9202a7785974 | 29 | svr.addHandler<HTTPFsRequestHandler>("/"); |
hjjeon | 14:9202a7785974 | 30 | |
hjjeon | 14:9202a7785974 | 31 | #ifdef TARGET_WIZWIKI_W7500 |
hjjeon | 14:9202a7785974 | 32 | |
hjjeon | 14:9202a7785974 | 33 | #ifdef DHCP |
hjjeon | 14:9202a7785974 | 34 | eth.init(mac_addr); //Use DHCP |
hjjeon | 14:9202a7785974 | 35 | #else |
hjjeon | 14:9202a7785974 | 36 | eth.init(mac_addr, ip_addr, subnet_mask, gateway_addr); //Not Use DHCP |
hjjeon | 14:9202a7785974 | 37 | #endif |
hjjeon | 14:9202a7785974 | 38 | |
hjjeon | 14:9202a7785974 | 39 | #else |
hjjeon | 14:9202a7785974 | 40 | |
hjjeon | 14:9202a7785974 | 41 | #ifdef DHCP |
hjjeon | 14:9202a7785974 | 42 | eth.init(); //Use DHCP |
hjjeon | 14:9202a7785974 | 43 | #else |
hjjeon | 14:9202a7785974 | 44 | eth.init(ip_addr, subnet_mask, gateway_addr); //Not Use DHCP |
hjjeon | 14:9202a7785974 | 45 | #endif |
hjjeon | 14:9202a7785974 | 46 | |
hjjeon | 14:9202a7785974 | 47 | #endif |
hjjeon | 14:9202a7785974 | 48 | |
hjjeon | 18:5d96484995cf | 49 | printf("Check Ethernet Link\r\n"); |
hjjeon | 18:5d96484995cf | 50 | while(1) //Wait link up |
hjjeon | 18:5d96484995cf | 51 | { |
hjjeon | 18:5d96484995cf | 52 | if(eth.link() == true) |
hjjeon | 18:5d96484995cf | 53 | break; |
hjjeon | 18:5d96484995cf | 54 | } |
hjjeon | 18:5d96484995cf | 55 | printf("Link up\r\n"); |
hjjeon | 14:9202a7785974 | 56 | |
justinkim | 8:f837e0d255e8 | 57 | eth.connect(); |
justinkim | 8:f837e0d255e8 | 58 | printf("Server IP Address is %s\r\n", eth.getIPAddress()); |
hjjeon | 14:9202a7785974 | 59 | |
hjjeon | 14:9202a7785974 | 60 | if (!svr.start(80, ð)) { |
hjjeon | 14:9202a7785974 | 61 | |
hjjeon | 14:9202a7785974 | 62 | error("Server not starting !"); |
hjjeon | 14:9202a7785974 | 63 | exit(0); |
hjjeon | 14:9202a7785974 | 64 | } |
hjjeon | 14:9202a7785974 | 65 | |
hjjeon | 14:9202a7785974 | 66 | while(1) { |
hjjeon | 14:9202a7785974 | 67 | svr.poll(); |
hjjeon | 14:9202a7785974 | 68 | } |
hjjeon | 12:d1e2995ca5f6 | 69 | |
justinkim | 8:f837e0d255e8 | 70 | } |
justinkim | 8:f837e0d255e8 | 71 |