Xively demo for cc3000

Dependencies:   NVIC_set_all_priorities cc3000_hostdriver_mbedsocket libxively mbed

Revision:
1:ad3b3e58ba36
Parent:
0:cc7d755246b3
Child:
2:ed5cf21e63b4
--- 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;