AlexaClass Class
AlexaClass Class
Description
Defines a class of Alexa
Syntax
class AlexaClass
Members
Public Constructors | |
AlexaClass::AlexaClass | Constructs an AlexaClass object. |
AlexaClass::~AlexaClass | Destructs the AlexaClass object |
Public Methods | |
AlexaClass::begin | Initialize AlexaClass |
AlexaClass::setAvsRefreshToken | Set the AVS refresh token |
AlexaClass::setAvsClientId | Set the AVS client ID |
AlexaClass::setAvsClientSecret | Set the AVS client secret |
AlexaClass::setAvsHttp2Host | Set the AVS host for http2 |
AlexaClass::begin
Description
Initialize AlexaClass.
Syntax
void AlexaClass::begin(void);
Parameters
The function requires no input parameter.
Returns
The function returns nothing.
Example Code
Example: alexa_basic
This example shows how to use the Amazon Alexa service on the Ameba board. You might need these items to proceed with this example: Ameba RTL8195AM x1, Realtek Audio Shield (ALC5680) x1, and Speaker x1. Teensy Audio Shield is required to connect to the Powered Speaker, and the button on Realtek Audio Shield is meant to trigger and listen to voice command from the user.
Besides, you might also need a pre-configured AVS (Alexa Voice Service) account to proceed with the example.
Notes and Warnings
Include “Alexa.h” to use the class function.
#include #include #include char ssid[] = "ssid"; // your network SSID (name) char pass[] = "password"; // your network password (use for WPA, or use as key for WEP) int keyIndex = 0; // your network key Index number (needed only for WEP) char avs_refresh_token[] = "Atzr|IwEBIIPONbIeIbsgOXzSs557Ug8yT2yVkoXBpeMepDLQJ_9NA9SOTUuiQaHU0ZIB_rCxvIjpYlSI9SabI8WIk946zsYx6qMzFyWj7Gf6ATmCgYxldZ7imL100NfqPk0UreuUXD5m9lYc0aI2U2tMZ2YLgLHgnOZuIbtQwGWoVn_HV0lhVXfubnZ7ZFbII5l9ZLLNB9dRswQ0r_geRDyCBucP8c_ZZMcDwVadtvkAku9eqF8CI0CqviJydcvy1T0Kq3OZj_aMEinoBMWM9eU6yrTn_-Er219AAXkP1t4f4NIeZOlBgkFvvxDplvHzdbIQ_dGNvEeg3pAUGNX5E10umwJgdbr9XYVO1KWvshSweZiU6BGLn9bvsaMmdV90cB453eYSeom953Gy_5ly7U0xg0XOeQPMPTziMBwK6JxRi420LdFc2TzAWFPwwFvucAdqxPdhHDz_lJdpK-Fa2GqEVjAM1pOd1OIpTgry2nIFcOR6qwaNt_-kpCjNPYiBhqhPQzFtCjcew_em9q23fyduBFhu1H2FPJHppG7Mh9bHaCFCbBGYgQ"; char avs_client_id[] = "amzn1.application-oa2-client.b4c18819f8ea421fafc1208818b25670"; char avs_client_secret[] = "b46599cb915d66268ec94645a07471b9dc53cb33e3a04f12e4c95a33730c928c"; char avs_http2_host[] = "avs-alexa-na.amazon.com"; void setup() { // attempt to connect to Wifi network: while (WiFi.begin(ssid, pass) != WL_CONNECTED) { delay(1000); } Serial.println("Connected to wifi"); WiFi.disablePowerSave(); // this sketch use huge code space, so we can't use default flash memory address //FlashMemory.begin(0x1FF000, 0x1000); setup_alexa(); } void loop() { if (WiFi.status() != WL_CONNECTED) { while (WiFi.begin(ssid, pass) != WL_CONNECTED) { delay(1000); } Serial.println("Connected to wifi"); } delay(100); } void setup_alexa() { Alexa.setAvsRefreshToken(avs_refresh_token, sizeof(avs_refresh_token)-1); Alexa.setAvsClientId(avs_client_id, sizeof(avs_client_id)-1); Alexa.setAvsClientSecret(avs_client_secret, sizeof(avs_client_secret)-1); Alexa.setAvsHttp2Host(avs_http2_host, sizeof(avs_http2_host)-1); Alexa.begin(); }
AlexaClass::setAvsRefreshToken
Description
Set the AVS refresh token.
Syntax
void AlexaClass::setAvsRefreshToken(char *avs_refresh_token, int len);
Parameters
avs_refresh_token: The AVS refresh token in char
len: The lengh of the token
Returns
The function returns nothing.
Example Code
Example: alexa_basic
This example shows how to use the Amazon Alexa service on the Ameba board. Details of the code can be found in the section of AlexaClass::begin.
Notes and Warnings
Include “Alexa.h” to use the class function.
AlexaClass::setAvsClientId
Description
Set the AVS client ID.
Syntax
void AlexaClass::setAvsClientId(char *avs_client_id, int len);
Parameters
avs_client_id: The AVS client ID in char
len: The lengh of the ID
Returns
The function returns nothing.
Example Code
Example: alexa_basic
This example shows how to use the Amazon Alexa service on the Ameba board. Details of the code can be found in the section of AlexaClass::begin.
Notes and Warnings
Include “Alexa.h” to use the class function.
AlexaClass::setAvsClientSecret
Description
Set the AVS client secret.
Syntax
void AlexaClass::setAvsClientSecret(char *avs_client_secret, int len);
Parameters
avs_client_ secret: The AVS client secret in char
len: The lengh of the secret
Returns
The function returns nothing.
Example Code
Example: alexa_basic
This example shows how to use the Amazon Alexa service on the Ameba board. Details of the code can be found in the section of AlexaClass::begin.
Notes and Warnings
Include “Alexa.h” to use the class function.
AlexaClass::setAvsHttp2Host
Description
Set the AVS host for http2.
Syntax
void AlexaClass::setAvsHttp2Host(char *avs_http2_host, int len);
Parameters
avs_ http2_host: The AVS http2 host in char
len: The lengh of the host name
Returns
The function returns nothing.
Example Code
Example: alexa_basic
This example shows how to use the Amazon Alexa service on the Ameba board. Details of the code can be found in the section of AlexaClass::begin.
Notes and Warnings
Include “Alexa.h” to use the class function.