Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jepenven-silabs committed Mar 1, 2022
1 parent 7903051 commit 2304848
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
12 changes: 5 additions & 7 deletions examples/chip-tool/commands/clusters/ClusterCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,23 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal

chip::Messaging::ExchangeManager * exchangeManager = chip::app::InteractionModelEngine::GetInstance()->GetExchangeManager();

ChipLogDetail(chipTool, "Sending command to Group %u, on Fabric %x, for cluster %u with commandId %u", groupId, fabricIndex,
clusterId, commandId);

auto commandSender = chip::Platform::MakeUnique<chip::app::CommandSender>(this, exchangeManager, false);
auto commandSender =
chip::Platform::MakeUnique<chip::app::CommandSender>(this, exchangeManager, mTimedInteractionTimeoutMs.HasValue());
VerifyOrReturnError(commandSender != nullptr, CHIP_ERROR_NO_MEMORY);
ReturnErrorOnFailure(commandSender->AddRequestDataNoTimedCheck(commandPath, value, chip::NullOptional));
ReturnErrorOnFailure(commandSender->AddRequestDataNoTimedCheck(commandPath, value, mTimedInteractionTimeoutMs));

chip::Optional<chip::SessionHandle> session =
exchangeManager->GetSessionManager()->CreateGroupSession(groupId, fabricIndex, senderNodeId);
if (!session.HasValue())
{
return CHIP_ERROR_NO_MEMORY;
}
ReturnErrorOnFailure(commandSender->SendGroupCommandRequest(session.Value()));
CHIP_ERROR err = commandSender->SendGroupCommandRequest(session.Value());

commandSender.release();
exchangeManager->GetSessionManager()->RemoveGroupSession(session.Value()->AsGroupSession());

return CHIP_NO_ERROR;
return err;
}

private:
Expand Down
7 changes: 4 additions & 3 deletions examples/chip-tool/commands/clusters/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ CHIP_ERROR ModelCommand::RunCommand()

if (IsGroupId(mNodeId))
{
FabricIndex fabricIndex;
ReturnErrorOnFailure(CurrentCommissioner().GetFabricIndex(&fabricIndex));
ChipLogProgress(chipTool, "Sending command to group 0x%" PRIx16 " on Fabric Index 0x%" PRIx16, GroupIdFromNodeId(mNodeId),
static_cast<FabricIndex>(mEndPointId));
fabricIndex);

return SendGroupCommand(GroupIdFromNodeId(mNodeId), static_cast<FabricIndex>(mEndPointId),
CurrentCommissioner().GetNodeId());
return SendGroupCommand(GroupIdFromNodeId(mNodeId), fabricIndex, CurrentCommissioner().GetNodeId());
}

ChipLogProgress(chipTool, "Sending command to node 0x%" PRIx64, mNodeId);
Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ModelCommand : public CHIPCommand
void AddArguments()
{
AddArgument("node-id/group-id", 0, UINT64_MAX, &mNodeId);
AddArgument("endpoint-id/FabricIndex", 0, UINT16_MAX, &mEndPointId);
AddArgument("endpoint-id-ignored-for-group-commands", 0, UINT16_MAX, &mEndPointId);
}

/////////// CHIPCommand Interface /////////
Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/clusters/WriteAttributeCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class WriteAttribute : public ModelCommand, public chip::app::WriteClient::Callb
ChipLogProgress(chipTool, "Sending WriteAttribute to cluster " ChipLogFormatMEI " on endpoint %" PRIu16,
ChipLogValueMEI(clusterId), endpointId);
chip::app::AttributePathParams attributePathParams;
if (!device->GetSecureSession().Value()->IsGroupSession())
if (device->GetSecureSession().Value()->IsGroupSession())
{
attributePathParams.mEndpointId = endpointId;
}
Expand Down Expand Up @@ -134,12 +134,12 @@ class WriteAttribute : public ModelCommand, public chip::app::WriteClient::Callb
{
return CHIP_ERROR_NO_MEMORY;
}
ReturnErrorOnFailure(writeClient->SendWriteRequest(session.Value()));
CHIP_ERROR err = writeClient->SendWriteRequest(session.Value());

writeClient.release();
exchangeManager->GetSessionManager()->RemoveGroupSession(session.Value()->AsGroupSession());

return CHIP_NO_ERROR;
return err;
}

private:
Expand Down
7 changes: 7 additions & 0 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate
*/
NodeId GetNodeId() const { return mLocalId.GetNodeId(); }

CHIP_ERROR GetFabricIndex(FabricIndex * value)
{
VerifyOrReturnError(mState == State::Initialized && mFabricInfo != nullptr && value != nullptr, CHIP_ERROR_INCORRECT_STATE);
*value = mFabricInfo->GetFabricIndex();
return CHIP_NO_ERROR;
}

void ReleaseOperationalDevice(NodeId remoteDeviceId);

OperationalCredentialsDelegate * GetOperationalCredentialsDelegate() { return mOperationalCredentialsDelegate; }
Expand Down

0 comments on commit 2304848

Please sign in to comment.