diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index ae660f17ab49a4..27c58b5cab1496 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -15397,6 +15397,14 @@ "incoming": 1, "outgoing": 0 }, + { + "name": "TestEmitTestEventRequest", + "code": 20, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, { "name": "TestSimpleOptionalArgumentRequest", "code": 19, @@ -15479,6 +15487,14 @@ "source": "server", "incoming": 0, "outgoing": 1 + }, + { + "name": "TestEmitTestEventResponse", + "code": 10, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 } ], "attributes": [ diff --git a/src/app/EventLogging.h b/src/app/EventLogging.h index 5a4a23d4d4f285..16de28217e2d7f 100644 --- a/src/app/EventLogging.h +++ b/src/app/EventLogging.h @@ -20,6 +20,7 @@ #include #include +#include #include #include // So we can encode lists @@ -27,7 +28,7 @@ namespace chip { namespace app { template -class EventLogger : EventLoggingDelegate +class EventLogger : public EventLoggingDelegate { public: EventLogger(const T & aEventData) : mEventData(aEventData){}; @@ -44,7 +45,9 @@ CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventOptions aEv ConcreteEventPath path(aEndpoint, aEventData.GetClusterId(), aEventData.GetEventId()); // log the actual event aEventNumber = 0; - return CHIP_NO_ERROR; + EventManagement & logMgmt = chip::app::EventManagement::GetInstance(); + aEventOptions.mPath = path; + return logMgmt.LogEvent(&eventData, aEventOptions, aEventNumber); } } // namespace app diff --git a/src/app/clusters/test-cluster-server/test-cluster-server.cpp b/src/app/clusters/test-cluster-server/test-cluster-server.cpp index 96e8a0246fd486..5ceca8662d94cf 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -449,10 +449,10 @@ bool emberAfTestClusterClusterTestEmitTestEventRequestCallback( const Commands::TestEmitTestEventRequest::DecodableType & commandData) { Commands::TestEmitTestEventResponse::Type responseData; - DataModel::List arg5; - DataModel::List arg6; + //DataModel::List arg5; + //DataModel::List arg6; EventOptions eventOptions; - Events::TestEvent::Type event{ commandData.arg1, commandData.arg2, commandData.arg3, commandData.arg4, arg5, arg6 }; + Events::TestEvent::Type event{ commandData.arg1 }; if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, eventOptions, responseData.value)) { emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); diff --git a/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml index fb890eeebedfa8..33d9cccbdb5a69 100644 --- a/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml @@ -376,11 +376,6 @@ limitations under the License. Command that takes identical arguments to the fields of the TestEvent and logs the TestEvent to the buffer. Command returns an event ID as the response. - - - - - @@ -505,11 +500,6 @@ limitations under the License. Example test event - - - - - diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 42de849d6f870a..ba7e6b04e26c55 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -25306,19 +25306,9 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ ClusterObjectFieldDescriptor(Label="arg1", Tag=0, Type=uint), - ClusterObjectFieldDescriptor(Label="arg2", Tag=1, Type=TestCluster.Enums.SimpleEnum), - ClusterObjectFieldDescriptor(Label="arg3", Tag=2, Type=bool), - ClusterObjectFieldDescriptor(Label="arg4", Tag=3, Type=TestCluster.Structs.SimpleStruct), - ClusterObjectFieldDescriptor(Label="arg5", Tag=4, Type=typing.List[TestCluster.Structs.SimpleStruct]), - ClusterObjectFieldDescriptor(Label="arg6", Tag=5, Type=typing.List[TestCluster.Enums.SimpleEnum]), ]) arg1: 'uint' = 0 - arg2: 'TestCluster.Enums.SimpleEnum' = 0 - arg3: 'bool' = False - arg4: 'TestCluster.Structs.SimpleStruct' = field(default_factory=lambda: TestCluster.Structs.SimpleStruct()) - arg5: 'typing.List[TestCluster.Structs.SimpleStruct]' = field(default_factory=lambda: []) - arg6: 'typing.List[TestCluster.Enums.SimpleEnum]' = field(default_factory=lambda: []) class Attributes: @@ -26614,19 +26604,9 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ ClusterObjectFieldDescriptor(Label="arg1", Tag=1, Type=uint), - ClusterObjectFieldDescriptor(Label="arg2", Tag=2, Type=TestCluster.Enums.SimpleEnum), - ClusterObjectFieldDescriptor(Label="arg3", Tag=3, Type=bool), - ClusterObjectFieldDescriptor(Label="arg4", Tag=4, Type=TestCluster.Structs.SimpleStruct), - ClusterObjectFieldDescriptor(Label="arg5", Tag=5, Type=typing.List[TestCluster.Structs.SimpleStruct], IsArray=True), - ClusterObjectFieldDescriptor(Label="arg6", Tag=6, Type=typing.List[TestCluster.Enums.SimpleEnum], IsArray=True), ]) arg1: 'uint' = 0 - arg2: 'TestCluster.Enums.SimpleEnum' = 0 - arg3: 'bool' = False - arg4: 'TestCluster.Structs.SimpleStruct' = field(default_factory=lambda: TestCluster.Structs.SimpleStruct()) - arg5: typing.List['typing.List[TestCluster.Structs.SimpleStruct]'] = field(default_factory=lambda: []) - arg6: typing.List['typing.List[TestCluster.Enums.SimpleEnum]'] = field(default_factory=lambda: []) @dataclass diff --git a/src/controller/python/test/test_scripts/cluster_objects.py b/src/controller/python/test/test_scripts/cluster_objects.py index 88ee79bb715f5b..51c3cc48be5bcf 100644 --- a/src/controller/python/test/test_scripts/cluster_objects.py +++ b/src/controller/python/test/test_scripts/cluster_objects.py @@ -97,6 +97,17 @@ async def SendCommandWithResponse(cls, devCtrl): if res.returnValue != 5: raise ValueError() + @classmethod + async def SendCommandWithTestClusterEventTrigger(cls, devCtrl): + req = Clusters.TestCluster.Commands.TestEmitTestEventRequest(arg1=1) + res = await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=LIGHTING_ENDPOINT_ID, payload=req) + if not isinstance(res, Clusters.TestCluster.Commands.TestEmitTestEventResponse): + logger.error(f"Unexpected response of type {type(res)} received.") + raise ValueError() + logger.info(f"Received response: {res}") + if res.returnValue != 5: + raise ValueError() + @classmethod async def SendWriteRequest(cls, devCtrl): res = await devCtrl.WriteAttribute(nodeid=NODE_ID, @@ -234,6 +245,7 @@ async def RunTest(cls, devCtrl): await cls.RoundTripTest(devCtrl) await cls.RoundTripTestWithBadEndpoint(devCtrl) await cls.SendCommandWithResponse(devCtrl) + await cls.SendCommandWithTestClusterEventTrigger(devCtrl) await cls.SendWriteRequest(devCtrl) await cls.TestReadAttributeRequests(devCtrl) await cls.TestReadEventRequests(devCtrl) diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h index 847b48085fe5bc..21b85f4b04a261 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h @@ -1932,11 +1932,6 @@ NS_ASSUME_NONNULL_BEGIN @interface CHIPTestClusterClusterTestEmitTestEventRequestParams : NSObject @property (strong, nonatomic) NSNumber * _Nonnull arg1; -@property (strong, nonatomic) NSNumber * _Nonnull arg2; -@property (strong, nonatomic) NSNumber * _Nonnull arg3; -@property (strong, nonatomic) CHIPTestClusterClusterSimpleStruct * _Nonnull arg4; -@property (strong, nonatomic) NSArray * _Nonnull arg5; -@property (strong, nonatomic) NSArray * _Nonnull arg6; - (instancetype)init; @end diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm index c06e298692dca6..f9040c9bc2a63d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm @@ -4118,16 +4118,6 @@ - (instancetype)init if (self = [super init]) { _arg1 = @(0); - - _arg2 = @(0); - - _arg3 = @(0); - - _arg4 = [CHIPTestClusterClusterSimpleStruct new]; - - _arg5 = [NSArray array]; - - _arg6 = [NSArray array]; } return self; } diff --git a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp index 6d3416f8f22840..dd5de60d663908 100644 --- a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp @@ -1846,6 +1846,15 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } break; } + case Commands::TestEmitTestEventRequest::Id: { + Commands::TestEmitTestEventRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfTestClusterClusterTestEmitTestEventRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } case Commands::TestEnumsRequest::Id: { Commands::TestEnumsRequest::DecodableType commandData; TLVError = DataModel::Decode(aDataTlv, commandData); diff --git a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h index d4b099bf99cf53..0eafb5c9197646 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -2613,7 +2613,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0, 0 \ + 22, 22, 22 \ } // Array of device versions diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 907f01b3e4089d..5384201f6dfd3d 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -18608,11 +18608,6 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg1)), arg1)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg2)), arg2)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg3)), arg3)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg4)), arg4)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg5)), arg5)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg6)), arg6)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } @@ -18631,21 +18626,6 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) case to_underlying(Fields::kArg1): ReturnErrorOnFailure(DataModel::Decode(reader, arg1)); break; - case to_underlying(Fields::kArg2): - ReturnErrorOnFailure(DataModel::Decode(reader, arg2)); - break; - case to_underlying(Fields::kArg3): - ReturnErrorOnFailure(DataModel::Decode(reader, arg3)); - break; - case to_underlying(Fields::kArg4): - ReturnErrorOnFailure(DataModel::Decode(reader, arg4)); - break; - case to_underlying(Fields::kArg5): - ReturnErrorOnFailure(DataModel::Decode(reader, arg5)); - break; - case to_underlying(Fields::kArg6): - ReturnErrorOnFailure(DataModel::Decode(reader, arg6)); - break; default: break; } @@ -18665,11 +18645,6 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg1)), arg1)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg2)), arg2)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg3)), arg3)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg4)), arg4)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg5)), arg5)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg6)), arg6)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } @@ -18688,21 +18663,6 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) case to_underlying(Fields::kArg1): ReturnErrorOnFailure(DataModel::Decode(reader, arg1)); break; - case to_underlying(Fields::kArg2): - ReturnErrorOnFailure(DataModel::Decode(reader, arg2)); - break; - case to_underlying(Fields::kArg3): - ReturnErrorOnFailure(DataModel::Decode(reader, arg3)); - break; - case to_underlying(Fields::kArg4): - ReturnErrorOnFailure(DataModel::Decode(reader, arg4)); - break; - case to_underlying(Fields::kArg5): - ReturnErrorOnFailure(DataModel::Decode(reader, arg5)); - break; - case to_underlying(Fields::kArg6): - ReturnErrorOnFailure(DataModel::Decode(reader, arg6)); - break; default: break; } diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 014b7875bf9f8e..50b09be20b7af6 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -31215,11 +31215,6 @@ namespace TestEmitTestEventRequest { enum class Fields { kArg1 = 0, - kArg2 = 1, - kArg3 = 2, - kArg4 = 3, - kArg5 = 4, - kArg6 = 5, }; struct Type @@ -31230,11 +31225,6 @@ struct Type static constexpr ClusterId GetClusterId() { return Clusters::TestCluster::Id; } uint8_t arg1; - SimpleEnum arg2; - bool arg3; - Structs::SimpleStruct::Type arg4; - DataModel::List arg5; - DataModel::List arg6; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; @@ -31250,11 +31240,6 @@ struct DecodableType static constexpr ClusterId GetClusterId() { return Clusters::TestCluster::Id; } uint8_t arg1; - SimpleEnum arg2; - bool arg3; - Structs::SimpleStruct::DecodableType arg4; - DataModel::DecodableList arg5; - DataModel::DecodableList arg6; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace TestEmitTestEventRequest @@ -32230,11 +32215,6 @@ static constexpr EventId kEventId = 0x00000001; enum class Fields { kArg1 = 1, - kArg2 = 2, - kArg3 = 3, - kArg4 = 4, - kArg5 = 5, - kArg6 = 6, }; struct Type @@ -32245,11 +32225,6 @@ struct Type static constexpr ClusterId GetClusterId() { return Clusters::TestCluster::Id; } uint8_t arg1; - SimpleEnum arg2; - bool arg3; - Structs::SimpleStruct::Type arg4; - DataModel::List arg5; - DataModel::List arg6; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; @@ -32262,11 +32237,6 @@ struct DecodableType static constexpr ClusterId GetClusterId() { return Clusters::TestCluster::Id; } uint8_t arg1; - SimpleEnum arg2; - bool arg3; - Structs::SimpleStruct::DecodableType arg4; - DataModel::DecodableList arg5; - DataModel::DecodableList arg6; CHIP_ERROR Decode(TLV::TLVReader & reader); }; diff --git a/zzz_generated/bridge-app/zap-generated/endpoint_config.h b/zzz_generated/bridge-app/zap-generated/endpoint_config.h index d6af2b97980fa9..33b0f92c7b3be4 100644 --- a/zzz_generated/bridge-app/zap-generated/endpoint_config.h +++ b/zzz_generated/bridge-app/zap-generated/endpoint_config.h @@ -924,7 +924,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0 \ + 14, 257 \ } // Array of device versions diff --git a/zzz_generated/controller-clusters/zap-generated/endpoint_config.h b/zzz_generated/controller-clusters/zap-generated/endpoint_config.h index 9a019898e4df25..13f19c2a6e335e 100644 --- a/zzz_generated/controller-clusters/zap-generated/endpoint_config.h +++ b/zzz_generated/controller-clusters/zap-generated/endpoint_config.h @@ -521,7 +521,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0 \ + 22 \ } // Array of device versions diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp b/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp index e0750390385579..9edc3818bdcd48 100644 --- a/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp @@ -187,246 +187,6 @@ CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * o // OtaSoftwareUpdateProvider Cluster Attributes // OnOff Cluster Commands -CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::Off::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get())); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::OffWithEffect(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t effectId, uint8_t effectVariant) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::OffWithEffect::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // effectId: onOffEffectIdentifier - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), effectId)); - // effectVariant: onOffDelayedAllOffEffectVariant - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), effectVariant)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get())); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::On::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get())); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::OnWithRecallGlobalScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::OnWithRecallGlobalScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get())); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::OnWithTimedOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t onOffControl, uint16_t onTime, uint16_t offWaitTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::OnWithTimedOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // onOffControl: onOffControl - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), onOffControl)); - // onTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), onTime)); - // offWaitTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), offWaitTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get())); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::Toggle::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get())); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - // OnOff Cluster Attributes CHIP_ERROR OnOffCluster::ReadAttributeOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClusters.h b/zzz_generated/lighting-app/zap-generated/CHIPClusters.h index 99582b54034c2f..d514557c511a5d 100644 --- a/zzz_generated/lighting-app/zap-generated/CHIPClusters.h +++ b/zzz_generated/lighting-app/zap-generated/CHIPClusters.h @@ -57,16 +57,6 @@ class DLL_EXPORT OnOffCluster : public ClusterBase OnOffCluster() : ClusterBase(app::Clusters::OnOff::Id) {} ~OnOffCluster() {} - // Cluster Commands - CHIP_ERROR Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR OffWithEffect(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t effectId, - uint8_t effectVariant); - CHIP_ERROR On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR OnWithRecallGlobalScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR OnWithTimedOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t onOffControl, uint16_t onTime, uint16_t offWaitTime); - CHIP_ERROR Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - // Cluster Attributes CHIP_ERROR ReadAttributeOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR SubscribeAttributeOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, @@ -103,8 +93,6 @@ class DLL_EXPORT OnOffCluster : public ClusterBase CHIP_ERROR SubscribeAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t minInterval, uint16_t maxInterval); CHIP_ERROR ReportAttributeClusterRevision(Callback::Cancelable * onReportCallback); - -private: }; } // namespace Controller diff --git a/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp index 08bede60e352f0..6e9b21e99a8dd0 100644 --- a/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp @@ -904,7 +904,82 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - ReportCommandUnsupported(apCommandObj, aCommandPath); + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::Off::Id: { + Commands::Off::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OffWithEffect::Id: { + Commands::OffWithEffect::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOffWithEffectCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::On::Id: { + Commands::On::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OnWithRecallGlobalScene::Id: { + Commands::OnWithRecallGlobalScene::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnWithRecallGlobalSceneCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OnWithTimedOff::Id: { + Commands::OnWithTimedOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnWithTimedOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Toggle::Id: { + Commands::Toggle::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterToggleCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + ReportCommandUnsupported(apCommandObj, aCommandPath); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } } } // namespace OnOff diff --git a/zzz_generated/lighting-app/zap-generated/endpoint_config.h b/zzz_generated/lighting-app/zap-generated/endpoint_config.h index 8201db083252f1..98cae9e048ca25 100644 --- a/zzz_generated/lighting-app/zap-generated/endpoint_config.h +++ b/zzz_generated/lighting-app/zap-generated/endpoint_config.h @@ -976,7 +976,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0, 0 \ + 22, 257, 259 \ } // Array of device versions diff --git a/zzz_generated/lock-app/zap-generated/endpoint_config.h b/zzz_generated/lock-app/zap-generated/endpoint_config.h index ae6136fd261ce0..ba7229863a445c 100644 --- a/zzz_generated/lock-app/zap-generated/endpoint_config.h +++ b/zzz_generated/lock-app/zap-generated/endpoint_config.h @@ -908,7 +908,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0 \ + 22, 10 \ } // Array of device versions diff --git a/zzz_generated/ota-provider-app/zap-generated/endpoint_config.h b/zzz_generated/ota-provider-app/zap-generated/endpoint_config.h index d137758c3bf789..ed71cff11a85c6 100644 --- a/zzz_generated/ota-provider-app/zap-generated/endpoint_config.h +++ b/zzz_generated/ota-provider-app/zap-generated/endpoint_config.h @@ -211,7 +211,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0 \ + 22 \ } // Array of device versions diff --git a/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h b/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h index 1eb504dc861c9b..4e9b63188b20c8 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h +++ b/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h @@ -219,7 +219,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0 \ + 22 \ } // Array of device versions diff --git a/zzz_generated/placeholder/app1/zap-generated/endpoint_config.h b/zzz_generated/placeholder/app1/zap-generated/endpoint_config.h index 04cf30fb5daafb..47928f845eb8d4 100644 --- a/zzz_generated/placeholder/app1/zap-generated/endpoint_config.h +++ b/zzz_generated/placeholder/app1/zap-generated/endpoint_config.h @@ -394,7 +394,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0 \ + 65280, 258 \ } // Array of device versions diff --git a/zzz_generated/placeholder/app2/zap-generated/endpoint_config.h b/zzz_generated/placeholder/app2/zap-generated/endpoint_config.h index 48bebe287d92b2..46db468d19aae4 100644 --- a/zzz_generated/placeholder/app2/zap-generated/endpoint_config.h +++ b/zzz_generated/placeholder/app2/zap-generated/endpoint_config.h @@ -373,7 +373,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0 \ + 65280, 257 \ } // Array of device versions diff --git a/zzz_generated/pump-app/zap-generated/endpoint_config.h b/zzz_generated/pump-app/zap-generated/endpoint_config.h index 74d8df0db7549e..c4a784a403803e 100644 --- a/zzz_generated/pump-app/zap-generated/endpoint_config.h +++ b/zzz_generated/pump-app/zap-generated/endpoint_config.h @@ -959,7 +959,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0 \ + 771, 771 \ } // Array of device versions diff --git a/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h b/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h index 96c66938528edb..ed910046a868a2 100644 --- a/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h +++ b/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h @@ -848,7 +848,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0 \ + 772, 772 \ } // Array of device versions diff --git a/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h b/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h index 4b90cdf52fc8b3..c5be871f5b355b 100644 --- a/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h +++ b/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h @@ -470,7 +470,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0 \ + 22, 22 \ } // Array of device versions diff --git a/zzz_generated/thermostat/zap-generated/endpoint_config.h b/zzz_generated/thermostat/zap-generated/endpoint_config.h index 97b0c2112a5bba..e4cc405a2bd594 100644 --- a/zzz_generated/thermostat/zap-generated/endpoint_config.h +++ b/zzz_generated/thermostat/zap-generated/endpoint_config.h @@ -1060,7 +1060,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0 \ + 22, 769 \ } // Array of device versions diff --git a/zzz_generated/tv-app/zap-generated/endpoint_config.h b/zzz_generated/tv-app/zap-generated/endpoint_config.h index f0c153f9b71043..c2f5f563273d7f 100644 --- a/zzz_generated/tv-app/zap-generated/endpoint_config.h +++ b/zzz_generated/tv-app/zap-generated/endpoint_config.h @@ -1606,7 +1606,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0, 0, 0, 0, 0 \ + 22, 35, 34, 36, 36, 36 \ } // Array of device versions diff --git a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h index 4bdc3730ba4e84..d0300054b7ad26 100644 --- a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h +++ b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h @@ -1876,7 +1876,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0, 0 \ + 22, 22, 22 \ } // Array of device versions diff --git a/zzz_generated/window-app/zap-generated/endpoint_config.h b/zzz_generated/window-app/zap-generated/endpoint_config.h index 2db2f2715f2500..54b3787b2d3f8b 100644 --- a/zzz_generated/window-app/zap-generated/endpoint_config.h +++ b/zzz_generated/window-app/zap-generated/endpoint_config.h @@ -957,7 +957,7 @@ // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0, 0, 0 \ + 514, 514, 514 \ } // Array of device versions