This library provides data update method to Fastsensing.

Dependents:   SCP1000_Fastsensing

Revision:
3:d0d34327ea79
Parent:
2:5e41a339e05c
Child:
4:45527abb7f40
--- a/Fastsensing.cpp	Tue Apr 04 08:21:49 2017 +0000
+++ b/Fastsensing.cpp	Tue Apr 04 08:41:28 2017 +0000
@@ -5,10 +5,19 @@
 */
 #include "Fastsensing.h"
 
+void Fastsensing::ethConnect() {
+    eth.init();                                 //Use DHCP. Initialize setting of eth.
+    eth.connect();                              //Connect Bring the interface up.
+}
+
+void Fastsensing::ethDisconnect() {
+    eth.disconnect();                       //EthernetInterface closed
+}
+
 int Fastsensing::updateData(char *deviceId, char *channelId, double data)
 {
-    eth.init();                                 //Use DHCP. Initialize setting of eth.
-    eth.connect();                              //Connect Bring the interface up.
+    //eth.init();                                 //Use DHCP. Initialize setting of eth.
+    //eth.connect();                              //Connect Bring the interface up.
     char reqUrl[1000];                          //Char array for request
     char basedUrl[20] = "http://f-io.net/D1/";  //based http url
     char query[256];                            //The array is for holding query
@@ -20,11 +29,11 @@
     int res = http.get(reqUrl, resResult, 128);//Send request is reqUrl as get method and get Response Result. Time out is 5000
     printf("%d\n", res);
     if(!res) {                                  //If session is completed
-        eth.disconnect();                       //EthernetInterface closed
+        //eth.disconnect();                       //EthernetInterface closed
         printf("disconnected\n");
         return 0;                               //Return 0
     } else {                                    //If session is not completed
-        eth.disconnect();                       //EthernetInterface closed
+        //eth.disconnect();                       //EthernetInterface closed
         printf("disconnected\n");
         return 1;                               //Return 1
     }
@@ -32,8 +41,8 @@
 
 int Fastsensing::updateDataAll(char *deviceId, char *channelId[3], float data[3])
 {
-    eth.init();                                                 //Use DHCP. Initialize setting of eth.
-    eth.connect();                                              //Connect Bring the interface up.
+    //eth.init();                                                 //Use DHCP. Initialize setting of eth.
+    //eth.connect();                                              //Connect Bring the interface up.
     char reqUrl[1000];                                          //Char array for request
     char basedUrl[20] = "http://f-io.net/D1/";                  //based http url
     char query[256];                                            //The array is for holding query
@@ -48,15 +57,15 @@
         strcat(reqUrl, query);                                  //Concatenate reqUrl and query
     }
     printf("%s\n", reqUrl);
-    int res = http.get(reqUrl, resResult, 300);                 //Send request is reqUrl as get method and get Response Result. Time out is 5000
+    int res = http.get(reqUrl, resResult, 128);                 //Send request is reqUrl as get method and get Response Result. Time out is 5000
     //printf("%d\n", res);
     //printf("%d\n", http.getHTTPResponseCode());
     if(!res) {                                                  //If session is completed
-        eth.disconnect();                                       //EthernetInterface closed
+        //eth.disconnect();                                       //EthernetInterface closed
         printf("disconnected\n");
         return 0;                                               //Return 0
     } else {                                                    //If session is not completed
-        eth.disconnect();                                       //EthernetInterface closed
+        //eth.disconnect();                                       //EthernetInterface closed
         printf("disconnected\n");
         return 1;                                               //Return 1
     }