diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino index 4a4e818bf..48c3b116f 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino @@ -25,6 +25,10 @@ #include "TembooAccount.h" // contains Temboo account information // as described in the footer comment below + +// the address for which a weather forecast will be retrieved +String ADDRESS_FOR_FORECAST = "104 Franklin St., New York NY 10013"; + int numRuns = 0; // execution count, so that this doesn't run forever int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run @@ -32,6 +36,7 @@ void setup() { Serial.begin(9600); // for debugging, wait until a serial console is connected + delay(4000); while(!Serial); Bridge.begin(); } @@ -58,14 +63,14 @@ void loop() GetWeatherByAddressChoreo.addParameter("-p"); GetWeatherByAddressChoreo.addParameter(TEMBOO_APP_KEY); - // identify the Temboo Library choreo to run (Yahoo > Weather > GetWeatherByAddress) + // identify the Temboo Library choreo to run (Yahoo > Weather > GetWeatherByAddress) GetWeatherByAddressChoreo.addParameter("-c"); GetWeatherByAddressChoreo.addParameter("/Library/Yahoo/Weather/GetWeatherByAddress"); // set choreo inputs; in this case, the address for which to retrieve weather data // the Temboo client provides standardized calls to 100+ cloud APIs GetWeatherByAddressChoreo.addParameter("-i"); - GetWeatherByAddressChoreo.addParameter("Address:104 Franklin St., New York NY 10013"); + GetWeatherByAddressChoreo.addParameter("Address:" + ADDRESS_FOR_FORECAST); // run the choreo GetWeatherByAddressChoreo.run(); @@ -76,34 +81,35 @@ void loop() // note that in this example, we just print the raw XML response from Yahoo // see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino // for information on how to filter this data - - Serial.print((char)GetWeatherByAddressChoreo.read()); + char c = GetWeatherByAddressChoreo.read(); + Serial.print(c); } GetWeatherByAddressChoreo.close(); } - Serial.println("Sleeping..."); + Serial.println("Waiting..."); Serial.println(""); - delay(30000); // sleep 30 seconds between GetWeatherByAddress calls + delay(30000); // wait 30 seconds between GetWeatherByAddress calls } /* IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and - include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. */ diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/TembooAccount.h new file mode 100644 index 000000000..c58b4479d --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/TembooAccount.h @@ -0,0 +1,4 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino index 5acdbab7f..e420e28f1 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino @@ -33,12 +33,14 @@ /*** SUBSTITUTE YOUR VALUES BELOW: ***/ +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token"; const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret"; const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key"; const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret"; -int numRuns = 0; // execution count, so this sketch doesn't run forever +int numRuns = 1; // execution count, so this sketch doesn't run forever int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run void setup() { @@ -53,7 +55,7 @@ void setup() { void loop() { // while we haven't reached the max number of runs... - if (numRuns < maxRuns) { + if (numRuns <= maxRuns) { // print status Serial.println("Running ReadATweet - Run #" + String(numRuns++) + "..."); @@ -108,12 +110,12 @@ void loop() // tell the Process to run and wait for the results. The - // return code (rc) will tell us whether the Temboo client + // return code will tell us whether the Temboo client // was able to send our request to the Temboo servers - unsigned int rc = HomeTimelineChoreo.run(); + unsigned int returnCode = HomeTimelineChoreo.run(); // a response code of 0 means success; print the API response - if(rc == 0) { + if(returnCode == 0) { String author; // a String to hold the tweet author's name String tweet; // a String to hold the text of the tweet @@ -152,34 +154,36 @@ void loop() // there was an error // print the raw output from the choreo while(HomeTimelineChoreo.available()) { - Serial.print((char)HomeTimelineChoreo.read()); + char c = HomeTimelineChoreo.read(); + Serial.print(c); } } HomeTimelineChoreo.close(); } - Serial.println("Sleeping..."); + Serial.println("Waiting..."); Serial.println(""); - delay(90000); // sleep 90 seconds between HomeTimeline calls + delay(90000); // wait 90 seconds between HomeTimeline calls } /* IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and - include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. */ diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/TembooAccount.h new file mode 100644 index 000000000..c58b4479d --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/TembooAccount.h @@ -0,0 +1,4 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino index 70befef8f..8b200fb78 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino @@ -10,8 +10,10 @@ http://www.temboo.com In order to run this sketch, you'll need to register an application using - the Twitter dev console at https://dev.twitter.com. After creating the - app, you'll find OAuth credentials for that application under the "OAuth Tool" tab. + the Twitter dev console at https://dev.twitter.com. Note that since this + sketch creates a new tweet, your application will need to be configured with + read+write permissions. After creating the app, you'll find OAuth credentials + for that application under the "OAuth Tool" tab. Substitute these values for the placeholders below. This example assumes basic familiarity with Arduino sketches, and that your Yun is connected @@ -33,6 +35,8 @@ /*** SUBSTITUTE YOUR VALUES BELOW: ***/ +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token"; const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret"; const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key"; @@ -72,7 +76,7 @@ void loop() StatusesUpdateChoreo.addParameter("-p"); StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY); - // identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate) + // identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate) StatusesUpdateChoreo.addParameter("-c"); StatusesUpdateChoreo.addParameter("/Library/Twitter/Tweets/StatusesUpdate"); @@ -96,24 +100,25 @@ void loop() StatusesUpdateChoreo.addParameter("StatusUpdate:" + tweet); // tell the Process to run and wait for the results. The - // return code (rc) will tell us whether the Temboo client + // return code (returnCode) will tell us whether the Temboo client // was able to send our request to the Temboo servers - unsigned int rc = StatusesUpdateChoreo.run(); + unsigned int returnCode = StatusesUpdateChoreo.run(); // a return code of zero (0) means everything worked - if (rc == 0) { + if (returnCode == 0) { Serial.println("Success! Tweet sent!"); } else { // a non-zero return code means there was an error // read and print the error message while (StatusesUpdateChoreo.available()) { - Serial.print((char)StatusesUpdateChoreo.read()); + char c = StatusesUpdateChoreo.read(); + Serial.print(c); } } StatusesUpdateChoreo.close(); // do nothing for the next 90 seconds - Serial.println("Sleeping..."); + Serial.println("Waiting..."); delay(90000); } } @@ -121,22 +126,22 @@ void loop() /* IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and - include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. */ - diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendATweet/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendATweet/TembooAccount.h new file mode 100644 index 000000000..c58b4479d --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendATweet/TembooAccount.h @@ -0,0 +1,4 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino index 76fdc1dba..1ed95dfe9 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino @@ -31,6 +31,9 @@ /*** SUBSTITUTE YOUR VALUES BELOW: ***/ +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + // your Gmail address, eg "bob.smith@gmail.com" const String GMAIL_USER_NAME = "xxxxxxxxxx"; @@ -74,7 +77,7 @@ void loop() SendEmailChoreo.addParameter("-p"); SendEmailChoreo.addParameter(TEMBOO_APP_KEY); - // identify the Temboo Library choreo to run (Google > Gmail > SendEmail) + // identify the Temboo Library choreo to run (Google > Gmail > SendEmail) SendEmailChoreo.addParameter("-c"); SendEmailChoreo.addParameter("/Library/Google/Gmail/SendEmail"); @@ -103,19 +106,20 @@ void loop() SendEmailChoreo.addParameter("MessageBody:Hey! The greenhouse is too cold!"); // tell the Process to run and wait for the results. The - // return code (rc) will tell us whether the Temboo client + // return code (returnCode) will tell us whether the Temboo client // was able to send our request to the Temboo servers - unsigned int rc = SendEmailChoreo.run(); + unsigned int returnCode = SendEmailChoreo.run(); // a return code of zero (0) means everything worked - if (rc == 0) { + if (returnCode == 0) { Serial.println("Success! Email sent!"); success = true; } else { // a non-zero return code means there was an error // read and print the error message while (SendEmailChoreo.available()) { - Serial.print((char)SendEmailChoreo.read()); + char c = SendEmailChoreo.read(); + Serial.print(c); } } SendEmailChoreo.close(); @@ -128,20 +132,20 @@ void loop() /* IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and - include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. */ - diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h new file mode 100644 index 000000000..8d7dcfb77 --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino index 67a0b250b..565f7fc5a 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino @@ -42,6 +42,9 @@ /*** SUBSTITUTE YOUR VALUES BELOW: ***/ +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + // the Account SID from your Twilio account const String TWILIO_ACCOUNT_SID = "xxxxxxxxxx"; @@ -116,25 +119,26 @@ void loop() SendSMSChoreo.addParameter("Body:Hey, there! This is a message from your Arduino Yun!"); // tell the Process to run and wait for the results. The - // return code (rc) will tell us whether the Temboo client + // return code (returnCode) will tell us whether the Temboo client // was able to send our request to the Temboo servers - unsigned int rc = SendSMSChoreo.run(); + unsigned int returnCode = SendSMSChoreo.run(); // a return code of zero (0) means everything worked - if (rc == 0) { + if (returnCode == 0) { Serial.println("Success! SMS sent!"); success = true; } else { // a non-zero return code means there was an error // read and print the error message while (SendSMSChoreo.available()) { - Serial.print((char)SendSMSChoreo.read()); + char c = SendSMSChoreo.read(); + Serial.print(c); } } SendSMSChoreo.close(); // do nothing for the next 60 seconds - Serial.println("Sleeping..."); + Serial.println("Waiting..."); delay(60000); } } @@ -142,19 +146,20 @@ void loop() /* IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and - include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. -*/ \ No newline at end of file +*/ diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnSMS/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnSMS/TembooAccount.h new file mode 100644 index 000000000..8d7dcfb77 --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnSMS/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino index 9698d811a..3c513deef 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino @@ -20,9 +20,8 @@ work properly. It doesn't matter what the column labels actually are, but there must be text in the first row of each column. This example assumes there are two columns. The first column is the time (in milliseconds) - that the row was appended, and the second column is a sensor value - (simulated in this example via a random number). In other words, your spreadsheet - should look like: + that the row was appended, and the second column is a sensor value. + In other words, your spreadsheet should look like: Time | Sensor Value | ------+----------------- @@ -48,13 +47,18 @@ /*** SUBSTITUTE YOUR VALUES BELOW: ***/ +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + const String GOOGLE_USERNAME = "your-google-username"; const String GOOGLE_PASSWORD = "your-google-password"; // the title of the spreadsheet you want to send data to +// (Note that this must actually be the title of a Google spreadsheet +// that exists in your Google Drive/Docs account, and is configured +// as described above.) const String SPREADSHEET_TITLE = "your-spreadsheet-title"; - const unsigned long RUN_INTERVAL_MILLIS = 60000; // how often to run the Choreo (in milliseconds) // the last time we ran the Choreo @@ -137,18 +141,19 @@ void loop() AppendRowChoreo.addParameter("RowData:" + rowData); // run the Choreo and wait for the results - // The return code (rc) will indicate success or failure - unsigned int rc = AppendRowChoreo.run(); + // The return code (returnCode) will indicate success or failure + unsigned int returnCode = AppendRowChoreo.run(); // return code of zero (0) means success - if (rc == 0) { + if (returnCode == 0) { Serial.println("Success! Appended " + rowData); Serial.println(""); } else { // return code of anything other than zero means failure // read and display any error messages while (AppendRowChoreo.available()) { - Serial.print((char)AppendRowChoreo.read()); + char c = AppendRowChoreo.read(); + Serial.print(c); } } @@ -157,28 +162,27 @@ void loop() } // this function simulates reading the value of a sensor -// in this example, we're generating a random number unsigned long getSensorValue() { - return (unsigned long)random(0, 256); + return analogRead(A0); } /* IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and - include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. */ - diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/TembooAccount.h new file mode 100644 index 000000000..8d7dcfb77 --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/TembooAccount.h new file mode 100644 index 000000000..8d7dcfb77 --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino index eea009e86..a99803ab6 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino @@ -27,8 +27,8 @@ #include "TembooAccount.h" // contains Temboo account information // as described in the footer comment below -// the zip code to search -const String US_ZIP_CODE = "11215"; +// the zip code to search for toxin-emitting facilities +String US_ZIP_CODE = "11215"; int numRuns = 1; // execution count, so that this doesn't run forever int maxRuns = 10; // max number of times the Envirofacts FacilitiesSearch Choreo should be run @@ -82,93 +82,98 @@ void loop() FacilitiesSearchByZipChoreo.addParameter("addr:STREET_ADDRESS:Response"); // run the choreo - FacilitiesSearchByZipChoreo.run(); - - String facs; - String addrs; + unsigned int returnCode = FacilitiesSearchByZipChoreo.run(); + if (returnCode == 0) { + String facilities; + String addresses; - // when the choreo results are available, process them. - // the output filters we specified will return comma delimited - // lists containing the name and street address of the facilities - // located in the specified zip code. - while(FacilitiesSearchByZipChoreo.available()) { - String name = FacilitiesSearchByZipChoreo.readStringUntil('\x1F'); - name.trim(); + // when the choreo results are available, process them. + // the output filters we specified will return comma delimited + // lists containing the name and street address of the facilities + // located in the specified zip code. + while(FacilitiesSearchByZipChoreo.available()) { + String name = FacilitiesSearchByZipChoreo.readStringUntil('\x1F'); + name.trim(); - String data = FacilitiesSearchByZipChoreo.readStringUntil('\x1E'); - data.trim(); + String data = FacilitiesSearchByZipChoreo.readStringUntil('\x1E'); + data.trim(); - if (name == "fac") { - facs = data; - } else if (name == "addr") { - addrs = data; + if (name == "fac") { + facilities = data; + } else if (name == "addr") { + addresses = data; + } + } + FacilitiesSearchByZipChoreo.close(); + + // parse the comma delimited lists of facilities to join the + // name with the address and print it to the serial monitor + if (facilities.length() > 0) { + int i = -1; + int facilityStart = 0; + int addressStart = 0; + String facility; + String address; + do { + i = facilities.indexOf(',', facilityStart); + if (i >= 0) { + facility = facilities.substring(facilityStart, i); + facilityStart = i + 1; + } + + i = addresses.indexOf(',', addressStart); + if (i >= 0) { + address = addresses.substring(addressStart, i); + addressStart = i + 1; + } + + if (i >= 0) { + printResult(facility, address); + } + + }while (i >= 0); + facility = facilities.substring(facilityStart); + address = addresses.substring(addressStart); + printResult(facility, address); + } else { + Serial.println("No facilities found in zip code " + US_ZIP_CODE); + } + } else { + while(FacilitiesSearchByZipChoreo.available()) { + char c = FacilitiesSearchByZipChoreo.read(); + Serial.print(c); } } - FacilitiesSearchByZipChoreo.close(); - - // parse the comma delimited lists of facilities to join the - // name with the address and print it to the serial monitor - if (facs.length() > 0) { - int i = -1; - int fstart = 0; - int astart = 0; - String f; - String a; - do { - i = facs.indexOf(',', fstart); - if (i >= 0) { - f = facs.substring(fstart, i); - fstart = i + 1; - } - - i = addrs.indexOf(',', astart); - if (i >= 0) { - a = addrs.substring(astart, i); - astart = i + 1; - } - - if (i >= 0) { - printResult(f, a); - } - - }while (i >= 0); - f = facs.substring(fstart); - a = addrs.substring(astart); - printResult(f, a); - } else { - Serial.println("No facilities found in zip code " + US_ZIP_CODE); - } } - - Serial.println("Sleeping..."); + Serial.println("Waiting..."); Serial.println(""); - delay(30000); // sleep 30 seconds between calls + delay(30000); // wait 30 seconds between calls } // a simple utility function, to output the facility name and address in the serial monitor. -void printResult(String fac, String addr) { - Serial.print(fac); +void printResult(String facility, String address) { + Serial.print(facility); Serial.print(" - "); - Serial.println(addr); + Serial.println(address); } /* IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and - include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys - + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. */ - diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/TembooAccount.h new file mode 100644 index 000000000..8d7dcfb77 --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino index 1352762ef..9bb1f2f1f 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino @@ -10,7 +10,7 @@ http://www.temboo.com In order to run this sketch, you'll need to register an application using - the Facebook dev console at https://developers.facebook.com/apps. After creating + the Facebook dev console at https://developers.facebook.com/apps -- after creating the app, log in to Temboo and visit https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/ to use our OAuth Wizard (or OAuth Choreos) to obtain a Facebook access token. Substitute your access token for the placeholder value of FACEBOOK_ACCESS_TOKEN below. @@ -33,6 +33,9 @@ /*** SUBSTITUTE YOUR VALUES BELOW: ***/ +// Note that for additional security and reusability, you could +// use a #define statement to specify this value in a .h file. + // the Facebook Access Token, which can be obtained using the Temboo OAuth Wizard or Choreos const String FACEBOOK_ACCESS_TOKEN = "xxxxxxxxxx"; @@ -89,45 +92,47 @@ void loop() { // tell the Process to run and wait for the results. The - // return code (rc) will tell us whether the Temboo client + // return code (returnCode) will tell us whether the Temboo client // was able to send our request to the Temboo servers - unsigned int rc = SetStatusChoreo.run(); + unsigned int returnCode = SetStatusChoreo.run(); // print the response code and API response. - Serial.println("Resonse code: " + String(rc)); + Serial.println("Response code: " + String(returnCode)); // note that in this case, we're just printing the raw response from Facebook. // see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino // for information on how to filter this data while(SetStatusChoreo.available()) { - Serial.print((char)SetStatusChoreo.read()); + char c = SetStatusChoreo.read(); + Serial.print(c); } SetStatusChoreo.close(); } - Serial.println("Sleeping..."); + Serial.println("Waiting..."); Serial.println(""); - delay(30000); // sleep 30 seconds between SetStatus calls + delay(30000); // wait 30 seconds between SetStatus calls } /* IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and - include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. -*/ \ No newline at end of file +*/ diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UploadToDropbox/TembooAccount.h b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UploadToDropbox/TembooAccount.h new file mode 100644 index 000000000..8d7dcfb77 --- /dev/null +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UploadToDropbox/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino index cb56582cb..5d9e93651 100644 --- a/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino +++ b/hardware/arduino/avr/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino @@ -11,7 +11,8 @@ You'll also need a valid Dropbox account, and OAuth credentials for Dropbox. To obtain OAuth credentials for Dropbox, you'll need to register a Dropbox app at - https://www.dropbox.com/developers/apps and then follow the instructions at + https://www.dropbox.com/developers/apps -- the app name and domain can be whatever + you'd like. After registering the app, follow the instructions at https://www.temboo.com/library/Library/Dropbox/OAuth/ to run the Initialize and Finalize OAuth Choreos to complete the OAuth handshake and retrieve your Access Token information. @@ -34,6 +35,9 @@ /*** SUBSTITUTE YOUR VALUES BELOW: ***/ +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + // your Dropbox app key, available on the Dropbox developer console after registering an app const String DROPBOX_APP_KEY = "xxxxxxxxxx"; @@ -117,12 +121,12 @@ void loop() UploadFileChoreo.addParameter("AppKey:" + DROPBOX_APP_KEY); // tell the Process to run and wait for the results. The - // return code (rc) will tell us whether the Temboo client + // return code (returnCode) will tell us whether the Temboo client // was able to send our request to the Temboo servers - unsigned int rc = UploadFileChoreo.run(); + unsigned int returnCode = UploadFileChoreo.run(); // a return code of zero (0) means everything worked - if (rc == 0) { + if (returnCode == 0) { Serial.println("Success! File uploaded!"); success = true; } else { @@ -133,14 +137,15 @@ void loop() // print out the full response to the serial monitor in all // cases, just for debugging while (UploadFileChoreo.available()) { - Serial.print((char)UploadFileChoreo.read()); + char c = UploadFileChoreo.read(); + Serial.print(c); } UploadFileChoreo.close(); - Serial.println("Sleeping..."); + Serial.println("Waiting..."); } - delay(30000); // sleep 30 seconds between upload attempts + delay(30000); // wait 30 seconds between upload attempts } @@ -193,20 +198,22 @@ String base64Encode(String toEncode) { } /* - IMPORTANT NOTE About TembooAccount.h: + IMPORTANT NOTE: TembooAccount.h: - TembooAccount.h is not included with this example because it contains your account information. - You need to create it for your own version of this application. To do so, make - a new tab in Arduino, call it TembooAccount.h, and include the following variables and constants: + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: - #define TEMBOO_ACCOUNT "matthew-yun" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "someKey" // your Temboo app key name - #define TEMBOO_APP_KEY "fveIrkjAVIkuNUUPE6df" // your Temboo app key - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key You can find your Temboo App Key information on the Temboo website, under My Account > Application Keys + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + Keeping your account information in a separate file means you can save it once, then just distribute the main .ino file without worrying that you forgot to delete your credentials. */