for znrobotics workshop

Dependencies:   DHT22 HTTPClient SDFileSystem WIZnet_Library mbed

Fork of archlink_Temperture_dweetio by Kevin Lee

This program is for seeed arch link, using wiznet w550 ethernet interface. not compatible with mbed ethernet interface.

Revision:
8:0f34e39a6674
Parent:
7:98c5b9eba03a
diff -r 98c5b9eba03a -r 0f34e39a6674 main.cpp
--- a/main.cpp	Mon Jun 20 11:14:37 2016 +0000
+++ b/main.cpp	Tue Jun 28 09:18:37 2016 +0000
@@ -5,7 +5,7 @@
 #include "HTTPClient.h"
 #include "DHT22.h"
 
-#define USE_DHCP 0
+#define USE_DHCP 1
 #define LOOPBACKPORT  5000
 
 const int USE_HTTP_PROTOCAL = 1;
@@ -21,7 +21,7 @@
 WIZnetInterface ethernet(&spi, p24, p17); // Spi ,cs, reset
 int ret, dummy, lv = 1;
 
-const char* http_port = "9090";
+const char* http_port = "80";
 const char* coap_port = "5683";
 const char* mqtt_port = "1883";
 
@@ -31,7 +31,7 @@
 const char * IP_Addr      = "192.168.1.223";
 const char * IP_Subnet    = "255.255.255.0";
 const char * IP_Gateway   = "192.168.1.1";
-const char * DEVICE_ID    = "933691ed-1f00-4826-953a-d56841f65240";
+const char * DEVICE_ID    = "1570f165-89ca-4fdf-a625-86736c8afd23";
 unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x1C,0xAA,0xCA};
 // which protocal to use
 // 1 => HTTP; 
@@ -39,7 +39,7 @@
 // 3 => MQTT
 const int PROTOCAL_INUSE  = 1;
 // unit: seconds;
-const int time_interval   = 15; //seconds
+const int time_interval   = 60; //seconds
 
 // timer event;
 Ticker flipper;
@@ -73,7 +73,7 @@
 void timer_ticked()
 {
     char str[512];
-    char get_msg[256]= "";
+    char get_msg[512]= "";
     
     float* th = temperature_get();
     printf("temperature: %.2f -- Humidity: %.2f.\r\n",th[0], th[1]);
@@ -84,22 +84,33 @@
     {
         case USE_HTTP_PROTOCAL:
         {
-//            sprintf(get_msg, "http://%s/sensors/temperature?deviceid=%s&temperature=%.2f", SERVER_REMOTE, DEVICE_ID, th[0]);
-            sprintf(get_msg, "http://52.76.14.222/hello");
-//            sprintf(get_msg,"http://dweet.io/dweet/for/%s?Temperature=%.2f\r\n","ArchLink", th[0]);
             HTTPClient http;
-        
+            
+            sprintf(get_msg, "http://%s/sensors/things?deviceid=%s&temperature=%.2f", SERVER_REMOTE, DEVICE_ID, th[0]);
             pc.printf("msg : %s\r\n",get_msg);
             ret = http.get(get_msg, str, sizeof(str));
             if(!ret)
             {
-                pc.printf("\r\nPage fetched successfully - read %d characters\r\n", strlen(str));
+                pc.printf("Response fetched successfully - read %d characters\r\n", strlen(str));
                 pc.printf("Result: %s\r\n", str);
             }
             else
             {
                 pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-            }                 
+            }
+            
+            sprintf(get_msg, "http://%s/sensors/things?deviceid=%s&humidity=%.2f", SERVER_REMOTE, DEVICE_ID, th[1]);
+            pc.printf("msg : %s\r\n",get_msg);
+            ret = http.get(get_msg, str, sizeof(str));
+            if(!ret)
+            {
+                pc.printf("Response fetched successfully - read %d characters\r\n", strlen(str));
+                pc.printf("Result: %s\r\n", str);
+            }
+            else
+            {
+                pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+            }
         }
         break;
         case USE_COAP_PROTOCAL:
@@ -113,6 +124,8 @@
         }
         break;
     }
+    
+    pc.printf("\n");
 }
 
 int W5500_Test(void)