diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index a55a53d06cecee..0ffce28d5216ca 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -121,12 +121,10 @@ 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(this, exchangeManager, false); + auto commandSender = + chip::Platform::MakeUnique(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 session = exchangeManager->GetSessionManager()->CreateGroupSession(groupId, fabricIndex, senderNodeId); @@ -134,12 +132,12 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal { 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: diff --git a/examples/chip-tool/commands/clusters/ModelCommand.cpp b/examples/chip-tool/commands/clusters/ModelCommand.cpp index b51341d7fadbc1..b0d77236a5f0e8 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.cpp +++ b/examples/chip-tool/commands/clusters/ModelCommand.cpp @@ -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(mEndPointId)); + fabricIndex); - return SendGroupCommand(GroupIdFromNodeId(mNodeId), static_cast(mEndPointId), - CurrentCommissioner().GetNodeId()); + return SendGroupCommand(GroupIdFromNodeId(mNodeId), fabricIndex, CurrentCommissioner().GetNodeId()); } ChipLogProgress(chipTool, "Sending command to node 0x%" PRIx64, mNodeId); diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index 788d2de3e1309b..f1576fd2a039f5 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -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 ///////// diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index 861228954dbe08..d84a0545e867c6 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -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; } @@ -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: diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index a7c796e906b2a6..5ba881fac445f6 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -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; }