diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index d39dd74c2d2819..151ec1beeb21de 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -230,6 +230,11 @@ static void CauseReadClientFailure( } #endif +static bool CheckMemberOfType(NSDictionary * responseValue, NSString * memberName, Class expectedClass, + NSString * errorMessage, NSError * __autoreleasing * error); +static void LogStringAndReturnError(NSString * errorStr, CHIP_ERROR errorCode, NSError * __autoreleasing * error); +static void LogStringAndReturnError(NSString * errorStr, MTRErrorCode errorCode, NSError * __autoreleasing * error); + @implementation MTRReadClientContainer - (void)onDone { @@ -1807,6 +1812,62 @@ + (NSDictionary *)eventReportForHeader:(const chip::app::EventHeader &)header an timestampKey : timestampValue }; } + ++ (System::PacketBufferHandle)_responseDataForCommand:(NSDictionary *)responseValue + clusterID:(chip::ClusterId)clusterID + commandID:(chip::CommandId)commandID + error:(NSError * __autoreleasing *)error +{ + if (!CheckMemberOfType(responseValue, MTRCommandPathKey, [MTRCommandPath class], + @"response-value command path is not an MTRCommandPath.", error)) { + return System::PacketBufferHandle(); + } + + MTRCommandPath * path = responseValue[MTRCommandPathKey]; + + if (![path.cluster isEqualToNumber:@(clusterID)]) { + LogStringAndReturnError([NSString stringWithFormat:@"Expected cluster id %@ but got %@", path.cluster, @(clusterID)], + MTRErrorCodeSchemaMismatch, error); + return System::PacketBufferHandle(); + } + + if (![path.command isEqualToNumber:@(commandID)]) { + LogStringAndReturnError([NSString stringWithFormat:@"Expected command id %@ but got %@", path.command, @(commandID)], + MTRErrorCodeSchemaMismatch, error); + return System::PacketBufferHandle(); + } + + if (!CheckMemberOfType( + responseValue, MTRDataKey, [NSDictionary class], @"response-value data is not a data-value dictionary.", error)) { + return System::PacketBufferHandle(); + } + + NSDictionary * data = responseValue[MTRDataKey]; + + auto buffer = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSizeWithoutReserve, 0); + if (buffer.IsNull()) { + LogStringAndReturnError(@"Unable to allocate encoding buffer", CHIP_ERROR_NO_MEMORY, error); + return System::PacketBufferHandle(); + } + + System::PacketBufferTLVWriter writer; + // Commands never need chained buffers, since they cannot be chunked. + writer.Init(std::move(buffer), /* useChainedBuffers = */ false); + + CHIP_ERROR errorCode = MTREncodeTLVFromDataValueDictionary(data, writer, TLV::AnonymousTag()); + if (errorCode != CHIP_NO_ERROR) { + LogStringAndReturnError(@"Unable to encode data-value to TLV", errorCode, error); + return System::PacketBufferHandle(); + } + + errorCode = writer.Finalize(&buffer); + if (errorCode != CHIP_NO_ERROR) { + LogStringAndReturnError(@"Unable to encode data-value to TLV", errorCode, error); + return System::PacketBufferHandle(); + } + + return buffer; +} @end @implementation MTRBaseDevice (Deprecated) diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h b/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h index c0c709fce7e7dc..4853d60be88471 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h @@ -26,6 +26,7 @@ #include #include #include +#include @class MTRDeviceController; @@ -83,6 +84,19 @@ static inline MTRTransportType MTRMakeTransportType(chip::Transport::Type type) * (e.g. when TLV decoding failed). */ + (NSDictionary *)eventReportForHeader:(const chip::app::EventHeader &)header andData:(id _Nullable)data; + +/** + * Extract a data-value for the given response command from the given response-value + * dictionary, encode it to TLV, and return a System::PacketBufferHandle with + * the encoded data. + * + * Will return a null handle and an error if the given response-value does not represent a + * data command response or is the wrong response command, or if encoding to TLV fails. + */ ++ (chip::System::PacketBufferHandle)_responseDataForCommand:(NSDictionary *)responseValue + clusterID:(chip::ClusterId)clusterID + commandID:(chip::CommandId)commandID + error:(NSError * __autoreleasing *)error; @end @interface MTRClusterPath () diff --git a/src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt b/src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt index ec16a56876b224..90fc5ebeda1d70 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt @@ -3,6 +3,7 @@ #import "MTRCallbackBridge.h" #import "MTRStructsObjc.h" #import "MTRCommandPayloadsObjc.h" +#import "MTRCommandPayloads_Internal.h" #include diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt index 4dcdba48065f7c..963f425cee7d08 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt @@ -1,6 +1,13 @@ {{> header excludeZapComment=true}} #import "MTRCommandPayloadsObjc.h" +#import "MTRCommandPayloads_Internal.h" +#import "MTRBaseDevice_Internal.h" +#import "MTRError_Internal.h" +#import "MTRLogging_Internal.h" + +#include +#include NS_ASSUME_NONNULL_BEGIN @@ -58,6 +65,48 @@ NS_ASSUME_NONNULL_BEGIN {{/if}} {{/zcl_command_arguments}} +{{#if (isStrEqual source "server")}} +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @ { NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} +{{/if}} + @end {{/if}} {{/inline}} @@ -70,6 +119,21 @@ NS_ASSUME_NONNULL_BEGIN {{> completeImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) includeRenamedProperties=false}} +{{#if (isStrEqual source "server")}} + +@implementation MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType &)decodableStruct +{ + {{#zcl_command_arguments}} + { + {{>decode_value target=(concat "self." (asStructPropertyName label)) source=(concat "decodableStruct." (asLowerCamelCase label)) cluster=parent.parent.name errorCode="return err;" depth=0}} + } + {{/zcl_command_arguments}} + return CHIP_NO_ERROR; +} +@end +{{/if}} {{#if (or (not (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) (compatClusterNameRemapping parent.name))) (not (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatCommandNameRemapping parent.name name))))}} {{> oldNameImpl cluster=(compatClusterNameRemapping parent.name) diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt index e6778ba0bfb062..e44945b52ec73e 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt @@ -68,6 +68,21 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs {{availability "" api="Timed Invoke for server to client commands" deprecationMessage="Timed invoke does not make sense for server to client commands"}}; {{/if}} +{{#if (isStrEqual source "server")}} + +/** + * Initialize an MTR{{cluster}}Cluster{{command}}Params with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; +{{/if}} @end {{/if}} {{/inline}} diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloads_Internal.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloads_Internal.zapt new file mode 100644 index 00000000000000..84fb84e238c07f --- /dev/null +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloads_Internal.zapt @@ -0,0 +1,26 @@ +{{> header excludeZapComment=true}} + +#import + +#include + +NS_ASSUME_NONNULL_BEGIN + +{{#zcl_clusters}} +{{#zcl_commands}} +{{! We only need to generate conversion functions for the server-generated commands }} +{{#if (isStrEqual source "server")}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) isForCommandPayload=true)}} + +@interface MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType &)decodableStruct; + +@end + +{{/if}} +{{/if}} +{{/zcl_commands}} +{{/zcl_clusters}} + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/src/darwin/Framework/CHIP/templates/partials/MTRCallbackBridge.zapt b/src/darwin/Framework/CHIP/templates/partials/MTRCallbackBridge.zapt index 06fc884dbf0a9a..8c4b60ca54a576 100644 --- a/src/darwin/Framework/CHIP/templates/partials/MTRCallbackBridge.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/MTRCallbackBridge.zapt @@ -78,11 +78,11 @@ void MTR{{> @partial-block}}Bridge::OnSuccessFn(void * context DispatchSuccess(context, nil); {{else if (isStrEqual partial-type "Command")}} auto * response = [MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params new]; - {{#zcl_command_arguments}} - { - {{>decode_value target=(concat "response." (asStructPropertyName label)) source=(concat "data." (asLowerCamelCase label)) cluster=parent.parent.name errorCode="OnFailureFn(context, err); return;" depth=0}} + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } - {{/zcl_command_arguments}} DispatchSuccess(context, response); {{else if (isStrEqual partial-type "CommandStatus")}} DispatchSuccess(context, nil); diff --git a/src/darwin/Framework/CHIP/templates/templates.json b/src/darwin/Framework/CHIP/templates/templates.json index 6561d17ee5c715..0a75f7adeb94d5 100644 --- a/src/darwin/Framework/CHIP/templates/templates.json +++ b/src/darwin/Framework/CHIP/templates/templates.json @@ -113,6 +113,11 @@ "name": "Objc reflections of MTR command payloads header", "output": "src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm" }, + { + "path": "MTRCommandPayloads_Internal.zapt", + "name": "Internal methods for objc reflections of MTR command payloads header", + "output": "src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h" + }, { "path": "MTRAttributeTLVValueDecoder-src.zapt", "name": "Decode TLV attribute values into Objc objects", diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm index 0fecca0312771c..76a7ca003ecd89 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm @@ -17,6 +17,7 @@ #import "MTRCallbackBridge.h" #import "MTRCommandPayloadsObjc.h" +#import "MTRCommandPayloads_Internal.h" #import "MTRStructsObjc.h" #include @@ -11366,11 +11367,10 @@ void * context, const chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType & data) { auto * response = [MTRGroupsClusterAddGroupResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11379,16 +11379,10 @@ void * context, const chip::app::Clusters::Groups::Commands::ViewGroupResponse::DecodableType & data) { auto * response = [MTRGroupsClusterViewGroupResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; - } - { - response.groupName = [[NSString alloc] initWithBytes:data.groupName.data() - length:data.groupName.size() - encoding:NSUTF8StringEncoding]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11397,30 +11391,10 @@ void * context, const chip::app::Clusters::Groups::Commands::GetGroupMembershipResponse::DecodableType & data) { auto * response = [MTRGroupsClusterGetGroupMembershipResponseParams new]; - { - if (data.capacity.IsNull()) { - response.capacity = nil; - } else { - response.capacity = [NSNumber numberWithUnsignedChar:data.capacity.Value()]; - } - } - { - { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = data.groupList.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - NSNumber * newElement_0; - newElement_0 = [NSNumber numberWithUnsignedShort:entry_0]; - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.groupList = array_0; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11429,11 +11403,10 @@ void * context, const chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType & data) { auto * response = [MTRGroupsClusterRemoveGroupResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11442,14 +11415,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::AddSceneResponse::DecodableType & data) { auto * response = [MTRScenesClusterAddSceneResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; - } - { - response.sceneID = [NSNumber numberWithUnsignedChar:data.sceneID]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11458,90 +11427,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::ViewSceneResponse::DecodableType & data) { auto * response = [MTRScenesClusterViewSceneResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; - } - { - response.sceneID = [NSNumber numberWithUnsignedChar:data.sceneID]; - } - { - if (data.transitionTime.HasValue()) { - response.transitionTime = [NSNumber numberWithUnsignedShort:data.transitionTime.Value()]; - } else { - response.transitionTime = nil; - } - } - { - if (data.sceneName.HasValue()) { - response.sceneName = [[NSString alloc] initWithBytes:data.sceneName.Value().data() - length:data.sceneName.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.sceneName = nil; - } - } - { - if (data.extensionFieldSets.HasValue()) { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.extensionFieldSets.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - MTRScenesClusterExtensionFieldSet * newElement_1; - newElement_1 = [MTRScenesClusterExtensionFieldSet new]; - newElement_1.clusterID = [NSNumber numberWithUnsignedInt:entry_1.clusterID]; - { // Scope for our temporary variables - auto * array_3 = [NSMutableArray new]; - auto iter_3 = entry_1.attributeValueList.begin(); - while (iter_3.Next()) { - auto & entry_3 = iter_3.GetValue(); - MTRScenesClusterAttributeValuePair * newElement_3; - newElement_3 = [MTRScenesClusterAttributeValuePair new]; - if (entry_3.attributeID.HasValue()) { - newElement_3.attributeID = [NSNumber numberWithUnsignedInt:entry_3.attributeID.Value()]; - } else { - newElement_3.attributeID = nil; - } - { // Scope for our temporary variables - auto * array_5 = [NSMutableArray new]; - auto iter_5 = entry_3.attributeValue.begin(); - while (iter_5.Next()) { - auto & entry_5 = iter_5.GetValue(); - NSNumber * newElement_5; - newElement_5 = [NSNumber numberWithUnsignedChar:entry_5]; - [array_5 addObject:newElement_5]; - } - CHIP_ERROR err = iter_5.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - newElement_3.attributeValue = array_5; - } - [array_3 addObject:newElement_3]; - } - CHIP_ERROR err = iter_3.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - newElement_1.attributeValueList = array_3; - } - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.extensionFieldSets = array_1; - } - } else { - response.extensionFieldSets = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11550,14 +11439,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::RemoveSceneResponse::DecodableType & data) { auto * response = [MTRScenesClusterRemoveSceneResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; - } - { - response.sceneID = [NSNumber numberWithUnsignedChar:data.sceneID]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11566,11 +11451,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::RemoveAllScenesResponse::DecodableType & data) { auto * response = [MTRScenesClusterRemoveAllScenesResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11579,14 +11463,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::StoreSceneResponse::DecodableType & data) { auto * response = [MTRScenesClusterStoreSceneResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; - } - { - response.sceneID = [NSNumber numberWithUnsignedChar:data.sceneID]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11595,40 +11475,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::GetSceneMembershipResponse::DecodableType & data) { auto * response = [MTRScenesClusterGetSceneMembershipResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - if (data.capacity.IsNull()) { - response.capacity = nil; - } else { - response.capacity = [NSNumber numberWithUnsignedChar:data.capacity.Value()]; - } - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; - } - { - if (data.sceneList.HasValue()) { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.sceneList.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - NSNumber * newElement_1; - newElement_1 = [NSNumber numberWithUnsignedChar:entry_1]; - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.sceneList = array_1; - } - } else { - response.sceneList = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11637,14 +11487,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::EnhancedAddSceneResponse::DecodableType & data) { auto * response = [MTRScenesClusterEnhancedAddSceneResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; - } - { - response.sceneID = [NSNumber numberWithUnsignedChar:data.sceneID]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11653,90 +11499,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::EnhancedViewSceneResponse::DecodableType & data) { auto * response = [MTRScenesClusterEnhancedViewSceneResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupID = [NSNumber numberWithUnsignedShort:data.groupID]; - } - { - response.sceneID = [NSNumber numberWithUnsignedChar:data.sceneID]; - } - { - if (data.transitionTime.HasValue()) { - response.transitionTime = [NSNumber numberWithUnsignedShort:data.transitionTime.Value()]; - } else { - response.transitionTime = nil; - } - } - { - if (data.sceneName.HasValue()) { - response.sceneName = [[NSString alloc] initWithBytes:data.sceneName.Value().data() - length:data.sceneName.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.sceneName = nil; - } - } - { - if (data.extensionFieldSets.HasValue()) { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.extensionFieldSets.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - MTRScenesClusterExtensionFieldSet * newElement_1; - newElement_1 = [MTRScenesClusterExtensionFieldSet new]; - newElement_1.clusterID = [NSNumber numberWithUnsignedInt:entry_1.clusterID]; - { // Scope for our temporary variables - auto * array_3 = [NSMutableArray new]; - auto iter_3 = entry_1.attributeValueList.begin(); - while (iter_3.Next()) { - auto & entry_3 = iter_3.GetValue(); - MTRScenesClusterAttributeValuePair * newElement_3; - newElement_3 = [MTRScenesClusterAttributeValuePair new]; - if (entry_3.attributeID.HasValue()) { - newElement_3.attributeID = [NSNumber numberWithUnsignedInt:entry_3.attributeID.Value()]; - } else { - newElement_3.attributeID = nil; - } - { // Scope for our temporary variables - auto * array_5 = [NSMutableArray new]; - auto iter_5 = entry_3.attributeValue.begin(); - while (iter_5.Next()) { - auto & entry_5 = iter_5.GetValue(); - NSNumber * newElement_5; - newElement_5 = [NSNumber numberWithUnsignedChar:entry_5]; - [array_5 addObject:newElement_5]; - } - CHIP_ERROR err = iter_5.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - newElement_3.attributeValue = array_5; - } - [array_3 addObject:newElement_3]; - } - CHIP_ERROR err = iter_3.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - newElement_1.attributeValueList = array_3; - } - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.extensionFieldSets = array_1; - } - } else { - response.extensionFieldSets = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11745,14 +11511,10 @@ void * context, const chip::app::Clusters::Scenes::Commands::CopySceneResponse::DecodableType & data) { auto * response = [MTRScenesClusterCopySceneResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:data.status]; - } - { - response.groupIdentifierFrom = [NSNumber numberWithUnsignedShort:data.groupIdentifierFrom]; - } - { - response.sceneIdentifierFrom = [NSNumber numberWithUnsignedChar:data.sceneIdentifierFrom]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11761,62 +11523,10 @@ void * context, const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::DecodableType & data) { auto * response = [MTROTASoftwareUpdateProviderClusterQueryImageResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.delayedActionTime.HasValue()) { - response.delayedActionTime = [NSNumber numberWithUnsignedInt:data.delayedActionTime.Value()]; - } else { - response.delayedActionTime = nil; - } - } - { - if (data.imageURI.HasValue()) { - response.imageURI = [[NSString alloc] initWithBytes:data.imageURI.Value().data() - length:data.imageURI.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.imageURI = nil; - } - } - { - if (data.softwareVersion.HasValue()) { - response.softwareVersion = [NSNumber numberWithUnsignedInt:data.softwareVersion.Value()]; - } else { - response.softwareVersion = nil; - } - } - { - if (data.softwareVersionString.HasValue()) { - response.softwareVersionString = [[NSString alloc] initWithBytes:data.softwareVersionString.Value().data() - length:data.softwareVersionString.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.softwareVersionString = nil; - } - } - { - if (data.updateToken.HasValue()) { - response.updateToken = [NSData dataWithBytes:data.updateToken.Value().data() length:data.updateToken.Value().size()]; - } else { - response.updateToken = nil; - } - } - { - if (data.userConsentNeeded.HasValue()) { - response.userConsentNeeded = [NSNumber numberWithBool:data.userConsentNeeded.Value()]; - } else { - response.userConsentNeeded = nil; - } - } - { - if (data.metadataForRequestor.HasValue()) { - response.metadataForRequestor = [NSData dataWithBytes:data.metadataForRequestor.Value().data() - length:data.metadataForRequestor.Value().size()]; - } else { - response.metadataForRequestor = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11825,11 +11535,10 @@ void * context, const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::DecodableType & data) { auto * response = [MTROTASoftwareUpdateProviderClusterApplyUpdateResponseParams new]; - { - response.action = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.action)]; - } - { - response.delayedActionTime = [NSNumber numberWithUnsignedInt:data.delayedActionTime]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11838,13 +11547,10 @@ void * context, const chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafeResponse::DecodableType & data) { auto * response = [MTRGeneralCommissioningClusterArmFailSafeResponseParams new]; - { - response.errorCode = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.errorCode)]; - } - { - response.debugText = [[NSString alloc] initWithBytes:data.debugText.data() - length:data.debugText.size() - encoding:NSUTF8StringEncoding]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11853,13 +11559,10 @@ void * context, const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType & data) { auto * response = [MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams new]; - { - response.errorCode = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.errorCode)]; - } - { - response.debugText = [[NSString alloc] initWithBytes:data.debugText.data() - length:data.debugText.size() - encoding:NSUTF8StringEncoding]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11868,13 +11571,10 @@ void * context, const chip::app::Clusters::GeneralCommissioning::Commands::CommissioningCompleteResponse::DecodableType & data) { auto * response = [MTRGeneralCommissioningClusterCommissioningCompleteResponseParams new]; - { - response.errorCode = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.errorCode)]; - } - { - response.debugText = [[NSString alloc] initWithBytes:data.debugText.data() - length:data.debugText.size() - encoding:NSUTF8StringEncoding]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11883,78 +11583,10 @@ void * context, const chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworksResponse::DecodableType & data) { auto * response = [MTRNetworkCommissioningClusterScanNetworksResponseParams new]; - { - response.networkingStatus = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.networkingStatus)]; - } - { - if (data.debugText.HasValue()) { - response.debugText = [[NSString alloc] initWithBytes:data.debugText.Value().data() - length:data.debugText.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.debugText = nil; - } - } - { - if (data.wiFiScanResults.HasValue()) { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.wiFiScanResults.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - MTRNetworkCommissioningClusterWiFiInterfaceScanResult * newElement_1; - newElement_1 = [MTRNetworkCommissioningClusterWiFiInterfaceScanResult new]; - newElement_1.security = [NSNumber numberWithUnsignedChar:entry_1.security.Raw()]; - newElement_1.ssid = [NSData dataWithBytes:entry_1.ssid.data() length:entry_1.ssid.size()]; - newElement_1.bssid = [NSData dataWithBytes:entry_1.bssid.data() length:entry_1.bssid.size()]; - newElement_1.channel = [NSNumber numberWithUnsignedShort:entry_1.channel]; - newElement_1.wiFiBand = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1.wiFiBand)]; - newElement_1.rssi = [NSNumber numberWithChar:entry_1.rssi]; - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.wiFiScanResults = array_1; - } - } else { - response.wiFiScanResults = nil; - } - } - { - if (data.threadScanResults.HasValue()) { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.threadScanResults.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - MTRNetworkCommissioningClusterThreadInterfaceScanResult * newElement_1; - newElement_1 = [MTRNetworkCommissioningClusterThreadInterfaceScanResult new]; - newElement_1.panId = [NSNumber numberWithUnsignedShort:entry_1.panId]; - newElement_1.extendedPanId = [NSNumber numberWithUnsignedLongLong:entry_1.extendedPanId]; - newElement_1.networkName = [[NSString alloc] initWithBytes:entry_1.networkName.data() - length:entry_1.networkName.size() - encoding:NSUTF8StringEncoding]; - newElement_1.channel = [NSNumber numberWithUnsignedShort:entry_1.channel]; - newElement_1.version = [NSNumber numberWithUnsignedChar:entry_1.version]; - newElement_1.extendedAddress = [NSData dataWithBytes:entry_1.extendedAddress.data() - length:entry_1.extendedAddress.size()]; - newElement_1.rssi = [NSNumber numberWithChar:entry_1.rssi]; - newElement_1.lqi = [NSNumber numberWithUnsignedChar:entry_1.lqi]; - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.threadScanResults = array_1; - } - } else { - response.threadScanResults = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11963,24 +11595,10 @@ void * context, const chip::app::Clusters::NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType & data) { auto * response = [MTRNetworkCommissioningClusterNetworkConfigResponseParams new]; - { - response.networkingStatus = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.networkingStatus)]; - } - { - if (data.debugText.HasValue()) { - response.debugText = [[NSString alloc] initWithBytes:data.debugText.Value().data() - length:data.debugText.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.debugText = nil; - } - } - { - if (data.networkIndex.HasValue()) { - response.networkIndex = [NSNumber numberWithUnsignedChar:data.networkIndex.Value()]; - } else { - response.networkIndex = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -11989,24 +11607,10 @@ void * context, const chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType & data) { auto * response = [MTRNetworkCommissioningClusterConnectNetworkResponseParams new]; - { - response.networkingStatus = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.networkingStatus)]; - } - { - if (data.debugText.HasValue()) { - response.debugText = [[NSString alloc] initWithBytes:data.debugText.Value().data() - length:data.debugText.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.debugText = nil; - } - } - { - if (data.errorValue.IsNull()) { - response.errorValue = nil; - } else { - response.errorValue = [NSNumber numberWithInt:data.errorValue.Value()]; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12015,25 +11619,10 @@ void * context, const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType & data) { auto * response = [MTRDiagnosticLogsClusterRetrieveLogsResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - response.logContent = [NSData dataWithBytes:data.logContent.data() length:data.logContent.size()]; - } - { - if (data.UTCTimeStamp.HasValue()) { - response.utcTimeStamp = [NSNumber numberWithUnsignedLongLong:data.UTCTimeStamp.Value()]; - } else { - response.utcTimeStamp = nil; - } - } - { - if (data.timeSinceBoot.HasValue()) { - response.timeSinceBoot = [NSNumber numberWithUnsignedLongLong:data.timeSinceBoot.Value()]; - } else { - response.timeSinceBoot = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12042,13 +11631,10 @@ void * context, const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType & data) { auto * response = [MTROperationalCredentialsClusterAttestationResponseParams new]; - { - response.attestationElements = [NSData dataWithBytes:data.attestationElements.data() - length:data.attestationElements.size()]; - } - { - response.attestationSignature = [NSData dataWithBytes:data.attestationSignature.data() - length:data.attestationSignature.size()]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12057,8 +11643,10 @@ void * context, const chip::app::Clusters::OperationalCredentials::Commands::CertificateChainResponse::DecodableType & data) { auto * response = [MTROperationalCredentialsClusterCertificateChainResponseParams new]; - { - response.certificate = [NSData dataWithBytes:data.certificate.data() length:data.certificate.size()]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12067,12 +11655,10 @@ void * context, const chip::app::Clusters::OperationalCredentials::Commands::CSRResponse::DecodableType & data) { auto * response = [MTROperationalCredentialsClusterCSRResponseParams new]; - { - response.nocsrElements = [NSData dataWithBytes:data.NOCSRElements.data() length:data.NOCSRElements.size()]; - } - { - response.attestationSignature = [NSData dataWithBytes:data.attestationSignature.data() - length:data.attestationSignature.size()]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12081,24 +11667,10 @@ void * context, const chip::app::Clusters::OperationalCredentials::Commands::NOCResponse::DecodableType & data) { auto * response = [MTROperationalCredentialsClusterNOCResponseParams new]; - { - response.statusCode = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.statusCode)]; - } - { - if (data.fabricIndex.HasValue()) { - response.fabricIndex = [NSNumber numberWithUnsignedChar:data.fabricIndex.Value()]; - } else { - response.fabricIndex = nil; - } - } - { - if (data.debugText.HasValue()) { - response.debugText = [[NSString alloc] initWithBytes:data.debugText.Value().data() - length:data.debugText.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.debugText = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12107,44 +11679,10 @@ void * context, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType & data) { auto * response = [MTRGroupKeyManagementClusterKeySetReadResponseParams new]; - { - response.groupKeySet = [MTRGroupKeyManagementClusterGroupKeySetStruct new]; - response.groupKeySet.groupKeySetID = [NSNumber numberWithUnsignedShort:data.groupKeySet.groupKeySetID]; - response.groupKeySet.groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:chip::to_underlying(data.groupKeySet.groupKeySecurityPolicy)]; - if (data.groupKeySet.epochKey0.IsNull()) { - response.groupKeySet.epochKey0 = nil; - } else { - response.groupKeySet.epochKey0 = [NSData dataWithBytes:data.groupKeySet.epochKey0.Value().data() - length:data.groupKeySet.epochKey0.Value().size()]; - } - if (data.groupKeySet.epochStartTime0.IsNull()) { - response.groupKeySet.epochStartTime0 = nil; - } else { - response.groupKeySet.epochStartTime0 = [NSNumber numberWithUnsignedLongLong:data.groupKeySet.epochStartTime0.Value()]; - } - if (data.groupKeySet.epochKey1.IsNull()) { - response.groupKeySet.epochKey1 = nil; - } else { - response.groupKeySet.epochKey1 = [NSData dataWithBytes:data.groupKeySet.epochKey1.Value().data() - length:data.groupKeySet.epochKey1.Value().size()]; - } - if (data.groupKeySet.epochStartTime1.IsNull()) { - response.groupKeySet.epochStartTime1 = nil; - } else { - response.groupKeySet.epochStartTime1 = [NSNumber numberWithUnsignedLongLong:data.groupKeySet.epochStartTime1.Value()]; - } - if (data.groupKeySet.epochKey2.IsNull()) { - response.groupKeySet.epochKey2 = nil; - } else { - response.groupKeySet.epochKey2 = [NSData dataWithBytes:data.groupKeySet.epochKey2.Value().data() - length:data.groupKeySet.epochKey2.Value().size()]; - } - if (data.groupKeySet.epochStartTime2.IsNull()) { - response.groupKeySet.epochStartTime2 = nil; - } else { - response.groupKeySet.epochStartTime2 = [NSNumber numberWithUnsignedLongLong:data.groupKeySet.epochStartTime2.Value()]; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12153,23 +11691,10 @@ void * context, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType & data) { auto * response = [MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams new]; - { - { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = data.groupKeySetIDs.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - NSNumber * newElement_0; - newElement_0 = [NSNumber numberWithUnsignedShort:entry_0]; - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.groupKeySetIDs = array_0; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12178,49 +11703,10 @@ void * context, const chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType & data) { auto * response = [MTRDoorLockClusterGetWeekDayScheduleResponseParams new]; - { - response.weekDayIndex = [NSNumber numberWithUnsignedChar:data.weekDayIndex]; - } - { - response.userIndex = [NSNumber numberWithUnsignedShort:data.userIndex]; - } - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.daysMask.HasValue()) { - response.daysMask = [NSNumber numberWithUnsignedChar:data.daysMask.Value().Raw()]; - } else { - response.daysMask = nil; - } - } - { - if (data.startHour.HasValue()) { - response.startHour = [NSNumber numberWithUnsignedChar:data.startHour.Value()]; - } else { - response.startHour = nil; - } - } - { - if (data.startMinute.HasValue()) { - response.startMinute = [NSNumber numberWithUnsignedChar:data.startMinute.Value()]; - } else { - response.startMinute = nil; - } - } - { - if (data.endHour.HasValue()) { - response.endHour = [NSNumber numberWithUnsignedChar:data.endHour.Value()]; - } else { - response.endHour = nil; - } - } - { - if (data.endMinute.HasValue()) { - response.endMinute = [NSNumber numberWithUnsignedChar:data.endMinute.Value()]; - } else { - response.endMinute = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12229,28 +11715,10 @@ void * context, const chip::app::Clusters::DoorLock::Commands::GetYearDayScheduleResponse::DecodableType & data) { auto * response = [MTRDoorLockClusterGetYearDayScheduleResponseParams new]; - { - response.yearDayIndex = [NSNumber numberWithUnsignedChar:data.yearDayIndex]; - } - { - response.userIndex = [NSNumber numberWithUnsignedShort:data.userIndex]; - } - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.localStartTime.HasValue()) { - response.localStartTime = [NSNumber numberWithUnsignedInt:data.localStartTime.Value()]; - } else { - response.localStartTime = nil; - } - } - { - if (data.localEndTime.HasValue()) { - response.localEndTime = [NSNumber numberWithUnsignedInt:data.localEndTime.Value()]; - } else { - response.localEndTime = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12259,32 +11727,10 @@ void * context, const chip::app::Clusters::DoorLock::Commands::GetHolidayScheduleResponse::DecodableType & data) { auto * response = [MTRDoorLockClusterGetHolidayScheduleResponseParams new]; - { - response.holidayIndex = [NSNumber numberWithUnsignedChar:data.holidayIndex]; - } - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.localStartTime.HasValue()) { - response.localStartTime = [NSNumber numberWithUnsignedInt:data.localStartTime.Value()]; - } else { - response.localStartTime = nil; - } - } - { - if (data.localEndTime.HasValue()) { - response.localEndTime = [NSNumber numberWithUnsignedInt:data.localEndTime.Value()]; - } else { - response.localEndTime = nil; - } - } - { - if (data.operatingMode.HasValue()) { - response.operatingMode = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.operatingMode.Value())]; - } else { - response.operatingMode = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12293,90 +11739,10 @@ void * context, const chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType & data) { auto * response = [MTRDoorLockClusterGetUserResponseParams new]; - { - response.userIndex = [NSNumber numberWithUnsignedShort:data.userIndex]; - } - { - if (data.userName.IsNull()) { - response.userName = nil; - } else { - response.userName = [[NSString alloc] initWithBytes:data.userName.Value().data() - length:data.userName.Value().size() - encoding:NSUTF8StringEncoding]; - } - } - { - if (data.userUniqueID.IsNull()) { - response.userUniqueID = nil; - } else { - response.userUniqueID = [NSNumber numberWithUnsignedInt:data.userUniqueID.Value()]; - } - } - { - if (data.userStatus.IsNull()) { - response.userStatus = nil; - } else { - response.userStatus = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.userStatus.Value())]; - } - } - { - if (data.userType.IsNull()) { - response.userType = nil; - } else { - response.userType = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.userType.Value())]; - } - } - { - if (data.credentialRule.IsNull()) { - response.credentialRule = nil; - } else { - response.credentialRule = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.credentialRule.Value())]; - } - } - { - if (data.credentials.IsNull()) { - response.credentials = nil; - } else { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.credentials.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - MTRDoorLockClusterCredentialStruct * newElement_1; - newElement_1 = [MTRDoorLockClusterCredentialStruct new]; - newElement_1.credentialType = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1.credentialType)]; - newElement_1.credentialIndex = [NSNumber numberWithUnsignedShort:entry_1.credentialIndex]; - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.credentials = array_1; - } - } - } - { - if (data.creatorFabricIndex.IsNull()) { - response.creatorFabricIndex = nil; - } else { - response.creatorFabricIndex = [NSNumber numberWithUnsignedChar:data.creatorFabricIndex.Value()]; - } - } - { - if (data.lastModifiedFabricIndex.IsNull()) { - response.lastModifiedFabricIndex = nil; - } else { - response.lastModifiedFabricIndex = [NSNumber numberWithUnsignedChar:data.lastModifiedFabricIndex.Value()]; - } - } - { - if (data.nextUserIndex.IsNull()) { - response.nextUserIndex = nil; - } else { - response.nextUserIndex = [NSNumber numberWithUnsignedShort:data.nextUserIndex.Value()]; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12385,22 +11751,10 @@ void * context, const chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType & data) { auto * response = [MTRDoorLockClusterSetCredentialResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.userIndex.IsNull()) { - response.userIndex = nil; - } else { - response.userIndex = [NSNumber numberWithUnsignedShort:data.userIndex.Value()]; - } - } - { - if (data.nextCredentialIndex.IsNull()) { - response.nextCredentialIndex = nil; - } else { - response.nextCredentialIndex = [NSNumber numberWithUnsignedShort:data.nextCredentialIndex.Value()]; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12409,36 +11763,10 @@ void * context, const chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType & data) { auto * response = [MTRDoorLockClusterGetCredentialStatusResponseParams new]; - { - response.credentialExists = [NSNumber numberWithBool:data.credentialExists]; - } - { - if (data.userIndex.IsNull()) { - response.userIndex = nil; - } else { - response.userIndex = [NSNumber numberWithUnsignedShort:data.userIndex.Value()]; - } - } - { - if (data.creatorFabricIndex.IsNull()) { - response.creatorFabricIndex = nil; - } else { - response.creatorFabricIndex = [NSNumber numberWithUnsignedChar:data.creatorFabricIndex.Value()]; - } - } - { - if (data.lastModifiedFabricIndex.IsNull()) { - response.lastModifiedFabricIndex = nil; - } else { - response.lastModifiedFabricIndex = [NSNumber numberWithUnsignedChar:data.lastModifiedFabricIndex.Value()]; - } - } - { - if (data.nextCredentialIndex.IsNull()) { - response.nextCredentialIndex = nil; - } else { - response.nextCredentialIndex = [NSNumber numberWithUnsignedShort:data.nextCredentialIndex.Value()]; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12447,43 +11775,10 @@ void * context, const chip::app::Clusters::Thermostat::Commands::GetWeeklyScheduleResponse::DecodableType & data) { auto * response = [MTRThermostatClusterGetWeeklyScheduleResponseParams new]; - { - response.numberOfTransitionsForSequence = [NSNumber numberWithUnsignedChar:data.numberOfTransitionsForSequence]; - } - { - response.dayOfWeekForSequence = [NSNumber numberWithUnsignedChar:data.dayOfWeekForSequence.Raw()]; - } - { - response.modeForSequence = [NSNumber numberWithUnsignedChar:data.modeForSequence.Raw()]; - } - { - { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = data.transitions.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - MTRThermostatClusterThermostatScheduleTransition * newElement_0; - newElement_0 = [MTRThermostatClusterThermostatScheduleTransition new]; - newElement_0.transitionTime = [NSNumber numberWithUnsignedShort:entry_0.transitionTime]; - if (entry_0.heatSetpoint.IsNull()) { - newElement_0.heatSetpoint = nil; - } else { - newElement_0.heatSetpoint = [NSNumber numberWithShort:entry_0.heatSetpoint.Value()]; - } - if (entry_0.coolSetpoint.IsNull()) { - newElement_0.coolSetpoint = nil; - } else { - newElement_0.coolSetpoint = [NSNumber numberWithShort:entry_0.coolSetpoint.Value()]; - } - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.transitions = array_0; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12492,17 +11787,10 @@ void * context, const chip::app::Clusters::Channel::Commands::ChangeChannelResponse::DecodableType & data) { auto * response = [MTRChannelClusterChangeChannelResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.data.HasValue()) { - response.data = [[NSString alloc] initWithBytes:data.data.Value().data() - length:data.data.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.data = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12511,17 +11799,10 @@ void * context, const chip::app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::DecodableType & data) { auto * response = [MTRTargetNavigatorClusterNavigateTargetResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.data.HasValue()) { - response.data = [[NSString alloc] initWithBytes:data.data.Value().data() - length:data.data.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.data = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12530,17 +11811,10 @@ void * context, const chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::DecodableType & data) { auto * response = [MTRMediaPlaybackClusterPlaybackResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.data.HasValue()) { - response.data = [[NSString alloc] initWithBytes:data.data.Value().data() - length:data.data.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.data = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12549,8 +11823,10 @@ void * context, const chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::DecodableType & data) { auto * response = [MTRKeypadInputClusterSendKeyResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12559,17 +11835,10 @@ void * context, const chip::app::Clusters::ContentLauncher::Commands::LauncherResponse::DecodableType & data) { auto * response = [MTRContentLauncherClusterLauncherResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.data.HasValue()) { - response.data = [[NSString alloc] initWithBytes:data.data.Value().data() - length:data.data.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.data = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12578,15 +11847,10 @@ void * context, const chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::DecodableType & data) { auto * response = [MTRApplicationLauncherClusterLauncherResponseParams new]; - { - response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; - } - { - if (data.data.HasValue()) { - response.data = [NSData dataWithBytes:data.data.Value().data() length:data.data.Value().size()]; - } else { - response.data = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12595,10 +11859,10 @@ void * context, const chip::app::Clusters::AccountLogin::Commands::GetSetupPINResponse::DecodableType & data) { auto * response = [MTRAccountLoginClusterGetSetupPINResponseParams new]; - { - response.setupPIN = [[NSString alloc] initWithBytes:data.setupPIN.data() - length:data.setupPIN.size() - encoding:NSUTF8StringEncoding]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12607,8 +11871,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestSpecificResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestSpecificResponseParams new]; - { - response.returnValue = [NSNumber numberWithUnsignedChar:data.returnValue]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12617,8 +11883,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestAddArgumentsResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestAddArgumentsResponseParams new]; - { - response.returnValue = [NSNumber numberWithUnsignedChar:data.returnValue]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12627,8 +11895,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestSimpleArgumentResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestSimpleArgumentResponseParams new]; - { - response.returnValue = [NSNumber numberWithBool:data.returnValue]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12637,200 +11907,22 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestStructArrayArgumentResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestStructArrayArgumentResponseParams new]; - { { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = data.arg1.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - MTRUnitTestingClusterNestedStructList * newElement_0; - newElement_0 = [MTRUnitTestingClusterNestedStructList new]; - newElement_0.a = [NSNumber numberWithUnsignedChar:entry_0.a]; - newElement_0.b = [NSNumber numberWithBool:entry_0.b]; - newElement_0.c = [MTRUnitTestingClusterSimpleStruct new]; - newElement_0.c.a = [NSNumber numberWithUnsignedChar:entry_0.c.a]; - newElement_0.c.b = [NSNumber numberWithBool:entry_0.c.b]; - newElement_0.c.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c.c)]; - newElement_0.c.d = [NSData dataWithBytes:entry_0.c.d.data() length:entry_0.c.d.size()]; - newElement_0.c.e = [[NSString alloc] initWithBytes:entry_0.c.e.data() - length:entry_0.c.e.size() - encoding:NSUTF8StringEncoding]; - newElement_0.c.f = [NSNumber numberWithUnsignedChar:entry_0.c.f.Raw()]; - newElement_0.c.g = [NSNumber numberWithFloat:entry_0.c.g]; - newElement_0.c.h = [NSNumber numberWithDouble:entry_0.c.h]; - { // Scope for our temporary variables - auto * array_2 = [NSMutableArray new]; - auto iter_2 = entry_0.d.begin(); - while (iter_2.Next()) { - auto & entry_2 = iter_2.GetValue(); - MTRUnitTestingClusterSimpleStruct * newElement_2; - newElement_2 = [MTRUnitTestingClusterSimpleStruct new]; - newElement_2.a = [NSNumber numberWithUnsignedChar:entry_2.a]; - newElement_2.b = [NSNumber numberWithBool:entry_2.b]; - newElement_2.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_2.c)]; - newElement_2.d = [NSData dataWithBytes:entry_2.d.data() length:entry_2.d.size()]; - newElement_2.e = [[NSString alloc] initWithBytes:entry_2.e.data() - length:entry_2.e.size() - encoding:NSUTF8StringEncoding]; - newElement_2.f = [NSNumber numberWithUnsignedChar:entry_2.f.Raw()]; - newElement_2.g = [NSNumber numberWithFloat:entry_2.g]; - newElement_2.h = [NSNumber numberWithDouble:entry_2.h]; - [array_2 addObject:newElement_2]; - } - CHIP_ERROR err = iter_2.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - newElement_0.d = array_2; - } - { // Scope for our temporary variables - auto * array_2 = [NSMutableArray new]; - auto iter_2 = entry_0.e.begin(); - while (iter_2.Next()) { - auto & entry_2 = iter_2.GetValue(); - NSNumber * newElement_2; - newElement_2 = [NSNumber numberWithUnsignedInt:entry_2]; - [array_2 addObject:newElement_2]; - } - CHIP_ERROR err = iter_2.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - newElement_0.e = array_2; - } - { // Scope for our temporary variables - auto * array_2 = [NSMutableArray new]; - auto iter_2 = entry_0.f.begin(); - while (iter_2.Next()) { - auto & entry_2 = iter_2.GetValue(); - NSData * newElement_2; - newElement_2 = [NSData dataWithBytes:entry_2.data() length:entry_2.size()]; - [array_2 addObject:newElement_2]; - } - CHIP_ERROR err = iter_2.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - newElement_0.f = array_2; - } - { // Scope for our temporary variables - auto * array_2 = [NSMutableArray new]; - auto iter_2 = entry_0.g.begin(); - while (iter_2.Next()) { - auto & entry_2 = iter_2.GetValue(); - NSNumber * newElement_2; - newElement_2 = [NSNumber numberWithUnsignedChar:entry_2]; - [array_2 addObject:newElement_2]; - } - CHIP_ERROR err = iter_2.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - newElement_0.g = array_2; - } - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; if (err != CHIP_NO_ERROR) { OnFailureFn(context, err); return; } - response.arg1 = array_0; -} -} -{ { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; -auto iter_0 = data.arg2.begin(); -while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - MTRUnitTestingClusterSimpleStruct * newElement_0; - newElement_0 = [MTRUnitTestingClusterSimpleStruct new]; - newElement_0.a = [NSNumber numberWithUnsignedChar:entry_0.a]; - newElement_0.b = [NSNumber numberWithBool:entry_0.b]; - newElement_0.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c)]; - newElement_0.d = [NSData dataWithBytes:entry_0.d.data() length:entry_0.d.size()]; - newElement_0.e = [[NSString alloc] initWithBytes:entry_0.e.data() length:entry_0.e.size() encoding:NSUTF8StringEncoding]; - newElement_0.f = [NSNumber numberWithUnsignedChar:entry_0.f.Raw()]; - newElement_0.g = [NSNumber numberWithFloat:entry_0.g]; - newElement_0.h = [NSNumber numberWithDouble:entry_0.h]; - [array_0 addObject:newElement_0]; -} -CHIP_ERROR err = iter_0.GetStatus(); -if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; -} -response.arg2 = array_0; -} -} -{ { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; -auto iter_0 = data.arg3.begin(); -while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - NSNumber * newElement_0; - newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; - [array_0 addObject:newElement_0]; -} -CHIP_ERROR err = iter_0.GetStatus(); -if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; -} -response.arg3 = array_0; -} -} -{ { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; -auto iter_0 = data.arg4.begin(); -while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - NSNumber * newElement_0; - newElement_0 = [NSNumber numberWithBool:entry_0]; - [array_0 addObject:newElement_0]; -} -CHIP_ERROR err = iter_0.GetStatus(); -if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; -} -response.arg4 = array_0; -} -} -{ - response.arg5 = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.arg5)]; -} -{ - response.arg6 = [NSNumber numberWithBool:data.arg6]; -} -DispatchSuccess(context, response); -} -; + DispatchSuccess(context, response); +}; void MTRUnitTestingClusterTestListInt8UReverseResponseCallbackBridge::OnSuccessFn( void * context, const chip::app::Clusters::UnitTesting::Commands::TestListInt8UReverseResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestListInt8UReverseResponseParams new]; - { - { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = data.arg1.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - NSNumber * newElement_0; - newElement_0 = [NSNumber numberWithUnsignedChar:entry_0]; - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.arg1 = array_0; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12839,11 +11931,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestEnumsResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestEnumsResponseParams new]; - { - response.arg1 = [NSNumber numberWithUnsignedShort:chip::to_underlying(data.arg1)]; - } - { - response.arg2 = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.arg2)]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12852,33 +11943,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestNullableOptionalResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestNullableOptionalResponseParams new]; - { - response.wasPresent = [NSNumber numberWithBool:data.wasPresent]; - } - { - if (data.wasNull.HasValue()) { - response.wasNull = [NSNumber numberWithBool:data.wasNull.Value()]; - } else { - response.wasNull = nil; - } - } - { - if (data.value.HasValue()) { - response.value = [NSNumber numberWithUnsignedChar:data.value.Value()]; - } else { - response.value = nil; - } - } - { - if (data.originalValue.HasValue()) { - if (data.originalValue.Value().IsNull()) { - response.originalValue = nil; - } else { - response.originalValue = [NSNumber numberWithUnsignedChar:data.originalValue.Value().Value()]; - } - } else { - response.originalValue = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -12887,242 +11955,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestComplexNullableOptionalResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestComplexNullableOptionalResponseParams new]; - { - response.nullableIntWasNull = [NSNumber numberWithBool:data.nullableIntWasNull]; - } - { - if (data.nullableIntValue.HasValue()) { - response.nullableIntValue = [NSNumber numberWithUnsignedShort:data.nullableIntValue.Value()]; - } else { - response.nullableIntValue = nil; - } - } - { - response.optionalIntWasPresent = [NSNumber numberWithBool:data.optionalIntWasPresent]; - } - { - if (data.optionalIntValue.HasValue()) { - response.optionalIntValue = [NSNumber numberWithUnsignedShort:data.optionalIntValue.Value()]; - } else { - response.optionalIntValue = nil; - } - } - { - response.nullableOptionalIntWasPresent = [NSNumber numberWithBool:data.nullableOptionalIntWasPresent]; - } - { - if (data.nullableOptionalIntWasNull.HasValue()) { - response.nullableOptionalIntWasNull = [NSNumber numberWithBool:data.nullableOptionalIntWasNull.Value()]; - } else { - response.nullableOptionalIntWasNull = nil; - } - } - { - if (data.nullableOptionalIntValue.HasValue()) { - response.nullableOptionalIntValue = [NSNumber numberWithUnsignedShort:data.nullableOptionalIntValue.Value()]; - } else { - response.nullableOptionalIntValue = nil; - } - } - { - response.nullableStringWasNull = [NSNumber numberWithBool:data.nullableStringWasNull]; - } - { - if (data.nullableStringValue.HasValue()) { - response.nullableStringValue = [[NSString alloc] initWithBytes:data.nullableStringValue.Value().data() - length:data.nullableStringValue.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.nullableStringValue = nil; - } - } - { - response.optionalStringWasPresent = [NSNumber numberWithBool:data.optionalStringWasPresent]; - } - { - if (data.optionalStringValue.HasValue()) { - response.optionalStringValue = [[NSString alloc] initWithBytes:data.optionalStringValue.Value().data() - length:data.optionalStringValue.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.optionalStringValue = nil; - } - } - { - response.nullableOptionalStringWasPresent = [NSNumber numberWithBool:data.nullableOptionalStringWasPresent]; - } - { - if (data.nullableOptionalStringWasNull.HasValue()) { - response.nullableOptionalStringWasNull = [NSNumber numberWithBool:data.nullableOptionalStringWasNull.Value()]; - } else { - response.nullableOptionalStringWasNull = nil; - } - } - { - if (data.nullableOptionalStringValue.HasValue()) { - response.nullableOptionalStringValue = [[NSString alloc] initWithBytes:data.nullableOptionalStringValue.Value().data() - length:data.nullableOptionalStringValue.Value().size() - encoding:NSUTF8StringEncoding]; - } else { - response.nullableOptionalStringValue = nil; - } - } - { - response.nullableStructWasNull = [NSNumber numberWithBool:data.nullableStructWasNull]; - } - { - if (data.nullableStructValue.HasValue()) { - response.nullableStructValue = [MTRUnitTestingClusterSimpleStruct new]; - response.nullableStructValue.a = [NSNumber numberWithUnsignedChar:data.nullableStructValue.Value().a]; - response.nullableStructValue.b = [NSNumber numberWithBool:data.nullableStructValue.Value().b]; - response.nullableStructValue.c = - [NSNumber numberWithUnsignedChar:chip::to_underlying(data.nullableStructValue.Value().c)]; - response.nullableStructValue.d = [NSData dataWithBytes:data.nullableStructValue.Value().d.data() - length:data.nullableStructValue.Value().d.size()]; - response.nullableStructValue.e = [[NSString alloc] initWithBytes:data.nullableStructValue.Value().e.data() - length:data.nullableStructValue.Value().e.size() - encoding:NSUTF8StringEncoding]; - response.nullableStructValue.f = [NSNumber numberWithUnsignedChar:data.nullableStructValue.Value().f.Raw()]; - response.nullableStructValue.g = [NSNumber numberWithFloat:data.nullableStructValue.Value().g]; - response.nullableStructValue.h = [NSNumber numberWithDouble:data.nullableStructValue.Value().h]; - } else { - response.nullableStructValue = nil; - } - } - { - response.optionalStructWasPresent = [NSNumber numberWithBool:data.optionalStructWasPresent]; - } - { - if (data.optionalStructValue.HasValue()) { - response.optionalStructValue = [MTRUnitTestingClusterSimpleStruct new]; - response.optionalStructValue.a = [NSNumber numberWithUnsignedChar:data.optionalStructValue.Value().a]; - response.optionalStructValue.b = [NSNumber numberWithBool:data.optionalStructValue.Value().b]; - response.optionalStructValue.c = - [NSNumber numberWithUnsignedChar:chip::to_underlying(data.optionalStructValue.Value().c)]; - response.optionalStructValue.d = [NSData dataWithBytes:data.optionalStructValue.Value().d.data() - length:data.optionalStructValue.Value().d.size()]; - response.optionalStructValue.e = [[NSString alloc] initWithBytes:data.optionalStructValue.Value().e.data() - length:data.optionalStructValue.Value().e.size() - encoding:NSUTF8StringEncoding]; - response.optionalStructValue.f = [NSNumber numberWithUnsignedChar:data.optionalStructValue.Value().f.Raw()]; - response.optionalStructValue.g = [NSNumber numberWithFloat:data.optionalStructValue.Value().g]; - response.optionalStructValue.h = [NSNumber numberWithDouble:data.optionalStructValue.Value().h]; - } else { - response.optionalStructValue = nil; - } - } - { - response.nullableOptionalStructWasPresent = [NSNumber numberWithBool:data.nullableOptionalStructWasPresent]; - } - { - if (data.nullableOptionalStructWasNull.HasValue()) { - response.nullableOptionalStructWasNull = [NSNumber numberWithBool:data.nullableOptionalStructWasNull.Value()]; - } else { - response.nullableOptionalStructWasNull = nil; - } - } - { - if (data.nullableOptionalStructValue.HasValue()) { - response.nullableOptionalStructValue = [MTRUnitTestingClusterSimpleStruct new]; - response.nullableOptionalStructValue.a = [NSNumber numberWithUnsignedChar:data.nullableOptionalStructValue.Value().a]; - response.nullableOptionalStructValue.b = [NSNumber numberWithBool:data.nullableOptionalStructValue.Value().b]; - response.nullableOptionalStructValue.c = - [NSNumber numberWithUnsignedChar:chip::to_underlying(data.nullableOptionalStructValue.Value().c)]; - response.nullableOptionalStructValue.d = [NSData dataWithBytes:data.nullableOptionalStructValue.Value().d.data() - length:data.nullableOptionalStructValue.Value().d.size()]; - response.nullableOptionalStructValue.e = - [[NSString alloc] initWithBytes:data.nullableOptionalStructValue.Value().e.data() - length:data.nullableOptionalStructValue.Value().e.size() - encoding:NSUTF8StringEncoding]; - response.nullableOptionalStructValue.f = - [NSNumber numberWithUnsignedChar:data.nullableOptionalStructValue.Value().f.Raw()]; - response.nullableOptionalStructValue.g = [NSNumber numberWithFloat:data.nullableOptionalStructValue.Value().g]; - response.nullableOptionalStructValue.h = [NSNumber numberWithDouble:data.nullableOptionalStructValue.Value().h]; - } else { - response.nullableOptionalStructValue = nil; - } - } - { - response.nullableListWasNull = [NSNumber numberWithBool:data.nullableListWasNull]; - } - { - if (data.nullableListValue.HasValue()) { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.nullableListValue.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - NSNumber * newElement_1; - newElement_1 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1)]; - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.nullableListValue = array_1; - } - } else { - response.nullableListValue = nil; - } - } - { - response.optionalListWasPresent = [NSNumber numberWithBool:data.optionalListWasPresent]; - } - { - if (data.optionalListValue.HasValue()) { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.optionalListValue.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - NSNumber * newElement_1; - newElement_1 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1)]; - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.optionalListValue = array_1; - } - } else { - response.optionalListValue = nil; - } - } - { - response.nullableOptionalListWasPresent = [NSNumber numberWithBool:data.nullableOptionalListWasPresent]; - } - { - if (data.nullableOptionalListWasNull.HasValue()) { - response.nullableOptionalListWasNull = [NSNumber numberWithBool:data.nullableOptionalListWasNull.Value()]; - } else { - response.nullableOptionalListWasNull = nil; - } - } - { - if (data.nullableOptionalListValue.HasValue()) { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = data.nullableOptionalListValue.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - NSNumber * newElement_1; - newElement_1 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1)]; - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - OnFailureFn(context, err); - return; - } - response.nullableOptionalListValue = array_1; - } - } else { - response.nullableOptionalListValue = nil; - } + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -13131,8 +11967,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::BooleanResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterBooleanResponseParams new]; - { - response.value = [NSNumber numberWithBool:data.value]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -13141,18 +11979,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::SimpleStructResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterSimpleStructResponseParams new]; - { - response.arg1 = [MTRUnitTestingClusterSimpleStruct new]; - response.arg1.a = [NSNumber numberWithUnsignedChar:data.arg1.a]; - response.arg1.b = [NSNumber numberWithBool:data.arg1.b]; - response.arg1.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.arg1.c)]; - response.arg1.d = [NSData dataWithBytes:data.arg1.d.data() length:data.arg1.d.size()]; - response.arg1.e = [[NSString alloc] initWithBytes:data.arg1.e.data() - length:data.arg1.e.size() - encoding:NSUTF8StringEncoding]; - response.arg1.f = [NSNumber numberWithUnsignedChar:data.arg1.f.Raw()]; - response.arg1.g = [NSNumber numberWithFloat:data.arg1.g]; - response.arg1.h = [NSNumber numberWithDouble:data.arg1.h]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -13161,8 +11991,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestEmitTestEventResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestEmitTestEventResponseParams new]; - { - response.value = [NSNumber numberWithUnsignedLongLong:data.value]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; @@ -13171,8 +12003,10 @@ void * context, const chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventResponse::DecodableType & data) { auto * response = [MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams new]; - { - response.value = [NSNumber numberWithUnsignedLongLong:data.value]; + CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data]; + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; } DispatchSuccess(context, response); }; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 2e257f43660372..70853ec6637b07 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -143,6 +143,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGroupsClusterAddGroupResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRGroupsClusterAddGroupResponseParams (Deprecated) @@ -212,6 +225,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGroupsClusterViewGroupResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRGroupsClusterViewGroupResponseParams (Deprecated) @@ -273,6 +299,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGroupsClusterGetGroupMembershipResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -334,6 +373,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGroupsClusterRemoveGroupResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRGroupsClusterRemoveGroupResponseParams (Deprecated) @@ -480,6 +532,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterAddSceneResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterAddSceneResponseParams (Deprecated) @@ -563,6 +628,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterViewSceneResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterViewSceneResponseParams (Deprecated) @@ -640,6 +718,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterRemoveSceneResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterRemoveSceneResponseParams (Deprecated) @@ -710,6 +801,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterRemoveAllScenesResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterRemoveAllScenesResponseParams (Deprecated) @@ -784,6 +888,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterStoreSceneResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterStoreSceneResponseParams (Deprecated) @@ -901,6 +1018,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterGetSceneMembershipResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterGetSceneMembershipResponseParams (Deprecated) @@ -981,6 +1111,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterEnhancedAddSceneResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterEnhancedAddSceneResponseParams (Deprecated) @@ -1064,6 +1207,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterEnhancedViewSceneResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterEnhancedViewSceneResponseParams (Deprecated) @@ -1153,6 +1309,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRScenesClusterCopySceneResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRScenesClusterCopySceneResponseParams (Deprecated) @@ -2179,6 +2348,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTROTASoftwareUpdateProviderClusterQueryImageResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTROTASoftwareUpdateProviderClusterQueryImageResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -2247,6 +2429,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTROTASoftwareUpdateProviderClusterApplyUpdateResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTROTASoftwareUpdateProviderClusterApplyUpdateResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -2401,6 +2596,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGeneralCommissioningClusterArmFailSafeResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -2461,6 +2669,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -2514,6 +2735,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGeneralCommissioningClusterCommissioningCompleteResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -2575,6 +2809,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRNetworkCommissioningClusterScanNetworksResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -2700,6 +2947,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRNetworkCommissioningClusterNetworkConfigResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -2759,6 +3019,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRNetworkCommissioningClusterConnectNetworkResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -2857,6 +3130,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRDiagnosticLogsClusterRetrieveLogsResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRDiagnosticLogsClusterRetrieveLogsResponseParams (Deprecated) @@ -3203,6 +3489,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTROperationalCredentialsClusterAttestationResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTROperationalCredentialsClusterAttestationResponseParams (Deprecated) @@ -3262,6 +3561,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTROperationalCredentialsClusterCertificateChainResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -3319,6 +3631,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTROperationalCredentialsClusterCSRResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -3416,6 +3741,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTROperationalCredentialsClusterNOCResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -3597,6 +3935,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGroupKeyManagementClusterKeySetReadResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -3680,6 +4031,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -3914,6 +4278,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRDoorLockClusterGetWeekDayScheduleResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -4045,6 +4422,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRDoorLockClusterGetYearDayScheduleResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -4174,6 +4564,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRDoorLockClusterGetHolidayScheduleResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -4324,6 +4727,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRDoorLockClusterGetUserResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end @interface MTRDoorLockClusterGetUserResponseParams (Deprecated) @@ -4429,6 +4845,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRDoorLockClusterSetCredentialResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -4493,6 +4922,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRDoorLockClusterGetCredentialStatusResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -4851,6 +5293,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRThermostatClusterGetWeeklyScheduleResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -5729,6 +6184,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRChannelClusterChangeChannelResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -5849,6 +6317,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRTargetNavigatorClusterNavigateTargetResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -6165,6 +6646,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRMediaPlaybackClusterPlaybackResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -6394,6 +6888,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRKeypadInputClusterSendKeyResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -6489,6 +6996,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRContentLauncherClusterLauncherResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRContentLauncherClusterLauncherResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), @@ -6676,6 +7196,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRApplicationLauncherClusterLauncherResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -6730,6 +7263,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRAccountLoginClusterGetSetupPINResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -6822,6 +7368,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRElectricalMeasurementClusterGetProfileInfoResponseCommandParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -6885,6 +7444,19 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRElectricalMeasurementClusterGetMeasurementProfileResponseCommandParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @@ -6975,6 +7547,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestSpecificResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestSpecificResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), @@ -7036,6 +7621,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestAddArgumentsResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestAddArgumentsResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -7097,6 +7695,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestSimpleArgumentResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestSimpleArgumentResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -7168,6 +7779,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestStructArrayArgumentResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestStructArrayArgumentResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -7233,6 +7857,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestListInt8UReverseResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestListInt8UReverseResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -7298,6 +7935,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestEnumsResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestEnumsResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), @@ -7377,6 +8027,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestNullableOptionalResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestNullableOptionalResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -7517,6 +8180,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestComplexNullableOptionalResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestComplexNullableOptionalResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -7582,6 +8258,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterBooleanResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterBooleanResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), @@ -7646,6 +8335,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterSimpleStructResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterSimpleStructResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), @@ -7709,6 +8411,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestEmitTestEventResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestEmitTestEventResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), @@ -7774,6 +8489,19 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs MTR_DEPRECATED("Timed invoke does not make sense for server to client commands", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); + +/** + * Initialize an MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams", ios(16.1, 16.4), macos(13.0, 13.3), diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index b0a66d4e6484ee..3da492592f1964 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -16,6 +16,13 @@ */ #import "MTRCommandPayloadsObjc.h" +#import "MTRBaseDevice_Internal.h" +#import "MTRCommandPayloads_Internal.h" +#import "MTRError_Internal.h" +#import "MTRLogging_Internal.h" + +#include +#include NS_ASSUME_NONNULL_BEGIN @@ -162,6 +169,61 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGroupsClusterAddGroupResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRGroupsClusterAddGroupResponseParams (Deprecated) @@ -253,6 +315,66 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Groups::Commands::ViewGroupResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGroupsClusterViewGroupResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Groups::Commands::ViewGroupResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + { + self.groupName = [[NSString alloc] initWithBytes:decodableStruct.groupName.data() + length:decodableStruct.groupName.size() + encoding:NSUTF8StringEncoding]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRGroupsClusterViewGroupResponseParams (Deprecated) @@ -328,6 +450,79 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Groups::Commands::GetGroupMembershipResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGroupsClusterGetGroupMembershipResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Groups::Commands::GetGroupMembershipResponse::DecodableType &)decodableStruct +{ + { + if (decodableStruct.capacity.IsNull()) { + self.capacity = nil; + } else { + self.capacity = [NSNumber numberWithUnsignedChar:decodableStruct.capacity.Value()]; + } + } + { + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.groupList.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedShort:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.groupList = array_0; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRGroupsClusterRemoveGroupParams - (instancetype)init @@ -403,6 +598,61 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGroupsClusterRemoveGroupResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRGroupsClusterRemoveGroupResponseParams (Deprecated) @@ -592,6 +842,64 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::AddSceneResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterAddSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::AddSceneResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + { + self.sceneID = [NSNumber numberWithUnsignedChar:decodableStruct.sceneID]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterAddSceneResponseParams (Deprecated) @@ -717,6 +1025,137 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::ViewSceneResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterViewSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::ViewSceneResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + { + self.sceneID = [NSNumber numberWithUnsignedChar:decodableStruct.sceneID]; + } + { + if (decodableStruct.transitionTime.HasValue()) { + self.transitionTime = [NSNumber numberWithUnsignedShort:decodableStruct.transitionTime.Value()]; + } else { + self.transitionTime = nil; + } + } + { + if (decodableStruct.sceneName.HasValue()) { + self.sceneName = [[NSString alloc] initWithBytes:decodableStruct.sceneName.Value().data() + length:decodableStruct.sceneName.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.sceneName = nil; + } + } + { + if (decodableStruct.extensionFieldSets.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.extensionFieldSets.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRScenesClusterExtensionFieldSet * newElement_1; + newElement_1 = [MTRScenesClusterExtensionFieldSet new]; + newElement_1.clusterID = [NSNumber numberWithUnsignedInt:entry_1.clusterID]; + { // Scope for our temporary variables + auto * array_3 = [NSMutableArray new]; + auto iter_3 = entry_1.attributeValueList.begin(); + while (iter_3.Next()) { + auto & entry_3 = iter_3.GetValue(); + MTRScenesClusterAttributeValuePair * newElement_3; + newElement_3 = [MTRScenesClusterAttributeValuePair new]; + if (entry_3.attributeID.HasValue()) { + newElement_3.attributeID = [NSNumber numberWithUnsignedInt:entry_3.attributeID.Value()]; + } else { + newElement_3.attributeID = nil; + } + { // Scope for our temporary variables + auto * array_5 = [NSMutableArray new]; + auto iter_5 = entry_3.attributeValue.begin(); + while (iter_5.Next()) { + auto & entry_5 = iter_5.GetValue(); + NSNumber * newElement_5; + newElement_5 = [NSNumber numberWithUnsignedChar:entry_5]; + [array_5 addObject:newElement_5]; + } + CHIP_ERROR err = iter_5.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_3.attributeValue = array_5; + } + [array_3 addObject:newElement_3]; + } + CHIP_ERROR err = iter_3.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_1.attributeValueList = array_3; + } + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.extensionFieldSets = array_1; + } + } else { + self.extensionFieldSets = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterViewSceneResponseParams (Deprecated) @@ -832,6 +1271,64 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::RemoveSceneResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterRemoveSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::RemoveSceneResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + { + self.sceneID = [NSNumber numberWithUnsignedChar:decodableStruct.sceneID]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterRemoveSceneResponseParams (Deprecated) @@ -930,6 +1427,61 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::RemoveAllScenesResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterRemoveAllScenesResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::RemoveAllScenesResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterRemoveAllScenesResponseParams (Deprecated) @@ -1035,6 +1587,64 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::StoreSceneResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterStoreSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::StoreSceneResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + { + self.sceneID = [NSNumber numberWithUnsignedChar:decodableStruct.sceneID]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterStoreSceneResponseParams (Deprecated) @@ -1199,6 +1809,89 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::GetSceneMembershipResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterGetSceneMembershipResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::GetSceneMembershipResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + if (decodableStruct.capacity.IsNull()) { + self.capacity = nil; + } else { + self.capacity = [NSNumber numberWithUnsignedChar:decodableStruct.capacity.Value()]; + } + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + { + if (decodableStruct.sceneList.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.sceneList.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + NSNumber * newElement_1; + newElement_1 = [NSNumber numberWithUnsignedChar:entry_1]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.sceneList = array_1; + } + } else { + self.sceneList = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterGetSceneMembershipResponseParams (Deprecated) @@ -1314,6 +2007,64 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::EnhancedAddSceneResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterEnhancedAddSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::EnhancedAddSceneResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + { + self.sceneID = [NSNumber numberWithUnsignedChar:decodableStruct.sceneID]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterEnhancedAddSceneResponseParams (Deprecated) @@ -1439,6 +2190,137 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::EnhancedViewSceneResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterEnhancedViewSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::EnhancedViewSceneResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupID = [NSNumber numberWithUnsignedShort:decodableStruct.groupID]; + } + { + self.sceneID = [NSNumber numberWithUnsignedChar:decodableStruct.sceneID]; + } + { + if (decodableStruct.transitionTime.HasValue()) { + self.transitionTime = [NSNumber numberWithUnsignedShort:decodableStruct.transitionTime.Value()]; + } else { + self.transitionTime = nil; + } + } + { + if (decodableStruct.sceneName.HasValue()) { + self.sceneName = [[NSString alloc] initWithBytes:decodableStruct.sceneName.Value().data() + length:decodableStruct.sceneName.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.sceneName = nil; + } + } + { + if (decodableStruct.extensionFieldSets.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.extensionFieldSets.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRScenesClusterExtensionFieldSet * newElement_1; + newElement_1 = [MTRScenesClusterExtensionFieldSet new]; + newElement_1.clusterID = [NSNumber numberWithUnsignedInt:entry_1.clusterID]; + { // Scope for our temporary variables + auto * array_3 = [NSMutableArray new]; + auto iter_3 = entry_1.attributeValueList.begin(); + while (iter_3.Next()) { + auto & entry_3 = iter_3.GetValue(); + MTRScenesClusterAttributeValuePair * newElement_3; + newElement_3 = [MTRScenesClusterAttributeValuePair new]; + if (entry_3.attributeID.HasValue()) { + newElement_3.attributeID = [NSNumber numberWithUnsignedInt:entry_3.attributeID.Value()]; + } else { + newElement_3.attributeID = nil; + } + { // Scope for our temporary variables + auto * array_5 = [NSMutableArray new]; + auto iter_5 = entry_3.attributeValue.begin(); + while (iter_5.Next()) { + auto & entry_5 = iter_5.GetValue(); + NSNumber * newElement_5; + newElement_5 = [NSNumber numberWithUnsignedChar:entry_5]; + [array_5 addObject:newElement_5]; + } + CHIP_ERROR err = iter_5.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_3.attributeValue = array_5; + } + [array_3 addObject:newElement_3]; + } + CHIP_ERROR err = iter_3.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_1.attributeValueList = array_3; + } + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.extensionFieldSets = array_1; + } + } else { + self.extensionFieldSets = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterEnhancedViewSceneResponseParams (Deprecated) @@ -1585,6 +2467,64 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Scenes::Commands::CopySceneResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRScenesClusterCopySceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::CopySceneResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.groupIdentifierFrom = [NSNumber numberWithUnsignedShort:decodableStruct.groupIdentifierFrom]; + } + { + self.sceneIdentifierFrom = [NSNumber numberWithUnsignedChar:decodableStruct.sceneIdentifierFrom]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRScenesClusterCopySceneResponseParams (Deprecated) @@ -2733,6 +3673,113 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTROTASoftwareUpdateProviderClusterQueryImageResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.delayedActionTime.HasValue()) { + self.delayedActionTime = [NSNumber numberWithUnsignedInt:decodableStruct.delayedActionTime.Value()]; + } else { + self.delayedActionTime = nil; + } + } + { + if (decodableStruct.imageURI.HasValue()) { + self.imageURI = [[NSString alloc] initWithBytes:decodableStruct.imageURI.Value().data() + length:decodableStruct.imageURI.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.imageURI = nil; + } + } + { + if (decodableStruct.softwareVersion.HasValue()) { + self.softwareVersion = [NSNumber numberWithUnsignedInt:decodableStruct.softwareVersion.Value()]; + } else { + self.softwareVersion = nil; + } + } + { + if (decodableStruct.softwareVersionString.HasValue()) { + self.softwareVersionString = [[NSString alloc] initWithBytes:decodableStruct.softwareVersionString.Value().data() + length:decodableStruct.softwareVersionString.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.softwareVersionString = nil; + } + } + { + if (decodableStruct.updateToken.HasValue()) { + self.updateToken = [NSData dataWithBytes:decodableStruct.updateToken.Value().data() + length:decodableStruct.updateToken.Value().size()]; + } else { + self.updateToken = nil; + } + } + { + if (decodableStruct.userConsentNeeded.HasValue()) { + self.userConsentNeeded = [NSNumber numberWithBool:decodableStruct.userConsentNeeded.Value()]; + } else { + self.userConsentNeeded = nil; + } + } + { + if (decodableStruct.metadataForRequestor.HasValue()) { + self.metadataForRequestor = [NSData dataWithBytes:decodableStruct.metadataForRequestor.Value().data() + length:decodableStruct.metadataForRequestor.Value().size()]; + } else { + self.metadataForRequestor = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTROtaSoftwareUpdateProviderClusterQueryImageResponseParams @@ -2806,6 +3853,61 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTROTASoftwareUpdateProviderClusterApplyUpdateResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::DecodableType &)decodableStruct +{ + { + self.action = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.action)]; + } + { + self.delayedActionTime = [NSNumber numberWithUnsignedInt:decodableStruct.delayedActionTime]; + } + return CHIP_NO_ERROR; +} @end @implementation MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseParams @@ -2984,15 +4086,72 @@ - (NSString *)description return descriptionString; } -@end -@implementation MTRGeneralCommissioningClusterSetRegulatoryConfigParams -- (instancetype)init +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error { - if (self = [super init]) { + if (!(self = [super init])) { + return nil; + } - _newRegulatoryConfig = @(0); + using DecodableType = chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafeResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } - _countryCode = @""; + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGeneralCommissioningClusterArmFailSafeResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafeResponse::DecodableType &)decodableStruct +{ + { + self.errorCode = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.errorCode)]; + } + { + self.debugText = [[NSString alloc] initWithBytes:decodableStruct.debugText.data() + length:decodableStruct.debugText.size() + encoding:NSUTF8StringEncoding]; + } + return CHIP_NO_ERROR; +} +@end +@implementation MTRGeneralCommissioningClusterSetRegulatoryConfigParams +- (instancetype)init +{ + if (self = [super init]) { + + _newRegulatoryConfig = @(0); + + _countryCode = @""; _breadcrumb = @(0); _timedInvokeTimeoutMs = nil; @@ -3053,6 +4212,63 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType &)decodableStruct +{ + { + self.errorCode = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.errorCode)]; + } + { + self.debugText = [[NSString alloc] initWithBytes:decodableStruct.debugText.data() + length:decodableStruct.debugText.size() + encoding:NSUTF8StringEncoding]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRGeneralCommissioningClusterCommissioningCompleteParams - (instancetype)init @@ -3112,6 +4328,63 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::GeneralCommissioning::Commands::CommissioningCompleteResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGeneralCommissioningClusterCommissioningCompleteResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GeneralCommissioning::Commands::CommissioningCompleteResponse::DecodableType &)decodableStruct +{ + { + self.errorCode = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.errorCode)]; + } + { + self.debugText = [[NSString alloc] initWithBytes:decodableStruct.debugText.data() + length:decodableStruct.debugText.size() + encoding:NSUTF8StringEncoding]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRNetworkCommissioningClusterScanNetworksParams - (instancetype)init @@ -3185,6 +4458,126 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworksResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRNetworkCommissioningClusterScanNetworksResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworksResponse::DecodableType &)decodableStruct +{ + { + self.networkingStatus = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.networkingStatus)]; + } + { + if (decodableStruct.debugText.HasValue()) { + self.debugText = [[NSString alloc] initWithBytes:decodableStruct.debugText.Value().data() + length:decodableStruct.debugText.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.debugText = nil; + } + } + { + if (decodableStruct.wiFiScanResults.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.wiFiScanResults.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRNetworkCommissioningClusterWiFiInterfaceScanResult * newElement_1; + newElement_1 = [MTRNetworkCommissioningClusterWiFiInterfaceScanResult new]; + newElement_1.security = [NSNumber numberWithUnsignedChar:entry_1.security.Raw()]; + newElement_1.ssid = [NSData dataWithBytes:entry_1.ssid.data() length:entry_1.ssid.size()]; + newElement_1.bssid = [NSData dataWithBytes:entry_1.bssid.data() length:entry_1.bssid.size()]; + newElement_1.channel = [NSNumber numberWithUnsignedShort:entry_1.channel]; + newElement_1.wiFiBand = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1.wiFiBand)]; + newElement_1.rssi = [NSNumber numberWithChar:entry_1.rssi]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.wiFiScanResults = array_1; + } + } else { + self.wiFiScanResults = nil; + } + } + { + if (decodableStruct.threadScanResults.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.threadScanResults.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRNetworkCommissioningClusterThreadInterfaceScanResult * newElement_1; + newElement_1 = [MTRNetworkCommissioningClusterThreadInterfaceScanResult new]; + newElement_1.panId = [NSNumber numberWithUnsignedShort:entry_1.panId]; + newElement_1.extendedPanId = [NSNumber numberWithUnsignedLongLong:entry_1.extendedPanId]; + newElement_1.networkName = [[NSString alloc] initWithBytes:entry_1.networkName.data() + length:entry_1.networkName.size() + encoding:NSUTF8StringEncoding]; + newElement_1.channel = [NSNumber numberWithUnsignedShort:entry_1.channel]; + newElement_1.version = [NSNumber numberWithUnsignedChar:entry_1.version]; + newElement_1.extendedAddress = [NSData dataWithBytes:entry_1.extendedAddress.data() + length:entry_1.extendedAddress.size()]; + newElement_1.rssi = [NSNumber numberWithChar:entry_1.rssi]; + newElement_1.lqi = [NSNumber numberWithUnsignedChar:entry_1.lqi]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.threadScanResults = array_1; + } + } else { + self.threadScanResults = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRNetworkCommissioningClusterAddOrUpdateWiFiNetworkParams - (instancetype)init @@ -3328,6 +4721,74 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRNetworkCommissioningClusterNetworkConfigResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType &)decodableStruct +{ + { + self.networkingStatus = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.networkingStatus)]; + } + { + if (decodableStruct.debugText.HasValue()) { + self.debugText = [[NSString alloc] initWithBytes:decodableStruct.debugText.Value().data() + length:decodableStruct.debugText.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.debugText = nil; + } + } + { + if (decodableStruct.networkIndex.HasValue()) { + self.networkIndex = [NSNumber numberWithUnsignedChar:decodableStruct.networkIndex.Value()]; + } else { + self.networkIndex = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRNetworkCommissioningClusterConnectNetworkParams - (instancetype)init @@ -3398,6 +4859,74 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRNetworkCommissioningClusterConnectNetworkResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType &)decodableStruct +{ + { + self.networkingStatus = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.networkingStatus)]; + } + { + if (decodableStruct.debugText.HasValue()) { + self.debugText = [[NSString alloc] initWithBytes:decodableStruct.debugText.Value().data() + length:decodableStruct.debugText.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.debugText = nil; + } + } + { + if (decodableStruct.errorValue.IsNull()) { + self.errorValue = nil; + } else { + self.errorValue = [NSNumber numberWithInt:decodableStruct.errorValue.Value()]; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRNetworkCommissioningClusterReorderNetworkParams - (instancetype)init @@ -3512,6 +5041,75 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRDiagnosticLogsClusterRetrieveLogsResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + self.logContent = [NSData dataWithBytes:decodableStruct.logContent.data() length:decodableStruct.logContent.size()]; + } + { + if (decodableStruct.UTCTimeStamp.HasValue()) { + self.utcTimeStamp = [NSNumber numberWithUnsignedLongLong:decodableStruct.UTCTimeStamp.Value()]; + } else { + self.utcTimeStamp = nil; + } + } + { + if (decodableStruct.timeSinceBoot.HasValue()) { + self.timeSinceBoot = [NSNumber numberWithUnsignedLongLong:decodableStruct.timeSinceBoot.Value()]; + } else { + self.timeSinceBoot = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRDiagnosticLogsClusterRetrieveLogsResponseParams (Deprecated) @@ -3895,6 +5493,63 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTROperationalCredentialsClusterAttestationResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType &)decodableStruct +{ + { + self.attestationElements = [NSData dataWithBytes:decodableStruct.attestationElements.data() + length:decodableStruct.attestationElements.size()]; + } + { + self.attestationSignature = [NSData dataWithBytes:decodableStruct.attestationSignature.data() + length:decodableStruct.attestationSignature.size()]; + } + return CHIP_NO_ERROR; +} @end @implementation MTROperationalCredentialsClusterAttestationResponseParams (Deprecated) @@ -3968,6 +5623,58 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::OperationalCredentials::Commands::CertificateChainResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTROperationalCredentialsClusterCertificateChainResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OperationalCredentials::Commands::CertificateChainResponse::DecodableType &)decodableStruct +{ + { + self.certificate = [NSData dataWithBytes:decodableStruct.certificate.data() length:decodableStruct.certificate.size()]; + } + return CHIP_NO_ERROR; +} @end @implementation MTROperationalCredentialsClusterCSRRequestParams - (instancetype)init @@ -4036,6 +5743,63 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::OperationalCredentials::Commands::CSRResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTROperationalCredentialsClusterCSRResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OperationalCredentials::Commands::CSRResponse::DecodableType &)decodableStruct +{ + { + self.nocsrElements = [NSData dataWithBytes:decodableStruct.NOCSRElements.data() + length:decodableStruct.NOCSRElements.size()]; + } + { + self.attestationSignature = [NSData dataWithBytes:decodableStruct.attestationSignature.data() + length:decodableStruct.attestationSignature.size()]; + } + return CHIP_NO_ERROR; +} @end @implementation MTROperationalCredentialsClusterAddNOCParams - (instancetype)init @@ -4152,6 +5916,74 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::OperationalCredentials::Commands::NOCResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTROperationalCredentialsClusterNOCResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OperationalCredentials::Commands::NOCResponse::DecodableType &)decodableStruct +{ + { + self.statusCode = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.statusCode)]; + } + { + if (decodableStruct.fabricIndex.HasValue()) { + self.fabricIndex = [NSNumber numberWithUnsignedChar:decodableStruct.fabricIndex.Value()]; + } else { + self.fabricIndex = nil; + } + } + { + if (decodableStruct.debugText.HasValue()) { + self.debugText = [[NSString alloc] initWithBytes:decodableStruct.debugText.Value().data() + length:decodableStruct.debugText.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.debugText = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTROperationalCredentialsClusterUpdateFabricLabelParams - (instancetype)init @@ -4348,6 +6180,97 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGroupKeyManagementClusterKeySetReadResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType &)decodableStruct +{ + { + self.groupKeySet = [MTRGroupKeyManagementClusterGroupKeySetStruct new]; + self.groupKeySet.groupKeySetID = [NSNumber numberWithUnsignedShort:decodableStruct.groupKeySet.groupKeySetID]; + self.groupKeySet.groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.groupKeySet.groupKeySecurityPolicy)]; + if (decodableStruct.groupKeySet.epochKey0.IsNull()) { + self.groupKeySet.epochKey0 = nil; + } else { + self.groupKeySet.epochKey0 = [NSData dataWithBytes:decodableStruct.groupKeySet.epochKey0.Value().data() + length:decodableStruct.groupKeySet.epochKey0.Value().size()]; + } + if (decodableStruct.groupKeySet.epochStartTime0.IsNull()) { + self.groupKeySet.epochStartTime0 = nil; + } else { + self.groupKeySet.epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:decodableStruct.groupKeySet.epochStartTime0.Value()]; + } + if (decodableStruct.groupKeySet.epochKey1.IsNull()) { + self.groupKeySet.epochKey1 = nil; + } else { + self.groupKeySet.epochKey1 = [NSData dataWithBytes:decodableStruct.groupKeySet.epochKey1.Value().data() + length:decodableStruct.groupKeySet.epochKey1.Value().size()]; + } + if (decodableStruct.groupKeySet.epochStartTime1.IsNull()) { + self.groupKeySet.epochStartTime1 = nil; + } else { + self.groupKeySet.epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:decodableStruct.groupKeySet.epochStartTime1.Value()]; + } + if (decodableStruct.groupKeySet.epochKey2.IsNull()) { + self.groupKeySet.epochKey2 = nil; + } else { + self.groupKeySet.epochKey2 = [NSData dataWithBytes:decodableStruct.groupKeySet.epochKey2.Value().data() + length:decodableStruct.groupKeySet.epochKey2.Value().size()]; + } + if (decodableStruct.groupKeySet.epochStartTime2.IsNull()) { + self.groupKeySet.epochStartTime2 = nil; + } else { + self.groupKeySet.epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:decodableStruct.groupKeySet.epochStartTime2.Value()]; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRGroupKeyManagementClusterKeySetRemoveParams - (instancetype)init @@ -4439,6 +6362,72 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType &)decodableStruct +{ + { + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.groupKeySetIDs.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedShort:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.groupKeySetIDs = array_0; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRModeSelectClusterChangeToModeParams - (instancetype)init @@ -4702,6 +6691,99 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRDoorLockClusterGetWeekDayScheduleResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType &)decodableStruct +{ + { + self.weekDayIndex = [NSNumber numberWithUnsignedChar:decodableStruct.weekDayIndex]; + } + { + self.userIndex = [NSNumber numberWithUnsignedShort:decodableStruct.userIndex]; + } + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.daysMask.HasValue()) { + self.daysMask = [NSNumber numberWithUnsignedChar:decodableStruct.daysMask.Value().Raw()]; + } else { + self.daysMask = nil; + } + } + { + if (decodableStruct.startHour.HasValue()) { + self.startHour = [NSNumber numberWithUnsignedChar:decodableStruct.startHour.Value()]; + } else { + self.startHour = nil; + } + } + { + if (decodableStruct.startMinute.HasValue()) { + self.startMinute = [NSNumber numberWithUnsignedChar:decodableStruct.startMinute.Value()]; + } else { + self.startMinute = nil; + } + } + { + if (decodableStruct.endHour.HasValue()) { + self.endHour = [NSNumber numberWithUnsignedChar:decodableStruct.endHour.Value()]; + } else { + self.endHour = nil; + } + } + { + if (decodableStruct.endMinute.HasValue()) { + self.endMinute = [NSNumber numberWithUnsignedChar:decodableStruct.endMinute.Value()]; + } else { + self.endMinute = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRDoorLockClusterClearWeekDayScheduleParams - (instancetype)init @@ -4853,6 +6935,78 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::DoorLock::Commands::GetYearDayScheduleResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRDoorLockClusterGetYearDayScheduleResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetYearDayScheduleResponse::DecodableType &)decodableStruct +{ + { + self.yearDayIndex = [NSNumber numberWithUnsignedChar:decodableStruct.yearDayIndex]; + } + { + self.userIndex = [NSNumber numberWithUnsignedShort:decodableStruct.userIndex]; + } + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.localStartTime.HasValue()) { + self.localStartTime = [NSNumber numberWithUnsignedInt:decodableStruct.localStartTime.Value()]; + } else { + self.localStartTime = nil; + } + } + { + if (decodableStruct.localEndTime.HasValue()) { + self.localEndTime = [NSNumber numberWithUnsignedInt:decodableStruct.localEndTime.Value()]; + } else { + self.localEndTime = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRDoorLockClusterClearYearDayScheduleParams - (instancetype)init @@ -5001,11 +7155,87 @@ - (NSString *)description return descriptionString; } -@end -@implementation MTRDoorLockClusterClearHolidayScheduleParams -- (instancetype)init +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error { - if (self = [super init]) { + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::DoorLock::Commands::GetHolidayScheduleResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRDoorLockClusterGetHolidayScheduleResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetHolidayScheduleResponse::DecodableType &)decodableStruct +{ + { + self.holidayIndex = [NSNumber numberWithUnsignedChar:decodableStruct.holidayIndex]; + } + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.localStartTime.HasValue()) { + self.localStartTime = [NSNumber numberWithUnsignedInt:decodableStruct.localStartTime.Value()]; + } else { + self.localStartTime = nil; + } + } + { + if (decodableStruct.localEndTime.HasValue()) { + self.localEndTime = [NSNumber numberWithUnsignedInt:decodableStruct.localEndTime.Value()]; + } else { + self.localEndTime = nil; + } + } + { + if (decodableStruct.operatingMode.HasValue()) { + self.operatingMode = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.operatingMode.Value())]; + } else { + self.operatingMode = nil; + } + } + return CHIP_NO_ERROR; +} +@end +@implementation MTRDoorLockClusterClearHolidayScheduleParams +- (instancetype)init +{ + if (self = [super init]) { _holidayIndex = @(0); _timedInvokeTimeoutMs = nil; @@ -5186,6 +7416,139 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRDoorLockClusterGetUserResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType &)decodableStruct +{ + { + self.userIndex = [NSNumber numberWithUnsignedShort:decodableStruct.userIndex]; + } + { + if (decodableStruct.userName.IsNull()) { + self.userName = nil; + } else { + self.userName = [[NSString alloc] initWithBytes:decodableStruct.userName.Value().data() + length:decodableStruct.userName.Value().size() + encoding:NSUTF8StringEncoding]; + } + } + { + if (decodableStruct.userUniqueID.IsNull()) { + self.userUniqueID = nil; + } else { + self.userUniqueID = [NSNumber numberWithUnsignedInt:decodableStruct.userUniqueID.Value()]; + } + } + { + if (decodableStruct.userStatus.IsNull()) { + self.userStatus = nil; + } else { + self.userStatus = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.userStatus.Value())]; + } + } + { + if (decodableStruct.userType.IsNull()) { + self.userType = nil; + } else { + self.userType = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.userType.Value())]; + } + } + { + if (decodableStruct.credentialRule.IsNull()) { + self.credentialRule = nil; + } else { + self.credentialRule = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.credentialRule.Value())]; + } + } + { + if (decodableStruct.credentials.IsNull()) { + self.credentials = nil; + } else { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.credentials.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRDoorLockClusterCredentialStruct * newElement_1; + newElement_1 = [MTRDoorLockClusterCredentialStruct new]; + newElement_1.credentialType = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1.credentialType)]; + newElement_1.credentialIndex = [NSNumber numberWithUnsignedShort:entry_1.credentialIndex]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.credentials = array_1; + } + } + } + { + if (decodableStruct.creatorFabricIndex.IsNull()) { + self.creatorFabricIndex = nil; + } else { + self.creatorFabricIndex = [NSNumber numberWithUnsignedChar:decodableStruct.creatorFabricIndex.Value()]; + } + } + { + if (decodableStruct.lastModifiedFabricIndex.IsNull()) { + self.lastModifiedFabricIndex = nil; + } else { + self.lastModifiedFabricIndex = [NSNumber numberWithUnsignedChar:decodableStruct.lastModifiedFabricIndex.Value()]; + } + } + { + if (decodableStruct.nextUserIndex.IsNull()) { + self.nextUserIndex = nil; + } else { + self.nextUserIndex = [NSNumber numberWithUnsignedShort:decodableStruct.nextUserIndex.Value()]; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRDoorLockClusterGetUserResponseParams (Deprecated) @@ -5312,6 +7675,72 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRDoorLockClusterSetCredentialResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.userIndex.IsNull()) { + self.userIndex = nil; + } else { + self.userIndex = [NSNumber numberWithUnsignedShort:decodableStruct.userIndex.Value()]; + } + } + { + if (decodableStruct.nextCredentialIndex.IsNull()) { + self.nextCredentialIndex = nil; + } else { + self.nextCredentialIndex = [NSNumber numberWithUnsignedShort:decodableStruct.nextCredentialIndex.Value()]; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRDoorLockClusterGetCredentialStatusParams - (instancetype)init @@ -5387,6 +7816,86 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRDoorLockClusterGetCredentialStatusResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType &)decodableStruct +{ + { + self.credentialExists = [NSNumber numberWithBool:decodableStruct.credentialExists]; + } + { + if (decodableStruct.userIndex.IsNull()) { + self.userIndex = nil; + } else { + self.userIndex = [NSNumber numberWithUnsignedShort:decodableStruct.userIndex.Value()]; + } + } + { + if (decodableStruct.creatorFabricIndex.IsNull()) { + self.creatorFabricIndex = nil; + } else { + self.creatorFabricIndex = [NSNumber numberWithUnsignedChar:decodableStruct.creatorFabricIndex.Value()]; + } + } + { + if (decodableStruct.lastModifiedFabricIndex.IsNull()) { + self.lastModifiedFabricIndex = nil; + } else { + self.lastModifiedFabricIndex = [NSNumber numberWithUnsignedChar:decodableStruct.lastModifiedFabricIndex.Value()]; + } + } + { + if (decodableStruct.nextCredentialIndex.IsNull()) { + self.nextCredentialIndex = nil; + } else { + self.nextCredentialIndex = [NSNumber numberWithUnsignedShort:decodableStruct.nextCredentialIndex.Value()]; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRDoorLockClusterClearCredentialParams - (instancetype)init @@ -5752,6 +8261,92 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Thermostat::Commands::GetWeeklyScheduleResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRThermostatClusterGetWeeklyScheduleResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Thermostat::Commands::GetWeeklyScheduleResponse::DecodableType &)decodableStruct +{ + { + self.numberOfTransitionsForSequence = [NSNumber numberWithUnsignedChar:decodableStruct.numberOfTransitionsForSequence]; + } + { + self.dayOfWeekForSequence = [NSNumber numberWithUnsignedChar:decodableStruct.dayOfWeekForSequence.Raw()]; + } + { + self.modeForSequence = [NSNumber numberWithUnsignedChar:decodableStruct.modeForSequence.Raw()]; + } + { + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.transitions.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRThermostatClusterThermostatScheduleTransition * newElement_0; + newElement_0 = [MTRThermostatClusterThermostatScheduleTransition new]; + newElement_0.transitionTime = [NSNumber numberWithUnsignedShort:entry_0.transitionTime]; + if (entry_0.heatSetpoint.IsNull()) { + newElement_0.heatSetpoint = nil; + } else { + newElement_0.heatSetpoint = [NSNumber numberWithShort:entry_0.heatSetpoint.Value()]; + } + if (entry_0.coolSetpoint.IsNull()) { + newElement_0.coolSetpoint = nil; + } else { + newElement_0.coolSetpoint = [NSNumber numberWithShort:entry_0.coolSetpoint.Value()]; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.transitions = array_0; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRThermostatClusterSetWeeklyScheduleParams - (instancetype)init @@ -6753,6 +9348,67 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::Channel::Commands::ChangeChannelResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRChannelClusterChangeChannelResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Channel::Commands::ChangeChannelResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.data.HasValue()) { + self.data = [[NSString alloc] initWithBytes:decodableStruct.data.Value().data() + length:decodableStruct.data.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.data = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRChannelClusterChangeChannelByNumberParams - (instancetype)init @@ -6883,6 +9539,67 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRTargetNavigatorClusterNavigateTargetResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.data.HasValue()) { + self.data = [[NSString alloc] initWithBytes:decodableStruct.data.Value().data() + length:decodableStruct.data.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.data = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRMediaPlaybackClusterPlayParams - (instancetype)init @@ -7196,6 +9913,67 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRMediaPlaybackClusterPlaybackResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.data.HasValue()) { + self.data = [[NSString alloc] initWithBytes:decodableStruct.data.Value().data() + length:decodableStruct.data.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.data = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRMediaPlaybackClusterSeekParams - (instancetype)init @@ -7429,6 +10207,58 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRKeypadInputClusterSendKeyResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRContentLauncherClusterLaunchContentParams - (instancetype)init @@ -7535,6 +10365,67 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::ContentLauncher::Commands::LauncherResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRContentLauncherClusterLauncherResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::ContentLauncher::Commands::LauncherResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.data.HasValue()) { + self.data = [[NSString alloc] initWithBytes:decodableStruct.data.Value().data() + length:decodableStruct.data.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.data = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRContentLauncherClusterLaunchResponseParams @@ -7730,6 +10621,65 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRApplicationLauncherClusterLauncherResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::DecodableType &)decodableStruct +{ + { + self.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.status)]; + } + { + if (decodableStruct.data.HasValue()) { + self.data = [NSData dataWithBytes:decodableStruct.data.Value().data() length:decodableStruct.data.Value().size()]; + } else { + self.data = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRAccountLoginClusterGetSetupPINParams - (instancetype)init @@ -7789,6 +10739,60 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::AccountLogin::Commands::GetSetupPINResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRAccountLoginClusterGetSetupPINResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::AccountLogin::Commands::GetSetupPINResponse::DecodableType &)decodableStruct +{ + { + self.setupPIN = [[NSString alloc] initWithBytes:decodableStruct.setupPIN.data() + length:decodableStruct.setupPIN.size() + encoding:NSUTF8StringEncoding]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRAccountLoginClusterLoginParams - (instancetype)init @@ -7889,6 +10893,81 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::ElectricalMeasurement::Commands::GetProfileInfoResponseCommand::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRElectricalMeasurementClusterGetProfileInfoResponseCommandParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::ElectricalMeasurement::Commands::GetProfileInfoResponseCommand::DecodableType &)decodableStruct +{ + { + self.profileCount = [NSNumber numberWithUnsignedChar:decodableStruct.profileCount]; + } + { + self.profileIntervalPeriod = [NSNumber numberWithUnsignedChar:decodableStruct.profileIntervalPeriod]; + } + { + self.maxNumberOfIntervals = [NSNumber numberWithUnsignedChar:decodableStruct.maxNumberOfIntervals]; + } + { + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.listOfAttributes.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedShort:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.listOfAttributes = array_0; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRElectricalMeasurementClusterGetProfileInfoCommandParams - (instancetype)init @@ -7962,6 +11041,88 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::ElectricalMeasurement::Commands::GetMeasurementProfileResponseCommand::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRElectricalMeasurementClusterGetMeasurementProfileResponseCommandParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::ElectricalMeasurement::Commands::GetMeasurementProfileResponseCommand::DecodableType &) + decodableStruct +{ + { + self.startTime = [NSNumber numberWithUnsignedInt:decodableStruct.startTime]; + } + { + self.status = [NSNumber numberWithUnsignedChar:decodableStruct.status]; + } + { + self.profileIntervalPeriod = [NSNumber numberWithUnsignedChar:decodableStruct.profileIntervalPeriod]; + } + { + self.numberOfIntervalsDelivered = [NSNumber numberWithUnsignedChar:decodableStruct.numberOfIntervalsDelivered]; + } + { + self.attributeId = [NSNumber numberWithUnsignedShort:decodableStruct.attributeId]; + } + { + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.intervals.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.intervals = array_0; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRElectricalMeasurementClusterGetMeasurementProfileCommandParams - (instancetype)init @@ -8058,6 +11219,58 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestSpecificResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestSpecificResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestSpecificResponse::DecodableType &)decodableStruct +{ + { + self.returnValue = [NSNumber numberWithUnsignedChar:decodableStruct.returnValue]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestSpecificResponseParams @@ -8120,6 +11333,58 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestAddArgumentsResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestAddArgumentsResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestAddArgumentsResponse::DecodableType &)decodableStruct +{ + { + self.returnValue = [NSNumber numberWithUnsignedChar:decodableStruct.returnValue]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestAddArgumentsResponseParams @@ -8182,6 +11447,58 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestSimpleArgumentResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestSimpleArgumentResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestSimpleArgumentResponse::DecodableType &)decodableStruct +{ + { + self.returnValue = [NSNumber numberWithBool:decodableStruct.returnValue]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestSimpleArgumentResponseParams @@ -8259,6 +11576,221 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestStructArrayArgumentResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestStructArrayArgumentResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestStructArrayArgumentResponse::DecodableType &)decodableStruct +{ + { { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg1.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRUnitTestingClusterNestedStructList * newElement_0; + newElement_0 = [MTRUnitTestingClusterNestedStructList new]; + newElement_0.a = [NSNumber numberWithUnsignedChar:entry_0.a]; + newElement_0.b = [NSNumber numberWithBool:entry_0.b]; + newElement_0.c = [MTRUnitTestingClusterSimpleStruct new]; + newElement_0.c.a = [NSNumber numberWithUnsignedChar:entry_0.c.a]; + newElement_0.c.b = [NSNumber numberWithBool:entry_0.c.b]; + newElement_0.c.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c.c)]; + newElement_0.c.d = [NSData dataWithBytes:entry_0.c.d.data() length:entry_0.c.d.size()]; + newElement_0.c.e = [[NSString alloc] initWithBytes:entry_0.c.e.data() + length:entry_0.c.e.size() + encoding:NSUTF8StringEncoding]; + newElement_0.c.f = [NSNumber numberWithUnsignedChar:entry_0.c.f.Raw()]; + newElement_0.c.g = [NSNumber numberWithFloat:entry_0.c.g]; + newElement_0.c.h = [NSNumber numberWithDouble:entry_0.c.h]; + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.d.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + MTRUnitTestingClusterSimpleStruct * newElement_2; + newElement_2 = [MTRUnitTestingClusterSimpleStruct new]; + newElement_2.a = [NSNumber numberWithUnsignedChar:entry_2.a]; + newElement_2.b = [NSNumber numberWithBool:entry_2.b]; + newElement_2.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_2.c)]; + newElement_2.d = [NSData dataWithBytes:entry_2.d.data() length:entry_2.d.size()]; + newElement_2.e = [[NSString alloc] initWithBytes:entry_2.e.data() + length:entry_2.e.size() + encoding:NSUTF8StringEncoding]; + newElement_2.f = [NSNumber numberWithUnsignedChar:entry_2.f.Raw()]; + newElement_2.g = [NSNumber numberWithFloat:entry_2.g]; + newElement_2.h = [NSNumber numberWithDouble:entry_2.h]; + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_0.d = array_2; + } + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.e.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + NSNumber * newElement_2; + newElement_2 = [NSNumber numberWithUnsignedInt:entry_2]; + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_0.e = array_2; + } + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.f.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + NSData * newElement_2; + newElement_2 = [NSData dataWithBytes:entry_2.data() length:entry_2.size()]; + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_0.f = array_2; + } + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.g.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + NSNumber * newElement_2; + newElement_2 = [NSNumber numberWithUnsignedChar:entry_2]; + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_0.g = array_2; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.arg1 = array_0; +} +} +{ + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg2.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRUnitTestingClusterSimpleStruct * newElement_0; + newElement_0 = [MTRUnitTestingClusterSimpleStruct new]; + newElement_0.a = [NSNumber numberWithUnsignedChar:entry_0.a]; + newElement_0.b = [NSNumber numberWithBool:entry_0.b]; + newElement_0.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c)]; + newElement_0.d = [NSData dataWithBytes:entry_0.d.data() length:entry_0.d.size()]; + newElement_0.e = [[NSString alloc] initWithBytes:entry_0.e.data() + length:entry_0.e.size() + encoding:NSUTF8StringEncoding]; + newElement_0.f = [NSNumber numberWithUnsignedChar:entry_0.f.Raw()]; + newElement_0.g = [NSNumber numberWithFloat:entry_0.g]; + newElement_0.h = [NSNumber numberWithDouble:entry_0.h]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.arg2 = array_0; + } +} +{ + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg3.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.arg3 = array_0; + } +} +{ + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg4.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithBool:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.arg4 = array_0; + } +} +{ + self.arg5 = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.arg5)]; +} +{ + self.arg6 = [NSNumber numberWithBool:decodableStruct.arg6]; +} +return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestStructArrayArgumentResponseParams @@ -8327,6 +11859,72 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestListInt8UReverseResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestListInt8UReverseResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestListInt8UReverseResponse::DecodableType &)decodableStruct +{ + { + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg1.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.arg1 = array_0; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestListInt8UReverseResponseParams @@ -8395,6 +11993,61 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestEnumsResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestEnumsResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestEnumsResponse::DecodableType &)decodableStruct +{ + { + self.arg1 = [NSNumber numberWithUnsignedShort:chip::to_underlying(decodableStruct.arg1)]; + } + { + self.arg2 = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.arg2)]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestEnumsResponseParams @@ -8485,6 +12138,83 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestNullableOptionalResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestNullableOptionalResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestNullableOptionalResponse::DecodableType &)decodableStruct +{ + { + self.wasPresent = [NSNumber numberWithBool:decodableStruct.wasPresent]; + } + { + if (decodableStruct.wasNull.HasValue()) { + self.wasNull = [NSNumber numberWithBool:decodableStruct.wasNull.Value()]; + } else { + self.wasNull = nil; + } + } + { + if (decodableStruct.value.HasValue()) { + self.value = [NSNumber numberWithUnsignedChar:decodableStruct.value.Value()]; + } else { + self.value = nil; + } + } + { + if (decodableStruct.originalValue.HasValue()) { + if (decodableStruct.originalValue.Value().IsNull()) { + self.originalValue = nil; + } else { + self.originalValue = [NSNumber numberWithUnsignedChar:decodableStruct.originalValue.Value().Value()]; + } + } else { + self.originalValue = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestNullableOptionalResponseParams @@ -8645,6 +12375,292 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestComplexNullableOptionalResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestComplexNullableOptionalResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestComplexNullableOptionalResponse::DecodableType &)decodableStruct +{ + { + self.nullableIntWasNull = [NSNumber numberWithBool:decodableStruct.nullableIntWasNull]; + } + { + if (decodableStruct.nullableIntValue.HasValue()) { + self.nullableIntValue = [NSNumber numberWithUnsignedShort:decodableStruct.nullableIntValue.Value()]; + } else { + self.nullableIntValue = nil; + } + } + { + self.optionalIntWasPresent = [NSNumber numberWithBool:decodableStruct.optionalIntWasPresent]; + } + { + if (decodableStruct.optionalIntValue.HasValue()) { + self.optionalIntValue = [NSNumber numberWithUnsignedShort:decodableStruct.optionalIntValue.Value()]; + } else { + self.optionalIntValue = nil; + } + } + { + self.nullableOptionalIntWasPresent = [NSNumber numberWithBool:decodableStruct.nullableOptionalIntWasPresent]; + } + { + if (decodableStruct.nullableOptionalIntWasNull.HasValue()) { + self.nullableOptionalIntWasNull = [NSNumber numberWithBool:decodableStruct.nullableOptionalIntWasNull.Value()]; + } else { + self.nullableOptionalIntWasNull = nil; + } + } + { + if (decodableStruct.nullableOptionalIntValue.HasValue()) { + self.nullableOptionalIntValue = [NSNumber numberWithUnsignedShort:decodableStruct.nullableOptionalIntValue.Value()]; + } else { + self.nullableOptionalIntValue = nil; + } + } + { + self.nullableStringWasNull = [NSNumber numberWithBool:decodableStruct.nullableStringWasNull]; + } + { + if (decodableStruct.nullableStringValue.HasValue()) { + self.nullableStringValue = [[NSString alloc] initWithBytes:decodableStruct.nullableStringValue.Value().data() + length:decodableStruct.nullableStringValue.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.nullableStringValue = nil; + } + } + { + self.optionalStringWasPresent = [NSNumber numberWithBool:decodableStruct.optionalStringWasPresent]; + } + { + if (decodableStruct.optionalStringValue.HasValue()) { + self.optionalStringValue = [[NSString alloc] initWithBytes:decodableStruct.optionalStringValue.Value().data() + length:decodableStruct.optionalStringValue.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.optionalStringValue = nil; + } + } + { + self.nullableOptionalStringWasPresent = [NSNumber numberWithBool:decodableStruct.nullableOptionalStringWasPresent]; + } + { + if (decodableStruct.nullableOptionalStringWasNull.HasValue()) { + self.nullableOptionalStringWasNull = [NSNumber numberWithBool:decodableStruct.nullableOptionalStringWasNull.Value()]; + } else { + self.nullableOptionalStringWasNull = nil; + } + } + { + if (decodableStruct.nullableOptionalStringValue.HasValue()) { + self.nullableOptionalStringValue = + [[NSString alloc] initWithBytes:decodableStruct.nullableOptionalStringValue.Value().data() + length:decodableStruct.nullableOptionalStringValue.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + self.nullableOptionalStringValue = nil; + } + } + { + self.nullableStructWasNull = [NSNumber numberWithBool:decodableStruct.nullableStructWasNull]; + } + { + if (decodableStruct.nullableStructValue.HasValue()) { + self.nullableStructValue = [MTRUnitTestingClusterSimpleStruct new]; + self.nullableStructValue.a = [NSNumber numberWithUnsignedChar:decodableStruct.nullableStructValue.Value().a]; + self.nullableStructValue.b = [NSNumber numberWithBool:decodableStruct.nullableStructValue.Value().b]; + self.nullableStructValue.c = + [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.nullableStructValue.Value().c)]; + self.nullableStructValue.d = [NSData dataWithBytes:decodableStruct.nullableStructValue.Value().d.data() + length:decodableStruct.nullableStructValue.Value().d.size()]; + self.nullableStructValue.e = [[NSString alloc] initWithBytes:decodableStruct.nullableStructValue.Value().e.data() + length:decodableStruct.nullableStructValue.Value().e.size() + encoding:NSUTF8StringEncoding]; + self.nullableStructValue.f = [NSNumber numberWithUnsignedChar:decodableStruct.nullableStructValue.Value().f.Raw()]; + self.nullableStructValue.g = [NSNumber numberWithFloat:decodableStruct.nullableStructValue.Value().g]; + self.nullableStructValue.h = [NSNumber numberWithDouble:decodableStruct.nullableStructValue.Value().h]; + } else { + self.nullableStructValue = nil; + } + } + { + self.optionalStructWasPresent = [NSNumber numberWithBool:decodableStruct.optionalStructWasPresent]; + } + { + if (decodableStruct.optionalStructValue.HasValue()) { + self.optionalStructValue = [MTRUnitTestingClusterSimpleStruct new]; + self.optionalStructValue.a = [NSNumber numberWithUnsignedChar:decodableStruct.optionalStructValue.Value().a]; + self.optionalStructValue.b = [NSNumber numberWithBool:decodableStruct.optionalStructValue.Value().b]; + self.optionalStructValue.c = + [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.optionalStructValue.Value().c)]; + self.optionalStructValue.d = [NSData dataWithBytes:decodableStruct.optionalStructValue.Value().d.data() + length:decodableStruct.optionalStructValue.Value().d.size()]; + self.optionalStructValue.e = [[NSString alloc] initWithBytes:decodableStruct.optionalStructValue.Value().e.data() + length:decodableStruct.optionalStructValue.Value().e.size() + encoding:NSUTF8StringEncoding]; + self.optionalStructValue.f = [NSNumber numberWithUnsignedChar:decodableStruct.optionalStructValue.Value().f.Raw()]; + self.optionalStructValue.g = [NSNumber numberWithFloat:decodableStruct.optionalStructValue.Value().g]; + self.optionalStructValue.h = [NSNumber numberWithDouble:decodableStruct.optionalStructValue.Value().h]; + } else { + self.optionalStructValue = nil; + } + } + { + self.nullableOptionalStructWasPresent = [NSNumber numberWithBool:decodableStruct.nullableOptionalStructWasPresent]; + } + { + if (decodableStruct.nullableOptionalStructWasNull.HasValue()) { + self.nullableOptionalStructWasNull = [NSNumber numberWithBool:decodableStruct.nullableOptionalStructWasNull.Value()]; + } else { + self.nullableOptionalStructWasNull = nil; + } + } + { + if (decodableStruct.nullableOptionalStructValue.HasValue()) { + self.nullableOptionalStructValue = [MTRUnitTestingClusterSimpleStruct new]; + self.nullableOptionalStructValue.a = + [NSNumber numberWithUnsignedChar:decodableStruct.nullableOptionalStructValue.Value().a]; + self.nullableOptionalStructValue.b = [NSNumber numberWithBool:decodableStruct.nullableOptionalStructValue.Value().b]; + self.nullableOptionalStructValue.c = + [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.nullableOptionalStructValue.Value().c)]; + self.nullableOptionalStructValue.d = + [NSData dataWithBytes:decodableStruct.nullableOptionalStructValue.Value().d.data() + length:decodableStruct.nullableOptionalStructValue.Value().d.size()]; + self.nullableOptionalStructValue.e = + [[NSString alloc] initWithBytes:decodableStruct.nullableOptionalStructValue.Value().e.data() + length:decodableStruct.nullableOptionalStructValue.Value().e.size() + encoding:NSUTF8StringEncoding]; + self.nullableOptionalStructValue.f = + [NSNumber numberWithUnsignedChar:decodableStruct.nullableOptionalStructValue.Value().f.Raw()]; + self.nullableOptionalStructValue.g = [NSNumber numberWithFloat:decodableStruct.nullableOptionalStructValue.Value().g]; + self.nullableOptionalStructValue.h = [NSNumber numberWithDouble:decodableStruct.nullableOptionalStructValue.Value().h]; + } else { + self.nullableOptionalStructValue = nil; + } + } + { + self.nullableListWasNull = [NSNumber numberWithBool:decodableStruct.nullableListWasNull]; + } + { + if (decodableStruct.nullableListValue.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.nullableListValue.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + NSNumber * newElement_1; + newElement_1 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1)]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.nullableListValue = array_1; + } + } else { + self.nullableListValue = nil; + } + } + { + self.optionalListWasPresent = [NSNumber numberWithBool:decodableStruct.optionalListWasPresent]; + } + { + if (decodableStruct.optionalListValue.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.optionalListValue.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + NSNumber * newElement_1; + newElement_1 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1)]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.optionalListValue = array_1; + } + } else { + self.optionalListValue = nil; + } + } + { + self.nullableOptionalListWasPresent = [NSNumber numberWithBool:decodableStruct.nullableOptionalListWasPresent]; + } + { + if (decodableStruct.nullableOptionalListWasNull.HasValue()) { + self.nullableOptionalListWasNull = [NSNumber numberWithBool:decodableStruct.nullableOptionalListWasNull.Value()]; + } else { + self.nullableOptionalListWasNull = nil; + } + } + { + if (decodableStruct.nullableOptionalListValue.HasValue()) { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = decodableStruct.nullableOptionalListValue.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + NSNumber * newElement_1; + newElement_1 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1)]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + self.nullableOptionalListValue = array_1; + } + } else { + self.nullableOptionalListValue = nil; + } + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestComplexNullableOptionalResponseParams @@ -8709,6 +12725,58 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::BooleanResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterBooleanResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::BooleanResponse::DecodableType &)decodableStruct +{ + { + self.value = [NSNumber numberWithBool:decodableStruct.value]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterBooleanResponseParams @@ -8773,6 +12841,68 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::SimpleStructResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterSimpleStructResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::SimpleStructResponse::DecodableType &)decodableStruct +{ + { + self.arg1 = [MTRUnitTestingClusterSimpleStruct new]; + self.arg1.a = [NSNumber numberWithUnsignedChar:decodableStruct.arg1.a]; + self.arg1.b = [NSNumber numberWithBool:decodableStruct.arg1.b]; + self.arg1.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.arg1.c)]; + self.arg1.d = [NSData dataWithBytes:decodableStruct.arg1.d.data() length:decodableStruct.arg1.d.size()]; + self.arg1.e = [[NSString alloc] initWithBytes:decodableStruct.arg1.e.data() + length:decodableStruct.arg1.e.size() + encoding:NSUTF8StringEncoding]; + self.arg1.f = [NSNumber numberWithUnsignedChar:decodableStruct.arg1.f.Raw()]; + self.arg1.g = [NSNumber numberWithFloat:decodableStruct.arg1.g]; + self.arg1.h = [NSNumber numberWithDouble:decodableStruct.arg1.h]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterSimpleStructResponseParams @@ -8837,6 +12967,58 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestEmitTestEventResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestEmitTestEventResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestEmitTestEventResponse::DecodableType &)decodableStruct +{ + { + self.value = [NSNumber numberWithUnsignedLongLong:decodableStruct.value]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestEmitTestEventResponseParams @@ -8901,6 +13083,58 @@ - (NSString *)description return descriptionString; } +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventResponse::DecodableType &)decodableStruct +{ + { + self.value = [NSNumber numberWithUnsignedLongLong:decodableStruct.value]; + } + return CHIP_NO_ERROR; +} @end @implementation MTRTestClusterClusterTestEmitTestFabricScopedEventResponseParams diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h new file mode 100644 index 00000000000000..1de843868eb61f --- /dev/null +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h @@ -0,0 +1,417 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#include + +NS_ASSUME_NONNULL_BEGIN + +@interface MTRGroupsClusterAddGroupResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRGroupsClusterViewGroupResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Groups::Commands::ViewGroupResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRGroupsClusterGetGroupMembershipResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Groups::Commands::GetGroupMembershipResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRGroupsClusterRemoveGroupResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterAddSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::AddSceneResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterViewSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::ViewSceneResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterRemoveSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::RemoveSceneResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterRemoveAllScenesResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::RemoveAllScenesResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterStoreSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::StoreSceneResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterGetSceneMembershipResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::GetSceneMembershipResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterEnhancedAddSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::EnhancedAddSceneResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterEnhancedViewSceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::EnhancedViewSceneResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRScenesClusterCopySceneResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Scenes::Commands::CopySceneResponse::DecodableType &)decodableStruct; + +@end + +@interface MTROTASoftwareUpdateProviderClusterQueryImageResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::DecodableType &)decodableStruct; + +@end + +@interface MTROTASoftwareUpdateProviderClusterApplyUpdateResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRGeneralCommissioningClusterArmFailSafeResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafeResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRGeneralCommissioningClusterCommissioningCompleteResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GeneralCommissioning::Commands::CommissioningCompleteResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRNetworkCommissioningClusterScanNetworksResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworksResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRNetworkCommissioningClusterNetworkConfigResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRNetworkCommissioningClusterConnectNetworkResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRDiagnosticLogsClusterRetrieveLogsResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType &)decodableStruct; + +@end + +@interface MTROperationalCredentialsClusterAttestationResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType &)decodableStruct; + +@end + +@interface MTROperationalCredentialsClusterCertificateChainResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OperationalCredentials::Commands::CertificateChainResponse::DecodableType &)decodableStruct; + +@end + +@interface MTROperationalCredentialsClusterCSRResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OperationalCredentials::Commands::CSRResponse::DecodableType &)decodableStruct; + +@end + +@interface MTROperationalCredentialsClusterNOCResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::OperationalCredentials::Commands::NOCResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRGroupKeyManagementClusterKeySetReadResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRDoorLockClusterGetWeekDayScheduleResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRDoorLockClusterGetYearDayScheduleResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetYearDayScheduleResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRDoorLockClusterGetHolidayScheduleResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetHolidayScheduleResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRDoorLockClusterGetUserResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRDoorLockClusterSetCredentialResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRDoorLockClusterGetCredentialStatusResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRThermostatClusterGetWeeklyScheduleResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Thermostat::Commands::GetWeeklyScheduleResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRChannelClusterChangeChannelResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::Channel::Commands::ChangeChannelResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRTargetNavigatorClusterNavigateTargetResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRMediaPlaybackClusterPlaybackResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRKeypadInputClusterSendKeyResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRContentLauncherClusterLauncherResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::ContentLauncher::Commands::LauncherResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRApplicationLauncherClusterLauncherResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRAccountLoginClusterGetSetupPINResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::AccountLogin::Commands::GetSetupPINResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRElectricalMeasurementClusterGetProfileInfoResponseCommandParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::ElectricalMeasurement::Commands::GetProfileInfoResponseCommand::DecodableType &)decodableStruct; + +@end + +@interface MTRElectricalMeasurementClusterGetMeasurementProfileResponseCommandParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::ElectricalMeasurement::Commands::GetMeasurementProfileResponseCommand::DecodableType &) + decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestSpecificResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestSpecificResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestAddArgumentsResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestAddArgumentsResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestSimpleArgumentResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestSimpleArgumentResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestStructArrayArgumentResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestStructArrayArgumentResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestListInt8UReverseResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestListInt8UReverseResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestEnumsResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestEnumsResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestNullableOptionalResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestNullableOptionalResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestComplexNullableOptionalResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestComplexNullableOptionalResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterBooleanResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::BooleanResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterSimpleStructResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::SimpleStructResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestEmitTestEventResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestEmitTestEventResponse::DecodableType &)decodableStruct; + +@end + +@interface MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct: + (const chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventResponse::DecodableType &)decodableStruct; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/src/darwin/Framework/CHIPTests/MTRDataValueParserTests.m b/src/darwin/Framework/CHIPTests/MTRDataValueParserTests.m index 1eee9de6ccaded..53c4e47b498804 100644 --- a/src/darwin/Framework/CHIPTests/MTRDataValueParserTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDataValueParserTests.m @@ -973,4 +973,142 @@ - (void)test032_VeryLongListAttribute XCTAssertNil(report.error); } +- (void)test033_CommandResponse +{ + NSDictionary * input = @{ + MTRCommandPathKey : [MTRCommandPath commandPathWithEndpointID:@(0) + clusterID:@(MTRClusterIDTypeGroupsID) + commandID:@(MTRCommandIDTypeClusterGroupsCommandAddGroupResponseID)], + MTRDataKey : @ { + MTRTypeKey : MTRStructureValueType, + MTRValueKey : @[ + @{ + MTRContextTagKey : @(0), // Status + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(1), + }, + }, + @{ + MTRContextTagKey : @(1), // GroupID + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(0x176), + }, + }, + ], + }, + }; + + NSError * error; + __auto_type * payload = [[MTRGroupsClusterAddGroupResponseParams alloc] initWithResponseValue:input error:&error]; + XCTAssertNil(error); + XCTAssertNotNil(payload); + XCTAssertEqualObjects(payload.status, @(1)); + XCTAssertEqualObjects(payload.groupID, @(0x176)); +} + +- (void)test034_CommandResponseWrongCommandID +{ + NSDictionary * input = @{ + MTRCommandPathKey : + [MTRCommandPath commandPathWithEndpointID:@(0) + clusterID:@(MTRClusterIDTypeGroupsID) + commandID:@(MTRCommandIDTypeClusterGroupsCommandGetGroupMembershipResponseID)], + MTRDataKey : @ { + MTRTypeKey : MTRStructureValueType, + MTRValueKey : @[ + @{ + MTRContextTagKey : @(0), // Status + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(1), + }, + }, + @{ + MTRContextTagKey : @(1), // GroupID + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(0x176), + }, + }, + ], + }, + }; + + NSError * error; + __auto_type * payload = [[MTRGroupsClusterAddGroupResponseParams alloc] initWithResponseValue:input error:&error]; + XCTAssertNil(payload); + XCTAssertNotNil(error); + XCTAssertEqual(error.code, MTRErrorCodeSchemaMismatch); +} + +- (void)test035_CommandResponseWrongClusterID +{ + NSDictionary * input = @{ + MTRCommandPathKey : [MTRCommandPath commandPathWithEndpointID:@(0) + clusterID:@(MTRClusterIDTypeOnOffID) + commandID:@(MTRCommandIDTypeClusterGroupsCommandAddGroupResponseID)], + MTRDataKey : @ { + MTRTypeKey : MTRStructureValueType, + MTRValueKey : @[ + @{ + MTRContextTagKey : @(0), // Status + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(1), + }, + }, + @{ + MTRContextTagKey : @(1), // GroupID + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(0x176), + }, + }, + ], + }, + }; + + NSError * error; + __auto_type * payload = [[MTRGroupsClusterAddGroupResponseParams alloc] initWithResponseValue:input error:&error]; + XCTAssertNil(payload); + XCTAssertNotNil(error); + XCTAssertEqual(error.code, MTRErrorCodeSchemaMismatch); +} + +- (void)test036_CommandResponseWrongData +{ + NSDictionary * input = @{ + MTRCommandPathKey : [MTRCommandPath commandPathWithEndpointID:@(0) + clusterID:@(MTRClusterIDTypeGroupsID) + commandID:@(MTRCommandIDTypeClusterGroupsCommandAddGroupResponseID)], + MTRDataKey : @ { + MTRTypeKey : MTRStructureValueType, + MTRValueKey : @[ + @{ + MTRContextTagKey : @(0), // Status + MTRDataKey : @ { + MTRTypeKey : MTRSignedIntegerValueType, // Wrong data type + MTRValueKey : @(1), + }, + }, + @{ + MTRContextTagKey : @(1), // GroupID + MTRDataKey : @ { + MTRTypeKey : MTRUnsignedIntegerValueType, + MTRValueKey : @(0x176), + }, + }, + ], + }, + }; + + NSError * error; + __auto_type * payload = [[MTRGroupsClusterAddGroupResponseParams alloc] initWithResponseValue:input error:&error]; + XCTAssertNil(payload); + XCTAssertNotNil(error); + XCTAssertEqual(error.code, MTRErrorCodeSchemaMismatch); +} + @end diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index 2c3d949ba79ecc..9bef78fe0ab941 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -1271,6 +1271,17 @@ - (void)test014_InvokeCommandWithDifferentIdResponse }; XCTAssertEqualObjects(result[MTRDataKey], expectedResult); XCTAssertNil(result[MTRErrorKey]); + + // Now check our strong-typed parsing bits. + NSError * parseError; + __auto_type * response = + [[MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams alloc] + initWithResponseValue:result + error:&parseError]; + XCTAssertNil(parseError); + XCTAssertNotNil(response); + XCTAssertEqual(response.groupKeySetIDs.count, 1); + XCTAssertEqualObjects(response.groupKeySetIDs[0], @(0)); } XCTAssertEqual([resultArray count], 1); }