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, committed 2017-11-10
- Comitter:
- Jenny Plunkett
- Date:
- Fri Nov 10 17:43:29 2017 -0600
- Parent:
- 1:140166e52025
- Child:
- 3:53f29f617e33
- Commit message:
- Added LCD library and working main
Changed in this revision
| C12832.lib | 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/C12832.lib Fri Nov 10 17:43:29 2017 -0600 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/chris/code/C12832/#7de323fa46fe
--- 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;
}
}
Cambridge Hackathon

