![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
more
Dependencies: C12832_lcd Http_Wifi_Fileserver ZacsProgram mbed
Fork of HTTPServerHelloWorld by
main.cpp@3:c16d9e9076a1, 2014-10-29 (annotated)
- Committer:
- wellmon7
- Date:
- Wed Oct 29 01:42:04 2014 +0000
- Revision:
- 3:c16d9e9076a1
Trial 1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wellmon7 | 3:c16d9e9076a1 | 1 | /* |
wellmon7 | 3:c16d9e9076a1 | 2 | SY202 Final Project |
wellmon7 | 3:c16d9e9076a1 | 3 | 04 MAR 2014 |
wellmon7 | 3:c16d9e9076a1 | 4 | |
wellmon7 | 3:c16d9e9076a1 | 5 | Created by: |
wellmon7 | 3:c16d9e9076a1 | 6 | MIDN 3/C Villemez |
wellmon7 | 3:c16d9e9076a1 | 7 | MIDN 3/C DaCruz |
wellmon7 | 3:c16d9e9076a1 | 8 | MIDN 3/C Wellmon |
wellmon7 | 3:c16d9e9076a1 | 9 | |
wellmon7 | 3:c16d9e9076a1 | 10 | Resources: |
wellmon7 | 3:c16d9e9076a1 | 11 | LCDR Hoffmeister |
wellmon7 | 3:c16d9e9076a1 | 12 | MBED Cookbook |
wellmon7 | 3:c16d9e9076a1 | 13 | |
wellmon7 | 3:c16d9e9076a1 | 14 | */ |
wellmon7 | 3:c16d9e9076a1 | 15 | |
wellmon7 | 3:c16d9e9076a1 | 16 | |
wellmon7 | 3:c16d9e9076a1 | 17 | |
wellmon7 | 3:c16d9e9076a1 | 18 | #include "mbed.h" |
wellmon7 | 3:c16d9e9076a1 | 19 | #include "EthernetNetIf.h" |
wellmon7 | 3:c16d9e9076a1 | 20 | #include "HTTPServer.h" |
wellmon7 | 3:c16d9e9076a1 | 21 | #include <stdio.h> |
wellmon7 | 3:c16d9e9076a1 | 22 | #include <string.h> |
wellmon7 | 3:c16d9e9076a1 | 23 | #include <HTTPRequestHandler.h> |
wellmon7 | 3:c16d9e9076a1 | 24 | #include "PostHandler.h" |
wellmon7 | 3:c16d9e9076a1 | 25 | #include "C12832_lcd.h" |
wellmon7 | 3:c16d9e9076a1 | 26 | |
wellmon7 | 3:c16d9e9076a1 | 27 | |
wellmon7 | 3:c16d9e9076a1 | 28 | C12832_LCD lcd; |
wellmon7 | 3:c16d9e9076a1 | 29 | |
wellmon7 | 3:c16d9e9076a1 | 30 | EthernetNetIf eth; |
wellmon7 | 3:c16d9e9076a1 | 31 | HTTPServer svr; |
wellmon7 | 3:c16d9e9076a1 | 32 | |
wellmon7 | 3:c16d9e9076a1 | 33 | DigitalOut led1(LED1); |
wellmon7 | 3:c16d9e9076a1 | 34 | DigitalOut led2(LED2); |
wellmon7 | 3:c16d9e9076a1 | 35 | DigitalOut led3(LED3); |
wellmon7 | 3:c16d9e9076a1 | 36 | DigitalOut led4(LED4); |
wellmon7 | 3:c16d9e9076a1 | 37 | |
wellmon7 | 3:c16d9e9076a1 | 38 | |
wellmon7 | 3:c16d9e9076a1 | 39 | LocalFileSystem fs("home.htm"); |
wellmon7 | 3:c16d9e9076a1 | 40 | |
wellmon7 | 3:c16d9e9076a1 | 41 | int main() { |
wellmon7 | 3:c16d9e9076a1 | 42 | EthernetErr ethErr = eth.setup(); |
wellmon7 | 3:c16d9e9076a1 | 43 | if(ethErr) |
wellmon7 | 3:c16d9e9076a1 | 44 | { |
wellmon7 | 3:c16d9e9076a1 | 45 | printf("Error %d in setup.\n", ethErr); |
wellmon7 | 3:c16d9e9076a1 | 46 | return -1; |
wellmon7 | 3:c16d9e9076a1 | 47 | } |
wellmon7 | 3:c16d9e9076a1 | 48 | printf("Setup OK\n"); |
wellmon7 | 3:c16d9e9076a1 | 49 | |
wellmon7 | 3:c16d9e9076a1 | 50 | lcd.printf("DaCruz | Wellmon | Villemez\n"); |
wellmon7 | 3:c16d9e9076a1 | 51 | lcd.printf ("Server IP: %d.%d.%d.%d\n", eth.m_ip[0], eth.m_ip[1], eth.m_ip[2], eth.m_ip[3]); |
wellmon7 | 3:c16d9e9076a1 | 52 | printf("Server IP: %d.%d.%d.%d\n", eth.m_ip[0], eth.m_ip[1], eth.m_ip[2], eth.m_ip[3]); |
wellmon7 | 3:c16d9e9076a1 | 53 | |
wellmon7 | 3:c16d9e9076a1 | 54 | FSHandler::mount("/home.htm", "/"); |
wellmon7 | 3:c16d9e9076a1 | 55 | |
wellmon7 | 3:c16d9e9076a1 | 56 | svr.addHandler<FSHandler>("/"); //Default handler |
wellmon7 | 3:c16d9e9076a1 | 57 | svr.addHandler<PostHandler>("/list.htm"); |
wellmon7 | 3:c16d9e9076a1 | 58 | |
wellmon7 | 3:c16d9e9076a1 | 59 | svr.bind(80); |
wellmon7 | 3:c16d9e9076a1 | 60 | |
wellmon7 | 3:c16d9e9076a1 | 61 | printf("Listening...\n"); |
wellmon7 | 3:c16d9e9076a1 | 62 | |
wellmon7 | 3:c16d9e9076a1 | 63 | Timer tm; |
wellmon7 | 3:c16d9e9076a1 | 64 | tm.start(); |
wellmon7 | 3:c16d9e9076a1 | 65 | |
wellmon7 | 3:c16d9e9076a1 | 66 | //Listen indefinitely |
wellmon7 | 3:c16d9e9076a1 | 67 | while(true) |
wellmon7 | 3:c16d9e9076a1 | 68 | { |
wellmon7 | 3:c16d9e9076a1 | 69 | Net::poll(); |
wellmon7 | 3:c16d9e9076a1 | 70 | led1=!led1; |
wellmon7 | 3:c16d9e9076a1 | 71 | led2=!led2; |
wellmon7 | 3:c16d9e9076a1 | 72 | led3=!led3; |
wellmon7 | 3:c16d9e9076a1 | 73 | led4=!led4; |
wellmon7 | 3:c16d9e9076a1 | 74 | |
wellmon7 | 3:c16d9e9076a1 | 75 | } |
wellmon7 | 3:c16d9e9076a1 | 76 | |
wellmon7 | 3:c16d9e9076a1 | 77 | return 0; |
wellmon7 | 3:c16d9e9076a1 | 78 | } |