1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Temboo: library and examples update

This commit is contained in:
Federico Fissore
2014-04-03 19:56:46 +02:00
parent 710e4fb7b8
commit b2500b3b85
15 changed files with 689 additions and 355 deletions

View File

@ -5,17 +5,17 @@
Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
Since this sketch uses Gmail to send the email, you'll also need a valid
Google Gmail account. The sketch needs the username and password you use
Since this sketch uses Gmail to send the email, you'll also need a valid
Google Gmail account. The sketch needs the username and password you use
to log into your Gmail account - substitute the placeholders below for these values.
This example assumes basic familiarity with Arduino sketches, and that your Yun is connected
to the Internet.
Looking for another API to use with your Arduino Yun? We've got over 100 in our Library!
This example code is in the public domain.
@ -24,7 +24,7 @@
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
// as described in the footer comment below
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
@ -41,14 +41,14 @@ const String GMAIL_PASSWORD = "xxxxxxxxxx";
const String TO_EMAIL_ADDRESS = "xxxxxxxxxx";
// a flag to indicate whether we've tried to send the email yet or not
boolean attempted = false;
boolean attempted = false;
void setup() {
Serial.begin(9600);
// for debugging, wait until a serial console is connected
delay(4000);
while (!Serial);
while(!Serial);
Bridge.begin();
}
@ -59,14 +59,14 @@ void loop()
if (!attempted) {
Serial.println("Running SendAnEmail...");
TembooChoreo SendEmailChoreo;
// invoke the Temboo client
// NOTE that the client must be reinvoked, and repopulated with
// appropriate arguments, each time its run() method is called.
SendEmailChoreo.begin();
// set Temboo account credentials
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -74,13 +74,13 @@ void loop()
// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
// see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
// for complete details about the inputs for this Choreo
// the first input is your Gmail email address.
// the first input is your Gmail email address.
SendEmailChoreo.addInput("Username", GMAIL_USER_NAME);
// next is your Gmail password.
SendEmailChoreo.addInput("Password", GMAIL_PASSWORD);
@ -89,17 +89,17 @@ void loop()
// then a subject line
SendEmailChoreo.addInput("Subject", "ALERT: Greenhouse Temperature");
// next comes the message body, the main content of the email
// next comes the message body, the main content of the email
SendEmailChoreo.addInput("MessageBody", "Hey! The greenhouse is too cold!");
// tell the Choreo to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// tell the Choreo to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = SendEmailChoreo.run();
// a return code of zero (0) means everything worked
if (returnCode == 0) {
Serial.println("Success! Email sent!");
Serial.println("Success! Email sent!");
} else {
// a non-zero return code means there was an error
// read and print the error message
@ -107,9 +107,9 @@ void loop()
char c = SendEmailChoreo.read();
Serial.print(c);
}
}
}
SendEmailChoreo.close();
// set the flag showing we've tried
attempted = true;
}
@ -123,15 +123,15 @@ void loop()
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_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,
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 share the main .ino file without worrying
Keeping your account information in a separate file means you can share the main .ino file without worrying
that you forgot to delete your credentials.
*/