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

main.cpp

Committer:
hjjeon
Date:
2015-06-29
Revision:
14:9202a7785974
Parent:
13:a09c9ff30460
Child:
15:0091888ada99

File content as of revision 14:9202a7785974:

#include "mbed.h"
#include "EthernetInterface.h"
#include "FsHandler.h"
#include "HTTPServer.h"
#include "SDFileSystem.h"

#ifdef TARGET_WIZWIKI_W7500
    SDFileSystem local(SD_MOSI, SD_MISO, SD_CLK, SD_SEL, "local");//PB_3, PB_2, PB_1, PB_0
#else
    LocalFileSystem local("local");
    //or TODO:
#endif

#ifdef TARGET_WIZWIKI_W7500
    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
#endif

EthernetInterface eth;
HTTPServer  svr;
char ip_addr[] = "192.168.1.111";
char subnet_mask[] = "255.255.255.0";
char gateway_addr[] = "192.168.1.1";

//#define DHCP

int main()
{
    printf("Wait a second...\r\n");
    HTTPFsRequestHandler::mount("/local/", "/");
    svr.addHandler<HTTPFsRequestHandler>("/");

#ifdef TARGET_WIZWIKI_W7500
    
    #ifdef DHCP
        eth.init(mac_addr); //Use DHCP
    #else
        eth.init(mac_addr, ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
    #endif

#else

    #ifdef DHCP
        eth.init(); //Use DHCP
    #else
        eth.init(ip_addr, subnet_mask, gateway_addr); //Not Use DHCP
    #endif

#endif



    eth.connect();
    printf("Server IP Address is %s\r\n", eth.getIPAddress());

    if (!svr.start(80, &eth)) {

        error("Server not starting !");
        exit(0);
    }

    while(1) {
        svr.poll();
        wait(0.2);
    }
    
}