part of the preparation works for Ina-city Hackerthon

Dependencies:   Grove_temperature mbed-http

Fork of Mbed-to-cybozu-kintone_post_sample by Junichi Katsu

Revision:
1:6c0383514e5b
Parent:
0:b3812b1c103d
Child:
2:687ce876e4ee
--- a/main.cpp	Wed Aug 01 00:14:57 2018 +0000
+++ b/main.cpp	Thu Aug 23 04:06:06 2018 +0000
@@ -3,20 +3,32 @@
 #include "easy-connect.h"
 #include "https_request.h"
 #include "ssl_ca_pem.h"
-#include "C12832.h"
-#include "MMA7660.h"
-#include "LM75B.h"
+#include "Grove_temperature.h"
+
+#if !defined(TARGET_WIO_3G)
+#error Selected target is not supported.
+#endif
+
+// on-board resources
+Serial pc(USBTX, USBRX, 115200);
+DigitalOut GrovePower(PB_10, 1);
 
-C12832 lcd(D11, D13, D12, D7, D10);
-MMA7660 MMA(D14,D15);
-LM75B sensor(D14,D15);
+#define D20 (PB_4)
+
+// Grove sensors
+// Temperature sensor
+Grove_temperature tempSensor(A4);
 
-Serial pc(USBTX,USBRX);
 
+// For your API Token, refer to "API token" in your application setting page
+// Please DO NOT FORGET to assign "add records" to your key.
 const char API_TOKEN[] = "api-token";
+// Your domain name can be seen in the usage explanation with curl. 
 const char URL[] = "https://{domain}.cybozu.com/k/v1/record.json";
 
-int app_id = 2;
+// app_id, application id, can be checked with your application's URL
+// e.g. https://{domain}.cybozu.com/k/3/ -> app_id is 3
+int app_id = 3;
 
 bool post_kintone(NetworkInterface* nif, const char *url, int app_id_, char* field_code, float value)
 {    
@@ -49,14 +61,10 @@
 
 // main() runs in its own thread in the OS
 int main() {
+    pc.printf("Greetings from Ina-city Hackerthon on 25-26 of August\n");
+    
     NetworkInterface* network = NULL;
 
-    pc.baud(115200);
-
-    lcd.cls();
-    lcd.locate(0,3);
-    lcd.printf("Network Connect..");
-
     pc.printf("\r\n----- Start -----\r\n");
     
     network = easy_connect(true);    // If true, prints out connection details.
@@ -65,21 +73,15 @@
         return -1;
     }
 
-    lcd.printf("OK");
     pc.printf("\r\n----- Network Connected -----\r\n");
     
     wait(2.0);
     
     while(1) {
-        lcd.cls();
-        lcd.locate(0,3);
-        lcd.printf("x=%.2f y=%.2f z=%.2f",MMA.x(), MMA.y(), MMA.z());
         
-        float temp = sensor.read();
-        lcd.locate(0,14);
-        lcd.printf("Temp = %.1f\n", temp);
+        float currentTemp = tempSensor.getTemperature();
         
-        bool ret = post_kintone(network, URL, app_id, "temp", temp);
+        bool ret = post_kintone(network, URL, app_id, "temp", currentTemp);
         pc.printf("\n----- HTTPS POST response [%s]----- \n\r",ret== true ? "OK" : "NG");
         
         wait(10.0);