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

Files at this revision

API Documentation at this revision

Comitter:
wolfSSL
Date:
Sat Jul 12 07:14:53 2014 +0000
Parent:
0:70ada960373c
Child:
2:fa6565a5cb59
Commit message:
Common main.cpp for FRDM-K64F;

Changed in this revision

CyaSSL.lib Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
xively-main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/CyaSSL.lib	Thu Apr 24 11:09:53 2014 +0000
+++ b/CyaSSL.lib	Sat Jul 12 07:14:53 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/wolfSSL/code/CyaSSL/#9d17e4342598
+CyaSSL#4ec56e2a3a7c
--- a/EthernetInterface.lib	Thu Apr 24 11:09:53 2014 +0000
+++ b/EthernetInterface.lib	Sat Jul 12 07:14:53 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
+http://mbed.org/users/mbed_official/code/EthernetInterface/#e6b79f0ccd95
--- a/HTTPClient.lib	Thu Apr 24 11:09:53 2014 +0000
+++ b/HTTPClient.lib	Sat Jul 12 07:14:53 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/wolfSSL/code/HTTPClient/#14ecc2b2e282
+http://mbed.org/users/wolfSSL/code/HTTPClient/#f7e0ab858911
--- a/mbed-rtos.lib	Thu Apr 24 11:09:53 2014 +0000
+++ b/mbed-rtos.lib	Sat Jul 12 07:14:53 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#4e0e79c9b976
+http://mbed.org/users/mbed_official/code/mbed-rtos/#478a48c29e88
--- a/mbed.bld	Thu Apr 24 11:09:53 2014 +0000
+++ b/mbed.bld	Sat Jul 12 07:14:53 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file
--- 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);
+    } 
 }