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,35 +5,35 @@
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 Twilio to send the SMS, you'll also need a valid
Since this sketch uses Twilio to send the SMS, you'll also need a valid
Twilio account. You can create one for free at https://www.twilio.com.
The sketch needs your Twilio phone number, along with
the Account SID and Auth Token you get when you register with Twilio.
Make sure to use the Account SID and Auth Token from your Twilio Dashboard
Make sure to use the Account SID and Auth Token from your Twilio Dashboard
(not your test credentials from the Dev Tools panel).
Also note that if you're using a free Twilio account, you'll need to verify
Also note that if you're using a free Twilio account, you'll need to verify
the phone number to which messages are being sent by going to twilio.com and following
the instructions under the "Numbers > Verified Caller IDs" tab (this restriction
doesn't apply if you have a paid Twilio account).
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.
*/
#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
@ -55,14 +55,14 @@ const String TWILIO_NUMBER = "xxxxxxxxxx";
const String RECIPIENT_NUMBER = "xxxxxxxxxx";
// a flag to indicate whether we've attempted to send the SMS 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();
}
@ -73,7 +73,7 @@ void loop()
if (!attempted) {
Serial.println("Running SendAnSMS...");
// we need a Process object to send a Choreo request to Temboo
TembooChoreo SendSMSChoreo;
@ -81,7 +81,7 @@ void loop()
// NOTE that the client must be reinvoked and repopulated with
// appropriate arguments each time its run() method is called.
SendSMSChoreo.begin();
// set Temboo account credentials
SendSMSChoreo.setAccountName(TEMBOO_ACCOUNT);
SendSMSChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
@ -91,32 +91,32 @@ void loop()
SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS");
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/
// see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/
// for complete details about the inputs for this Choreo
// the first input is a your AccountSID
SendSMSChoreo.addInput("AccountSID", TWILIO_ACCOUNT_SID);
// next is your Auth Token
SendSMSChoreo.addInput("AuthToken", TWILIO_AUTH_TOKEN);
// next is your Twilio phone number
SendSMSChoreo.addInput("From", TWILIO_NUMBER);
// next, what number to send the SMS to
SendSMSChoreo.addInput("To", RECIPIENT_NUMBER);
// finally, the text of the message to send
SendSMSChoreo.addInput("Body", "Hey, there! This is a message from your Arduino Yun!");
// tell the Process to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// tell the Process 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 = SendSMSChoreo.run();
// a return code of zero (0) means everything worked
if (returnCode == 0) {
Serial.println("Success! SMS sent!");
Serial.println("Success! SMS sent!");
} else {
// a non-zero return code means there was an error
// read and print the error message
@ -124,11 +124,11 @@ void loop()
char c = SendSMSChoreo.read();
Serial.print(c);
}
}
}
SendSMSChoreo.close();
// set the flag indicatine we've tried once.
attempted = true;
attempted=true;
}
}
@ -140,15 +140,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.
*/