petfeeder st ver
Dependencies: SDFileSystem WIZnetInterface petfeeder_st_ver mbed
Fork of Nucleo_F103RB_W5500HelloWorld by
main.cpp@3:b66c4ea46ce6, 2017-06-09 (annotated)
- Committer:
- justinkim
- Date:
- Fri Jun 09 04:45:44 2017 +0000
- Revision:
- 3:b66c4ea46ce6
- Parent:
- 2:84c4d61780d7
petfeeder st ver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bangbh | 0:412f9c1172b7 | 1 | #include "mbed.h" |
justinkim | 2:84c4d61780d7 | 2 | #include "EthernetInterface.h" |
justinkim | 2:84c4d61780d7 | 3 | #include "FsHandler.h" |
justinkim | 2:84c4d61780d7 | 4 | #include "HTTPServer.h" |
justinkim | 2:84c4d61780d7 | 5 | #include "SDFileSystem.h" |
bangbh | 0:412f9c1172b7 | 6 | |
bangbh | 0:412f9c1172b7 | 7 | Serial pc(USBTX, USBRX); |
bangbh | 0:412f9c1172b7 | 8 | |
justinkim | 2:84c4d61780d7 | 9 | SPI spi(PA_7, PA_6, PA_5); // mosi, miso, sclk |
justinkim | 2:84c4d61780d7 | 10 | EthernetInterface eth(&spi, PB_6, PA_9);//scs(PB_6), nRESET(PA_9); // reset pin is dummy, don't affect any pin of WIZ550io |
justinkim | 2:84c4d61780d7 | 11 | SDFileSystem local(PA_7, PA_6, PA_5, PB_5, "local");//PB_3, PB_2, PB_1, PB_0 |
justinkim | 2:84c4d61780d7 | 12 | |
justinkim | 2:84c4d61780d7 | 13 | HTTPServer svr; |
justinkim | 2:84c4d61780d7 | 14 | |
justinkim | 2:84c4d61780d7 | 15 | char ip_addr[] = "192.168.0.111"; |
justinkim | 2:84c4d61780d7 | 16 | char subnet_mask[] = "255.255.255.0"; |
justinkim | 2:84c4d61780d7 | 17 | char gateway_addr[] = "192.168.0.1"; |
justinkim | 2:84c4d61780d7 | 18 | uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0xff, 0xff, 0x10}; |
bangbh | 0:412f9c1172b7 | 19 | |
justinkim | 2:84c4d61780d7 | 20 | double duty; |
bangbh | 0:412f9c1172b7 | 21 | |
justinkim | 2:84c4d61780d7 | 22 | int main() |
justinkim | 2:84c4d61780d7 | 23 | { |
justinkim | 2:84c4d61780d7 | 24 | HTTPFsRequestHandler::mount_eth(ð); |
justinkim | 2:84c4d61780d7 | 25 | HTTPFsRequestHandler::mount("/local/", "/"); |
justinkim | 2:84c4d61780d7 | 26 | svr.addHandler<HTTPFsRequestHandler>("/"); |
justinkim | 2:84c4d61780d7 | 27 | |
justinkim | 2:84c4d61780d7 | 28 | eth.init(mac_addr, ip_addr, subnet_mask, gateway_addr); //Not Use DHCP |
justinkim | 2:84c4d61780d7 | 29 | |
justinkim | 2:84c4d61780d7 | 30 | printf("Check Ethernet Link\r\n"); |
justinkim | 2:84c4d61780d7 | 31 | while(1) //Wait link up |
bangbh | 0:412f9c1172b7 | 32 | { |
justinkim | 2:84c4d61780d7 | 33 | printf("."); |
justinkim | 2:84c4d61780d7 | 34 | if(eth.link() == true) |
justinkim | 2:84c4d61780d7 | 35 | break; |
justinkim | 2:84c4d61780d7 | 36 | } |
justinkim | 2:84c4d61780d7 | 37 | printf("Link up\r\n"); |
justinkim | 2:84c4d61780d7 | 38 | |
justinkim | 2:84c4d61780d7 | 39 | wait(3); |
justinkim | 2:84c4d61780d7 | 40 | |
justinkim | 2:84c4d61780d7 | 41 | eth.connect(); |
justinkim | 2:84c4d61780d7 | 42 | |
justinkim | 2:84c4d61780d7 | 43 | printf("Server IP Address is %s\r\n", eth.getIPAddress()); |
justinkim | 2:84c4d61780d7 | 44 | |
justinkim | 2:84c4d61780d7 | 45 | if (!svr.start(80, ð)) { |
justinkim | 2:84c4d61780d7 | 46 | |
justinkim | 2:84c4d61780d7 | 47 | error("Server not starting !"); |
justinkim | 2:84c4d61780d7 | 48 | exit(0); |
justinkim | 2:84c4d61780d7 | 49 | } |
justinkim | 2:84c4d61780d7 | 50 | |
justinkim | 2:84c4d61780d7 | 51 | while(1) { |
justinkim | 2:84c4d61780d7 | 52 | svr.poll(); |
bangbh | 0:412f9c1172b7 | 53 | } |
bangbh | 0:412f9c1172b7 | 54 | } |