Demo for Mbed Connect Cloud board and an IFTTT integration with Google Sheets

Dependencies:   mbed-http C12832

View the tutorial for this demo here.

Revision:
2:ba90e563a0d0
Parent:
0:e7e395d6f1fc
Child:
4:0160ae8489f3
--- a/working/main_working.h	Fri Nov 10 16:18:05 2017 -0600
+++ b/working/main_working.h	Fri Nov 10 17:43:29 2017 -0600
@@ -12,12 +12,13 @@
 // from ARM Limited or its affiliates.
 //----------------------------------------------------------------------------
 #include "mbed.h"
+#include "C12832.h"
 #include "OdinWiFiInterface.h"
-#include "TCPSocket.h"
 #include "http_request.h"
 
 // GLOBAL VARIABLES HERE
 
+C12832  lcd(PE_14, PE_12, PD_12, PD_11, PE_9);
 OdinWiFiInterface wifi;
 InterruptIn button(PF_2);
 volatile int count = 0;
@@ -25,28 +26,31 @@
 
 // FUNCTION DEFINTIONS HERE
 
+void lcd_print(const char* message) {
+    lcd.cls();
+    lcd.locate(0, 3);
+    lcd.printf(message);
+}
+
 void button_clicked() {
     clicked = true;
     count += 1;
-    printf("Button Clicked %d\n\r", count);
+    char val[32];
+    sprintf(val, "# of clicks = %d", count);
+    lcd_print(val);
 }
 
 int main() {
 
     // MAIN CODE HERE
-
-    printf("\nConnecting to %s...\n", MBED_CONF_APP_WIFI_SSID);
+    
+    lcd_print("Connecting...");
     int ret = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
     if (ret != 0) {
-        printf("\nConnection error\n");
+        lcd_print("Connection error.");
         return -1;
     }
-    printf("Success\n\n");
-    printf("MAC: %s\n", wifi.get_mac_address());
-    printf("IP: %s\n", wifi.get_ip_address());
-    printf("Netmask: %s\n", wifi.get_netmask());
-    printf("Gateway: %s\n", wifi.get_gateway());
-    printf("RSSI: %d\n\n", wifi.get_rssi());
+    lcd_print("Successfully connected!");
 
     button.rise(&button_clicked);
 
@@ -60,7 +64,6 @@
             request->set_header("Content-Type", "application/json");
             sprintf(body, "{\"value1\":\"%s\", \"value2\":\"%d\"}", event_name, count);
             HttpResponse* response = request->send(body, strlen(body));
-            printf("%s\n\r", response->get_body_as_string().c_str());
             delete request;
         }
     }