Simpe IoT BoardにGrove温度センサを繋げてIFTTTにプッシュするプログラムです。
Dependencies: ESP8266Interface IFTTT mbed
Fork of SimpleIoTBoard_sample by
Revision 0:0f0676c43e4b, committed 2015-06-28
- Comitter:
- mbedAustin
- Date:
- Sun Jun 28 03:41:06 2015 +0000
- Child:
- 1:15dd4d0a3af0
- Commit message:
- Initial Commit of working GET/ POST interface with IFTT service;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Sun Jun 28 03:41:06 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient-SSL.lib Sun Jun 28 03:41:06 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/ansond/code/HTTPClient-SSL/#a18a06b000f3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Jun 28 03:41:06 2015 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "HTTPClient.h"
+
+EthernetInterface eth;
+HTTPClient http;
+char str[512] = {};
+char json[125] = {};
+char eventName[] = "helloworld";
+char key[] = "ChangeThisToTheKeyProvidedByIFTTonTheMakerChannel";
+char value1[] = {"A"}, value2[] = {"B"}, value3[] = {"C"};
+
+int main()
+{
+ eth.init(); //Use DHCP
+ eth.connect();
+ printf("IP Address is %s \n\r", eth.getIPAddress());
+
+ //GET
+ printf("GETing data... \n\r");
+ sprintf(str, "https://maker.ifttt.com/trigger/%s/with/key/%s?value1=%s&value2=%s&value3=%s",eventName,key,value1,value2,value3);
+ printf("String is : %s\n\r",str);
+ int ret = http.get(str, str, 128);
+ if (!ret)
+ {
+ printf("Page fetched successfully - read %d characters\n\r", strlen(str));
+ printf("Result: %s\n", str);
+ }
+ else
+ {
+ printf("Error - ret = %d - HTTP return code = %d \n\r", ret, http.getHTTPResponseCode());
+ }
+
+ //POST
+ HTTPMap map;
+ HTTPText inText(str, 512);
+ map.put("value1", value1);
+ map.put("value2", value2);
+ map.put("value3", value3);
+ sprintf(str, "https://maker.ifttt.com/trigger/%s/with/key/%s",eventName,key);
+ printf("String is : %s\n\r",str);
+ printf("POSTing data ....\n\r");
+ ret = http.post(str, map, &inText);
+ if (!ret)
+ {
+ printf("Executed POST successfully - read %d characters \n\r", strlen(str));
+ printf("Result: %s \n\r", str);
+ }
+ else
+ {
+ printf("Error - ret = %d - HTTP return code = %d \n\r", ret, http.getHTTPResponseCode());
+ }
+
+
+
+ eth.disconnect();
+
+ while(1) {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Sun Jun 28 03:41:06 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#d3d0e710b443
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jun 28 03:41:06 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file
