Skip to content

Commit

Permalink
[Group] Modification for group command processing on device side (#12406
Browse files Browse the repository at this point in the history
)

* Command processing on device side

* Added pointer check for ExchangeContext

* Move comment
  • Loading branch information
mkardous-silabs authored and pull[bot] committed Mar 24, 2023
1 parent bd1f13c commit 7168322
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
24 changes: 22 additions & 2 deletions src/app/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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)
{
Expand Down
5 changes: 5 additions & 0 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ void SetupEmberAfObjects(Command * command, const ConcreteCommandPath & commandP
imCompatibilityEmberApsFrame.sequence =
(commandExchangeCtx != nullptr ? static_cast<uint8_t>(commandExchangeCtx->GetExchangeId() & 0xFF) : 0);

if (commandExchangeCtx->IsGroupExchangeContext())
{
imCompatibilityEmberAfCluster.type = EMBER_INCOMING_MULTICAST;
}

imCompatibilityEmberAfCluster.commandId = commandPath.mCommandId;
imCompatibilityEmberAfCluster.apsFrame = &imCompatibilityEmberApsFrame;
imCompatibilityEmberAfCluster.interPanHeader = &imCompatibilityInterpanHeader;
Expand Down
8 changes: 4 additions & 4 deletions src/app/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 7168322

Please sign in to comment.