for pet feeder system

Dependents:   PetfeederWebServer

Fork of httpServer_with_Ethernt by IOP

Revision:
2:dd293a10a772
Parent:
0:e59cc54df17c
Child:
4:2903435e3811
--- a/Handler/FsHandler.cpp	Tue Jun 30 00:21:41 2015 +0000
+++ b/Handler/FsHandler.cpp	Wed Sep 02 02:03:22 2015 +0000
@@ -9,7 +9,8 @@
 DigitalOut led_blue(LED3);
 
 DigitalIn  din(PC_14);
-
+AnalogIn   ain0(A0);
+AnalogIn   ain1(A1);
 
 static int matchstrings(const char* one, const char* two)
 {
@@ -60,30 +61,33 @@
 {
 }
 
+std::map<int, EthernetInterface*> HTTPFsRequestHandler::m_eth_list;
+
 int HTTPFsRequestHandler::handleGetRequest()
 {
     HTTPHeaders headers;
+    EthernetInterface test_eth;
     int retval = 0;   //success
-    uint8_t pin_state;
     
-    if( std::string::npos != msg.uri.find("get_dio14.cgi") )
+    if( std::string::npos != msg.uri.find("get_netinfo.cgi") )
     {
-        if(din)
-            pin_state = 1;
-        else 
-            pin_state = 0;
+        char buf[256];
         
-        /*
-        *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"14\",\
-                                            \"dio_s\":\"%d\"\
-                                            });",
-                                            pin_state              // Digital io status
-                                            );
+        sprintf(buf, "NetinfoCallback({\"mac\":\"%s\",\"ip\":\"%s\",\"sn\":\"%s\",\"gw\":\"%s\"});"
+                    ,m_eth_list[0]->getMACAddress(),m_eth_list[0]->getIPAddress(),m_eth_list[0]->getNetworkMask(),m_eth_list[0]->getGateway());
+                
+        tcp.send(buf, strlen(buf));
+    }
+    
+    else if( std::string::npos != msg.uri.find("get_ain.cgi") )
+    {        
+        char buf[256];
         
-            
-        Tcp.
-        */
+        sprintf(buf, "AinCallback({\"ain_v0\":\"%.3f\",\"ain_v1\":\"%.3f\"});",ain0.read()*100, ain1.read()*100);
+                
+        tcp.send(buf, strlen(buf));
     }
+    
     else //read html pages
     {
         if (m_localPath.length() > 4) 
@@ -209,3 +213,4 @@
     return ret;
 }
 
+