https://github.com/ryantm/attcarhomehackathon

Dependencies:   EthernetInterface LM75B M2XStreamClient jsonlite mbed-rtos mbed

Dependents:   clothesItReceiver

Fork of m2x-demo-all by AT&T M2X Team

Files at this revision

API Documentation at this revision

Comitter:
jb8414
Date:
Fri Feb 21 21:12:15 2014 +0000
Child:
1:225ed64c9353
Commit message:
initial commit

Changed in this revision

EthernetInterface.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
M2XStreamClient.lib Show annotated file Show diff for this revision Revisions of this file
jsonlite.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Fri Feb 21 21:12:15 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Fri Feb 21 21:12:15 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/M2XStreamClient.lib	Fri Feb 21 21:12:15 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#f479e4f4db0e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jsonlite.lib	Fri Feb 21 21:12:15 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/citrusbyte/code/jsonlite/#01a2f8de46c8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Feb 21 21:12:15 2014 +0000
@@ -0,0 +1,75 @@
+#include <jsonlite.h>
+#include "M2XStreamClient.h"
+
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "LM75B.h"  //I2C Temperature Sensor
+
+char feedId[] = "<feed id>"; // Feed you want to post to
+char m2xKey[] = "<m2x api key>"; // Your M2X access key
+char streamName[] = "<stream name>"; // Stream you want to post to
+
+char name[] = "<location name>"; // Name of current location of datasource
+double latitude = 33.007872;
+double longitude = -96.751614; // You can also read those values from a GPS
+double elevation = 697.00;
+
+Client client;
+M2XStreamClient m2xClient(&client, m2xKey);
+
+EthernetInterface eth;
+LM75B tmp(p28,p27);         // I2C Temperature Sensor
+
+void on_data_point_found(const char* at, const char* value, int index, void* context) {
+  printf("Found a data point, index: %d\r\n", index);
+  printf("At: %s Value: %s\r\n", at, value);
+}
+
+void on_location_found(const char* name,
+                       double latitude,
+                       double longitude,
+                       double elevation,
+                       const char* timestamp,
+                       int index,
+                       void* context) {
+  printf("Found a location, index: %d\r\n", index);
+  printf("Name: %s  Latitude: %lf  Longitude: %lf\r\n", name, latitude, longitude);
+  printf("Elevation: %lf  Timestamp: %s\r\n", elevation, timestamp);
+}
+
+int main() {
+  eth.init();
+  eth.connect();
+  printf("IP Address: %s\r\n", eth.getIPAddress());
+
+  char amb_temp[6];
+  
+  while (true) {
+  
+    // read temp
+    sprintf(amb_temp, "%0.2f", tmp.read());
+    
+    // post temperature
+    int response = m2xClient.post(feedId, streamName, amb_temp);
+    printf("Post response code: %d\r\n", response);
+    if (response == -1) while (true) ;
+    
+    // read temperature
+    response = m2xClient.fetchValues(feedId, streamName, on_data_point_found, NULL);
+    printf("Fetch response code: %d\r\n", response);
+    if (response == -1) while (true) ;
+    
+    // update location
+    response = m2xClient.updateLocation(feedId, name, latitude, longitude, elevation);
+    printf("updateLocation response code: %d\r\n", response);
+    if (response == -1) while (true) ;
+    
+    // read location
+    response = m2xClient.readLocation(feedId, on_location_found, NULL);
+    printf("readLocation response code: %d\r\n", response);
+    if (response == -1) while (true) ;
+
+    // wait 60 secs and then loop
+    delay(60000);
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Feb 21 21:12:15 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#f88660a9bed1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 21 21:12:15 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43
\ No newline at end of file