forked from alexa/avs-device-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes in this update: Enhancements * Added the Bluetooth interface, which manages the Bluetooth connection between Alexa-enabled products and peer devices. This release supports A2DP-SINK and AVRCP profiles. Note: Bluetooth is optional and is currently limited to Raspberry Pi and Linux platforms. * Added new Bluetooth dependencies for Linux and Raspberry Pi. * Device Capability Framework (DCF) renamed to Capabilities. * Updated the non-CBL client ID error message to be more specific. * Updated the sample app to enter a limited interaction mode after an unrecoverable error. Bug Fixes * Issue 597 - Fixed a bug where the sample app did not respond to locale change settings. * Fixed issue where GStreamer 1.14 MediaPlayerTest failed on Windows. * Fixed an issue where a segmentation fault was triggered after unrecoverable error handling. Known Issues * The ACL may encounter issues if audio attachments are received but not consumed. * SpeechSynthesizerState currently uses GAINING_FOCUS and LOSING_FOCUS as a workaround for handling intermediate state. These states may be removed in a future release. * The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth. * Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback. * When streaming silence via Bluetooth, the Alexa companion app will sometimes indicate that media content is streaming. * The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported. * On some products, interrupted Bluetooth playback may not resume if other content is locally streamed. * When streaming content via Bluetooth, under certain conditions playback will fail to resume and the sample app hangs on exit. This is due to a conflict between the GStreamer pipeline and the Bluetooth agent. * On Raspberry Pi, when streaming audio via Bluetooth, sometimes the audio stream stutters. * On Raspberry Pi, BlueALSA must be terminated each time the device boots. See Raspberry Pi Quick Start Guide for more information.
- Loading branch information
1 parent
8bf0160
commit 32f85e2
Showing
134 changed files
with
12,705 additions
and
709 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#ifndef ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_REQUESTER_H_ | ||
#define ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_REQUESTER_H_ | ||
|
||
namespace alexaClientSDK { | ||
namespace avsCommon { | ||
namespace avs { | ||
|
||
/// An enum class indicating whether an operation originated from a Device or Cloud (AVS). | ||
enum class Requester { | ||
/// The request came from AVS as a result of a directive. | ||
CLOUD, | ||
/// The request came from the device. Can be from either the AVS device or a connected device. | ||
DEVICE | ||
}; | ||
|
||
/** | ||
* Converts an @c Requester enum to a string. | ||
* | ||
* @param requester The @c Requester enum. | ||
* @return The string representation of the enum. | ||
*/ | ||
inline std::string requesterToString(Requester requester) { | ||
switch (requester) { | ||
case Requester::CLOUD: | ||
return "CLOUD"; | ||
case Requester::DEVICE: | ||
return "DEVICE"; | ||
} | ||
return "UNKNOWN"; | ||
} | ||
|
||
/** | ||
* Write a @c Requester value to an @c ostream as a string. | ||
* | ||
* @param stream The stream to write the value to. | ||
* @param requester The @c Requester value to write to the @c ostream as a string. | ||
* @return The @c ostream that was passed in and written to. | ||
*/ | ||
inline std::ostream& operator<<(std::ostream& stream, Requester requester) { | ||
return stream << requesterToString(requester); | ||
} | ||
|
||
} // namespace avs | ||
} // namespace avsCommon | ||
} // namespace alexaClientSDK | ||
|
||
#endif // ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_REQUESTER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 186 additions & 0 deletions
186
AVSCommon/SDKInterfaces/include/AVSCommon/SDKInterfaces/Bluetooth/BluetoothDeviceInterface.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
/* | ||
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#ifndef ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEINTERFACE_H_ | ||
#define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEINTERFACE_H_ | ||
|
||
#include <future> | ||
#include <memory> | ||
#include <ostream> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <AVSCommon/SDKInterfaces/Bluetooth/Services/A2DPSourceInterface.h> | ||
#include <AVSCommon/SDKInterfaces/Bluetooth/Services/AVRCPTargetInterface.h> | ||
#include <AVSCommon/SDKInterfaces/Bluetooth/Services/BluetoothServiceInterface.h> | ||
#include <AVSCommon/SDKInterfaces/Bluetooth/Services/SDPRecordInterface.h> | ||
|
||
namespace alexaClientSDK { | ||
namespace avsCommon { | ||
namespace sdkInterfaces { | ||
namespace bluetooth { | ||
|
||
/** | ||
* clang-format off | ||
* Represents the state of the device. The state diagram is as follows: | ||
* | ||
* +------UNPAIRED-------------+ | ||
* | | | ||
* +------UNPAIRED---+ | | ||
* V | | | ||
* FOUND -> PAIRED -> IDLE -> CONNECTED | ||
* ^ | | ||
* +DISCONNECTED-+ | ||
* clang-format on | ||
*/ | ||
enum class DeviceState { | ||
// A device has been discovered. | ||
FOUND, | ||
// [Transitional] The device has been unpaired. | ||
UNPAIRED, | ||
// [Transitional] The device has successfully paired. | ||
PAIRED, | ||
// A paired device. | ||
IDLE, | ||
// [Transitional] A device has successfully disconnected. | ||
DISCONNECTED, | ||
// A device that has successfully connected. | ||
CONNECTED | ||
}; | ||
|
||
/** | ||
* Converts the @c DeviceState enum to a string. | ||
* | ||
* @param The @c DeviceState to convert. | ||
* @return A string representation of the @c DeviceState. | ||
*/ | ||
inline std::string deviceStateToString(DeviceState state) { | ||
switch (state) { | ||
case DeviceState::FOUND: | ||
return "FOUND"; | ||
case DeviceState::UNPAIRED: | ||
return "UNPAIRED"; | ||
case DeviceState::PAIRED: | ||
return "PAIRED"; | ||
case DeviceState::IDLE: | ||
return "IDLE"; | ||
case DeviceState::DISCONNECTED: | ||
return "DISCONNECTED"; | ||
case DeviceState::CONNECTED: | ||
return "CONNECTED"; | ||
} | ||
|
||
return "UNKNOWN"; | ||
} | ||
|
||
/** | ||
* Overload for the @c DeviceState enum. This will write the @c DeviceState as a string to the provided stream. | ||
* | ||
* @param An ostream to send the DeviceState as a string. | ||
* @param The @c DeviceState to convert. | ||
* @return The stream. | ||
*/ | ||
inline std::ostream& operator<<(std::ostream& stream, const DeviceState state) { | ||
return stream << deviceStateToString(state); | ||
} | ||
|
||
/// Represents a Bluetooth Device. | ||
class BluetoothDeviceInterface { | ||
public: | ||
/// Destructor | ||
virtual ~BluetoothDeviceInterface() = default; | ||
|
||
/** | ||
* Getter for the MAC address. | ||
* | ||
* @return The MAC address of the Bluetooth Device. | ||
*/ | ||
virtual std::string getMac() const = 0; | ||
|
||
/** | ||
* Getter for the friendly name. | ||
* | ||
* @return The friendly name of the Bluetooth Device. | ||
*/ | ||
virtual std::string getFriendlyName() const = 0; | ||
|
||
/** | ||
* Getter for the @c DeviceState. | ||
* | ||
* @return The @c DeviceState of the current device. | ||
*/ | ||
virtual DeviceState getDeviceState() = 0; | ||
|
||
/** | ||
* Getter for the paired state of the device. This should return | ||
* the state after any pending state changes have been resolved. | ||
* | ||
* @return A bool representing whether the device is paired. | ||
*/ | ||
virtual bool isPaired() = 0; | ||
|
||
/** | ||
* Initiate a pair with this device. | ||
* | ||
* @return Indicates whether pairing was successful. | ||
*/ | ||
virtual std::future<bool> pair() = 0; | ||
|
||
/** | ||
* Initiate an unpair with this device. | ||
* | ||
* @return Indicates whether the unpairing was successful. | ||
*/ | ||
virtual std::future<bool> unpair() = 0; | ||
|
||
/** | ||
* Getter for the paired state of the device. This should return | ||
* the state after any pending state changes have been resolved. | ||
* | ||
* @return A bool representing whether the device is connected. | ||
*/ | ||
virtual bool isConnected() = 0; | ||
|
||
/** | ||
* Initiate a connect with this device. | ||
* | ||
* @return Indicates whether connecting was successful. | ||
*/ | ||
virtual std::future<bool> connect() = 0; | ||
|
||
/** | ||
* Initiate a disconnect with this device. | ||
* | ||
* @return Indicates whether disconnect was successful. | ||
*/ | ||
virtual std::future<bool> disconnect() = 0; | ||
|
||
/// @return The Bluetooth Services that this device supports. | ||
virtual std::vector<std::shared_ptr<services::SDPRecordInterface>> getSupportedServices() = 0; | ||
|
||
// TODO : Generic getService method. | ||
/// @return A pointer to an instance of the @c A2DPSourceInterface if supported, else a nullptr. | ||
virtual std::shared_ptr<services::A2DPSourceInterface> getA2DPSource() = 0; | ||
|
||
/// @return A pointer to an instance of the @c AVRCPTargetInterface if supported, else a nullptr. | ||
virtual std::shared_ptr<services::AVRCPTargetInterface> getAVRCPTarget() = 0; | ||
}; | ||
|
||
} // namespace bluetooth | ||
} // namespace sdkInterfaces | ||
} // namespace avsCommon | ||
} // namespace alexaClientSDK | ||
|
||
#endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEINTERFACE_H_ |
64 changes: 64 additions & 0 deletions
64
...SDKInterfaces/include/AVSCommon/SDKInterfaces/Bluetooth/BluetoothDeviceManagerInterface.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#ifndef ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEMANAGERINTERFACE_H_ | ||
#define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEMANAGERINTERFACE_H_ | ||
|
||
#include <list> | ||
#include <memory> | ||
|
||
#include "AVSCommon/SDKInterfaces/Bluetooth/BluetoothDeviceInterface.h" | ||
#include "AVSCommon/SDKInterfaces/Bluetooth/BluetoothHostControllerInterface.h" | ||
|
||
namespace alexaClientSDK { | ||
namespace avsCommon { | ||
namespace sdkInterfaces { | ||
namespace bluetooth { | ||
|
||
/** | ||
* This component is a starting point of any platform specific implementation of bluetooth functionality. It is | ||
* responsible for ownership of @c BluetoothDeviceInterface objects and @c BluetootHostController objects. | ||
* | ||
*/ | ||
class BluetoothDeviceManagerInterface { | ||
public: | ||
/** | ||
* Destructor | ||
*/ | ||
virtual ~BluetoothDeviceManagerInterface() = default; | ||
|
||
/** | ||
* Get @c BluetoothHostControllerInterface instance | ||
* @return Pointer to a @c BluetoothHostControllerInterface instance | ||
*/ | ||
virtual std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothHostControllerInterface> | ||
getHostController() = 0; | ||
|
||
/** | ||
* Get a list of devices the Host Controller is aware of. This list must contain: | ||
* | ||
* i) Paired devices. | ||
* ii) Devices found during the scanning process. | ||
*/ | ||
virtual std::list<std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface>> | ||
getDiscoveredDevices() = 0; | ||
}; | ||
|
||
} // namespace bluetooth | ||
} // namespace sdkInterfaces | ||
} // namespace avsCommon | ||
} // namespace alexaClientSDK | ||
|
||
#endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_BLUETOOTH_BLUETOOTHDEVICEMANAGERINTERFACE_H_ |
Oops, something went wrong.