Xively demo for cc3000
Dependencies: NVIC_set_all_priorities cc3000_hostdriver_mbedsocket libxively mbed
Revision 2:ed5cf21e63b4, committed 2013-10-13
- Comitter:
- Kojto
- Date:
- Sun Oct 13 12:06:53 2013 +0000
- Parent:
- 1:ad3b3e58ba36
- Child:
- 3:6eb505b0beb3
- Commit message:
- seconds counter, led each 10 seconds
Changed in this revision
| 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 |
--- a/main.cpp Sun Oct 13 10:37:45 2013 +0000
+++ b/main.cpp Sun Oct 13 12:06:53 2013 +0000
@@ -19,14 +19,15 @@
#include "xively.h"
#include "xi_err.h"
-#define XI_FEED_ID 122217810 // set Xively Feed ID (numerical, no quoutes)
-#define XI_API_KEY "S6hdVWSPO2IWAr7IiqLtTKSjRh6kyUAAYZdbYcixuEJwhg6T" // set Xively API key (double-quoted string)
+#define XI_FEED_ID 123 // set Xively Feed ID (numerical, no quoutes)
+#define XI_API_KEY "apikey" // set Xively API key (double-quoted string)
using namespace mbed_cc3000;
tUserFS user_info;
DigitalOut myled(LED1);
-Ticker flipper;
+Ticker flipper_seconds;
+Ticker flipper_led;
uint32_t time_seconds;
/* cc3000 module declaration specific for user's board. Check also init() */
@@ -86,9 +87,15 @@
wifi.connect_open((uint8_t *)ssid);
}
+/**
+ * \brief Count seconds
+ * \param none
+ * \return none
+ */
void update_timer() {
time_seconds++;
}
+
/**
* \brief xively demo
* \param none
@@ -150,22 +157,16 @@
return -1;
}
- //flipper.attach(&update_timer, 1.0);
+ flipper_seconds.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);
xi_set_value_f32(counter, time_seconds);
printf( "update...\r\n");
xi_feed_update(xi_context, &feed);
printf( "done...\r\n");
-
- wait(15.0);
+ wait(10);
myled = myled ^ 0x1;
}
--- a/main.h Sun Oct 13 10:37:45 2013 +0000 +++ b/main.h Sun Oct 13 12:06:53 2013 +0000 @@ -32,9 +32,9 @@ #define USE_SMART_CONFIG 0 // Default SSID Settings -#define AP_KEY "zxcvbnm,./" +#define AP_KEY "test" #define AP_SECURITY WPA2 // WPA2 must be enabled for use with iPhone or Android phone hotspot! -#define SSID "SSID" +#define SSID "test" #define XI_USER_CONFIG 1