-
Notifications
You must be signed in to change notification settings - Fork 610
Linux Reference Guide
This guide assumes familiarity with Linux and requires you to build dependencies from source.
Follow these steps:
-
Update and install the latest packages using apt-get:
sudo apt-get update && sudo apt-get upgrade -y
-
Set up the SDK build environment.
Create a my_project folder, and these subfolders:
- build
- source
- third-party
- application-necessities > sound-files
Note: The following examples designate ~/ as the SDK installation location; be sure to replace all instances of ~/ in this guide with your explicit path.
cd $HOME mkdir my_project cd my_project mkdir build source third-party application-necessities cd application-necessities mkdir sound-files
-
Install the core SDK dependencies:
cd $HOME sudo apt-get install -y git gcc cmake openssl clang-format libgstreamer1.0-dev \ libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-good \ libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev \ gstreamer1.0-libav pulseaudio doxygen libsqlite3-dev repo libasound2-dev
IMPORTANT: Make sure that command ran successfully, and that no errors were thrown. If for any reason the install command fails, run brew install for each dependency individually.
-
Clone the AVS Device SDK into your $HOME/my_project/source folder:
git clone https://github.com/alexa/avs-device-sdk.git
You can use CMake parameters to customize the sample app. For example, to get debug logs from the sample app, include the -DCMAKE_BUILD_TYPE=DEBUG
option. To build with Bluetooth, see Build with Bluetooth.
In this example, it enables GStreamer and PortAudio, specifies the curl-openssl library location, and enables debug logging:
cd $HOME/my_project/build
cmake $HOME/my_project/source/avs-device-sdk \
-DGSTREAMER_MEDIA_PLAYER=ON \
-DPORTAUDIO=ON \
-DPORTAUDIO_LIB_PATH=$HOME/my_project/third-party/portaudio/lib/.libs/libportaudio.a \
-DPORTAUDIO_INCLUDE_DIR=$HOME/my_project/third-party/portaudio/include
-DCMAKE_BUILD_TYPE=DEBUG
Linux supports wake word detectors from Sensory and Kitt.ai. Each requires a license from the provider. For instructions to build with a wake word detector, please see Cmake parameters.
Building with Bluetooth is optional, and is currently limited to Linux and Raspberry Pi for A2DP-SINK
, A2DP-SOURCE
, AVRCPTarget
, and AVRCPController
profiles.
-
Install these dependencies:
- Core Bluetooth dependencies
- libpulse-dev
- PulseAudio
- PulseAudio bluetooth modules:
cd $HOME sudo apt-get install pulseaudio-module-bluetooth
-
Include the following CMake option in your build:
BLUETOOTH_BLUEZ_PULSEAUDIO_OVERRIDE_ENDPOINTS
- AVRCPTarget (if applicable)
If you are using the AVRCPTarget
profile, you'll need to enable permissions for BlueZ to interact with "org.mpris.MediaPlayer2.Player"
.
To do this, open /etc/dbus-1/system.d/bluetooth.conf and add <allow send_interface="org.mpris.MediaPlayer2.Player"/>
to your root policy.
For example:
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- ../system.conf have denied everything, so we just punch some holes -->
<policy user="root">
...
<allow send_interface="org.mpris.MediaPlayer2.Player"/>
</policy>
...
</busconfig>
Before you can use the Device SDK sample app, you'll need to authorize it with the Alexa cloud in order to leverage the full range of Alexa capabilities and features available to the sample app.
You must register an AVS Product and Create a Security Profile, if you haven't already.
Note: The product must be enabled for code-based linking.
Name | Description | Location |
---|---|---|
AlexaClientSDKConfig.json | The configuration file that you'll use to authorize the sample app with the Alexa cloud. | Comes with the SDK: avs-device-sdk/Integration/AlexaClientSDKConfig.json |
genConfig.sh | The configuration file generator. | Comes with the SDK: avs-device-sdk/tools/Install/genConfig.sh |
config.json | Downloaded when you created a security profile during the product registration process. | Your download location. |
-
First, move the config.json file into the avs-device-sdk/tools/Install directory:
mv $HOME/Downloads/config.json $HOME/my_project/source/avs-device-sdk/tools/Install
-
Next, create a database directory; this is the dynamic database used by AlexaClientSDKConfig.json:
mkdir $HOME/my_project/build/Integration/database
-
Now, run
genConfig.sh
from the $HOME/my_project/source/avs-device-sdk/tools/Install directory, with these arguments:Arguments:
- config.json - Downloaded when you created a security profile during the product registration process.
- device_serial_number - the device serial number can be any unique alpha-numeric string (up to 64 characters). You should use the device serial number to identify your product or application instance. Many developers choose to use a product's SKU for this value.
- db_path - The directory where the dynamic database used by AlexaClientSDKConfig.json is stored, such as: ~/my_project/build/Integration/database.
- SDK source directory - Path to the avs-device-sdk source code, such as: ~/my_project/source/avs-device-sdk
- AlexaClientSDKConfig.json location - Path to the AlexaClientSDKConfig.json file, such as: ~/my_project/build/Integration/AlexaClientSDKConfig.json.
For example:
cd $HOME/my_project/source/avs-device-sdk/tools/Install bash genConfig.sh config.json device_serial_number \ $HOME/my_project/build/Integration/database \ $HOME/my_project/source/avs-device-sdk \ $HOME/my_project/build/Integration/AlexaClientSDKConfig.json
IMPORTANT: Create a backup of your
AlexaClientSDKConfig.json
file. Subsequent builds will reset the contents of this file.
-
Navigate to your build folder, and initialize the SampleApp:
cd $HOME/my_project/build ./SampleApp/src/SampleApp ./Integration/AlexaClientSDKConfig.json
-
Wait for the sample app to display a message like this:
##################################
# NOT YET AUTHORIZED #
##################################
################################################################################################
# To authorize, browse to: 'https://amazon.com/us/code' and enter the code: {XXXX} #
################################################################################################
- Use a browser to navigate to the URL specified in the message from the sample app.
- If requested to do so, authenticate using your Amazon user credentials.
- Enter the code specified in the message from sample app.
- Select “Allow”.
- Wait for the sample app to report that it is authorized, and that Alexa is idle. It will look something like this:
###########################
# Authorized! #
###########################
########################################
# Alexa is currently idle! #
########################################
- You are now ready to use the sample app! The next time you start the sample app, you won't need to go through the authorization process.
A couple more details:
- If you exit out of sample app via the
k
command, theCBLAuthDelegate
database will be cleared and you will need to reauthorize your client. - If you want to move this authorization to another sample app installation, you need to copy the deviceInfo object within
AlexaClientSDKConfig.json
to the new installation. You will also need to copy the file"$HOME/my_project/application-necessities/cblAuthDelegate.db"
to the new installation, and update AlexaClientSDKConfig.json in the new installation so that the cblAuthDelegate's databaseFilePath property points to it.
Now that you have a working sample app, try an interaction with Alexa.
If you have quit the sample app, start it again:
./SampleApp/src/SampleApp ./Integration/AlexaClientSDKConfig.json DEBUG9
Press T+Enter, and ask Alexa something.
For example:
User taps-to-talk (T+Enter): "Alexa, what's the weather like?"
Alexa: "Right now in Portland, it's 71 degrees with sun..."
Interaction options
Action | Command |
---|---|
Tap to talk | t+Enter, followed by your query (no need to say "Alexa..."). |
Hold to talk | h+Enter, followed by your query (no need to say "Alexa..."). |
Simulate button release | h+Enter |
Stop an interaction | s+Enter |
Playback controls
Action | Command |
---|---|
Play | 1 |
Pause | 2 |
Next | 3 |
Previous | 4 |
Settings
Action | Command |
---|---|
View available settings | c+Enter |
Adjust speaker settings | p+Enter |
Report firmware version | f+Enter |
Help screen | i+Enter |
Reset device | k+Enter; this will erase any data stored on the device, and you will have to re-register it. This will also exit the application. |
Quit | q+Enter |
After you've authorized your sample app, run integration and unit tests to ensure that the AVS Device SDK is functioning as designed.
- Use this command to run integration tests:
make all integration
- Use this command to run unit tests:
make all test
For additional details, see Unit and Integration Tests.
You can designate aliases to launch the sample app. To do this:
- Open
~/.bash_profile
, and add these aliases and save:
IMPORTANT: Make sure you update the paths to match your folder structure.alias alexac="{path_to}/{build}/SampleApp/src/SampleApp {path_to}/{build}/Integration/AlexaClientSDKConfig.json" alias alexacdebug="{path_to}/{build}/SampleApp/src/SampleApp {path_to}/{build}/Integration/AlexaClientSDKConfig.json DEBUG9"
- After you've added these aliases, make sure to activate your
~/.bash_profile
:source ~/.bash_profile
- Now to launch the sample app, you can run this command:
alexac
API Reference
Quick-start Guides
- All Quick-start Guides
- For Android
- Cross-compile for iOS
- Generic Linux
- For macOS
- For Raspberry Pi
- For Ubuntu Linux
- For Windows 64-bit
Other Guides + Optimizations
- Authorizing AVS Device SDK Software with AVS
- Build libcurl with mbed TLS and nghttp2
- Build libcurl with nghttp2 for macOS
- Optimize libcurl for Size
- Runtime Configuration for CA Certificates
- Updating the SDK
Development Kits
Resources