Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface LM75B M2XStreamClient carbon_home_module jsonlite mbed-rtos mbed
Fork of carbon_home_module by
Revision 3:6fa1107c6129, committed 2015-01-04
- Comitter:
- buf006
- Date:
- Sun Jan 04 23:04:19 2015 +0000
- Parent:
- 2:3bec0454c754
- Commit message:
- working version of Clothes-It receiver;
Changed in this revision
| carbon_home_module.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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/carbon_home_module.lib Sun Jan 04 23:04:19 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/buf006/code/carbon_home_module/#3bec0454c754
--- a/main.cpp Sun Sep 07 23:22:50 2014 +0000
+++ b/main.cpp Sun Jan 04 23:04:19 2015 +0000
@@ -5,79 +5,77 @@
#include "EthernetInterface.h"
#include "LM75B.h" //I2C Temperature Sensor
+char feedId[] = "bb84147dbab191356d0b5fb090c19a9e"; // Feed you want to post to
+char m2xKey[] = "f68404a95d271e5d81c4d7f9224cbd8d"; // Your M2X access key
+char streamNameShirt[] = "shirtposition"; // Stream you want to post to
+char streamNamePants[] = "pantsposition";
-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);
DigitalOut led(LED_RED);
DigitalOut bled(LED_BLUE);
-/*
-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;
+Serial uart0(USBTX, USBRX);
+Serial uart3(PTC17, PTC16);
+
+int shirtPosition = 0;
+int pantsPosition = 0;
+
+int topPackage = 0;
+int bottomPackage = 0;
+int totalPackage = 0;
Client client;
M2XStreamClient m2xClient(&client, m2xKey);
EthernetInterface eth;
-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_data_point_found_shirt(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);
+ shirtPosition = atoi(value);
- if (danger == 1)
+ if(shirtPosition < 7 && shirtPosition > 0)
{
- printf("Carbonmonoxide levels are dangerous. \n");
- garage = 0;
-
+ uart0.printf("%x", shirtPosition);
+ uart3.printf("%x", shirtPosition);
}
+ }
+}
+void on_data_point_found_pants(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)
+ {
+ pantsPosition = atoi(value) + 6;
- if (danger == 0)
+ if(pantsPosition < 13 && pantsPosition > 6)
{
- garage = 1;
+ uart0.printf("%x", pantsPosition);
+ uart3.printf("%x", pantsPosition);
}
-
+
+
}
}
-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() {
- garage = 1;
+
led = 0;
eth.init();
eth.connect();
printf("IP Address: %s\r\n", eth.getIPAddress());
-
- char amb_temp[6];
-
while (true) {
- // read temperature
- 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)
+
+ int response1 = m2xClient.fetchValues(feedId, streamNameShirt, on_data_point_found_shirt, NULL, NULL, NULL, "1");
+ int response2 = m2xClient.fetchValues(feedId, streamNamePants, on_data_point_found_pants, NULL, NULL, NULL, "1");
+ //printf("Fetch response code: %d\r\n", response);
+ if (response1 == -1 || response2 == -1 )
bled = 0;
else
bled = 1;
@@ -85,6 +83,6 @@
led = !led;
// wait 5 secs and then loop
- delay(2000);
+ delay(2000); // was originally 2000
}
}
\ No newline at end of file
