
https://github.com/ryantm/attcarhomehackathon
Dependencies: EthernetInterface LM75B M2XStreamClient jsonlite mbed-rtos mbed
Fork of m2x-demo-all by
Revision 1:225ed64c9353, committed 2014-09-07
- Comitter:
- buf006
- Date:
- Sun Sep 07 20:33:58 2014 +0000
- Parent:
- 0:38a7a8cae773
- Child:
- 2:3bec0454c754
- Commit message:
- add AT&T car and home hackathon home module mbed code
Changed in this revision
--- a/EthernetInterface.lib Fri Feb 21 21:12:15 2014 +0000 +++ b/EthernetInterface.lib Sun Sep 07 20:33:58 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c +http://mbed.org/users/mbed_official/code/EthernetInterface/#5887ae6c0c2c
--- a/M2XStreamClient.lib Fri Feb 21 21:12:15 2014 +0000 +++ b/M2XStreamClient.lib Sun Sep 07 20:33:58 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#f479e4f4db0e +http://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#ba0d02be2835
--- a/jsonlite.lib Fri Feb 21 21:12:15 2014 +0000 +++ b/jsonlite.lib Sun Sep 07 20:33:58 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/citrusbyte/code/jsonlite/#01a2f8de46c8 +http://mbed.org/users/citrusbyte/code/jsonlite/#807034181e02
--- a/main.cpp Fri Feb 21 21:12:15 2014 +0000 +++ b/main.cpp Sun Sep 07 20:33:58 2014 +0000 @@ -5,9 +5,20 @@ #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 feedId[] = "c6eabf437b8c69efbb4e4a8d5c60c04d"; // Feed you want to post to +char m2xKey[] = "10bc8a4dc4a37c5dc549b41ffaa6d6c1"; // Your M2X access key +char streamName[] = "danger_bit"; // Stream you want to post to + +DigitalOut garage(PTB9); + + +/* +char feeidId[] = "08a3bceeee7e7bfa32340aadd282ea23"; // Feed you want to post to +char m2xKey[] = "41e5905679b7a6fa668303e00da65826"; // Your M2X access key +char streamName[] = "garagecommand"; // Stream you want to post to +*/ +int danger = 0; char name[] = "<location name>"; // Name of current location of datasource double latitude = 33.007872; @@ -18,11 +29,24 @@ M2XStreamClient m2xClient(&client, m2xKey); EthernetInterface eth; -LM75B tmp(p28,p27); // I2C Temperature Sensor +//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); + + if(index == 0) + { + danger = atoi(value); + + if (danger == 1) + { + printf("Carbonmonoxide levels are dangerous. \n"); + garage = 0; + + } + + } } void on_location_found(const char* name, @@ -44,32 +68,34 @@ char amb_temp[6]; + garage = 1; + while (true) { // read temp - sprintf(amb_temp, "%0.2f", tmp.read()); + //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) ; + //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); + int response = m2xClient.fetchValues(feedId, streamName, on_data_point_found, NULL); printf("Fetch response code: %d\r\n", response); - if (response == -1) while (true) ; + //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) ; + //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) ; + //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); + // wait 5 secs and then loop + delay(5000); } } \ No newline at end of file
--- a/mbed-rtos.lib Fri Feb 21 21:12:15 2014 +0000 +++ b/mbed-rtos.lib Sun Sep 07 20:33:58 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#f88660a9bed1 +http://mbed.org/users/mbed_official/code/mbed-rtos/#bd07334df5b1
--- a/mbed.bld Fri Feb 21 21:12:15 2014 +0000 +++ b/mbed.bld Sun Sep 07 20:33:58 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file