Skip to content

Commit 5f60509

Browse files
author
Federico Fissore
committed
updated temboo examples
1 parent 8f39da6 commit 5f60509

File tree

18 files changed

+259
-172
lines changed

18 files changed

+259
-172
lines changed

hardware/arduino/avr/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@
2525
#include "TembooAccount.h" // contains Temboo account information
2626
// as described in the footer comment below
2727

28+
29+
// the address for which a weather forecast will be retrieved
30+
String ADDRESS_FOR_FORECAST = "104 Franklin St., New York NY 10013";
31+
2832
int numRuns = 0; // execution count, so that this doesn't run forever
2933
int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run
3034

3135
void setup() {
3236
Serial.begin(9600);
3337

3438
// for debugging, wait until a serial console is connected
39+
delay(4000);
3540
while(!Serial);
3641
Bridge.begin();
3742
}
@@ -58,14 +63,14 @@ void loop()
5863
GetWeatherByAddressChoreo.addParameter("-p");
5964
GetWeatherByAddressChoreo.addParameter(TEMBOO_APP_KEY);
6065

61-
// identify the Temboo Library choreo to run (Yahoo > Weather > GetWeatherByAddress)
66+
// identify the Temboo Library choreo to run (Yahoo > Weather > GetWeatherByAddress)
6267
GetWeatherByAddressChoreo.addParameter("-c");
6368
GetWeatherByAddressChoreo.addParameter("/Library/Yahoo/Weather/GetWeatherByAddress");
6469

6570
// set choreo inputs; in this case, the address for which to retrieve weather data
6671
// the Temboo client provides standardized calls to 100+ cloud APIs
6772
GetWeatherByAddressChoreo.addParameter("-i");
68-
GetWeatherByAddressChoreo.addParameter("Address:104 Franklin St., New York NY 10013");
73+
GetWeatherByAddressChoreo.addParameter("Address:" + ADDRESS_FOR_FORECAST);
6974

7075
// run the choreo
7176
GetWeatherByAddressChoreo.run();
@@ -76,34 +81,35 @@ void loop()
7681
// note that in this example, we just print the raw XML response from Yahoo
7782
// see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino
7883
// for information on how to filter this data
79-
80-
Serial.print((char)GetWeatherByAddressChoreo.read());
84+
char c = GetWeatherByAddressChoreo.read();
85+
Serial.print(c);
8186
}
8287
GetWeatherByAddressChoreo.close();
8388

8489
}
8590

86-
Serial.println("Sleeping...");
91+
Serial.println("Waiting...");
8792
Serial.println("");
88-
delay(30000); // sleep 30 seconds between GetWeatherByAddress calls
93+
delay(30000); // wait 30 seconds between GetWeatherByAddress calls
8994
}
9095

9196
/*
9297
IMPORTANT NOTE: TembooAccount.h:
9398
94-
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
95-
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
96-
include the following variables and constants:
99+
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
100+
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
101+
by inserting your own Temboo account name and app key information. The contents of the file should
102+
look like:
97103
98104
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
99105
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
100106
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
101107
102-
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
103-
104108
You can find your Temboo App Key information on the Temboo website,
105109
under My Account > Application Keys
106110
111+
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
112+
107113
Keeping your account information in a separate file means you can save it once,
108114
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
109115
*/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
2+
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
3+
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
4+

hardware/arduino/avr/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@
3333

3434
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
3535

36+
// Note that for additional security and reusability, you could
37+
// use #define statements to specify these values in a .h file.
3638
const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
3739
const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
3840
const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
3941
const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret";
4042

41-
int numRuns = 0; // execution count, so this sketch doesn't run forever
43+
int numRuns = 1; // execution count, so this sketch doesn't run forever
4244
int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run
4345

4446
void setup() {
@@ -53,7 +55,7 @@ void setup() {
5355
void loop()
5456
{
5557
// while we haven't reached the max number of runs...
56-
if (numRuns < maxRuns) {
58+
if (numRuns <= maxRuns) {
5759

5860
// print status
5961
Serial.println("Running ReadATweet - Run #" + String(numRuns++) + "...");
@@ -108,12 +110,12 @@ void loop()
108110

109111

110112
// tell the Process to run and wait for the results. The
111-
// return code (rc) will tell us whether the Temboo client
113+
// return code will tell us whether the Temboo client
112114
// was able to send our request to the Temboo servers
113-
unsigned int rc = HomeTimelineChoreo.run();
115+
unsigned int returnCode = HomeTimelineChoreo.run();
114116

115117
// a response code of 0 means success; print the API response
116-
if(rc == 0) {
118+
if(returnCode == 0) {
117119

118120
String author; // a String to hold the tweet author's name
119121
String tweet; // a String to hold the text of the tweet
@@ -152,34 +154,36 @@ void loop()
152154
// there was an error
153155
// print the raw output from the choreo
154156
while(HomeTimelineChoreo.available()) {
155-
Serial.print((char)HomeTimelineChoreo.read());
157+
char c = HomeTimelineChoreo.read();
158+
Serial.print(c);
156159
}
157160
}
158161

159162
HomeTimelineChoreo.close();
160163
}
161164

162-
Serial.println("Sleeping...");
165+
Serial.println("Waiting...");
163166
Serial.println("");
164-
delay(90000); // sleep 90 seconds between HomeTimeline calls
167+
delay(90000); // wait 90 seconds between HomeTimeline calls
165168
}
166169

167170
/*
168171
IMPORTANT NOTE: TembooAccount.h:
169172
170-
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
171-
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
172-
include the following variables and constants:
173+
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
174+
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
175+
by inserting your own Temboo account name and app key information. The contents of the file should
176+
look like:
173177
174178
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
175179
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
176180
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
177181
178-
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
179-
180182
You can find your Temboo App Key information on the Temboo website,
181183
under My Account > Application Keys
182184
185+
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
186+
183187
Keeping your account information in a separate file means you can save it once,
184188
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
185189
*/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
2+
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
3+
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
4+

hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
http://www.temboo.com
1111
1212
In order to run this sketch, you'll need to register an application using
13-
the Twitter dev console at https://dev.twitter.com. After creating the
14-
app, you'll find OAuth credentials for that application under the "OAuth Tool" tab.
13+
the Twitter dev console at https://dev.twitter.com. Note that since this
14+
sketch creates a new tweet, your application will need to be configured with
15+
read+write permissions. After creating the app, you'll find OAuth credentials
16+
for that application under the "OAuth Tool" tab.
1517
Substitute these values for the placeholders below.
1618
1719
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
@@ -33,6 +35,8 @@
3335

3436
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
3537

38+
// Note that for additional security and reusability, you could
39+
// use #define statements to specify these values in a .h file.
3640
const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token";
3741
const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret";
3842
const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key";
@@ -72,7 +76,7 @@ void loop()
7276
StatusesUpdateChoreo.addParameter("-p");
7377
StatusesUpdateChoreo.addParameter(TEMBOO_APP_KEY);
7478

75-
// identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate)
79+
// identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate)
7680
StatusesUpdateChoreo.addParameter("-c");
7781
StatusesUpdateChoreo.addParameter("/Library/Twitter/Tweets/StatusesUpdate");
7882

@@ -96,47 +100,48 @@ void loop()
96100
StatusesUpdateChoreo.addParameter("StatusUpdate:" + tweet);
97101

98102
// tell the Process to run and wait for the results. The
99-
// return code (rc) will tell us whether the Temboo client
103+
// return code (returnCode) will tell us whether the Temboo client
100104
// was able to send our request to the Temboo servers
101-
unsigned int rc = StatusesUpdateChoreo.run();
105+
unsigned int returnCode = StatusesUpdateChoreo.run();
102106

103107
// a return code of zero (0) means everything worked
104-
if (rc == 0) {
108+
if (returnCode == 0) {
105109
Serial.println("Success! Tweet sent!");
106110
} else {
107111
// a non-zero return code means there was an error
108112
// read and print the error message
109113
while (StatusesUpdateChoreo.available()) {
110-
Serial.print((char)StatusesUpdateChoreo.read());
114+
char c = StatusesUpdateChoreo.read();
115+
Serial.print(c);
111116
}
112117
}
113118
StatusesUpdateChoreo.close();
114119

115120
// do nothing for the next 90 seconds
116-
Serial.println("Sleeping...");
121+
Serial.println("Waiting...");
117122
delay(90000);
118123
}
119124
}
120125

121126
/*
122127
IMPORTANT NOTE: TembooAccount.h:
123128
124-
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
125-
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
126-
include the following variables and constants:
129+
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
130+
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
131+
by inserting your own Temboo account name and app key information. The contents of the file should
132+
look like:
127133
128134
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
129135
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
130136
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
131137
132-
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
133-
134138
You can find your Temboo App Key information on the Temboo website,
135139
under My Account > Application Keys
136140
141+
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
142+
137143
Keeping your account information in a separate file means you can save it once,
138144
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
139145
*/
140146

141147

142-
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
2+
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
3+
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
4+

hardware/arduino/avr/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
3333

34+
// Note that for additional security and reusability, you could
35+
// use #define statements to specify these values in a .h file.
36+
3437
// your Gmail address, eg "bob.smith@gmail.com"
3538
const String GMAIL_USER_NAME = "xxxxxxxxxx";
3639

@@ -74,7 +77,7 @@ void loop()
7477
SendEmailChoreo.addParameter("-p");
7578
SendEmailChoreo.addParameter(TEMBOO_APP_KEY);
7679

77-
// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
80+
// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
7881
SendEmailChoreo.addParameter("-c");
7982
SendEmailChoreo.addParameter("/Library/Google/Gmail/SendEmail");
8083

@@ -103,19 +106,20 @@ void loop()
103106
SendEmailChoreo.addParameter("MessageBody:Hey! The greenhouse is too cold!");
104107

105108
// tell the Process to run and wait for the results. The
106-
// return code (rc) will tell us whether the Temboo client
109+
// return code (returnCode) will tell us whether the Temboo client
107110
// was able to send our request to the Temboo servers
108-
unsigned int rc = SendEmailChoreo.run();
111+
unsigned int returnCode = SendEmailChoreo.run();
109112

110113
// a return code of zero (0) means everything worked
111-
if (rc == 0) {
114+
if (returnCode == 0) {
112115
Serial.println("Success! Email sent!");
113116
success = true;
114117
} else {
115118
// a non-zero return code means there was an error
116119
// read and print the error message
117120
while (SendEmailChoreo.available()) {
118-
Serial.print((char)SendEmailChoreo.read());
121+
char c = SendEmailChoreo.read();
122+
Serial.print(c);
119123
}
120124
}
121125
SendEmailChoreo.close();
@@ -128,20 +132,20 @@ void loop()
128132
/*
129133
IMPORTANT NOTE: TembooAccount.h:
130134
131-
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
132-
You need to create this file. To do so, make a new tab in Arduino, call it TembooAccount.h, and
133-
include the following variables and constants:
135+
TembooAccount.h is a file referenced by this sketch that contains your Temboo account information.
136+
You'll need to edit the placeholder version of TembooAccount.h included with this example sketch,
137+
by inserting your own Temboo account name and app key information. The contents of the file should
138+
look like:
134139
135140
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
136141
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
137142
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
138143
139-
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
140-
141144
You can find your Temboo App Key information on the Temboo website,
142145
under My Account > Application Keys
143146
147+
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
148+
144149
Keeping your account information in a separate file means you can save it once,
145150
then just distribute the main .ino file without worrying that you forgot to delete your credentials.
146151
*/
147-
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name
2+
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name
3+
#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key
4+
5+

0 commit comments

Comments
 (0)