Minimalistischer RCP HTTP Server

Dependencies:   EthernetInterface HttpServer mbed-rpc mbed-rtos mbed

Fork of IoTKit_HttpServer by th.iotkit1.ch

main.cpp

Committer:
yueee_yt
Date:
2014-02-20
Revision:
0:050a5d4ffd55
Child:
3:5758cfefe980

File content as of revision 0:050a5d4ffd55:

//#define DNS_SERVER_ADDRESS(ipaddr)        (ip4_addr_set_u32(ipaddr, ipaddr_addr("208.67.222.222"))) /* resolver1.opendns.com */
#define __DEBUG
#include "mbed.h"
#include "rtos.h"
#include "EthernetInterface.h"
#include "HTTPServer.h"

EthernetInterface eth;
DigitalOut led1(LED1);

void aliveState(void const *args) {
    while (true) {
        led1 = !led1;
        Thread::wait(1000);
    }
}

int main()
{
    printf("********* PROGRAM START ***********\r\n");
    Thread thread(aliveState);
    printf("EthernetInterface Setting up...\r\n");
    if(eth.init()!=0) {                             //for DHCP Server
    //if(eth.init(IPAddress,NetMasks,Gateway)!=0) { //for Static IP Address
        printf("EthernetInterface Initialize Error \r\n");
        return -1;
    }
    if(eth.connect()!=0) {
        printf("EthernetInterface Connect Error \r\n");
        return -1;
    }
    printf("IP Address is %s\r\n", eth.getIPAddress());
    printf("NetMask is %s\r\n", eth.getNetworkMask());
    printf("Gateway Address is %s\r\n", eth.getGateway());
    printf("Ethernet Setup OK\r\n");

    HTTPServerAddHandler<SimpleHandler>("/"); //Default handler
    HTTPServerStart(80);
}