HTTP server example program for WIZwiki-W7500

Dependencies:   WIZnetInterface SDFileSystem httpServer mbed-src

Fork of TCPEchoServer-WIZwiki-W7500 by WIZnet

This is HTTP server example program for WIZwiki-W7500.

In this example, only you can control RGB LED on/off.

Sample html pages and image are needed. So download samples.

  • index.html
  • dio_page.html
  • image

https://github.com/WIZnet-MbedEthernet/httpServer-WIZwiki-W7500

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.

There are Korean language in index.html

Committer:
hjjeon
Date:
Mon Jun 29 23:06:22 2015 +0000
Revision:
15:0091888ada99
Parent:
14:9202a7785974
Child:
16:e96ef766fc4d
Bug fix

Who changed what in which revision?

UserRevisionLine numberNew 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 14:9202a7785974 8 SDFileSystem local(SD_MOSI, SD_MISO, SD_CLK, SD_SEL, "local");//PB_3, PB_2, PB_1, PB_0
hjjeon 14:9202a7785974 9 #else
hjjeon 14:9202a7785974 10 LocalFileSystem local("local");
hjjeon 14:9202a7785974 11 //or TODO:
hjjeon 14:9202a7785974 12 #endif
hjjeon 9:a63ff95c354b 13
hjjeon 14:9202a7785974 14 #ifdef TARGET_WIZWIKI_W7500
hjjeon 14:9202a7785974 15 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
hjjeon 14:9202a7785974 16 #endif
hjjeon 14:9202a7785974 17
hjjeon 14:9202a7785974 18 EthernetInterface eth;
hjjeon 14:9202a7785974 19 HTTPServer svr;
hjjeon 14:9202a7785974 20 char ip_addr[] = "192.168.1.111";
hjjeon 14:9202a7785974 21 char subnet_mask[] = "255.255.255.0";
hjjeon 14:9202a7785974 22 char gateway_addr[] = "192.168.1.1";
hjjeon 14:9202a7785974 23
hjjeon 15:0091888ada99 24 //#define DHCP //If uncomment, W7500 runs DHCP
hjjeon 14:9202a7785974 25
hjjeon 14:9202a7785974 26 int main()
justinkim 8:f837e0d255e8 27 {
justinkim 8:f837e0d255e8 28 printf("Wait a second...\r\n");
hjjeon 14:9202a7785974 29 HTTPFsRequestHandler::mount("/local/", "/");
hjjeon 14:9202a7785974 30 svr.addHandler<HTTPFsRequestHandler>("/");
hjjeon 14:9202a7785974 31
hjjeon 14:9202a7785974 32 #ifdef TARGET_WIZWIKI_W7500
hjjeon 14:9202a7785974 33
hjjeon 14:9202a7785974 34 #ifdef DHCP
hjjeon 14:9202a7785974 35 eth.init(mac_addr); //Use DHCP
hjjeon 14:9202a7785974 36 #else
hjjeon 14:9202a7785974 37 eth.init(mac_addr, ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
hjjeon 14:9202a7785974 38 #endif
hjjeon 14:9202a7785974 39
hjjeon 14:9202a7785974 40 #else
hjjeon 14:9202a7785974 41
hjjeon 14:9202a7785974 42 #ifdef DHCP
hjjeon 14:9202a7785974 43 eth.init(); //Use DHCP
hjjeon 14:9202a7785974 44 #else
hjjeon 14:9202a7785974 45 eth.init(ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
hjjeon 14:9202a7785974 46 #endif
hjjeon 14:9202a7785974 47
hjjeon 14:9202a7785974 48 #endif
hjjeon 14:9202a7785974 49
hjjeon 14:9202a7785974 50
hjjeon 14:9202a7785974 51
justinkim 8:f837e0d255e8 52 eth.connect();
justinkim 8:f837e0d255e8 53 printf("Server IP Address is %s\r\n", eth.getIPAddress());
hjjeon 14:9202a7785974 54
hjjeon 14:9202a7785974 55 if (!svr.start(80, &eth)) {
hjjeon 14:9202a7785974 56
hjjeon 14:9202a7785974 57 error("Server not starting !");
hjjeon 14:9202a7785974 58 exit(0);
hjjeon 14:9202a7785974 59 }
hjjeon 14:9202a7785974 60
hjjeon 14:9202a7785974 61 while(1) {
hjjeon 14:9202a7785974 62 svr.poll();
hjjeon 14:9202a7785974 63 wait(0.2);
hjjeon 14:9202a7785974 64 }
hjjeon 12:d1e2995ca5f6 65
justinkim 8:f837e0d255e8 66 }
justinkim 8:f837e0d255e8 67