Xively demo for cc3000

Dependencies:   NVIC_set_all_priorities cc3000_hostdriver_mbedsocket libxively mbed

Files at this revision

API Documentation at this revision

Comitter:
Kojto
Date:
Sun Oct 13 10:37:45 2013 +0000
Parent:
0:cc7d755246b3
Child:
2:ed5cf21e63b4
Commit message:
update xively, ticker to count seconds

Changed in this revision

cc3000_hostdriver_mbedsocket.lib Show annotated file Show diff for this revision Revisions of this file
libxively.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
xi_user_config.h Show annotated file Show diff for this revision Revisions of this file
--- a/cc3000_hostdriver_mbedsocket.lib	Fri Oct 11 20:13:19 2013 +0000
+++ b/cc3000_hostdriver_mbedsocket.lib	Sun Oct 13 10:37:45 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Kojto/code/cc3000_hostdriver_mbedsocket/#1f70a62a160e
+http://mbed.org/users/Kojto/code/cc3000_hostdriver_mbedsocket/#960b73df5981
--- a/libxively.lib	Fri Oct 11 20:13:19 2013 +0000
+++ b/libxively.lib	Sun Oct 13 10:37:45 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/xively/code/libxively/#037241ec3163
+http://mbed.org/users/xively/code/libxively/#ec8b7d78ea10
--- a/main.cpp	Fri Oct 11 20:13:19 2013 +0000
+++ b/main.cpp	Sun Oct 13 10:37:45 2013 +0000
@@ -26,6 +26,8 @@
 
 tUserFS user_info;
 DigitalOut myled(LED1);
+Ticker flipper;
+uint32_t time_seconds;
 
 /* cc3000 module declaration specific for user's board. Check also init() */
 #if (MY_BOARD == WIGO)
@@ -84,6 +86,9 @@
     wifi.connect_open((uint8_t *)ssid);
 }
 
+void update_timer() {
+    time_seconds++;
+}
 /**
  *  \brief xively demo
  *  \param  none
@@ -123,34 +128,42 @@
     std::memset(&feed, 0, sizeof( xi_feed_t ) );
    
     feed.feed_id = XI_FEED_ID;
-    feed.datastream_count = 1;
+    feed.datastream_count = 2;
     
     feed.datastreams[0].datapoint_count = 1;
     xi_datastream_t* status_datastream = &feed.datastreams[0];
-    strcpy( status_datastream->datastream_id, "LED1");
+    strcpy(status_datastream->datastream_id, "LED1");
     xi_datapoint_t* led_status = &status_datastream->datapoints[0];
 
+    feed.datastreams[1].datapoint_count = 1;
+    xi_datastream_t* counter_datastream = &feed.datastreams[1];
+    strcpy(counter_datastream->datastream_id, "Uptime");
+    xi_datapoint_t* counter = &counter_datastream->datapoints[0];
+    
     // create the cosm library context
     xi_context_t* xi_context = xi_create_context(XI_HTTP, XI_API_KEY, feed.feed_id);
 
     // check if everything works
     if(xi_context == NULL)
     {
+        printf("Context failed to initialized. \r\n");
         return -1;
     }
         
-    while(1) {    
+    //flipper.attach(&update_timer, 1.0);
+
+    while(1) {  
       if (myled) {
           xi_set_value_str(led_status, "off");
       } else {
           xi_set_value_str(led_status, "on");
       }
       
-      xi_set_value_f32(led_status, myled);
-        
-      printf( "update...\r\n" );
+      xi_set_value_f32(counter, time_seconds);
+      
+      printf( "update...\r\n");
       xi_feed_update(xi_context, &feed);
-      printf( "done...\r\n" );
+      printf( "done...\r\n");
       
       wait(15.0);
       myled = myled ^ 0x1;
--- a/main.h	Fri Oct 11 20:13:19 2013 +0000
+++ b/main.h	Sun Oct 13 10:37:45 2013 +0000
@@ -36,9 +36,7 @@
 #define AP_SECURITY  WPA2            // WPA2 must be enabled for use with iPhone or Android phone hotspot!
 #define SSID         "SSID"
 
-// xively setup - less memory
-#define XI_MAX_DATAPOINTS                  1
-#define XI_MAX_DATASTREAMS                 3
+#define XI_USER_CONFIG 1
 
 void init();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xi_user_config.h	Sun Oct 13 10:37:45 2013 +0000
@@ -0,0 +1,23 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 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.
+ */
+#ifndef XI_USER_CONFIG_H
+#define XI_USER_CONFIG_H
+
+// xively setup - less memory
+#define XI_MAX_DATAPOINTS                  1
+#define XI_MAX_DATASTREAMS                 2
+
+#endif