Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed HTTPServer EthernetNetIf
HTTPServerHelloWorld.cpp
- Committer:
- solarca2
- Date:
- 2020-09-02
- Revision:
- 3:e95519dde71d
- Parent:
- 0:5630d7e58a0b
File content as of revision 3:e95519dde71d:
#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPServer.h"
EthernetNetIf eth;
HTTPServer svr;
Serial pc(USBTX,USBRX);
DigitalOut led1(LED1);
int main() {
pc.printf("Setting up...\n");
EthernetErr ethErr = eth.setup();
if(ethErr)
{
pc.printf("Error %d in setup.\n", ethErr);
return -1;
}
pc.printf("Setup OK\n");
svr.addHandler<SimpleHandler>("/"); //Default handler
svr.bind(80);
pc.printf("Listening...\n");
Timer tm;
tm.start();
//Listen indefinitely
while(true)
{
Net::poll();
if(tm.read()>.5)
{
led1=!led1; //Show that we are alive
tm.start();
}
}
return 0;
}