From 71683222621b96f0cffb5b4982a3ecc6397a3b3e Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Mon, 6 Dec 2021 10:01:28 -0500 Subject: [PATCH] [Group] Modification for group command processing on device side (#12406) * Command processing on device side * Added pointer check for ExchangeContext * Move comment --- src/app/CommandHandler.cpp | 24 +++++++++++++++++-- .../util/ember-compatibility-functions.cpp | 5 ++++ src/app/util/util.cpp | 8 +++---- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index acbc59f5e431e7..96dbdf4d93e019 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -173,7 +173,13 @@ void CommandHandler::DecrementHoldOff() { return; } - CHIP_ERROR err = SendCommandResponse(); + + CHIP_ERROR err = CHIP_NO_ERROR; + if (!mpExchangeCtx->IsGroupExchangeContext()) + { + err = SendCommandResponse(); + } + if (err != CHIP_NO_ERROR) { ChipLogError(DataManagement, "Failed to send command response: %" CHIP_ERROR_FORMAT, err.Format()); @@ -223,10 +229,24 @@ CHIP_ERROR CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommand err = commandPath.GetCommandId(&commandId); SuccessOrExit(err); - err = commandPath.GetEndpointId(&endpointId); + if (mpExchangeCtx != nullptr && mpExchangeCtx->IsGroupExchangeContext()) + { + // TODO retrieve Endpoint ID with GroupDataProvider using GroupId and FabricId + // Issue 11075 + + // Using endpoint 1 for test purposes + endpointId = 1; + err = CHIP_NO_ERROR; + } + else + { + err = commandPath.GetEndpointId(&endpointId); + } SuccessOrExit(err); + VerifyOrExit(mpCallback->CommandExists(ConcreteCommandPath(endpointId, clusterId, commandId)), err = CHIP_ERROR_INVALID_PROFILE_ID); + err = aCommandElement.GetData(&commandDataReader); if (CHIP_END_OF_TLV == err) { diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 0650865392e2ca..7433fe29311f1a 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -147,6 +147,11 @@ void SetupEmberAfObjects(Command * command, const ConcreteCommandPath & commandP imCompatibilityEmberApsFrame.sequence = (commandExchangeCtx != nullptr ? static_cast(commandExchangeCtx->GetExchangeId() & 0xFF) : 0); + if (commandExchangeCtx->IsGroupExchangeContext()) + { + imCompatibilityEmberAfCluster.type = EMBER_INCOMING_MULTICAST; + } + imCompatibilityEmberAfCluster.commandId = commandPath.mCommandId; imCompatibilityEmberAfCluster.apsFrame = &imCompatibilityEmberApsFrame; imCompatibilityEmberAfCluster.interPanHeader = &imCompatibilityInterpanHeader; diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index 200242ef8ca6fd..8aea09fb21529a 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -782,15 +782,15 @@ EmberStatus emberAfSendDefaultResponseWithCallback(const EmberAfClusterCommand * { uint8_t frameControl; - if (chip::app::Compatibility::IMEmberAfSendDefaultResponseWithCallback(status)) + // Default Response commands are only sent in response to unicast commands. + if (cmd->type != EMBER_INCOMING_UNICAST && cmd->type != EMBER_INCOMING_UNICAST_REPLY) { - // If the compatibility can handle this response return EMBER_SUCCESS; } - // Default Response commands are only sent in response to unicast commands. - if (cmd->type != EMBER_INCOMING_UNICAST && cmd->type != EMBER_INCOMING_UNICAST_REPLY) + if (chip::app::Compatibility::IMEmberAfSendDefaultResponseWithCallback(status)) { + // If the compatibility can handle this response return EMBER_SUCCESS; }