Minimalistischer RCP HTTP Server Erweiterte Variante mit RCPVariable und Servo

Dependencies:   EthernetInterface HttpServer Servo mbed-rpc mbed-rtos mbed

Fork of RPCHTTPServerSimple by th.iotkit2.ch

Committer:
yueee_yt
Date:
Thu Feb 20 05:37:05 2014 +0000
Revision:
0:050a5d4ffd55
Child:
3:5758cfefe980
Checked SimpleHandler

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yueee_yt 0:050a5d4ffd55 1 //#define DNS_SERVER_ADDRESS(ipaddr) (ip4_addr_set_u32(ipaddr, ipaddr_addr("208.67.222.222"))) /* resolver1.opendns.com */
yueee_yt 0:050a5d4ffd55 2 #define __DEBUG
yueee_yt 0:050a5d4ffd55 3 #include "mbed.h"
yueee_yt 0:050a5d4ffd55 4 #include "rtos.h"
yueee_yt 0:050a5d4ffd55 5 #include "EthernetInterface.h"
yueee_yt 0:050a5d4ffd55 6 #include "HTTPServer.h"
yueee_yt 0:050a5d4ffd55 7
yueee_yt 0:050a5d4ffd55 8 EthernetInterface eth;
yueee_yt 0:050a5d4ffd55 9 DigitalOut led1(LED1);
yueee_yt 0:050a5d4ffd55 10
yueee_yt 0:050a5d4ffd55 11 void aliveState(void const *args) {
yueee_yt 0:050a5d4ffd55 12 while (true) {
yueee_yt 0:050a5d4ffd55 13 led1 = !led1;
yueee_yt 0:050a5d4ffd55 14 Thread::wait(1000);
yueee_yt 0:050a5d4ffd55 15 }
yueee_yt 0:050a5d4ffd55 16 }
yueee_yt 0:050a5d4ffd55 17
yueee_yt 0:050a5d4ffd55 18 int main()
yueee_yt 0:050a5d4ffd55 19 {
yueee_yt 0:050a5d4ffd55 20 printf("********* PROGRAM START ***********\r\n");
yueee_yt 0:050a5d4ffd55 21 Thread thread(aliveState);
yueee_yt 0:050a5d4ffd55 22 printf("EthernetInterface Setting up...\r\n");
yueee_yt 0:050a5d4ffd55 23 if(eth.init()!=0) { //for DHCP Server
yueee_yt 0:050a5d4ffd55 24 //if(eth.init(IPAddress,NetMasks,Gateway)!=0) { //for Static IP Address
yueee_yt 0:050a5d4ffd55 25 printf("EthernetInterface Initialize Error \r\n");
yueee_yt 0:050a5d4ffd55 26 return -1;
yueee_yt 0:050a5d4ffd55 27 }
yueee_yt 0:050a5d4ffd55 28 if(eth.connect()!=0) {
yueee_yt 0:050a5d4ffd55 29 printf("EthernetInterface Connect Error \r\n");
yueee_yt 0:050a5d4ffd55 30 return -1;
yueee_yt 0:050a5d4ffd55 31 }
yueee_yt 0:050a5d4ffd55 32 printf("IP Address is %s\r\n", eth.getIPAddress());
yueee_yt 0:050a5d4ffd55 33 printf("NetMask is %s\r\n", eth.getNetworkMask());
yueee_yt 0:050a5d4ffd55 34 printf("Gateway Address is %s\r\n", eth.getGateway());
yueee_yt 0:050a5d4ffd55 35 printf("Ethernet Setup OK\r\n");
yueee_yt 0:050a5d4ffd55 36
yueee_yt 0:050a5d4ffd55 37 HTTPServerAddHandler<SimpleHandler>("/"); //Default handler
yueee_yt 0:050a5d4ffd55 38 HTTPServerStart(80);
yueee_yt 0:050a5d4ffd55 39 }
yueee_yt 0:050a5d4ffd55 40