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 DS1307 Servo TextLCD
main.cpp
- Committer:
- rikvandyck
- Date:
- 2014-12-04
- Revision:
- 0:e1edd52b1ee2
- Child:
- 1:7db3698243d8
File content as of revision 0:e1edd52b1ee2:
#include "mbed.h"
#include "EthernetNetIf.h"
//#include "HTTPClient.h"
//#include "NTPClient.h"
#include "HTTPServer.h"
#include "RPCFunction.h"
EthernetNetIf eth(
IpAddr(192,168,1,2), //ipadress
IpAddr(255,255,255,0), //network mask
IpAddr(192,168,1,1), //gateway
IpAddr(192,168,1,1) //dns
);
//HTTPClient http;
//NTPClient ntp;
HTTPServer svr;
DigitalOut led1(LED1, "led1");
AnalogIn mypot(p20);
int c=0;
int main() {
EthernetErr ethErr;
int count = 0;
do {
printf("Setting up %d...\n\r", ++count);
ethErr = eth.setup();
if (ethErr) printf("Timeout\n\r", ethErr);
} while (ethErr != ETH_OK);
printf("Connected OK\n\r");
const char* hwAddr = eth.getHwAddr();
IpAddr ethIp = eth.getIp();
printf("IP address : %d.%d.%d.%d\n\r", ethIp[0], ethIp[1], ethIp[2], ethIp[3]);
LocalFileSystem local("local");
//svr.addHandler<SimpleHandler>("/hello");
svr.addHandler<FSHandler>("");
svr.bind(80);
printf("Server listening\n\r");
while (true) {
Net::poll();
FILE *fp = fopen("/webfs/mydata.htm","w");
fprintf(fp,"<HTML>\r\n");
fprintf(fp,"<HEAD>\r\n");
fprintf(fp,"</HEAD>\r\n");
fprintf(fp,"<BODY>\r\n");
fprintf(fp," \r\n");
fprintf(fp,"The variable resistor reads %f\r\n",mypot.read());
fprintf(fp," \r\n");
fprintf(fp,"</BODY>\r\n");
fprintf(fp,"</HTML>\r\n");
fclose(fp);
}
}