WebServer for WIZwiki-W7500 Network Information LED controller Analog value Monitoring image load
Dependencies: SDFileSystem WIZnetInterface httpServer_with_Ethernt mbed
Fork of httpServer-WIZwiki-W7500 by
This is HTTP server example program for WIZwiki-W7500.
In this example, you can get Network Information and control LED and... Monitoring Analog value!!
Sample html pages and image are needed. So download samples.
- index.html
- net_info.html
- dio_page.html
- ain_page.html
- wiznet_logo.png
This example use SD card. So copy html and image files to SD card. If not WIZwiki-W7500 platform, copy html and image files to local filesystem.
main.cpp@3:36fd3cfad85a, 2012-08-01 (annotated)
- Committer:
- emilmont
- Date:
- Wed Aug 01 13:07:32 2012 +0000
- Revision:
- 3:36fd3cfad85a
- Parent:
- 2:ec5ae99791da
- Child:
- 7:a5ead1402704
Update socket library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:38cbb854d85f | 1 | #include "mbed.h" |
emilmont | 1:5cebe0e38cd2 | 2 | #include "EthernetInterface.h" |
emilmont | 1:5cebe0e38cd2 | 3 | |
emilmont | 3:36fd3cfad85a | 4 | #define ECHO_SERVER_PORT 7 |
emilmont | 3:36fd3cfad85a | 5 | |
emilmont | 1:5cebe0e38cd2 | 6 | int main (void) { |
emilmont | 1:5cebe0e38cd2 | 7 | EthernetInterface eth; |
emilmont | 1:5cebe0e38cd2 | 8 | eth.init(); //Use DHCP |
emilmont | 1:5cebe0e38cd2 | 9 | eth.connect(); |
emilmont | 1:5cebe0e38cd2 | 10 | printf("IP Address is %s\n", eth.getIPAddress()); |
emilmont | 1:5cebe0e38cd2 | 11 | |
emilmont | 1:5cebe0e38cd2 | 12 | TCPSocketServer server; |
emilmont | 3:36fd3cfad85a | 13 | server.bind(ECHO_SERVER_PORT); |
emilmont | 3:36fd3cfad85a | 14 | server.listen(); |
emilmont | 1:5cebe0e38cd2 | 15 | |
emilmont | 1:5cebe0e38cd2 | 16 | while (true) { |
emilmont | 1:5cebe0e38cd2 | 17 | printf("\nWait for new connection...\n"); |
emilmont | 1:5cebe0e38cd2 | 18 | TCPSocketConnection client; |
emilmont | 1:5cebe0e38cd2 | 19 | server.accept(client); |
emilmont | 3:36fd3cfad85a | 20 | client.set_blocking(false, 1500); // Timeout after (1.5)s |
emilmont | 1:5cebe0e38cd2 | 21 | |
emilmont | 1:5cebe0e38cd2 | 22 | printf("Connection from: %s\n", client.get_address()); |
emilmont | 1:5cebe0e38cd2 | 23 | char buffer[256]; |
emilmont | 1:5cebe0e38cd2 | 24 | while (true) { |
emilmont | 3:36fd3cfad85a | 25 | int n = client.receive(buffer, sizeof(buffer)); |
emilmont | 1:5cebe0e38cd2 | 26 | if (n <= 0) break; |
emilmont | 1:5cebe0e38cd2 | 27 | |
emilmont | 2:ec5ae99791da | 28 | client.send_all(buffer, n); |
emilmont | 1:5cebe0e38cd2 | 29 | if (n <= 0) break; |
emilmont | 1:5cebe0e38cd2 | 30 | } |
emilmont | 3:36fd3cfad85a | 31 | |
emilmont | 1:5cebe0e38cd2 | 32 | client.close(); |
emilmont | 1:5cebe0e38cd2 | 33 | } |
emilmont | 1:5cebe0e38cd2 | 34 | } |