HTTP Server upon new mbed Ethernet Interface. Based on original code by Henry Leinen.

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of HTTP_server by pablo gindel

main.cpp

Committer:
pabloxid
Date:
2013-07-26
Revision:
0:fcceff3299be
Child:
1:f0c641cd9bad

File content as of revision 0:fcceff3299be:


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

LocalFileSystem local("local");

DigitalOut led1(LED1);

void http_thread (void const* arg);                   ///////

int main() {
   
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("IP Address is %s\n", eth.getIPAddress());
    
    Timer onesec;
    onesec.start();

    Thread httpsvr( &http_thread );

    while (true) {

        if (onesec.read() > 1) {
            onesec.reset();
            led1 = 1-led1;
        }
        
    }
    
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                            HTTP THREAD                                           //
//////////////////////////////////////////////////////////////////////////////////////////////////////

void http_thread (void const* arg) {

    HTTPServer svr (80, "/local/");    // esto incluye el init

    // osThreadSetPriority( Thread::gettid() ,  osPriorityBelowNormal );

    while (1) {

        svr.poll();

    }
}