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

Revision:
2:3bec0454c754
Parent:
1:225ed64c9353
--- a/main.cpp	Sun Sep 07 20:33:58 2014 +0000
+++ b/main.cpp	Sun Sep 07 23:22:50 2014 +0000
@@ -11,7 +11,8 @@
 char streamName[] = "danger_bit"; // Stream you want to post to
 
 DigitalOut garage(PTB9);
-
+DigitalOut led(LED_RED);
+DigitalOut bled(LED_BLUE);
 
 /*
 char feeidId[] = "08a3bceeee7e7bfa32340aadd282ea23"; // Feed you want to post to
@@ -20,16 +21,10 @@
 */
 int danger = 0;
 
-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);
@@ -46,6 +41,11 @@
         
     }
     
+    if (danger == 0)
+    {
+        garage = 1;
+    }
+    
   }
 }
 
@@ -62,40 +62,29 @@
 }
 
 int main() {
+  garage = 1; 
+  led = 0;
+  
   eth.init();
   eth.connect();
   printf("IP Address: %s\r\n", eth.getIPAddress());
 
   char amb_temp[6];
   
-  garage = 1;
   
   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
-    int response = m2xClient.fetchValues(feedId, streamName, on_data_point_found, NULL);
+    int response = m2xClient.fetchValues(feedId, streamName, on_data_point_found, NULL, NULL, NULL, "1");
     printf("Fetch response code: %d\r\n", response);
-    //if (response == -1) while (true) ;
+    if (response == -1) 
+        bled = 0;
+    else 
+        bled = 1;
     
-    // 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) ;
+    led = !led;
 
     // wait 5 secs and then loop
-    delay(5000);
+    delay(2000);
   }
 }
\ No newline at end of file