Http Server

Dependencies:   EthernetNetIf HTTPServer RPCInterface mbed

Fork of WeatherRx by Lotfi Baghli

Revision:
1:574f254ef68c
Parent:
0:7f9517ce9e71
--- a/main.cpp	Sat Aug 27 16:45:11 2011 +0000
+++ b/main.cpp	Sat Dec 27 08:11:08 2014 +0000
@@ -1,43 +1,41 @@
 #include "mbed.h"
 #include "EthernetNetIf.h"
-//#include "HTTPClient.h"
 #include "HTTPServer.h"
 #include "RPCFunction.h"
-#include "x10rf.h"
-
 EthernetNetIf eth(
-    IpAddr(192,168,1,25), //IP Address
+    IpAddr(172,16,20,20), //IP Address
     IpAddr(255,255,255,0), //Network Mask
-    IpAddr(192,168,1,1), //Gateway
-    IpAddr(192,168,1,1)  //DNS
+    IpAddr(172,16,20,1), //Gateway
+    IpAddr(172,16,1,1)  
 );
-//HTTPClient http;
 HTTPServer svr;
 
 DigitalOut led1(LED1, "led1");
 DigitalOut led2(LED2, "led2");
 DigitalOut led3(LED3, "led3");
 DigitalOut led4(LED4, "led4");
+DigitalOut pin1(p21);
+DigitalOut pin2(p22);
+DigitalOut pin3(p23);
+DigitalOut pin4(p24);
 
 LocalFileSystem fs("webfs");
-
 //Create a function of the required format
 void rpcX10rf(char * input, char * output);
-//Attach it to an RPC object
 RPCFunction rpc_foo(&rpcX10rf, "rpcX10rf");
-
 void rpcX10rf(char * input, char * output) {
-char houseCode;
-short int numberCode, action;
-    printf("%s\r\n", input);
-    sscanf(input, "  %c,%d,%d", &houseCode, &numberCode, &action);
-    printf("%c, %d,%d\r\n", houseCode, numberCode, action);
-    // calls the X10RFLib
-    SendX10rf( houseCode, numberCode, action);
-    
-    //nothing to send back - sprintf(output, "%i, %i", x, y );
-}
-
+            char houseCode;
+            short int numberCode, action;
+            printf("%s\r\n", input);
+            sscanf(input, "  %c,%d,%d", &houseCode, &numberCode, &action);
+            printf("%c, %d,%d\r\n", houseCode, numberCode, action);
+                 if(numberCode==1 && action==1){pin1=1;led2=1;}
+            else if(numberCode==1 && action==0){pin1=0;led2=0;}
+            else if(numberCode==2 && action==1){pin2=1;led3=1;}
+            else if(numberCode==2 && action==0){pin2=0;led3=0;}
+            else if(numberCode==3 && action==1){pin3=1;led4=1;}
+            else {pin3=0;led4=0;}
+            }
 int main() {
     Base::add_rpc_class<DigitalOut>();
     EthernetErr ethErr = eth.setup();