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

Dependencies:   mbed-http C12832

View the tutorial for this demo here.

Files at this revision

API Documentation at this revision

Comitter:
Jenny Plunkett
Date:
Fri Nov 10 15:56:35 2017 -0600
Child:
1:140166e52025
Commit message:
Blank program for tutorial (with working main)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-http.lib Show annotated file Show diff for this revision Revisions of this file
mbed-os.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
mbed_settings.py Show annotated file Show diff for this revision Revisions of this file
mbed_settings.pyc Show annotated file Show diff for this revision Revisions of this file
working/main_working.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 10 15:56:35 2017 -0600
@@ -0,0 +1,30 @@
+//----------------------------------------------------------------------------
+// The confidential and proprietary information contained in this file may
+// only be used by a person authorised under and to the extent permitted
+// by a subsisting licensing agreement from ARM Limited or its affiliates.
+//
+// (C) COPYRIGHT 2016 ARM Limited or its affiliates.
+// ALL RIGHTS RESERVED
+//
+// This entire notice must be reproduced on all copies of this file
+// and copies of this file may only be made by a person if such person is
+// permitted to do so under the terms of a subsisting license agreement
+// from ARM Limited or its affiliates.
+//----------------------------------------------------------------------------
+#include "mbed.h"
+#include "OdinWiFiInterface.h"
+#include "TCPSocket.h"
+#include "http_request.h"
+
+// GLOBAL VARIABLES HERE
+
+
+// FUNCTION DEFINTIONS HERE
+
+
+int main() {
+
+    // MAIN CODE HERE
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-http.lib	Fri Nov 10 15:56:35 2017 -0600
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/sandbox/code/mbed-http/#3004056e4661
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Nov 10 15:56:35 2017 -0600
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#78474a5129e18e136cc7e872adbaa5b74fbb8f6a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Fri Nov 10 15:56:35 2017 -0600
@@ -0,0 +1,20 @@
+{
+    "config": {
+        "wifi-ssid": {
+            "help": "WiFi SSID",
+            "value": "\"SSID\""
+        },
+        "wifi-password": {
+            "help": "WiFi Password",
+            "value": "\"PASSWORD\""
+        }
+    },
+    "target_overrides": {
+        "*": {
+            "platform.stdio-convert-newlines": true
+        },
+        "UBLOX_EVK_ODIN_W2": {
+            "target.device_has": ["EMAC"]
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_settings.py	Fri Nov 10 15:56:35 2017 -0600
@@ -0,0 +1,45 @@
+"""
+mbed SDK
+Copyright (c) 2016 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from os.path import join, abspath, dirname
+
+#ROOT = abspath(join(dirname(__file__), "."))
+
+##############################################################################
+# Build System Settings
+##############################################################################
+#BUILD_DIR = abspath(join(ROOT, "build"))
+
+# ARM
+#ARM_PATH = "C:/Program Files/ARM"
+
+# GCC ARM
+#GCC_ARM_PATH = ""
+
+# GCC CodeRed
+#GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"
+
+# IAR
+#IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
+
+# Goanna static analyser. Please overload it in private_settings.py
+#GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin"
+
+#BUILD_OPTIONS = []
+
+# mbed.org username
+#MBED_ORG_USER = ""
Binary file mbed_settings.pyc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/working/main_working.h	Fri Nov 10 15:56:35 2017 -0600
@@ -0,0 +1,68 @@
+//----------------------------------------------------------------------------
+// The confidential and proprietary information contained in this file may
+// only be used by a person authorised under and to the extent permitted
+// by a subsisting licensing agreement from ARM Limited or its affiliates.
+//
+// (C) COPYRIGHT 2016 ARM Limited or its affiliates.
+// ALL RIGHTS RESERVED
+//
+// This entire notice must be reproduced on all copies of this file
+// and copies of this file may only be made by a person if such person is
+// permitted to do so under the terms of a subsisting license agreement
+// from ARM Limited or its affiliates.
+//----------------------------------------------------------------------------
+#include "mbed.h"
+#include "OdinWiFiInterface.h"
+#include "TCPSocket.h"
+#include "http_request.h"
+
+// GLOBAL VARIABLES HERE
+
+OdinWiFiInterface wifi;
+InterruptIn button(PF_2);
+volatile int count = 0;
+volatile bool clicked = false;
+
+// FUNCTION DEFINTIONS HERE
+
+void button_clicked() {
+    clicked = true;
+    count += 1;
+    printf("Button Clicked %d\n\r", count);
+}
+
+int main() {
+
+    // MAIN CODE HERE
+
+    printf("\nConnecting to %s...\n", MBED_CONF_APP_WIFI_SSID);
+    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");
+        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());
+
+    button.rise(&button_clicked);
+
+    while (true) {
+        if (clicked) {
+            clicked = false;
+            char body[140];
+            char event_name[] = "Button Clicked";
+            NetworkInterface* net = &wifi;
+            HttpRequest* request = new HttpRequest(net, HTTP_POST, "http://maker.ifttt.com/trigger/mbed_connect/with/key/SECRETKEY");
+            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;
+        }
+    }
+
+}