by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
main.cpp@0:4a5bf258d7dd, 2013-06-16 (annotated)
- Committer:
- robt
- Date:
- Sun Jun 16 15:33:22 2013 +0000
- Revision:
- 0:4a5bf258d7dd
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robt | 0:4a5bf258d7dd | 1 | /* Program Example: 12.10 mbed file server setup |
robt | 0:4a5bf258d7dd | 2 | */ |
robt | 0:4a5bf258d7dd | 3 | #include "mbed.h" |
robt | 0:4a5bf258d7dd | 4 | #include "EthernetNetIf.h" |
robt | 0:4a5bf258d7dd | 5 | #include "HTTPServer.h" |
robt | 0:4a5bf258d7dd | 6 | LocalFileSystem fs("webfs"); |
robt | 0:4a5bf258d7dd | 7 | EthernetNetIf eth( |
robt | 0:4a5bf258d7dd | 8 | IpAddr(192,168,0,101), //IP Address |
robt | 0:4a5bf258d7dd | 9 | IpAddr(255,255,255,0), //Network Mask |
robt | 0:4a5bf258d7dd | 10 | IpAddr(192,168,0,1), //Gateway |
robt | 0:4a5bf258d7dd | 11 | IpAddr(192,168,0,1) //DNS |
robt | 0:4a5bf258d7dd | 12 | ); |
robt | 0:4a5bf258d7dd | 13 | HTTPServer svr; |
robt | 0:4a5bf258d7dd | 14 | int main() { |
robt | 0:4a5bf258d7dd | 15 | eth.setup(); |
robt | 0:4a5bf258d7dd | 16 | FSHandler::mount("/webfs", "/"); //Mount webfs path on root path |
robt | 0:4a5bf258d7dd | 17 | svr.addHandler<FSHandler>("/"); //Default handler |
robt | 0:4a5bf258d7dd | 18 | svr.bind(80); |
robt | 0:4a5bf258d7dd | 19 | while(1) |
robt | 0:4a5bf258d7dd | 20 | { |
robt | 0:4a5bf258d7dd | 21 | Net::poll(); // poll for internet data exchange requests |
robt | 0:4a5bf258d7dd | 22 | } |
robt | 0:4a5bf258d7dd | 23 | } |
robt | 0:4a5bf258d7dd | 24 |