Xively park working

Dependencies:   C12832_lcd LM75B MMA7660 WiflyInterface libxively mbed-rtos mbed

Fork of IOT-Project-LED-ControlTelnet by Bhakti Kulkarni

Files at this revision

API Documentation at this revision

Comitter:
bhakti08
Date:
Sat Jun 07 01:04:41 2014 +0000
Parent:
4:d1e0e52f7f6b
Commit message:
IOT_Project_Xively;

Changed in this revision

C12832_lcd.lib Show annotated file Show diff for this revision Revisions of this file
LM75B.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.lib Show diff for this revision Revisions of this file
app_board_io.cpp Show annotated file Show diff for this revision Revisions of this file
app_board_io.h 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
mbed-rtos.lib 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
diff -r d1e0e52f7f6b -r efa4a9eafe7d C12832_lcd.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832_lcd.lib	Sat Jun 07 01:04:41 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/C12832_lcd/#468cdccff7af
diff -r d1e0e52f7f6b -r efa4a9eafe7d LM75B.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Sat Jun 07 01:04:41 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
diff -r d1e0e52f7f6b -r efa4a9eafe7d WebSocketClient.lib
--- a/WebSocketClient.lib	Fri Jun 06 13:44:53 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/samux/code/WebSocketClient/#466f90b7849a
diff -r d1e0e52f7f6b -r efa4a9eafe7d app_board_io.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app_board_io.cpp	Sat Jun 07 01:04:41 2014 +0000
@@ -0,0 +1,19 @@
+#include "app_board_io.h"
+#include "C12832_lcd.h"
+
+extern C12832_LCD lcd;
+
+extern "C" void lcd_printf( const char* fmt, ...  )
+{
+    char buffer[ 64 ];
+    
+    va_list ap;
+    va_start( ap, fmt );
+    vsnprintf( buffer, 64, fmt, ap );
+    va_end( ap );
+    
+    lcd.cls();
+    lcd.locate( 0, 3 );
+    lcd.printf( buffer );
+    //wait( 1.0 );
+}
\ No newline at end of file
diff -r d1e0e52f7f6b -r efa4a9eafe7d app_board_io.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app_board_io.h	Sat Jun 07 01:04:41 2014 +0000
@@ -0,0 +1,7 @@
+#include <stdarg.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void lcd_printf( const char* fmt, ...  );
\ No newline at end of file
diff -r d1e0e52f7f6b -r efa4a9eafe7d libxively.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libxively.lib	Sat Jun 07 01:04:41 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/xively/code/libxively/#4ce6299f7535
diff -r d1e0e52f7f6b -r efa4a9eafe7d main.cpp
--- a/main.cpp	Fri Jun 06 13:44:53 2014 +0000
+++ b/main.cpp	Sat Jun 07 01:04:41 2014 +0000
@@ -1,14 +1,31 @@
 //This Program is used to turn the LED ON/OFF via telent (Wifly connected)
 #include "mbed.h"
 #include "WiflyInterface.h"
-#include "Websocket.h"
 #include <string.h>
+#include "LM75B.h"
+#include "MMA7660.h"
+
+#define XI_FEED_ID 209829319 // set Xively Feed ID (numerical, no quoutes)
+#define XI_API_KEY "T0izYrB6TZVkmhhEWpzs5L7F5wqpJixxc6MtenkLDg3BLMIu" // set Xively API key (double-quoted string)
+
+#include "xively.h"
+#include "xi_err.h"
+
+#include "C12832_lcd.h"
+
+#define SEC 1000
+
 
 #define ECHO_SERVER_PORT   7
 
 
 PwmOut servo(p22);
 DigitalOut dir(LED1);
+//LM75B temp(p28,p27);
+AnalogIn temp(p19);
+MMA7660 axl(p28,p27);
+Serial pc(USBTX,USBRX);
+C12832_LCD lcd;
 
 #define FWD 1
 #define REV 0
@@ -30,36 +47,36 @@
 
 int main() {
     
-    char    recv[128];
+   // char    recv[128];
     
     wifly.init(); //Use DHCP
-    printf("1\r\n");
+    pc.printf("1\r\n");
     while (!wifly.connect());
-    printf("IP Address is %s\n\r", wifly.getIPAddress());
-
-   TCPSocketServer server;
-    
-    server.bind(ECHO_SERVER_PORT);
-    server.listen();
-
-    printf("\nWait for new connection...\n");
-    TCPSocketConnection client;
-    server.accept(client);
+    pc.printf("IP Address is %s\n\r", wifly.getIPAddress());
 
-    char buffer[256];
-    servo.period_us(50);
-    while (true) {
-        int n = client.receive(buffer, sizeof(buffer));
-        if (n <= 0) continue;
-        buffer[n] = 0;
-        printf("String is : %s\r\n",buffer);
-
-        client.send_all(buffer, n);
-        if (!(strcmp (buffer, "f")))
-            dir = FWD;
-        else if (!(strcmp(buffer,"r")))
-            dir = REV;
-        servo.pulsewidth_us(10);
-        wait_us(1);
+    xi_feed_t feed;
+        memset( &feed, NULL, sizeof( xi_feed_t ) );
+    
+        feed.feed_id = XI_FEED_ID;
+        feed.datastream_count = 1;
+    
+        feed.datastreams[0].datapoint_count = 1;
+        xi_datastream_t* temperature_datastream = &feed.datastreams[0];
+        strcpy( temperature_datastream->datastream_id, "Temperature" );
+        xi_datapoint_t* current_temperature = &temperature_datastream->datapoints[0];
+        
+        xi_context_t* xi_context
+            = xi_create_context( XI_HTTP, XI_API_KEY, feed.feed_id );
+        if( xi_context == NULL )
+        {
+            pc.printf("Error in Xi_Context\r\n");
+            exit (0);
+        }
+ 
+        
+       while (true) {
+        xi_set_value_f32( current_temperature, temp.read() ); 
+        xi_feed_update( xi_context, &feed );
+      wait(10.0);
     }
 }
\ No newline at end of file
diff -r d1e0e52f7f6b -r efa4a9eafe7d mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Sat Jun 07 01:04:41 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#88a1a9c26ae3
diff -r d1e0e52f7f6b -r efa4a9eafe7d xi_user_config.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xi_user_config.h	Sat Jun 07 01:04:41 2014 +0000
@@ -0,0 +1,24 @@
+#ifndef __XI_USER_CONFIG_H__
+#define __XI_USER_CONFIG_H__
+
+// The following settings should lower memory footprint.
+// The library currently allows one to send batch datapoint
+// and feed updates, but it's not needed in most use cases
+#define XI_MAX_DATAPOINTS         1
+// The number of channels can be increased if needed
+#define XI_MAX_DATASTREAMS        5
+
+// Below are optimisations that reduce some minor functionality
+#define XI_OPT_NO_ERROR_STRINGS
+
+// If you wish to enable assertions, set this to 1
+#define XI_DEBUG_ASSERT 0
+// If you wish to disable debug output, set this to 0
+#define XI_DEBUG_OUTPUT 0
+
+// On the mbed app board we can use the LCD for debug output,
+// but one may wish to modify this and write to file instead
+#include "app_board_io.h"
+#define XI_DEBUG_PRINTF lcd_printf //TODO: use serial port...
+
+#endif /* __XI_USER_CONFIG_H__ */