Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Version 1.26.0 alexa-client-sdk
Browse files Browse the repository at this point in the history
Changes in this update:

Feature enhancements, updates, and resolved issues from all releases are available on the [Amazon developer portal](https://developer.amazon.com/docs/alexa/avs-device-sdk/release-notes.html)
  • Loading branch information
womw committed Nov 15, 2021
1 parent f0c606d commit 703b061
Show file tree
Hide file tree
Showing 754 changed files with 53,817 additions and 3,651 deletions.
47 changes: 30 additions & 17 deletions ACL/src/AVSConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ static const std::string TAG("AVSConnectionManager");
/**
* Create a LogEntry using this file's TAG and the specified event string.
*
* @param The event string for this @c LogEntry.
* @param event The event string for this @c LogEntry.
*/
#define LX(event) alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)

/**
* Create a LogEntry using this file's TAG, the specified event string, and pointer to disambiguate the instance.
*
* @param event The event string for this @c LogEntry.
*/
#define LX_P(event) LX(event).p("this", this)

std::shared_ptr<MessageSenderInterface> AVSConnectionManager::createMessageSenderInterface(
const std::shared_ptr<AVSConnectionManagerInterface>& connectionManager) {
return connectionManager;
Expand Down Expand Up @@ -64,19 +71,20 @@ std::shared_ptr<AVSConnectionManager> AVSConnectionManager::create(

if (!messageRouter) {
ACSDK_ERROR(LX("createFailed").d("reason", "nullMessageRouter").d("return", "nullptr"));

return nullptr;
}

for (auto observer : connectionStatusObservers) {
if (!observer) {
ACSDK_ERROR(LX("createFailed").d("reason", "nullConnectionStatusObserver").d("return", "nullptr"));
ACSDK_ERROR(LX("createFailed").d("reason", "nullConnectionStatusObserver"));
return nullptr;
}
}

for (auto observer : messageObservers) {
if (!observer) {
ACSDK_ERROR(LX("createFailed").d("reason", "nullMessageObserver").d("return", "nullptr"));
ACSDK_ERROR(LX("createFailed").d("reason", "nullMessageObserver"));
return nullptr;
}
}
Expand All @@ -91,7 +99,7 @@ std::shared_ptr<AVSConnectionManager> AVSConnectionManager::create(
}

if (internetConnectionMonitor) {
ACSDK_DEBUG5(LX(__func__).m("Subscribing to InternetConnectionMonitor Callbacks"));
ACSDK_DEBUG5(LX("create").m("Subscribing to InternetConnectionMonitor Callbacks"));
internetConnectionMonitor->addInternetConnectionObserver(connectionManager);
}

Expand All @@ -109,9 +117,11 @@ AVSConnectionManager::AVSConnectionManager(
m_messageObservers{messageObservers},
m_messageRouter{messageRouter},
m_internetConnectionMonitor{internetConnectionMonitor} {
ACSDK_DEBUG5(LX_P("AVSConnectionManager"));
}

void AVSConnectionManager::doShutdown() {
ACSDK_DEBUG5(LX_P("doShutdown"));
if (m_internetConnectionMonitor) {
m_internetConnectionMonitor->removeInternetConnectionObserver(shared_from_this());
}
Expand All @@ -136,8 +146,8 @@ void AVSConnectionManager::doShutdown() {
}

void AVSConnectionManager::enable() {
ACSDK_DEBUG5(LX_P("enable"));
std::lock_guard<std::mutex> lock(m_isEnabledMutex);
ACSDK_DEBUG5(LX(__func__));
m_isEnabled = true;
auto messageRouter = getMessageRouter();
if (messageRouter) {
Expand All @@ -146,8 +156,8 @@ void AVSConnectionManager::enable() {
}

void AVSConnectionManager::disable() {
ACSDK_DEBUG5(LX_P("disable"));
std::lock_guard<std::mutex> lock(m_isEnabledMutex);
ACSDK_DEBUG5(LX(__func__));
m_isEnabled = false;
auto messageRouter = getMessageRouter();
if (messageRouter) {
Expand All @@ -161,8 +171,9 @@ bool AVSConnectionManager::isEnabled() {
}

void AVSConnectionManager::reconnect() {
ACSDK_DEBUG5(LX_P("reconnect"));
std::lock_guard<std::mutex> lock(m_isEnabledMutex);
ACSDK_DEBUG5(LX(__func__).d("isEnabled", m_isEnabled));
ACSDK_DEBUG5(LX_P("reconnect").d("isEnabled", m_isEnabled));
if (m_isEnabled) {
auto messageRouter = getMessageRouter();
if (messageRouter) {
Expand All @@ -175,9 +186,10 @@ void AVSConnectionManager::reconnect() {
void AVSConnectionManager::sendMessage(std::shared_ptr<avsCommon::avs::MessageRequest> request) {
auto messageRouter = getMessageRouter();
if (messageRouter) {
ACSDK_DEBUG7(LX_P("sendMessage"));
messageRouter->sendMessage(request);
} else {
ACSDK_WARN(LX("sendMessageFailed")
ACSDK_WARN(LX_P("sendMessageFailed")
.d("reason", "nullMessageRouter")
.m("setting status for request to NOT_CONNECTED")
.d("request", request->getJsonContent()));
Expand All @@ -194,12 +206,12 @@ bool AVSConnectionManager::isConnected() const {
}

void AVSConnectionManager::onWakeConnectionRetry() {
ACSDK_DEBUG9(LX(__func__));
ACSDK_DEBUG9(LX_P("onWakeConnectionRetry"));
auto messageRouter = getMessageRouter();
if (messageRouter) {
messageRouter->onWakeConnectionRetry();
} else {
ACSDK_WARN(LX("onWakeConnectionRetryFailed").d("reason", "nullMessageRouter"));
ACSDK_WARN(LX_P("onWakeConnectionRetryFailed").d("reason", "nullMessageRouter"));
}
}

Expand All @@ -208,7 +220,7 @@ void AVSConnectionManager::setAVSGateway(const std::string& avsGateway) {
if (messageRouter) {
messageRouter->setAVSGateway(avsGateway);
} else {
ACSDK_WARN(LX("setAVSGatewayFailed").d("reason", "nullMessageRouter"));
ACSDK_WARN(LX_P("setAVSGatewayFailed").d("reason", "nullMessageRouter"));
}
}

Expand All @@ -217,13 +229,13 @@ std::string AVSConnectionManager::getAVSGateway() const {
if (messageRouter) {
return messageRouter->getAVSGateway();
} else {
ACSDK_WARN(LX("getAVSGatewayFailed").d("reason", "nullMessageRouter"));
ACSDK_WARN(LX_P("getAVSGatewayFailed").d("reason", "nullMessageRouter"));
}
return "";
}

void AVSConnectionManager::onConnectionStatusChanged(bool connected) {
ACSDK_DEBUG5(LX(__func__).d("connected", connected).d("isEnabled", m_isEnabled));
ACSDK_DEBUG5(LX_P("onConnectionStatusChanged").d("connected", connected).d("isEnabled", m_isEnabled));
if (m_isEnabled) {
auto messageRouter = getMessageRouter();
if (messageRouter) {
Expand All @@ -233,15 +245,15 @@ void AVSConnectionManager::onConnectionStatusChanged(bool connected) {
messageRouter->onWakeVerifyConnectivity();
}
} else {
ACSDK_WARN(LX("onConnectionStatusChangedFailed").d("reason", "nullMessageRouter"));
ACSDK_WARN(LX_P("onConnectionStatusChangedFailed").d("reason", "nullMessageRouter"));
}
}
}

void AVSConnectionManager::addMessageObserver(
std::shared_ptr<avsCommon::sdkInterfaces::MessageObserverInterface> observer) {
if (!observer) {
ACSDK_ERROR(LX("addObserverFailed").d("reason", "nullObserver"));
ACSDK_ERROR(LX_P("addObserverFailed").d("reason", "nullObserver"));
return;
}

Expand All @@ -252,7 +264,7 @@ void AVSConnectionManager::addMessageObserver(
void AVSConnectionManager::removeMessageObserver(
std::shared_ptr<avsCommon::sdkInterfaces::MessageObserverInterface> observer) {
if (!observer) {
ACSDK_ERROR(LX("removeObserverFailed").d("reason", "nullObserver"));
ACSDK_ERROR(LX_P("removeObserverFailed").d("reason", "nullObserver"));
return;
}

Expand All @@ -264,7 +276,8 @@ void AVSConnectionManager::onConnectionStatusChanged(
const ConnectionStatusObserverInterface::Status status,
const std::vector<avsCommon::sdkInterfaces::ConnectionStatusObserverInterface::EngineConnectionStatus>&
engineConnectionStatuses) {
ACSDK_DEBUG(LX(__func__).d("status", status).d("engine_count", engineConnectionStatuses.size()));
ACSDK_DEBUG(
LX_P("onConnectionStatusChanged").d("status", status).d("engine_count", engineConnectionStatuses.size()));
updateConnectionStatus(status, engineConnectionStatuses);
}

Expand Down
2 changes: 1 addition & 1 deletion ACL/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
file(GLOB_RECURSE ACL_SRC "${ACL_SOURCE_DIR}/src/*.cpp")
add_definitions("-DACSDK_LOG_MODULE=acl")
add_definitions("-DACSDK_OPENSSL_MIN_VER_REQUIRED=${OPENSSL_MIN_VERSION}")
add_library(ACL SHARED ${ACL_SRC})
add_library(ACL ${ACL_SRC})
target_include_directories(ACL PUBLIC "${MultipartParser_SOURCE_DIR}")
target_include_directories(ACL PUBLIC ${CURL_INCLUDE_DIRS})
target_include_directories(ACL PUBLIC "${ACL_SOURCE_DIR}/include")
Expand Down
20 changes: 10 additions & 10 deletions ACL/src/Transport/DownchannelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ static const std::string RESPONSE_FINISHED = "RESPONSE_FINISHED";
/**
* Create a LogEntry using this file's TAG and the specified event string.
*
* @param The event string for this @c LogEntry.
* @param event The event string for this @c LogEntry.
*/
#define LX(event) alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)

/**
* Creates a MetricEvent with the given event name and datapoint and submits it with the metric recorder.
* @param metricRecorder - The @c MetricRecorderInterface used log the metric.
* @param eventName - The event name of the metric to be logged.
* @param dataPoint - The @c DataPoint to be added to the metric.
* @param metricRecorder The @c MetricRecorderInterface used log the metric.
* @param eventName The event name of the metric to be logged.
* @param dataPoint The @c DataPoint to be added to the metric.
*/
void submitMetric(
const std::shared_ptr<MetricRecorderInterface>& metricRecorder,
Expand Down Expand Up @@ -111,7 +111,7 @@ std::shared_ptr<DownchannelHandler> DownchannelHandler::create(
std::shared_ptr<MessageConsumerInterface> messageConsumer,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
const std::shared_ptr<MetricRecorderInterface>& metricRecorder) {
ACSDK_DEBUG9(LX(__func__).d("context", context.get()));
ACSDK_DEBUG9(LX("create").d("context", context.get()));

if (!context) {
ACSDK_CRITICAL(LX("createFailed").d("reason", "nullHttp2Transport"));
Expand Down Expand Up @@ -144,12 +144,12 @@ std::shared_ptr<DownchannelHandler> DownchannelHandler::create(
}

std::vector<std::string> DownchannelHandler::getRequestHeaderLines() {
ACSDK_DEBUG9(LX(__func__));
ACSDK_DEBUG9(LX("getRequestHeaderLines"));
return {m_authHeader};
}

HTTP2SendDataResult DownchannelHandler::onSendData(char* bytes, size_t size) {
ACSDK_DEBUG9(LX(__func__).d("size", size));
ACSDK_DEBUG9(LX("onSendData").d("size", size));
return HTTP2SendDataResult::COMPLETE;
}

Expand All @@ -159,7 +159,7 @@ DownchannelHandler::DownchannelHandler(
const std::shared_ptr<MetricRecorderInterface>& metricRecorder) :
ExchangeHandler{context, authToken},
m_metricRecorder{metricRecorder} {
ACSDK_DEBUG9(LX(__func__).d("context", context.get()));
ACSDK_DEBUG9(LX("init").d("context", context.get()));
m_powerResource = PowerMonitor::getInstance()->createLocalPowerResource(TAG);
if (m_powerResource) {
m_powerResource->acquire();
Expand All @@ -171,7 +171,7 @@ void DownchannelHandler::onActivity() {
}

bool DownchannelHandler::onReceiveResponseCode(long responseCode) {
ACSDK_DEBUG5(LX(__func__).d("responseCode", responseCode));
ACSDK_DEBUG5(LX("onReceiveResponseCode").d("responseCode", responseCode));
switch (intToHTTPResponseCode(responseCode)) {
case HTTPResponseCode::HTTP_RESPONSE_CODE_UNDEFINED:
case HTTPResponseCode::SUCCESS_CREATED:
Expand Down Expand Up @@ -205,7 +205,7 @@ bool DownchannelHandler::onReceiveResponseCode(long responseCode) {
}

void DownchannelHandler::onResponseFinished(HTTP2ResponseFinishedStatus status, const std::string& nonMimeBody) {
ACSDK_DEBUG5(LX(__func__).d("status", status).d("nonMimeBody", nonMimeBody));
ACSDK_DEBUG5(LX("onResponseFinished").d("status", status).d("nonMimeBody", nonMimeBody));
m_context->onDownchannelFinished();
submitResponseFinishedMetric(m_metricRecorder, status);
}
Expand Down
6 changes: 3 additions & 3 deletions ACL/src/Transport/ExchangeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static const std::string TAG("ExchangeHandler");
/**
* Create a LogEntry using this file's TAG and the specified event string.
*
* @param The event string for this @c LogEntry.
* @param event The event string for this @c LogEntry.
*/
#define LX(event) alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)

Expand All @@ -42,9 +42,9 @@ ExchangeHandler::ExchangeHandler(
m_context{context},
m_authToken{authToken},
m_authHeader{AUTHORIZATION_HEADER + authToken} {
ACSDK_DEBUG5(LX(__func__).d("context", context.get()).sensitive("authToken", authToken));
ACSDK_DEBUG5(LX("init").d("context", context.get()).sensitive("authToken", authToken));
if (m_authToken.empty()) {
ACSDK_ERROR(LX(__func__).m("emptyAuthToken"));
ACSDK_ERROR(LX("initError").m("emptyAuthToken"));
}
}

Expand Down

0 comments on commit 703b061

Please sign in to comment.