thingspark example

Dependencies:   MbedJSONValue mbed-http HTS221

Files at this revision

API Documentation at this revision

Comitter:
master_k1
Date:
Mon Oct 21 11:56:25 2019 +0000
Parent:
36:3c86e52c9e75
Child:
38:7734b54de565
Commit message:
thingspark

Changed in this revision

mbed-http.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
source/main-http.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/mbed-http.lib	Mon Oct 21 06:49:02 2019 +0000
+++ b/mbed-http.lib	Mon Oct 21 11:56:25 2019 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/sandbox/code/mbed-http/#6daf67a96a91
+https://developer.mbed.org/teams/sandbox/code/mbed-http/#a8d157986ad8
--- a/mbed_app.json	Mon Oct 21 06:49:02 2019 +0000
+++ b/mbed_app.json	Mon Oct 21 11:56:25 2019 +0000
@@ -21,8 +21,8 @@
             "mbed-trace.enable": null,
             "mbed-http.http-buffer-size": 2048,
             "nsapi.default-wifi-security": "WPA_WPA2",
-            "nsapi.default-wifi-ssid": "\"SSID\"",
-            "nsapi.default-wifi-password": "\"PASSWORD\""
+            "nsapi.default-wifi-ssid": "\"master\"",
+            "nsapi.default-wifi-password": "\"1234567890\""
         },
         "DISCO_L475VG_IOT01A": {
             "target.network-default-interface-type" : "WIFI"
--- a/source/main-http.cpp	Mon Oct 21 06:49:02 2019 +0000
+++ b/source/main-http.cpp	Mon Oct 21 11:56:25 2019 +0000
@@ -11,8 +11,8 @@
 static DevI2C devI2c(PB_11,PB_10);
 static HTS221Sensor hum_temp(&devI2c);
 //theKsystemsURL = "https://api.theksystem.com/update?apiKey=9Q8vOz1lguaV6Ou4&field1=21"
-char* theKsystemsURL = "http://api.theksystem.com";
-char* theKsystemsAPIkey = "9Q8vOz1lguaV6Ou4";
+char* thingspark_URL = "http://api.thingspark.kr";
+char* thingspark_APIkey = "hKqQALm22Hd79N6I";
 char urlBuffer[256];
 
 void dump_response(HttpResponse* res) {
@@ -30,7 +30,7 @@
     unsigned int updateCnt=0;
     float hum_val=12, temp_val=34;
     
-    printf("DISCO-L457VG-IOT01A WiFi + TheKsystem example\r\n");
+    printf("DISCO-L457VG-IOT01A WiFi + thingspark example\r\n");
 
 #ifdef MBED_MAJOR_VERSION
     printf("Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
@@ -54,11 +54,11 @@
     printf("Gateway: %s\n", network->get_gateway());
 
     printf("<< =========== Sensor check.. =========== >>\r\n");
-    unsigned int a=0;
+    
     hum_temp.init(NULL);
     hum_temp.enable();
 
-    // Do a GET request to httpbin.org
+    // Do a GET request to thingspark.kr
     while(1){
         // By default the body is automatically parsed and stored in a buffer, this is memory heavy.
         // To receive chunked response, pass in a callback as last parameter to the constructor.
@@ -66,7 +66,7 @@
         hum_temp.get_humidity(&hum_val);
         hum_temp.get_temperature(&temp_val);
         printf("HT221 hum: %.1f %, temp: %.1f C\n", hum_val, temp_val);
-        sprintf(urlBuffer, "%s/update?apiKey=%s&field1=%.1f&field2=%.1f", theKsystemsURL, theKsystemsAPIkey, hum_val, temp_val);
+        sprintf(urlBuffer, "%s/update?apiKey=%s&field1=%.1f&field2=%.1f", thingspark_URL, thingspark_APIkey, hum_val, temp_val);
 
         printf("[DEBUG] %s\n", urlBuffer);
         HttpRequest* get_req = new HttpRequest(network, HTTP_GET, urlBuffer);
@@ -81,8 +81,8 @@
         dump_response(get_res);
 
         delete get_req;
-        printf("\nUpdate count %d (Every 10sec, data update to theK server)\n",updateCnt++);
-        wait(10);
+        printf("\nUpdate count %d (Every 30sec, data update to thingspark server)\n",updateCnt++);
+        wait(30);
     }
 #if 0
     // POST request to httpbin.org