CyaSSL usage example: Xively access with HTTPS

Dependencies:   EthernetInterface HTTPClient mbed-rtos LM75B mbed

Import this for FRDM-k64f: http://mbed.org/users/wolfSSL/code/CyaSSL-Xively-FRDM/

For using this example:

- Prepare mbed with Ethernet connection.

- Go to http://xively.com. Sign up, and create your channel.

- Copy "Feed ID" and "API Key" on the page to XI_FEED_ID and XI_API_KEY in xively-main.cpp.

- The demo assumes LM75B temperature sensor on Xively Jumpstart Kit board. If your board does not have it, replace tmp.read() with your own read.

- Build, download it to mbed, and you will get the result "Temp" on your Xively channel page.

- Click "Temp" to get temperature graph.

Have fun!

日本語: https://mbed.org/users/wolfSSL/code/CyaSSL-Xively/wiki/Xively-example-jp

Revision:
1:1bb146136465
Parent:
0:70ada960373c
--- a/xively-main.cpp	Thu Apr 24 11:09:53 2014 +0000
+++ b/xively-main.cpp	Sat Jul 12 07:14:53 2014 +0000
@@ -19,9 +19,10 @@
 
 
 #include "mbed.h"
+
 #include "EthernetInterface.h"
 #include "HTTPClient.h"
-#include "LM75B.h"
+//#include "LM75B.h"
 
 #define XI_FEED_ID 123456789// set Xively Feed ID (numerical, no quoutes)
 #define XI_API_KEY "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // set Xively API key (double-quoted string)
@@ -33,9 +34,9 @@
 #define TIMEOUT 500
 
 HTTPClient http;
-LM75B tmp(p28, p27);
+//LM75B tmp(p28, p27);
 
-int xively()
+void xively(void const *av)
 {
     int ret ;
     int i ;
@@ -66,11 +67,11 @@
                    ret, http.getHTTPResponseCode());
         }
     }
-
+ 
     for(i=0; ; i++) {
         printf("<<<< %d >>>>\n", i) ;
         sprintf(uri, "%s/%d.json", XI_API, XI_FEED_ID) ;
-        sprintf(put_data, put_template, XI_CHANNEL, tmp.read()) ;
+        sprintf(put_data, put_template, XI_CHANNEL, (double)(i%100)/*tmp.read()*/) ;
         printf("Put Data:\n%s\n", put_data) ;
 
         HTTPText outText(put_data, strlen(put_data));
@@ -88,11 +89,12 @@
     }
 }
 
-main()
-{
+int main() {      
     int ret ;
+    void *av ;
+ 
+    EthernetInterface eth;
 
-    EthernetInterface eth;
     printf("Xively Starting,...\n") ;
     ret = eth.init(); //Use DHCP
     while(1) {
@@ -101,7 +103,14 @@
     }
     printf("IP = %s\n", eth.getIPAddress());
 
-    xively() ;
-
-    eth.disconnect();
+    //#define BOARD_FRDM_K64F
+    #ifdef BOARD_FRDM_K64F
+    #define STACK_SIZE 10000
+    Thread t( xively, NULL, osPriorityNormal, STACK_SIZE);
+    #else
+     xively(av) ;
+    #endif
+    while (true) {
+        Thread::wait(1000);
+    } 
 }