From 6f47b109d3e1a228e6682c30ca579962ffceb3d2 Mon Sep 17 00:00:00 2001 From: Jeff Tung Date: Wed, 27 Jul 2022 17:31:22 -0700 Subject: [PATCH] Issue 18505 - Darwin: synchronous API part 1: basic structure and serial read --- .restyled.yaml | 1 + .../CHIP/MTRAsyncCallbackWorkQueue.h | 62 + .../CHIP/MTRAsyncCallbackWorkQueue.mm | 197 + .../CHIP/MTRAsyncCallbackWorkQueue_Internal.h | 34 + .../CHIP/MTRAttributeCacheContainer.mm | 2 +- src/darwin/Framework/CHIP/MTRBaseDevice.h | 14 +- src/darwin/Framework/CHIP/MTRBaseDevice.mm | 143 +- .../Framework/CHIP/MTRBaseDevice_Internal.h | 19 +- src/darwin/Framework/CHIP/MTRCluster.h | 4 + src/darwin/Framework/CHIP/MTRDevice.h | 152 + src/darwin/Framework/CHIP/MTRDevice.mm | 818 + .../Framework/CHIP/MTRDeviceController.mm | 30 + .../CHIP/MTRDeviceController_Internal.h | 13 +- .../Framework/CHIP/MTRDevice_Internal.h | 46 + src/darwin/Framework/CHIP/Matter.h | 3 + .../CHIP/templates/MTRBaseClusters.zapt | 4 - .../templates/MTRBaseClusters_internal.zapt | 2 +- .../CHIP/templates/MTRClusters-src.zapt | 151 + .../Framework/CHIP/templates/MTRClusters.zapt | 50 + .../CHIP/templates/MTRClusters_internal.zapt | 19 + .../Framework/CHIP/templates/templates.json | 21 +- .../CHIP/zap-generated/MTRBaseClusters.h | 4 - .../zap-generated/MTRBaseClusters_internal.h | 130 +- .../CHIP/zap-generated/MTRClusters.h | 5284 ++++ .../CHIP/zap-generated/MTRClusters.mm | 23957 ++++++++++++++++ .../CHIP/zap-generated/MTRClusters_internal.h | 352 + .../CHIPTests/MTRAsyncCallbackQueueTests.m | 147 + .../Framework/CHIPTests/MTRDeviceTests.m | 20 +- .../Framework/CHIPTests/MTRXPCProtocolTests.m | 48 +- .../Matter.xcodeproj/project.pbxproj | 44 + 30 files changed, 31589 insertions(+), 182 deletions(-) create mode 100644 src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.h create mode 100644 src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.mm create mode 100644 src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue_Internal.h create mode 100644 src/darwin/Framework/CHIP/MTRDevice.h create mode 100644 src/darwin/Framework/CHIP/MTRDevice.mm create mode 100644 src/darwin/Framework/CHIP/MTRDevice_Internal.h create mode 100644 src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt create mode 100644 src/darwin/Framework/CHIP/templates/MTRClusters.zapt create mode 100644 src/darwin/Framework/CHIP/templates/MTRClusters_internal.zapt create mode 100644 src/darwin/Framework/CHIP/zap-generated/MTRClusters.h create mode 100644 src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm create mode 100644 src/darwin/Framework/CHIP/zap-generated/MTRClusters_internal.h create mode 100644 src/darwin/Framework/CHIPTests/MTRAsyncCallbackQueueTests.m diff --git a/.restyled.yaml b/.restyled.yaml index c45fe98588b7ec..77e24305402490 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -73,6 +73,7 @@ exclude: - "examples/chef/sample_app_util/test_files/*.yaml" - "examples/chef/zzz_generated/**/*" - "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm" # https://github.com/project-chip/connectedhomeip/issues/20236 + - "src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm" changed_paths: diff --git a/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.h b/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.h new file mode 100644 index 00000000000000..473aed2797c9f0 --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.h @@ -0,0 +1,62 @@ +/** + * + * 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 + +NS_ASSUME_NONNULL_BEGIN + +@class MTRDevice; +@class MTRAsyncCallbackQueueWorkItem; + +typedef void (^MTRAsyncCallbackReadyHandler)(MTRDevice * device, NSUInteger retryCount); + +// How to queue a new work item: +// - Create MTRAsyncCallbackQueueWorkItem object +// - Create ready handler block (MTRAsyncCallbackReadyHandler) +// - block is called when it's the work item's turn to do work +// - its body is to do work with the device +// - at the end of work, call on the work item object: +// - endWork for success or failure +// - retryWork for temporary failures +// - Set the work handler block to the Item object +// - Call enqueueWorkItem on the MTRDevice's work queue property + +// A serial one-at-a-time queue for performing work items +@interface MTRAsyncCallbackWorkQueue : NSObject +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +- (void)enqueueWorkItem:(MTRAsyncCallbackQueueWorkItem *)item; + +// TODO: Add a "set concurrency width" method to allow for more than 1 work item at a time +@end + +// An item in the work queue +@interface MTRAsyncCallbackQueueWorkItem : NSObject +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +- (instancetype)initWithQueue:(dispatch_queue_t)queue; +@property (nonatomic, strong) MTRAsyncCallbackReadyHandler readyHandler; +@property (nonatomic, strong) dispatch_block_t cancelHandler; + +// Called by Cluster object's after async work is done +- (void)endWork; +- (void)retryWork; +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.mm b/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.mm new file mode 100644 index 00000000000000..26c9f664646349 --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.mm @@ -0,0 +1,197 @@ +/** + * + * 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 +#import + +#import "MTRAsyncCallbackWorkQueue_Internal.h" +#import "MTRLogging.h" + +#pragma mark - Class extensions + +@interface MTRAsyncCallbackWorkQueue () +@property (nonatomic, readonly) os_unfair_lock lock; +@property (nonatomic, strong, readonly) MTRDevice * device; +@property (nonatomic, strong, readonly) dispatch_queue_t queue; +@property (nonatomic, strong, readonly) NSMutableArray * items; +@property (nonatomic, readwrite) NSUInteger runningWorkItemCount; + +// For WorkItem's use only - the parameter is for sanity check +- (void)endWork:(MTRAsyncCallbackQueueWorkItem *)workItem; +- (void)retryWork:(MTRAsyncCallbackQueueWorkItem *)workItem; +@end + +@interface MTRAsyncCallbackQueueWorkItem () +@property (nonatomic, strong, readonly) dispatch_queue_t queue; +@property (nonatomic, readwrite) NSUInteger retryCount; +@property (nonatomic, strong) MTRAsyncCallbackWorkQueue * workQueue; +// Called by the queue +- (void)callReadyHandlerWithDevice:(MTRDevice *)device; +- (void)cancel; +@end + +#pragma mark - Class implementations + +@implementation MTRAsyncCallbackWorkQueue +- (instancetype)initWithDevice:(MTRDevice *)device queue:(dispatch_queue_t)queue +{ + if (self = [super init]) { + _lock = OS_UNFAIR_LOCK_INIT; + _device = device; + _queue = queue; + _items = [NSMutableArray array]; + } + return self; +} + +- (void)enqueueWorkItem:(MTRAsyncCallbackQueueWorkItem *)item +{ + os_unfair_lock_lock(&_lock); + item.workQueue = self; + [self.items addObject:item]; + + [self _callNextReadyWorkItem]; + os_unfair_lock_unlock(&_lock); +} + +- (void)invalidate +{ + os_unfair_lock_lock(&_lock); + NSMutableArray * invalidateItems = _items; + _items = nil; + os_unfair_lock_unlock(&_lock); + + for (MTRAsyncCallbackQueueWorkItem * item in invalidateItems) { + [item cancel]; + } + [invalidateItems removeAllObjects]; +} + +- (void)endWork:(MTRAsyncCallbackQueueWorkItem *)workItem +{ + os_unfair_lock_lock(&_lock); + // sanity check if running + if (!self.runningWorkItemCount) { + // something is wrong with state - nothing is currently running + os_unfair_lock_unlock(&_lock); + MTR_LOG_ERROR("endWork: no work is running on work queue"); + return; + } + + // sanity check the same work item is running + // when "concurrency width" is implemented need to check first N items + MTRAsyncCallbackQueueWorkItem * firstWorkItem = self.items.firstObject; + if (firstWorkItem != workItem) { + // something is wrong with this work item - should not be currently running + os_unfair_lock_unlock(&_lock); + MTR_LOG_ERROR("endWork: work item is not first on work queue"); + return; + } + + // since work is done, remove from queue and call ready on the next item + [self.items removeObjectAtIndex:0]; + + // when "concurrency width" is implemented this will be decremented instead + self.runningWorkItemCount = 0; + [self _callNextReadyWorkItem]; + os_unfair_lock_unlock(&_lock); +} + +- (void)retryWork:(MTRAsyncCallbackQueueWorkItem *)workItem +{ + // reset BOOL and call again + os_unfair_lock_lock(&_lock); + // sanity check if running + if (!self.runningWorkItemCount) { + // something is wrong with state - nothing is currently running + os_unfair_lock_unlock(&_lock); + MTR_LOG_ERROR("retryWork: no work is running on work queue"); + return; + } + + // sanity check the same work item is running + // when "concurrency width" is implemented need to check first N items + MTRAsyncCallbackQueueWorkItem * firstWorkItem = self.items.firstObject; + if (firstWorkItem != workItem) { + // something is wrong with this work item - should not be currently running + os_unfair_lock_unlock(&_lock); + MTR_LOG_ERROR("retryWork: work item is not first on work queue"); + return; + } + + // when "concurrency width" is implemented this will be decremented instead + self.runningWorkItemCount = 0; + [self _callNextReadyWorkItem]; + os_unfair_lock_unlock(&_lock); +} + +// assume lock is held while calling this +- (void)_callNextReadyWorkItem +{ + // when "concurrency width" is implemented this will be checked against the width + if (self.runningWorkItemCount) { + // can't run next work item until the current one is done + return; + } + + // when "concurrency width" is implemented this will be incremented instead + self.runningWorkItemCount = 1; + + MTRAsyncCallbackQueueWorkItem * workItem = self.items.firstObject; + [workItem callReadyHandlerWithDevice:self.device]; +} +@end + +@implementation MTRAsyncCallbackQueueWorkItem + +- (instancetype)initWithQueue:(dispatch_queue_t)queue +{ + if (self = [super init]) { + _queue = queue; + } + return self; +} + +// Called by Cluster object's after async work is done +- (void)endWork +{ + [self.workQueue endWork:self]; +} + +// Called by Cluster object's after async work is done +- (void)retryWork +{ + [self.workQueue retryWork:self]; +} + +// Called by the work queue +- (void)callReadyHandlerWithDevice:(MTRDevice *)device +{ + dispatch_async(self.queue, ^{ + self.readyHandler(device, self.retryCount); + self.retryCount++; + }); +} + +// Called by the work queue +- (void)cancel +{ + dispatch_async(self.queue, ^{ + self.cancelHandler(); + }); +} +@end diff --git a/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue_Internal.h b/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue_Internal.h new file mode 100644 index 00000000000000..6a727d08aecaaf --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue_Internal.h @@ -0,0 +1,34 @@ +/** + * + * 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 + +#import "MTRAsyncCallbackWorkQueue.h" + +NS_ASSUME_NONNULL_BEGIN + +@class MTRDevice; + +@interface MTRAsyncCallbackWorkQueue () +// The MTRDevice object is only held and passed back as a reference and is opaque to the queue +- (instancetype)initWithDevice:(MTRDevice *)device queue:(dispatch_queue_t)queue; + +// Called by DeviceController at device clean up time +- (void)invalidate; +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm b/src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm index e0ee3e77e43a4b..2ec0d10d4eac38 100644 --- a/src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm +++ b/src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm @@ -58,7 +58,7 @@ static CHIP_ERROR AppendAttibuteValueToArray( chip::TLV::TLVReader reader; CHIP_ERROR err = cache->Get(path, reader); if (err == CHIP_NO_ERROR) { - id obj = NSObjectFromCHIPTLV(&reader); + id obj = MTRDecodeDataValueDictionaryFromCHIPTLV(&reader); if (obj) { [array addObject:@ { MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:path], MTRDataKey : obj }]; return CHIP_NO_ERROR; diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.h b/src/darwin/Framework/CHIP/MTRBaseDevice.h index 815e37c3c7d655..8d0b89406abbd2 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.h @@ -67,6 +67,8 @@ NS_ASSUME_NONNULL_BEGIN * MTRDataKey : Data-value NSDictionary object. */ typedef void (^MTRDeviceResponseHandler)(NSArray *> * _Nullable values, NSError * _Nullable error); +typedef void (^MTRDeviceReportHandler)(NSArray * values); +typedef void (^MTRDeviceErrorHandler)(NSError * error); extern NSString * const MTRAttributePathKey; extern NSString * const MTRCommandPathKey; @@ -129,12 +131,12 @@ extern NSString * const MTRArrayValueType; - (void)subscribeWithQueue:(dispatch_queue_t)queue minInterval:(uint16_t)minInterval maxInterval:(uint16_t)maxInterval - params:(nullable MTRSubscribeParams *)params + params:(MTRSubscribeParams * _Nullable)params cacheContainer:(MTRAttributeCacheContainer * _Nullable)attributeCacheContainer - attributeReportHandler:(nullable void (^)(NSArray * value))attributeReportHandler - eventReportHandler:(nullable void (^)(NSArray * value))eventReportHandler - errorHandler:(void (^)(NSError * error))errorHandler - subscriptionEstablished:(nullable void (^)(void))subscriptionEstablishedHandler; + attributeReportHandler:(MTRDeviceReportHandler _Nullable)attributeReportHandler + eventReportHandler:(MTRDeviceReportHandler _Nullable)eventReportHandler + errorHandler:(MTRDeviceErrorHandler)errorHandler + subscriptionEstablished:(dispatch_block_t _Nullable)subscriptionEstablishedHandler; /** * Read attribute in a designated attribute path @@ -211,7 +213,7 @@ extern NSString * const MTRArrayValueType; @end -@interface MTRAttributePath : NSObject +@interface MTRAttributePath : NSObject @property (nonatomic, readonly, strong, nonnull) NSNumber * endpoint; @property (nonatomic, readonly, strong, nonnull) NSNumber * cluster; @property (nonatomic, readonly, strong, nonnull) NSNumber * attribute; diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index c1a54ac7b6983d..52b2e98375f81c 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -63,7 +63,7 @@ NSString * const MTRStructureValueType = @"Structure"; NSString * const MTRArrayValueType = @"Array"; -class NSObjectDataValueCallbackBridge; +class MTRDataValueDictionaryCallbackBridge; @interface MTRBaseDevice () @@ -73,19 +73,6 @@ @interface MTRBaseDevice () @end -@interface MTRAttributeReport () -- (instancetype)initWithPath:(const ConcreteDataAttributePath &)path value:(nullable id)value error:(nullable NSError *)error; -@end - -@interface MTREventReport () -- (instancetype)initWithPath:(const ConcreteEventPath &)path - eventNumber:(NSNumber *)eventNumber - priority:(NSNumber *)priority - timestamp:(NSNumber *)timestamp - value:(nullable id)value - error:(nullable NSError *)error; -@end - @interface MTRReadClientContainer : NSObject @property (nonatomic, readwrite) app::ReadClient * readClientPtr; @property (nonatomic, readwrite) app::AttributePathParams * pathParams; @@ -430,8 +417,8 @@ - (void)subscribeWithQueue:(dispatch_queue_t)queue }); } -// Convert TLV data into NSObject -id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) +// Convert TLV data into data-value dictionary as described in MTRDeviceResponseHandler +id _Nullable MTRDecodeDataValueDictionaryFromCHIPTLV(chip::TLV::TLVReader * data) { chip::TLV::TLVType dataTLVType = data->GetType(); switch (dataTLVType) { @@ -529,7 +516,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) NSMutableArray * array = [[NSMutableArray alloc] init]; while ((err = data->Next()) == CHIP_NO_ERROR) { chip::TLV::Tag tag = data->GetTag(); - id value = NSObjectFromCHIPTLV(data); + id value = MTRDecodeDataValueDictionaryFromCHIPTLV(data); if (value == nullptr) { MTR_LOG_ERROR("Error when decoding TLV container"); return nil; @@ -558,7 +545,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) } } -static CHIP_ERROR EncodeTLVFromObject(id object, chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) +static CHIP_ERROR MTREncodeTLVFromDataValueDictionary(id object, chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) { if (![object isKindOfClass:[NSDictionary class]]) { MTR_LOG_ERROR("Error: Unsupported object to encode: %@", [object class]); @@ -640,7 +627,8 @@ static CHIP_ERROR EncodeTLVFromObject(id object, chip::TLV::TLVWriter & writer, MTR_LOG_ERROR("Error: Structure element to encode has corrupt value: %@", element); return CHIP_ERROR_INVALID_ARGUMENT; } - ReturnErrorOnFailure(EncodeTLVFromObject(elementValue, writer, chip::TLV::ContextTag([elementTag unsignedCharValue]))); + ReturnErrorOnFailure( + MTREncodeTLVFromDataValueDictionary(elementValue, writer, chip::TLV::ContextTag([elementTag unsignedCharValue]))); } ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; @@ -662,7 +650,7 @@ static CHIP_ERROR EncodeTLVFromObject(id object, chip::TLV::TLVWriter & writer, MTR_LOG_ERROR("Error: Array element to encode has corrupt value: %@", element); return CHIP_ERROR_INVALID_ARGUMENT; } - ReturnErrorOnFailure(EncodeTLVFromObject(elementValue, writer, chip::TLV::AnonymousTag())); + ReturnErrorOnFailure(MTREncodeTLVFromDataValueDictionary(elementValue, writer, chip::TLV::AnonymousTag())); } ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; @@ -672,24 +660,24 @@ static CHIP_ERROR EncodeTLVFromObject(id object, chip::TLV::TLVWriter & writer, } // Callback type to pass data value as an NSObject -typedef void (*NSObjectDataValueCallback)(void * context, id value); +typedef void (*MTRDataValueDictionaryCallback)(void * context, id value); typedef void (*MTRErrorCallback)(void * context, CHIP_ERROR error); // Rename to be generic for decode and encode -class NSObjectData { +class MTRDataValueDictionaryDecodableType { public: - NSObjectData() + MTRDataValueDictionaryDecodableType() : decodedObj(nil) { } - NSObjectData(id obj) + MTRDataValueDictionaryDecodableType(id obj) : decodedObj(obj) { } CHIP_ERROR Decode(chip::TLV::TLVReader & data) { - decodedObj = NSObjectFromCHIPTLV(&data); + decodedObj = MTRDecodeDataValueDictionaryFromCHIPTLV(&data); if (decodedObj == nil) { MTR_LOG_ERROR("Error: Failed to get value from TLV data for attribute reading response"); } @@ -698,7 +686,7 @@ CHIP_ERROR Decode(chip::TLV::TLVReader & data) CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const { - return EncodeTLVFromObject(decodedObj, writer, tag); + return MTREncodeTLVFromDataValueDictionary(decodedObj, writer, tag); } static constexpr bool kIsFabricScoped = false; @@ -711,12 +699,12 @@ CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const id _Nullable decodedObj; }; -// Callback bridge for NSObjectDataValueCallback -class NSObjectDataValueCallbackBridge : public MTRCallbackBridge { +// Callback bridge for MTRDataValueDictionaryCallback +class MTRDataValueDictionaryCallbackBridge : public MTRCallbackBridge { public: - NSObjectDataValueCallbackBridge( + MTRDataValueDictionaryCallbackBridge( dispatch_queue_t queue, MTRDeviceResponseHandler handler, MTRActionBlock action, bool keepAlive = false) - : MTRCallbackBridge(queue, handler, action, OnSuccessFn, keepAlive) {}; + : MTRCallbackBridge(queue, handler, action, OnSuccessFn, keepAlive) {}; static void OnSuccessFn(void * context, id value) { DispatchSuccess(context, value); } }; @@ -805,9 +793,9 @@ - (void)readAttributeWithEndpointId:(NSNumber *)endpointId clientQueue:(dispatch_queue_t)clientQueue completion:(MTRDeviceResponseHandler)completion { - new NSObjectDataValueCallbackBridge( + new MTRDataValueDictionaryCallbackBridge( clientQueue, completion, ^(chip::Callback::Cancelable * success, chip::Callback::Cancelable * failure) { - auto successFn = chip::Callback::Callback::FromCancelable(success); + auto successFn = chip::Callback::Callback::FromCancelable(success); auto failureFn = chip::Callback::Callback::FromCancelable(failure); auto context = successFn->mContext; auto successCb = successFn->mCall; @@ -815,16 +803,16 @@ new NSObjectDataValueCallbackBridge( auto resultArray = [[NSMutableArray alloc] init]; auto resultSuccess = [[NSMutableArray alloc] init]; auto resultFailure = [[NSMutableArray alloc] init]; - auto onSuccessCb - = [resultArray, resultSuccess](const app::ConcreteAttributePath & attribPath, const NSObjectData & aData) { - [resultArray addObject:@ { - MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:attribPath], - MTRDataKey : aData.GetDecodedObject() - }]; - if ([resultSuccess count] == 0) { - [resultSuccess addObject:[NSNumber numberWithBool:YES]]; - } - }; + auto onSuccessCb = [resultArray, resultSuccess](const app::ConcreteAttributePath & attribPath, + const MTRDataValueDictionaryDecodableType & aData) { + [resultArray addObject:@ { + MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:attribPath], + MTRDataKey : aData.GetDecodedObject() + }]; + if ([resultSuccess count] == 0) { + [resultSuccess addObject:[NSNumber numberWithBool:YES]]; + } + }; auto onFailureCb = [resultArray, resultFailure](const app::ConcreteAttributePath * attribPath, CHIP_ERROR aError) { if (attribPath) { @@ -856,7 +844,7 @@ new NSObjectDataValueCallbackBridge( readParams.mIsFabricFiltered = params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]; auto onDone = [resultArray, resultSuccess, resultFailure, context, successCb, failureCb]( - BufferedReadAttributeCallback * callback) { + BufferedReadAttributeCallback * callback) { if ([resultFailure count] > 0 || [resultSuccess count] == 0) { // Failure if (failureCb) { @@ -877,7 +865,7 @@ new NSObjectDataValueCallbackBridge( chip::Platform::Delete(callback); }; - auto callback = chip::Platform::MakeUnique>( + auto callback = chip::Platform::MakeUnique>( attributePath.mClusterId, attributePath.mAttributeId, onSuccessCb, onFailureCb, onDone, nullptr); VerifyOrReturnError(callback != nullptr, CHIP_ERROR_NO_MEMORY); @@ -910,9 +898,9 @@ - (void)writeAttributeWithEndpointId:(NSNumber *)endpointId clientQueue:(dispatch_queue_t)clientQueue completion:(MTRDeviceResponseHandler)completion { - new NSObjectDataValueCallbackBridge( + new MTRDataValueDictionaryCallbackBridge( clientQueue, completion, ^(chip::Callback::Cancelable * success, chip::Callback::Cancelable * failure) { - auto successFn = chip::Callback::Callback::FromCancelable(success); + auto successFn = chip::Callback::Callback::FromCancelable(success); auto failureFn = chip::Callback::Callback::FromCancelable(failure); auto context = successFn->mContext; auto successCb = successFn->mCall; @@ -961,18 +949,19 @@ new NSObjectDataValueCallbackBridge( } }; - return chip::Controller::WriteAttribute([self internalDevice]->GetSecureSession().Value(), - static_cast([endpointId unsignedShortValue]), + return chip::Controller::WriteAttribute( + [self internalDevice]->GetSecureSession().Value(), static_cast([endpointId unsignedShortValue]), static_cast([clusterId unsignedLongValue]), - static_cast([attributeId unsignedLongValue]), NSObjectData(value), onSuccessCb, onFailureCb, - (timeoutMs == nil) ? NullOptional : Optional([timeoutMs unsignedShortValue]), onDoneCb, NullOptional); + static_cast([attributeId unsignedLongValue]), MTRDataValueDictionaryDecodableType(value), + onSuccessCb, onFailureCb, (timeoutMs == nil) ? NullOptional : Optional([timeoutMs unsignedShortValue]), + onDoneCb, NullOptional); }); } class NSObjectCommandCallback final : public app::CommandSender::Callback { public: using OnSuccessCallbackType - = std::function; + = std::function; using OnErrorCallbackType = std::function; using OnDoneCallbackType = std::function; @@ -1013,7 +1002,7 @@ void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommand void NSObjectCommandCallback::OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aCommandPath, const app::StatusIB & aStatus, TLV::TLVReader * aReader) { - NSObjectData response; + MTRDataValueDictionaryDecodableType response; CHIP_ERROR err = CHIP_NO_ERROR; // @@ -1042,9 +1031,9 @@ - (void)invokeCommandWithEndpointId:(NSNumber *)endpointId clientQueue:(dispatch_queue_t)clientQueue completion:(MTRDeviceResponseHandler)completion { - new NSObjectDataValueCallbackBridge( + new MTRDataValueDictionaryCallbackBridge( clientQueue, completion, ^(chip::Callback::Cancelable * success, chip::Callback::Cancelable * failure) { - auto successFn = chip::Callback::Callback::FromCancelable(success); + auto successFn = chip::Callback::Callback::FromCancelable(success); auto failureFn = chip::Callback::Callback::FromCancelable(failure); auto context = successFn->mContext; auto successCb = successFn->mCall; @@ -1053,7 +1042,7 @@ new NSObjectDataValueCallbackBridge( auto resultSuccess = [[NSMutableArray alloc] init]; auto resultFailure = [[NSMutableArray alloc] init]; auto onSuccessCb = [resultArray, resultSuccess](const app::ConcreteCommandPath & commandPath, - const app::StatusIB & status, const NSObjectData & responseData) { + const app::StatusIB & status, const MTRDataValueDictionaryDecodableType & responseData) { if (responseData.GetDecodedObject()) { [resultArray addObject:@ { MTRCommandPathKey : [[MTRCommandPath alloc] initWithPath:commandPath], @@ -1109,7 +1098,7 @@ new NSObjectDataValueCallbackBridge( = chip::Platform::MakeUnique(decoder.get(), [self internalDevice]->GetExchangeManager(), false); VerifyOrReturnError(commandSender != nullptr, CHIP_ERROR_NO_MEMORY); - ReturnErrorOnFailure(commandSender->AddRequestData(commandPath, NSObjectData(commandFields), + ReturnErrorOnFailure(commandSender->AddRequestData(commandPath, MTRDataValueDictionaryDecodableType(commandFields), (timeoutMs == nil) ? NullOptional : Optional([timeoutMs unsignedShortValue]))); ReturnErrorOnFailure(commandSender->SendCommandRequest([self internalDevice]->GetSecureSession().Value())); @@ -1130,7 +1119,8 @@ - (void)subscribeAttributeWithEndpointId:(NSNumber * _Nullable)endpointId subscriptionEstablished:(SubscriptionEstablishedHandler)subscriptionEstablishedHandler { dispatch_async(DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{ - auto onReportCb = [clientQueue, reportHandler](const app::ConcreteAttributePath & attribPath, const NSObjectData & data) { + auto onReportCb = [clientQueue, reportHandler]( + const app::ConcreteAttributePath & attribPath, const MTRDataValueDictionaryDecodableType & data) { id valueObject = data.GetDecodedObject(); app::ConcreteAttributePath pathCopy = attribPath; dispatch_async(clientQueue, ^{ @@ -1191,12 +1181,12 @@ - (void)subscribeAttributeWithEndpointId:(NSNumber * _Nullable)endpointId readParams.mKeepSubscriptions = (params != nil && params.keepPreviousSubscriptions != nil && [params.keepPreviousSubscriptions boolValue]); - auto onDone = [container](BufferedReadAttributeCallback * callback) { + auto onDone = [container](BufferedReadAttributeCallback * callback) { chip::Platform::Delete(callback); [container onDone]; }; - auto callback = chip::Platform::MakeUnique>( + auto callback = chip::Platform::MakeUnique>( container.pathParams->mClusterId, container.pathParams->mAttributeId, onReportCb, onFailureCb, onDone, onEstablishedCb); auto readClient = Platform::New(engine, [self internalDevice]->GetExchangeManager(), @@ -1240,7 +1230,7 @@ - (void)failSubscribers:(dispatch_queue_t)clientQueue completion:(void (^)(void) // The following method is for unit testing purpose only + (id)CHIPEncodeAndDecodeNSObject:(id)object { - NSObjectData originalData(object); + MTRDataValueDictionaryDecodableType originalData(object); chip::TLV::TLVWriter writer; uint8_t buffer[1024]; writer.Init(buffer, sizeof(buffer)); @@ -1268,7 +1258,7 @@ + (id)CHIPEncodeAndDecodeNSObject:(id)object MTR_LOG_ERROR("Error: TLV reader did not read the tag correctly: %llu", tag.mVal); return nil; } - NSObjectData decodedData; + MTRDataValueDictionaryDecodableType decodedData; error = decodedData.Decode(reader); if (error != CHIP_NO_ERROR) { MTR_LOG_ERROR("Error: Data decoding failed: %s", error.AsString()); @@ -1290,6 +1280,13 @@ - (instancetype)initWithPath:(const ConcreteDataAttributePath &)path return self; } +- (NSString *)description +{ + return [NSString stringWithFormat:@" endpoint %u cluster %u attribute %u", + (uint16_t) _endpoint.unsignedShortValue, (uint32_t) _cluster.unsignedLongValue, + (uint32_t) _attribute.unsignedLongValue]; +} + + (instancetype)attributePathWithEndpointId:(NSNumber *)endpoint clusterId:(NSNumber *)clusterId attributeId:(NSNumber *)attributeId { ConcreteDataAttributePath path(static_cast([endpoint unsignedShortValue]), @@ -1298,6 +1295,30 @@ ConcreteDataAttributePath path(static_cast([endpoint unsignedS return [[MTRAttributePath alloc] initWithPath:path]; } + +- (BOOL)isEqualToAttributePath:(MTRAttributePath *)attributePath +{ + return [_endpoint isEqualToNumber:attributePath.endpoint] && [_cluster isEqualToNumber:attributePath.cluster] && + [_attribute isEqualToNumber:attributePath.attribute]; +} + +- (BOOL)isEqual:(id)object +{ + if (![object isKindOfClass:[self class]]) { + return NO; + } + return [self isEqualToAttributePath:object]; +} + +- (NSUInteger)hash +{ + return _endpoint.unsignedShortValue ^ _cluster.unsignedLongValue ^ _attribute.unsignedLongValue; +} + +- (id)copyWithZone:(NSZone *)zone +{ + return [MTRAttributePath attributePathWithEndpointId:_endpoint clusterId:_cluster attributeId:_attribute]; +} @end @implementation MTREventPath diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h b/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h index 0bc99ae0c3c7ba..385ff1790fcda0 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h @@ -20,6 +20,7 @@ #include #include +#include #include NS_ASSUME_NONNULL_BEGIN @@ -46,7 +47,23 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithPath:(const chip::app::ConcreteCommandPath &)path; @end +@interface MTRAttributeReport () +- (instancetype)initWithPath:(const chip::app::ConcreteDataAttributePath &)path + value:(nullable id)value + error:(nullable NSError *)error; +@end + +@interface MTREventReport () +- (instancetype)initWithPath:(const chip::app::ConcreteEventPath &)path + eventNumber:(NSNumber *)eventNumber + priority:(NSNumber *)priority + timestamp:(NSNumber *)timestamp + value:(nullable id)value + error:(nullable NSError *)error; +@end + // Exported utility function -id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data); +// Convert TLV data into data-value dictionary as described in MTRDeviceResponseHandler +id _Nullable MTRDecodeDataValueDictionaryFromCHIPTLV(chip::TLV::TLVReader * data); NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/MTRCluster.h b/src/darwin/Framework/CHIP/MTRCluster.h index 3517772447353e..f1598acde51d9d 100644 --- a/src/darwin/Framework/CHIP/MTRCluster.h +++ b/src/darwin/Framework/CHIP/MTRCluster.h @@ -17,6 +17,10 @@ #import +typedef void (^ResponseHandler)(id _Nullable value, NSError * _Nullable error); +typedef void (^StatusCompletion)(NSError * _Nullable error); +typedef void (^SubscriptionEstablishedHandler)(void); + @class MTRBaseDevice; NS_ASSUME_NONNULL_BEGIN diff --git a/src/darwin/Framework/CHIP/MTRDevice.h b/src/darwin/Framework/CHIP/MTRDevice.h new file mode 100644 index 00000000000000..5b4bcc9224005e --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRDevice.h @@ -0,0 +1,152 @@ +/** + * + * 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 +#import + +NS_ASSUME_NONNULL_BEGIN + +@class MTRDeviceController; +@class MTRAsyncCallbackWorkQueue; + +@protocol MTRDeviceSubscriptionDelegate; + +@interface MTRDevice : NSObject +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +/** + * Directly instantiate a MTRDevice with a MTRDeviceController as a shim. + * + * All device-specific information would be stored on the device controller, and + * retrieved when performing actions using a combination of MTRBaseDevice + * and MTRAsyncCallbackQueue. + */ ++ (instancetype)deviceWithDeviceID:(uint64_t)deviceID deviceController:(MTRDeviceController *)deviceController; + +/** + * Subscribe to receive attribute reports for everything (all endpoints, all + * clusters, all attributes, all events) on the device. + * + * The subscriber provides a delegate object conforming to MTRDeviceSubscriptionDelegate + */ +- (void)subscribeWithDelegate:(id)delegate + queue:(dispatch_queue_t)queue + minInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + params:(MTRSubscribeParams * _Nullable)params; + +/** + * Read attribute in a designated attribute path + * + * @return a data-value dictionary of the attribute as described in MTRDeviceResponseHandler + */ +- (NSDictionary *)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId + clusterId:(NSNumber * _Nullable)clusterId + attributeId:(NSNumber * _Nullable)attributeId + params:(MTRReadParams * _Nullable)params; + +/** + * Write to attribute in a designated attribute path + * + * @param value A data-value NSDictionary object as described in + * MTRDeviceResponseHandler. + * + * @param expectedValueIntervalMs interval that the write value is assumed to hold true before actual interaction happens. This + * value will be clamped to timeoutMs. + * + * @param timeoutMs timeout in milliseconds for timed write, or nil. + * + * Received values are an NSArray object with response-value element as described in + * readAttributeWithEndpointId:clusterId:attributeId:clientQueue:completion:. + */ +- (void)writeAttributeWithEndpointId:(NSNumber *)endpointId + clusterId:(NSNumber *)clusterId + attributeId:(NSNumber *)attributeId + value:(id)value + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + timedWriteTimeout:(NSNumber * _Nullable)timeoutMs; + +/** + * Invoke a command with a designated command path + * + * @param commandFields command fields object. The object must be a data-value NSDictionary object + * as described in the MTRDeviceResponseHandler. + * The attribute must be a Structure, i.e., + * the NSDictionary MTRTypeKey key must have the value MTRStructureValueType. + * + * @param expectedValues array of dictionaries containing the expected values in the same format as + * attribute read completion handler. Requires MTRAttributePathKey values. + * See MTRDeviceResponseHandler definition for dictionary details. + * + * @param expectedValueIntervalMs interval that the write value is assumed to hold true before actual interaction happens. This + * value will be clamped to timeoutMs. + * + * @param timeoutMs timeout in milliseconds for timed invoke, or nil. + * + * @param completion response handler will receive either values or error. + */ +- (void)invokeCommandWithEndpointId:(NSNumber *)endpointId + clusterId:(NSNumber *)clusterId + commandId:(NSNumber *)commandId + commandFields:(id)commandFields + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + timedInvokeTimeout:(NSNumber * _Nullable)timeoutMs + clientQueue:(dispatch_queue_t)clientQueue + completion:(MTRDeviceResponseHandler)completion; + +@end + +@protocol MTRDeviceSubscriptionDelegate +@required +/** + * subscriptionEstablished + * + * Called once the subscription is established. This will + * be _after_ the first (priming) call to both report callbacks. + */ +- (void)subscriptionEstablished; + +/** + * subscriptionReceivedAttributeReport: + * + * Notifies delegate of attribute reports from the MTRDevice + * + * @param attributeReport An array of response-value objects as described in MTRDeviceResponseHandler + */ +- (void)subscriptionReceivedAttributeReport:(NSArray *)attributeReport; + +/** + * subscriptionReceivedEventReport: + * + * Notifies delegate of event reports from the MTRDevice + * + * @param eventReport An array of MTREventReport objects + */ +- (void)subscriptionReceivedEventReport:(NSArray *)eventReport; + +/** + * subscriptionEndedWithError: + * + * Called any time there is an error for the + * entire subscription (with a non-nil "error"), and terminate the subscription + */ +- (void)subscriptionEndedWithError:(NSError *)error; +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm new file mode 100644 index 00000000000000..21555ac22a7611 --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -0,0 +1,818 @@ +/** + * + * 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 + +#import "MTRAsyncCallbackWorkQueue_Internal.h" +#import "MTRBaseDevice_Internal.h" +#import "MTRCluster.h" +#import "MTRDeviceController_Internal.h" +#import "MTRDevice_Internal.h" +#import "MTRError_Internal.h" +#import "MTREventTLVValueDecoder_Internal.h" +#import "MTRLogging.h" + +#include "lib/core/CHIPError.h" +#include "lib/core/DataModelTypes.h" +#include + +#include +#include +#include +#include +#include + +typedef void (^MTRDeviceAttributeReportHandler)(NSArray * _Nonnull); + +// Consider moving utility classes to their own file +#pragma mark - Utility Classes +@interface MTRPair : NSObject ++ (instancetype)pairWithFirst:(FirstObjectType)first second:(SecondObjectType)second; +@property (nonatomic, readonly) FirstObjectType first; +@property (nonatomic, readonly) SecondObjectType second; +@end + +@implementation MTRPair +- (instancetype)initWithFirst:(id)first second:(id)second +{ + if (self = [super init]) { + _first = first; + _second = second; + } + return self; +} ++ (instancetype)pairWithFirst:(id)first second:(id)second +{ + return [[MTRPair alloc] initWithFirst:first second:second]; +} +@end + +@interface MTRWeakReference : NSObject ++ (instancetype)weakReferenceWithObject:(ObjectType)object; +- (instancetype)initWithObject:(ObjectType)object; +- (ObjectType)strongObject; // returns strong object or NULL +@end + +@interface MTRWeakReference () { +@private + __weak id _object; +} +@end + +@implementation MTRWeakReference +- (instancetype)initWithObject:(id)object +{ + if (self = [super init]) { + _object = object; + } + return self; +} ++ (instancetype)weakReferenceWithObject:(id)object +{ + return [[MTRWeakReference alloc] initWithObject:object]; +} +- (id)strongObject +{ + return _object; +} +@end + +#pragma mark - SubscriptionCallback class declaration +using namespace chip; +using namespace chip::app; +using namespace chip::Protocols::InteractionModel; + +typedef void (^DataReportCallback)(NSArray * value); +typedef void (^ErrorCallback)(NSError * error); + +namespace { + +class SubscriptionCallback final : public ClusterStateCache::Callback { +public: + SubscriptionCallback(dispatch_queue_t queue, DataReportCallback attributeReportCallback, DataReportCallback eventReportCallback, + ErrorCallback errorCallback, SubscriptionEstablishedHandler _Nullable subscriptionEstablishedHandler) + : mQueue(queue) + , mAttributeReportCallback(attributeReportCallback) + , mEventReportCallback(eventReportCallback) + , mErrorCallback(errorCallback) + , mSubscriptionEstablishedHandler(subscriptionEstablishedHandler) + , mBufferedReadAdapter(*this) + { + } + + SubscriptionCallback(dispatch_queue_t queue, DataReportCallback attributeReportCallback, DataReportCallback eventReportCallback, + ErrorCallback errorCallback, SubscriptionEstablishedHandler _Nullable subscriptionEstablishedHandler, + void (^onDoneHandler)(void)) + : mQueue(queue) + , mAttributeReportCallback(attributeReportCallback) + , mEventReportCallback(eventReportCallback) + , mErrorCallback(errorCallback) + , mSubscriptionEstablishedHandler(subscriptionEstablishedHandler) + , mBufferedReadAdapter(*this) + , mOnDoneHandler(onDoneHandler) + { + } + + BufferedReadCallback & GetBufferedCallback() { return mBufferedReadAdapter; } + + // We need to exist to get a ReadClient, so can't take this as a constructor argument. + void AdoptReadClient(std::unique_ptr aReadClient) { mReadClient = std::move(aReadClient); } + void AdoptAttributeCache(std::unique_ptr aAttributeCache) { mAttributeCache = std::move(aAttributeCache); } + +private: + void OnReportBegin() override; + + void OnReportEnd() override; + + void OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus) override; + + void OnAttributeData(const ConcreteDataAttributePath & aPath, TLV::TLVReader * apData, const StatusIB & aStatus) override; + + void OnError(CHIP_ERROR aError) override; + + void OnDone(ReadClient * aReadClient) override; + + void OnDeallocatePaths(ReadPrepareParams && aReadPrepareParams) override; + + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override; + + void ReportData(); + void ReportError(CHIP_ERROR err); + void ReportError(const StatusIB & status); + void ReportError(NSError * _Nullable err); + +private: + dispatch_queue_t mQueue; + DataReportCallback _Nullable mAttributeReportCallback = nil; + DataReportCallback _Nullable mEventReportCallback = nil; + // We set mErrorCallback to nil when queueing error reports, so we + // make sure to only report one error. + ErrorCallback _Nullable mErrorCallback = nil; + SubscriptionEstablishedHandler _Nullable mSubscriptionEstablishedHandler; + BufferedReadCallback mBufferedReadAdapter; + NSMutableArray * _Nullable mAttributeReports = nil; + NSMutableArray * _Nullable mEventReports = nil; + + // Our lifetime management is a little complicated. On error we + // attempt to delete the ReadClient, but asynchronously. While + // that's pending, someone else (e.g. an error it runs into) could + // delete it too. And if someone else does attempt to delete it, we want to + // make sure we delete ourselves as well. + // + // To handle this, enforce the following rules: + // + // 1) We guarantee that mErrorCallback is only invoked with an error once. + // 2) We ensure that we delete ourselves and the passed in ReadClient only from OnDone or a queued-up + // error callback, but not both, by tracking whether we have a queued-up + // deletion. + std::unique_ptr mReadClient; + std::unique_ptr mAttributeCache; + bool mHaveQueuedDeletion = false; + void (^mOnDoneHandler)(void) = nil; +}; + +} // anonymous namespace + +#pragma mark - MTRDevice +@interface MTRDevice () +@property (nonatomic, readonly) os_unfair_lock lock; +@property (nonatomic) dispatch_queue_t queue; +@property (nonatomic) NSMutableSet> *> * subscribers; + +@property (nonatomic) BOOL subscriptionActive; + +// Read cache is attributePath => NSDictionary of value. +// See MTRDeviceResponseHandler definition for value dictionary details. +@property (nonatomic) NSMutableDictionary * readCache; + +// Expected value cache is attributePath => MTRPair of [NSDate of expiration time, NSDictionary of value] +// See MTRDeviceResponseHandler definition for value dictionary details. +@property (nonatomic) NSMutableDictionary *> * expectedValueCache; + +@property (nonatomic) MTRAsyncCallbackWorkQueue * asyncCallbackWorkQueue; +@end + +@implementation MTRDevice + +- (instancetype)initWithDeviceID:(uint64_t)deviceID + deviceController:(MTRDeviceController *)deviceController + queue:(dispatch_queue_t)queue +{ + if (self = [super init]) { + _lock = OS_UNFAIR_LOCK_INIT; + _deviceID = deviceID; + _deviceController = deviceController; + _queue = queue; + _readCache = [NSMutableDictionary dictionary]; + _expectedValueCache = [NSMutableDictionary dictionary]; + _asyncCallbackWorkQueue = [[MTRAsyncCallbackWorkQueue alloc] initWithDevice:self queue:queue]; + } + return self; +} + ++ (instancetype)deviceWithDeviceID:(uint64_t)deviceID deviceController:(MTRDeviceController *)deviceController +{ + return [deviceController deviceForDeviceID:deviceID]; +} + +- (void)connectAndPerformAsync:(MTRDevicePerformAsyncBlock)asyncBlock +{ + [_deviceController getBaseDevice:_deviceID + queue:_queue + completionHandler:^(MTRBaseDevice * _Nullable device, NSError * _Nullable error) { + asyncBlock(device); + }]; +} + +#pragma mark Subscription +- (void)performBlockForDelegates:(void (^)(id))block +{ + os_unfair_lock_lock(&self->_lock); + NSSet * delegatesToCall = _subscribers.copy; + os_unfair_lock_unlock(&self->_lock); + + NSMutableSet * lostDelegates = [NSMutableSet set]; + for (MTRWeakReference> * delegateWeakReference in delegatesToCall) { + id delegate = delegateWeakReference.strongObject; + if (!delegate) { + [lostDelegates addObject:delegateWeakReference]; + } + + block(delegate); + } + + os_unfair_lock_lock(&self->_lock); + [_subscribers minusSet:lostDelegates]; + os_unfair_lock_unlock(&self->_lock); + + // Options to consider when no more subscribers are alive: + // A) tear down subscription + // B) keep subscription until error, and wait for client to resubscribe + // C) keep subscription / resubscribe on error, until EOL MTRDevice +} + +- (void)_handleSubscriptionEstablished +{ + [self performBlockForDelegates:^(id delegate) { + [delegate subscriptionEstablished]; + }]; +} + +- (void)_handleSubscriptionError:(NSError *)error +{ + _subscriptionActive = NO; + + [self performBlockForDelegates:^(id delegate) { + [delegate subscriptionEndedWithError:error]; + }]; + [_subscribers removeAllObjects]; +} + +- (void)_reportAttributes:(NSArray *> *)attributes +{ + if (attributes.count) { + [self performBlockForDelegates:^(id delegate) { + [delegate subscriptionReceivedAttributeReport:attributes]; + }]; + } +} + +- (void)_handleAttributeReport:(NSArray *> *)attributeReport +{ + NSArray * attributesToReport = [self _getAttributesToReportWithReportedValues:attributeReport]; + + [self _reportAttributes:attributesToReport]; +} + +- (void)_handleEventReport:(NSArray *)eventReport +{ + [self performBlockForDelegates:^(id delegate) { + [delegate subscriptionReceivedEventReport:eventReport]; + }]; +} + +- (void)subscribeWithMinInterval:(uint16_t)minInterval maxInterval:(uint16_t)maxInterval +{ + // for now just subscribe once + if (_subscriptionActive) { + return; + } + + _subscriptionActive = YES; + + [_deviceController getBaseDevice:_deviceID + queue:_queue + completionHandler:^(MTRBaseDevice * _Nullable baseDevice, NSError * _Nullable error) { + dispatch_async(DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{ + DeviceProxy * device = [baseDevice internalDevice]; + if (!device) { + dispatch_async(self->_queue, ^{ + [self _handleSubscriptionError:[MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]]; + }); + return; + } + + // Wildcard endpoint, cluster, attribute, event. + auto attributePath = std::make_unique(); + auto eventPath = std::make_unique(); + ReadPrepareParams readParams(device->GetSecureSession().Value()); + readParams.mMinIntervalFloorSeconds = minInterval; + readParams.mMaxIntervalCeilingSeconds = maxInterval; + readParams.mpAttributePathParamsList = attributePath.get(); + readParams.mAttributePathParamsListSize = 1; + readParams.mpEventPathParamsList = eventPath.get(); + readParams.mEventPathParamsListSize = 1; + readParams.mKeepSubscriptions = true; + + std::unique_ptr callback; + std::unique_ptr readClient; + std::unique_ptr attributeCache; + callback = std::make_unique( + self->_queue, + ^(NSArray * value) { + [self _handleAttributeReport:value]; + }, + ^(NSArray * value) { + [self _handleEventReport:value]; + }, + ^(NSError * error) { + [self _handleSubscriptionError:error]; + }, + ^(void) { + [self _handleSubscriptionEstablished]; + }); + readClient + = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), + callback->GetBufferedCallback(), ReadClient::InteractionType::Subscribe); + + CHIP_ERROR err; + err = readClient->SendAutoResubscribeRequest(std::move(readParams)); + // SendAutoResubscribeRequest cleans up the params, even on failure. + attributePath.release(); + eventPath.release(); + + if (err != CHIP_NO_ERROR) { + dispatch_async(self->_queue, ^{ + [self _handleSubscriptionError:[MTRError errorForCHIPErrorCode:err]]; + }); + + return; + } + + // Callback and ReadClient will be deleted when OnDone is called or an error is + // encountered. + callback->AdoptReadClient(std::move(readClient)); + callback.release(); + }); + }]; +} + +// TODO: support more than one subscriber / subscription delegate +// * reconcile second+ subscriptions with different min and max intervals +// (save min/max intervals for each subscriber and resubscribe when they change) +// * events should be cached and replayed for second+ subscribers +- (void)subscribeWithDelegate:(id)delegate + queue:(dispatch_queue_t)queue + minInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + params:(MTRSubscribeParams *)params +{ + // Save a weak reference to delegate, so if/when the object goes away, they are automatically unsubscribed + MTRWeakReference> * weakDelegate = [MTRWeakReference weakReferenceWithObject:delegate]; + [_subscribers addObject:weakDelegate]; + + // perform the actual subscription + [self subscribeWithMinInterval:minInterval maxInterval:maxInterval]; +} + +#pragma mark Device Interactions +- (NSDictionary *)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId + clusterId:(NSNumber * _Nullable)clusterId + attributeId:(NSNumber * _Nullable)attributeId + params:(MTRReadParams * _Nullable)params +{ + // Create work item, set ready handler to perform task, then enqueue the work + MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:_queue]; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { + [self connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + [baseDevice readAttributeWithEndpointId:endpointId + clusterId:clusterId + attributeId:attributeId + params:params + clientQueue:self->_queue + completion:^(NSArray *> * _Nullable values, + NSError * _Nullable error) { + if (values) { + // Since the format is the same data-value dictionary, this looks like an attribute + // report + [self _handleAttributeReport:values]; + } + // TODO: retry on error + [workItem endWork]; + }]; + }]; + }; + workItem.readyHandler = readyHandler; + [_asyncCallbackWorkQueue enqueueWorkItem:workItem]; + + // Return current known / expected value right away + MTRAttributePath * attributePath = [MTRAttributePath attributePathWithEndpointId:endpointId + clusterId:clusterId + attributeId:attributeId]; + NSDictionary * attributeValueToReturn = [self _attributeValueDictionaryForAttributePath:attributePath]; + + return attributeValueToReturn; +} + +- (void)writeAttributeWithEndpointId:(NSNumber *)endpointId + clusterId:(NSNumber *)clusterId + attributeId:(NSNumber *)attributeId + value:(id)value + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + timedWriteTimeout:(NSNumber * _Nullable)timeoutMs +{ + // Start the asynchronous operation + [self connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + [baseDevice + writeAttributeWithEndpointId:endpointId + clusterId:clusterId + attributeId:attributeId + value:value + timedWriteTimeout:timeoutMs + clientQueue:self->_queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + if (values) { + [self _handleAttributeReport:values]; + } + }]; + }]; + + // Commit change into expected value cache + MTRAttributePath * attributePath = [MTRAttributePath attributePathWithEndpointId:endpointId + clusterId:clusterId + attributeId:attributeId]; + NSDictionary * newExpectedValueDictionary = @{ MTRAttributePathKey : attributePath, MTRDataKey : value }; + + [self setExpectedValues:@[ newExpectedValueDictionary ] expectedValueInterval:expectedValueIntervalMs]; +} + +- (void)invokeCommandWithEndpointId:(NSNumber *)endpointId + clusterId:(NSNumber *)clusterId + commandId:(NSNumber *)commandId + commandFields:(id)commandFields + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + timedInvokeTimeout:(NSNumber * _Nullable)timeoutMs + clientQueue:(dispatch_queue_t)clientQueue + completion:(MTRDeviceResponseHandler)completion +{ + // Perform this operation + [self connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + [baseDevice + invokeCommandWithEndpointId:endpointId + clusterId:clusterId + commandId:commandId + commandFields:commandFields + timedInvokeTimeout:timeoutMs + clientQueue:self->_queue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + dispatch_async(clientQueue, ^{ + completion(values, error); + }); + }]; + }]; + + [self setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; +} + +#pragma mark - Cache management + +// (assume lock is held) +- (void)_checkExpiredExpectedValues +{ +} + +// Get attribute value dictionary for an attribute path from the right cache +- (NSDictionary *)_attributeValueDictionaryForAttributePath:(MTRAttributePath *)attributePath +{ + os_unfair_lock_lock(&self->_lock); + // First check expected value cache + MTRPair * expectedValue = _expectedValueCache[attributePath]; + if (expectedValue) { + NSDate * now = [NSDate date]; + if ([now compare:expectedValue.first] == NSOrderedDescending) { + // expired - purge and fall through + _expectedValueCache[attributePath] = nil; + } else { + // not yet expired - return result + return expectedValue.second; + } + } + + // Then check read cache + NSDictionary * cachedAttributeValue = _readCache[attributePath]; + if (cachedAttributeValue) { + return cachedAttributeValue; + } else { + // TODO: when not found in cache, generated default values should be used + MTR_LOG_INFO( + "_attributeValueDictionaryForAttributePath: could not find cached attribute values for attribute %@", attributePath); + } + + return nil; +} + +- (BOOL)_attributeDataValue:(NSDictionary *)one isEqualToDataValue:(NSDictionary *)theOther +{ + // Attribute data-value dictionary should be all standard containers which + // means isEqual: comparisons all the way down, making a deep comparison. + return [one isEqualToDictionary:theOther]; +} + +- (NSArray *)_getAttributesToReportWithReportedValues:(NSArray *> *)reportedAttributeValues +{ + NSMutableArray * attributesToReport = [NSMutableArray array]; + + os_unfair_lock_lock(&self->_lock); + for (NSDictionary * attributeReponseValue in reportedAttributeValues) { + MTRAttributePath * attributePath = attributeReponseValue[MTRAttributePathKey]; + NSDictionary * attributeDataValue = attributeReponseValue[MTRDataKey]; + NSError * attributeError = attributeReponseValue[MTRErrorKey]; + + // sanity check either data value or error must exist + if (!attributeDataValue && attributeError) { + continue; + } + + // check if value is different than cache, and report if needed + BOOL shouldReportAttribute = NO; + + // if this is an error, report and purge cache + if (attributeError) { + shouldReportAttribute = YES; + _expectedValueCache[attributePath] = nil; + _readCache[attributePath] = nil; + } else { + // check write cache and purge if needed + MTRPair * expectedValue = _expectedValueCache[attributePath]; + if (expectedValue) { + if (![self _attributeDataValue:attributeDataValue isEqualToDataValue:expectedValue.second]) { + shouldReportAttribute = YES; + } + _expectedValueCache[attributePath] = nil; + } + + // then compare and update read cache + if (![self _attributeDataValue:attributeDataValue isEqualToDataValue:_readCache[attributePath]]) { + _readCache[attributePath] = attributeDataValue; + shouldReportAttribute = YES; + } + } + + if (shouldReportAttribute) { + [attributesToReport addObject:attributeReponseValue]; + } + } + os_unfair_lock_unlock(&self->_lock); + + return attributesToReport; +} + +- (NSArray *)_getAttributesToReportWithNewExpectedValues:(NSArray *> *)expectedAttributeValues + expirationTime:(NSDate *)expirationTime +{ + NSMutableArray * attributesToReport = [NSMutableArray array]; + + // First update cache + os_unfair_lock_lock(&self->_lock); + for (NSDictionary * attributeReponseValue in expectedAttributeValues) { + MTRAttributePath * attributePath = attributeReponseValue[MTRAttributePathKey]; + NSDictionary * attributeDataValue = attributeReponseValue[MTRDataKey]; + + // check if value is different than cache, and report if needed + BOOL shouldReportAttribute = NO; + + MTRPair * expectedValue = _expectedValueCache[attributePath]; + if (expectedValue) { + // first check write cache and purge / update + if (![self _attributeDataValue:attributeDataValue isEqualToDataValue:expectedValue.second]) { + shouldReportAttribute = YES; + } + _expectedValueCache[attributePath] = [MTRPair pairWithFirst:expirationTime second:expectedValue]; + } else { + // if new expected value then compare with read cache and report if needed + if (![self _attributeDataValue:attributeDataValue isEqualToDataValue:_readCache[attributePath]]) { + shouldReportAttribute = YES; + } + } + + if (shouldReportAttribute) { + [attributesToReport addObject:attributeReponseValue]; + } + } + os_unfair_lock_unlock(&self->_lock); + + return attributesToReport; +} + +- (void)setExpectedValues:(NSArray *> *)values + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + // since NSTimeInterval is in seconds, convert ms into seconds in double + NSTimeInterval expectedValueInterval = expectedValueIntervalMs.doubleValue / 1000; + NSDate * expirationTime = [NSDate dateWithTimeIntervalSinceNow:expectedValueInterval]; + + NSArray * attributesToReport = [self _getAttributesToReportWithNewExpectedValues:values expirationTime:expirationTime]; + + [self _reportAttributes:attributesToReport]; +} + +@end + +#pragma mark - SubscriptionCallback +namespace { +void SubscriptionCallback::OnReportBegin() +{ + mAttributeReports = [NSMutableArray new]; + mEventReports = [NSMutableArray new]; +} + +// Reports attribute and event data if any exists +void SubscriptionCallback::ReportData() +{ + __block NSArray * attributeReports = mAttributeReports; + mAttributeReports = nil; + __block NSArray * eventReports = mEventReports; + mEventReports = nil; + if (mAttributeReportCallback && attributeReports.count) { + dispatch_async(mQueue, ^{ + mAttributeReportCallback(attributeReports); + }); + } + if (mEventReportCallback && eventReports.count) { + dispatch_async(mQueue, ^{ + mEventReportCallback(eventReports); + }); + } +} + +void SubscriptionCallback::OnReportEnd() { ReportData(); } + +void SubscriptionCallback::OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus) +{ + id _Nullable value = nil; + NSError * _Nullable error = nil; + if (apStatus != nullptr) { + error = [MTRError errorForIMStatus:*apStatus]; + } else if (apData == nullptr) { + error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT]; + } else { + CHIP_ERROR err; + value = MTRDecodeEventPayload(aEventHeader.mPath, *apData, &err); + if (err == CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB) { + // We don't know this event; just skip it. + return; + } + + if (err != CHIP_NO_ERROR) { + value = nil; + error = [MTRError errorForCHIPErrorCode:err]; + } + } + + if (mEventReports == nil) { + // Never got a OnReportBegin? Not much to do other than tear things down. + ReportError(CHIP_ERROR_INCORRECT_STATE); + return; + } + + [mEventReports addObject:[[MTREventReport alloc] initWithPath:aEventHeader.mPath + eventNumber:@(aEventHeader.mEventNumber) + priority:@((uint8_t) aEventHeader.mPriorityLevel) + timestamp:@(aEventHeader.mTimestamp.mValue) + value:value + error:error]]; +} + +void SubscriptionCallback::OnAttributeData( + const ConcreteDataAttributePath & aPath, TLV::TLVReader * apData, const StatusIB & aStatus) +{ + if (aPath.IsListItemOperation()) { + ReportError(CHIP_ERROR_INCORRECT_STATE); + return; + } + + if (mAttributeReports == nil) { + // Never got a OnReportBegin? Not much to do other than tear things down. + ReportError(CHIP_ERROR_INCORRECT_STATE); + return; + } + + id _Nullable value = MTRDecodeDataValueDictionaryFromCHIPTLV(apData); + + if (value) { + [mAttributeReports addObject:@ { MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:aPath], MTRDataKey : value }]; + } +} + +void SubscriptionCallback::OnError(CHIP_ERROR aError) +{ + // If OnError is called after OnReportBegin, we should report the collected data + ReportData(); + ReportError([MTRError errorForCHIPErrorCode:aError]); +} + +void SubscriptionCallback::OnDone(ReadClient *) +{ + if (mOnDoneHandler) { + mOnDoneHandler(); + mOnDoneHandler = nil; + } + if (!mHaveQueuedDeletion) { + delete this; + return; // Make sure we touch nothing else. + } +} + +void SubscriptionCallback::OnDeallocatePaths(ReadPrepareParams && aReadPrepareParams) +{ + VerifyOrDie((aReadPrepareParams.mAttributePathParamsListSize == 0 && aReadPrepareParams.mpAttributePathParamsList == nullptr) + || (aReadPrepareParams.mAttributePathParamsListSize == 1 && aReadPrepareParams.mpAttributePathParamsList != nullptr)); + if (aReadPrepareParams.mpAttributePathParamsList) { + delete aReadPrepareParams.mpAttributePathParamsList; + } + + VerifyOrDie((aReadPrepareParams.mDataVersionFilterListSize == 0 && aReadPrepareParams.mpDataVersionFilterList == nullptr) + || (aReadPrepareParams.mDataVersionFilterListSize == 1 && aReadPrepareParams.mpDataVersionFilterList != nullptr)); + if (aReadPrepareParams.mpDataVersionFilterList != nullptr) { + delete aReadPrepareParams.mpDataVersionFilterList; + } + + VerifyOrDie((aReadPrepareParams.mEventPathParamsListSize == 0 && aReadPrepareParams.mpEventPathParamsList == nullptr) + || (aReadPrepareParams.mEventPathParamsListSize == 1 && aReadPrepareParams.mpEventPathParamsList != nullptr)); + if (aReadPrepareParams.mpEventPathParamsList) { + delete aReadPrepareParams.mpEventPathParamsList; + } +} + +void SubscriptionCallback::OnSubscriptionEstablished(SubscriptionId aSubscriptionId) +{ + if (mSubscriptionEstablishedHandler) { + dispatch_async(mQueue, mSubscriptionEstablishedHandler); + } +} + +void SubscriptionCallback::ReportError(CHIP_ERROR err) { ReportError([MTRError errorForCHIPErrorCode:err]); } + +void SubscriptionCallback::ReportError(const StatusIB & status) { ReportError([MTRError errorForIMStatus:status]); } + +void SubscriptionCallback::ReportError(NSError * _Nullable err) +{ + if (!err) { + // Very strange... Someone tried to create a MTRError for a success status? + return; + } + + if (mHaveQueuedDeletion) { + // Already have an error report pending which will delete us. + return; + } + + __block ErrorCallback callback = mErrorCallback; + __block auto * myself = this; + mErrorCallback = nil; + mAttributeReportCallback = nil; + mEventReportCallback = nil; + __auto_type onDoneHandler = mOnDoneHandler; + mOnDoneHandler = nil; + dispatch_async(mQueue, ^{ + callback(err); + if (onDoneHandler) { + onDoneHandler(); + } + + // Deletion of our ReadClient (and hence of ourselves, since the + // ReadClient has a pointer to us) needs to happen on the Matter work + // queue. + dispatch_async(DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{ + delete myself; + }); + }); + + mHaveQueuedDeletion = true; +} +} // anonymous namespace diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 586219008e55e6..61d8806ed9b44a 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -14,11 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#import + #import "MTRDeviceController.h" #import "MTRBaseDevice_Internal.h" #import "MTRCommissioningParameters.h" #import "MTRControllerFactory_Internal.h" +#import "MTRDevice_Internal.h" #import "MTRDeviceControllerStartupParams.h" #import "MTRDeviceControllerStartupParams_Internal.h" #import "MTRDevicePairingDelegateBridge.h" @@ -80,6 +83,8 @@ @interface MTRDeviceController () @property (readonly) MTRP256KeypairBridge operationalKeypairBridge; @property (readonly) MTRDeviceAttestationDelegateBridge * deviceAttestationDelegateBridge; @property (readonly) MTRControllerFactory * factory; +@property (readonly) NSMutableDictionary * deviceIDToDeviceMap; +@property (readonly) os_unfair_lock deviceMapLock; @end @implementation MTRDeviceController @@ -89,6 +94,8 @@ - (instancetype)initWithFactory:(MTRControllerFactory *)factory queue:(dispatch_ if (self = [super init]) { _chipWorkQueue = queue; _factory = factory; + _deviceMapLock = OS_UNFAIR_LOCK_INIT; + _deviceIDToDeviceMap = [NSMutableDictionary dictionary]; _pairingDelegateBridge = new MTRDevicePairingDelegateBridge(); if ([self checkForInitError:(_pairingDelegateBridge != nullptr) logMsg:kErrorPairingInit]) { @@ -525,6 +532,29 @@ - (BOOL)getBaseDevice:(uint64_t)deviceID return YES; } +- (MTRDevice *)deviceForDeviceID:(uint64_t)deviceID { + os_unfair_lock_lock(&_deviceMapLock); + MTRDevice *deviceToReturn = self.deviceIDToDeviceMap[@(deviceID)]; + if (deviceToReturn) { + deviceToReturn = [[MTRDevice alloc] initWithDeviceID:deviceID deviceController:self queue:self.chipWorkQueue]; + self.deviceIDToDeviceMap[@(deviceID)] = deviceToReturn; + } + os_unfair_lock_unlock(&_deviceMapLock); + + return deviceToReturn; +} + +- (void)removeDevice:(MTRDevice *)device { + os_unfair_lock_lock(&_deviceMapLock); + MTRDevice *deviceToRemove = self.deviceIDToDeviceMap[@(device.deviceID)]; + if (deviceToRemove == device) { + self.deviceIDToDeviceMap[@(device.deviceID)] = nil; + } else { + MTR_LOG_ERROR("Error: Cannot remove device %p with deviceID %llu", device, device.deviceID); + } + os_unfair_lock_unlock(&_deviceMapLock); +} + - (BOOL)openPairingWindow:(uint64_t)deviceID duration:(NSUInteger)duration error:(NSError * __autoreleasing *)error { VerifyOrReturnValue([self checkIsRunning:error], NO); diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h b/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h index 687eef7a22c74b..ac4f15473d66b3 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h @@ -21,13 +21,15 @@ #import -#import "MTRDeviceController.h" - #include #include +#import "MTRBaseDevice.h" +#import "MTRDeviceController.h" + @class MTRDeviceControllerStartupParamsInternal; @class MTRControllerFactory; +@class MTRDevice; namespace chip { class FabricTable; @@ -37,6 +39,8 @@ NS_ASSUME_NONNULL_BEGIN @interface MTRDeviceController (InternalMethods) +#pragma mark - MTRControllerFactory methods + /** * Start a new controller. Returns whether startup succeeded. If this fails, * it guarantees that it has called controllerShuttingDown on the @@ -85,6 +89,11 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)shutDownCppController; +#pragma mark - Device-specific data and SDK access +// DeviceController will act as a central repository for this opaque dictionary that MTRDevice manages +- (MTRDevice *)deviceForDeviceID:(uint64_t)deviceID; +- (void)removeDevice:(MTRDevice *)device; + @end NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/MTRDevice_Internal.h b/src/darwin/Framework/CHIP/MTRDevice_Internal.h new file mode 100644 index 00000000000000..5eab8157dbe428 --- /dev/null +++ b/src/darwin/Framework/CHIP/MTRDevice_Internal.h @@ -0,0 +1,46 @@ +/** + * + * 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 + +#import "MTRBaseDevice.h" +#import "MTRDevice.h" + +#include + +NS_ASSUME_NONNULL_BEGIN + +typedef void (^MTRDevicePerformAsyncBlock)(MTRBaseDevice * baseDevice); + +@interface MTRDevice () +- (instancetype)initWithDeviceID:(uint64_t)deviceID + deviceController:(MTRDeviceController *)deviceController + queue:(dispatch_queue_t)queue; + +// Called to run commands with a live underlying connection +- (void)connectAndPerformAsync:(MTRDevicePerformAsyncBlock)asyncBlock; + +// Called from MTRClusters for writes and commands +- (void)setExpectedValues:(NSArray *> *)values + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; + +@property (nonatomic, readonly, strong, nonnull) MTRDeviceController * deviceController; +@property (nonatomic, readonly) uint64_t deviceID; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/Matter.h b/src/darwin/Framework/CHIP/Matter.h index cabba655deaa11..9c5af0634a904f 100644 --- a/src/darwin/Framework/CHIP/Matter.h +++ b/src/darwin/Framework/CHIP/Matter.h @@ -17,15 +17,18 @@ #import +#import #import #import #import #import #import #import +#import #import #import #import +#import #import #import #import diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt index 98adfc639f4bf0..335cb2c1c4b14d 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt @@ -7,10 +7,6 @@ #import #import -typedef void (^ResponseHandler)(id _Nullable value, NSError * _Nullable error); -typedef void (^StatusCompletion)(NSError * _Nullable error); -typedef void (^SubscriptionEstablishedHandler)(void); - NS_ASSUME_NONNULL_BEGIN {{#chip_client_clusters includeAll=true}} diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters_internal.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters_internal.zapt index a86993b5977210..f788b141ce9753 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters_internal.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters_internal.zapt @@ -11,7 +11,7 @@ @interface MTRBaseCluster{{asUpperCamelCase name}} () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::{{asUpperCamelCase name}}Cluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::{{asUpperCamelCase name}}Cluster * cppCluster; - (chip::Controller::{{asUpperCamelCase name}}Cluster **) cppClusterSlot; @end diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt new file mode 100644 index 00000000000000..c7be856a0030d7 --- /dev/null +++ b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt @@ -0,0 +1,151 @@ +{{> header}} + +#import + +#import "MTRAttributeCacheContainer_Internal.h" +#import "MTRBaseDevice_internal.h" +#import "MTRClusterConstants.h" +#import "MTRClusters_internal.h" +#import "MTRDevice.h" +#import "MTRDevice_Internal.h" +#import "MTRCallbackBridge_internal.h" +#import "MTRCluster_internal.h" +#import "MTRStructsObjc.h" +#import "MTRCommandPayloadsObjc.h" + +#include +#include +#include + +using chip::Callback::Callback; +using chip::Callback::Cancelable; +using namespace chip::app::Clusters; +// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects. +{{#chip_client_clusters includeAll=true}} +@implementation MTRCluster{{asUpperCamelCase name}} + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::{{asUpperCamelCase name}}Cluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::{{asUpperCamelCase name}}Cluster *cppCluster = new chip::Controller::{{asUpperCamelCase name}}Cluster(* internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +{{#chip_cluster_commands}} +{{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase responseName}}{{else}}CommandSuccess{{/if}}{{/inline}} +{{#unless (hasArguments)}} +- (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=.}})completionHandler +{ + [self {{asLowerCamelCase name}}WithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completionHandler:completionHandler]; +} +{{/unless}} +- (void){{asLowerCamelCase name}}WithParams: (MTR{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=.}})completionHandler +{ + NSDate *waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::{{asUpperCamelCase parent.name}}Cluster * cppCluster) { + ListFreer listFreer; + {{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::Type request; + {{#chip_cluster_command_arguments}} + {{#first}} + {{#unless (commandHasRequiredField parent)}} + if (params != nil) { + {{/unless}} + {{/first}} + {{>encode_value target=(concat "request." (asLowerCamelCase label)) source=(concat "params." (asStructPropertyName label)) cluster=parent.parent.name errorCode="return;" depth=0}} + {{#last}} + {{#unless (commandHasRequiredField parent)}} + } + {{/unless}} + {{/last}} + {{/chip_cluster_command_arguments}} + + new MTR{{>callbackName}}CallbackBridge(self.callbackQueue, + {{#if hasSpecificResponse}} + {{! This treats completionHandler as taking an id for the data. This is + not great from a type-safety perspective, of course. }} + completionHandler, + {{else}} + {{! For now, don't change the bridge API; instead just use an adapter + to invoke our completion handler. This is not great from a + type-safety perspective, of course. }} + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + {{/if}} + ^(Cancelable * success, Cancelable * failure) { + {{! convert seconds to ms and calculate how much timeout is left for work }} + NSNumber *waitTimeInMs = params.timedInvokeTimeoutMs; + {{#if mustUseTimedInvoke}} + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + {{/if}} + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback<{{>callbackName}}CallbackType>::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand(request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} +{{/chip_cluster_commands}} + +{{#chip_server_cluster_attributes}} +{{#*inline "attribute"}}Attribute{{asUpperCamelCase name}}{{/inline}} +- (NSDictionary *)read{{>attribute}}WithParams:(MTRReadParams * _Nullable)params { + return [self.device readAttributeWithEndpointId:@(_endpoint) clusterId:@(MTRCluster{{asUpperCamelCase parent.name}}ID) attributeId:@(MTRCluster{{asUpperCamelCase parent.name}}Attribute{{asUpperCamelCase name}}ID) params:params]; +} + +{{#if isWritableAttribute}} +{{#*inline "callbackName"}}DefaultSuccess{{/inline}} +- (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self write{{>attribute}}WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params +{ + NSNumber *waitTimeInMs = params.timedWriteTimeout; + {{#if mustUseTimedInvoke}} + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + {{/if}} + + [self.device writeAttributeWithEndpointId:@(_endpoint) clusterId:@(MTRCluster{{asUpperCamelCase parent.name}}ID) attributeId:@(MTRCluster{{asUpperCamelCase parent.name}}Attribute{{asUpperCamelCase name}}ID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:waitTimeInMs]; +} + +{{/if}} + +{{/chip_server_cluster_attributes}} + +@end + +{{/chip_client_clusters}} +// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt new file mode 100644 index 00000000000000..9bd1fad459ae2d --- /dev/null +++ b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt @@ -0,0 +1,50 @@ +{{> header}} + +#import + +#import + +#import +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +{{#chip_client_clusters includeAll=true}} + + +/** + * Cluster {{name}} + * {{description}} + */ +@interface MTRCluster{{asUpperCamelCase name}} : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +{{#chip_cluster_commands}} +- (void){{asLowerCamelCase name}}WithParams:(MTR{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Params * {{#unless (commandHasRequiredField .)}}_Nullable{{/unless}})params expectedValues:(NSArray *> *)expectedDataValueDictionaries expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=.}})completionHandler; +{{#unless (hasArguments)}} +- (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=.}})completionHandler; +{{/unless}} +{{/chip_cluster_commands}} + +{{#chip_server_cluster_attributes}} +{{#*inline "attribute"}}Attribute{{asUpperCamelCase name}}{{/inline}} +- (NSDictionary *)read{{>attribute}}WithParams:(MTRReadParams * _Nullable)params; +{{#if isWritableAttribute}} +- (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params; +{{/if}} +{{/chip_server_cluster_attributes}} + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +{{/chip_client_clusters}} + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters_internal.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters_internal.zapt new file mode 100644 index 00000000000000..9ab103ba73c690 --- /dev/null +++ b/src/darwin/Framework/CHIP/templates/MTRClusters_internal.zapt @@ -0,0 +1,19 @@ +{{> header}} + +#import +#import + +#import "MTRClusters.h" +#import "MTRDevice.h" +#import "MTRDevice_Internal.h" + +#include + +{{#chip_client_clusters includeAll=true}} + +@interface MTRCluster{{asUpperCamelCase name}} () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice *device; +@end + +{{/chip_client_clusters}} diff --git a/src/darwin/Framework/CHIP/templates/templates.json b/src/darwin/Framework/CHIP/templates/templates.json index 3939322c5601b3..f91c8c3815bca8 100644 --- a/src/darwin/Framework/CHIP/templates/templates.json +++ b/src/darwin/Framework/CHIP/templates/templates.json @@ -54,19 +54,34 @@ }, { "path": "MTRBaseClusters_internal.zapt", - "name": "Objc ZCL API Internal Header", + "name": "Objc ZCL asynchronous API Internal Header", "output": "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_internal.h" }, { "path": "MTRBaseClusters.zapt", - "name": "Objc ZCL API Header", + "name": "Objc ZCL asynchronous API Header", "output": "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h" }, { "path": "MTRBaseClusters-src.zapt", - "name": "Objc ZCL API", + "name": "Objc ZCL asynchronous API", "output": "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm" }, + { + "path": "MTRClusters_internal.zapt", + "name": "Objc ZCL synchronous API Internal Header", + "output": "src/darwin/Framework/CHIP/zap-generated/MTRClusters_internal.h" + }, + { + "path": "MTRClusters.zapt", + "name": "Objc ZCL synchronous API Header", + "output": "src/darwin/Framework/CHIP/zap-generated/MTRClusters.h" + }, + { + "path": "MTRClusters-src.zapt", + "name": "Objc ZCL synchronous API", + "output": "src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm" + }, { "path": "MTRStructsObjc.zapt", "name": "Objc reflections of MTR spec structs header", diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index cd23e90e68d856..5e8279c522cee7 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -24,10 +24,6 @@ #import #import -typedef void (^ResponseHandler)(id _Nullable value, NSError * _Nullable error); -typedef void (^StatusCompletion)(NSError * _Nullable error); -typedef void (^SubscriptionEstablishedHandler)(void); - NS_ASSUME_NONNULL_BEGIN /** diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_internal.h index 00d3b6a5d98626..5209a7c2591533 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_internal.h @@ -26,390 +26,390 @@ @interface MTRBaseClusterIdentify () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::IdentifyCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::IdentifyCluster * cppCluster; - (chip::Controller::IdentifyCluster **)cppClusterSlot; @end @interface MTRBaseClusterGroups () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::GroupsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::GroupsCluster * cppCluster; - (chip::Controller::GroupsCluster **)cppClusterSlot; @end @interface MTRBaseClusterScenes () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ScenesCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ScenesCluster * cppCluster; - (chip::Controller::ScenesCluster **)cppClusterSlot; @end @interface MTRBaseClusterOnOff () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::OnOffCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::OnOffCluster * cppCluster; - (chip::Controller::OnOffCluster **)cppClusterSlot; @end @interface MTRBaseClusterOnOffSwitchConfiguration () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::OnOffSwitchConfigurationCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::OnOffSwitchConfigurationCluster * cppCluster; - (chip::Controller::OnOffSwitchConfigurationCluster **)cppClusterSlot; @end @interface MTRBaseClusterLevelControl () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::LevelControlCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::LevelControlCluster * cppCluster; - (chip::Controller::LevelControlCluster **)cppClusterSlot; @end @interface MTRBaseClusterBinaryInputBasic () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::BinaryInputBasicCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::BinaryInputBasicCluster * cppCluster; - (chip::Controller::BinaryInputBasicCluster **)cppClusterSlot; @end @interface MTRBaseClusterDescriptor () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::DescriptorCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::DescriptorCluster * cppCluster; - (chip::Controller::DescriptorCluster **)cppClusterSlot; @end @interface MTRBaseClusterBinding () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::BindingCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::BindingCluster * cppCluster; - (chip::Controller::BindingCluster **)cppClusterSlot; @end @interface MTRBaseClusterAccessControl () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::AccessControlCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::AccessControlCluster * cppCluster; - (chip::Controller::AccessControlCluster **)cppClusterSlot; @end @interface MTRBaseClusterBridgedActions () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::BridgedActionsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::BridgedActionsCluster * cppCluster; - (chip::Controller::BridgedActionsCluster **)cppClusterSlot; @end @interface MTRBaseClusterBasic () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::BasicCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::BasicCluster * cppCluster; - (chip::Controller::BasicCluster **)cppClusterSlot; @end @interface MTRBaseClusterOtaSoftwareUpdateProvider () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster; - (chip::Controller::OtaSoftwareUpdateProviderCluster **)cppClusterSlot; @end @interface MTRBaseClusterOtaSoftwareUpdateRequestor () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster; - (chip::Controller::OtaSoftwareUpdateRequestorCluster **)cppClusterSlot; @end @interface MTRBaseClusterLocalizationConfiguration () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::LocalizationConfigurationCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::LocalizationConfigurationCluster * cppCluster; - (chip::Controller::LocalizationConfigurationCluster **)cppClusterSlot; @end @interface MTRBaseClusterTimeFormatLocalization () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::TimeFormatLocalizationCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::TimeFormatLocalizationCluster * cppCluster; - (chip::Controller::TimeFormatLocalizationCluster **)cppClusterSlot; @end @interface MTRBaseClusterUnitLocalization () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::UnitLocalizationCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::UnitLocalizationCluster * cppCluster; - (chip::Controller::UnitLocalizationCluster **)cppClusterSlot; @end @interface MTRBaseClusterPowerSourceConfiguration () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::PowerSourceConfigurationCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::PowerSourceConfigurationCluster * cppCluster; - (chip::Controller::PowerSourceConfigurationCluster **)cppClusterSlot; @end @interface MTRBaseClusterPowerSource () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::PowerSourceCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::PowerSourceCluster * cppCluster; - (chip::Controller::PowerSourceCluster **)cppClusterSlot; @end @interface MTRBaseClusterGeneralCommissioning () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::GeneralCommissioningCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::GeneralCommissioningCluster * cppCluster; - (chip::Controller::GeneralCommissioningCluster **)cppClusterSlot; @end @interface MTRBaseClusterNetworkCommissioning () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::NetworkCommissioningCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::NetworkCommissioningCluster * cppCluster; - (chip::Controller::NetworkCommissioningCluster **)cppClusterSlot; @end @interface MTRBaseClusterDiagnosticLogs () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::DiagnosticLogsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::DiagnosticLogsCluster * cppCluster; - (chip::Controller::DiagnosticLogsCluster **)cppClusterSlot; @end @interface MTRBaseClusterGeneralDiagnostics () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::GeneralDiagnosticsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::GeneralDiagnosticsCluster * cppCluster; - (chip::Controller::GeneralDiagnosticsCluster **)cppClusterSlot; @end @interface MTRBaseClusterSoftwareDiagnostics () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::SoftwareDiagnosticsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::SoftwareDiagnosticsCluster * cppCluster; - (chip::Controller::SoftwareDiagnosticsCluster **)cppClusterSlot; @end @interface MTRBaseClusterThreadNetworkDiagnostics () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster; - (chip::Controller::ThreadNetworkDiagnosticsCluster **)cppClusterSlot; @end @interface MTRBaseClusterWiFiNetworkDiagnostics () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster; - (chip::Controller::WiFiNetworkDiagnosticsCluster **)cppClusterSlot; @end @interface MTRBaseClusterEthernetNetworkDiagnostics () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster; - (chip::Controller::EthernetNetworkDiagnosticsCluster **)cppClusterSlot; @end @interface MTRBaseClusterBridgedDeviceBasic () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::BridgedDeviceBasicCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::BridgedDeviceBasicCluster * cppCluster; - (chip::Controller::BridgedDeviceBasicCluster **)cppClusterSlot; @end @interface MTRBaseClusterSwitch () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::SwitchCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::SwitchCluster * cppCluster; - (chip::Controller::SwitchCluster **)cppClusterSlot; @end @interface MTRBaseClusterAdministratorCommissioning () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::AdministratorCommissioningCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::AdministratorCommissioningCluster * cppCluster; - (chip::Controller::AdministratorCommissioningCluster **)cppClusterSlot; @end @interface MTRBaseClusterOperationalCredentials () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::OperationalCredentialsCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::OperationalCredentialsCluster * cppCluster; - (chip::Controller::OperationalCredentialsCluster **)cppClusterSlot; @end @interface MTRBaseClusterGroupKeyManagement () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::GroupKeyManagementCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::GroupKeyManagementCluster * cppCluster; - (chip::Controller::GroupKeyManagementCluster **)cppClusterSlot; @end @interface MTRBaseClusterFixedLabel () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::FixedLabelCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::FixedLabelCluster * cppCluster; - (chip::Controller::FixedLabelCluster **)cppClusterSlot; @end @interface MTRBaseClusterUserLabel () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::UserLabelCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::UserLabelCluster * cppCluster; - (chip::Controller::UserLabelCluster **)cppClusterSlot; @end @interface MTRBaseClusterBooleanState () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::BooleanStateCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::BooleanStateCluster * cppCluster; - (chip::Controller::BooleanStateCluster **)cppClusterSlot; @end @interface MTRBaseClusterModeSelect () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ModeSelectCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ModeSelectCluster * cppCluster; - (chip::Controller::ModeSelectCluster **)cppClusterSlot; @end @interface MTRBaseClusterDoorLock () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::DoorLockCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::DoorLockCluster * cppCluster; - (chip::Controller::DoorLockCluster **)cppClusterSlot; @end @interface MTRBaseClusterWindowCovering () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::WindowCoveringCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::WindowCoveringCluster * cppCluster; - (chip::Controller::WindowCoveringCluster **)cppClusterSlot; @end @interface MTRBaseClusterBarrierControl () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::BarrierControlCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::BarrierControlCluster * cppCluster; - (chip::Controller::BarrierControlCluster **)cppClusterSlot; @end @interface MTRBaseClusterPumpConfigurationAndControl () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::PumpConfigurationAndControlCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::PumpConfigurationAndControlCluster * cppCluster; - (chip::Controller::PumpConfigurationAndControlCluster **)cppClusterSlot; @end @interface MTRBaseClusterThermostat () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ThermostatCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ThermostatCluster * cppCluster; - (chip::Controller::ThermostatCluster **)cppClusterSlot; @end @interface MTRBaseClusterFanControl () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::FanControlCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::FanControlCluster * cppCluster; - (chip::Controller::FanControlCluster **)cppClusterSlot; @end @interface MTRBaseClusterThermostatUserInterfaceConfiguration () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster; - (chip::Controller::ThermostatUserInterfaceConfigurationCluster **)cppClusterSlot; @end @interface MTRBaseClusterColorControl () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ColorControlCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ColorControlCluster * cppCluster; - (chip::Controller::ColorControlCluster **)cppClusterSlot; @end @interface MTRBaseClusterBallastConfiguration () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::BallastConfigurationCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::BallastConfigurationCluster * cppCluster; - (chip::Controller::BallastConfigurationCluster **)cppClusterSlot; @end @interface MTRBaseClusterIlluminanceMeasurement () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::IlluminanceMeasurementCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::IlluminanceMeasurementCluster * cppCluster; - (chip::Controller::IlluminanceMeasurementCluster **)cppClusterSlot; @end @interface MTRBaseClusterTemperatureMeasurement () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::TemperatureMeasurementCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::TemperatureMeasurementCluster * cppCluster; - (chip::Controller::TemperatureMeasurementCluster **)cppClusterSlot; @end @interface MTRBaseClusterPressureMeasurement () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::PressureMeasurementCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::PressureMeasurementCluster * cppCluster; - (chip::Controller::PressureMeasurementCluster **)cppClusterSlot; @end @interface MTRBaseClusterFlowMeasurement () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::FlowMeasurementCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::FlowMeasurementCluster * cppCluster; - (chip::Controller::FlowMeasurementCluster **)cppClusterSlot; @end @interface MTRBaseClusterRelativeHumidityMeasurement () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::RelativeHumidityMeasurementCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::RelativeHumidityMeasurementCluster * cppCluster; - (chip::Controller::RelativeHumidityMeasurementCluster **)cppClusterSlot; @end @interface MTRBaseClusterOccupancySensing () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::OccupancySensingCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::OccupancySensingCluster * cppCluster; - (chip::Controller::OccupancySensingCluster **)cppClusterSlot; @end @interface MTRBaseClusterWakeOnLan () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::WakeOnLanCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::WakeOnLanCluster * cppCluster; - (chip::Controller::WakeOnLanCluster **)cppClusterSlot; @end @interface MTRBaseClusterChannel () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ChannelCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ChannelCluster * cppCluster; - (chip::Controller::ChannelCluster **)cppClusterSlot; @end @interface MTRBaseClusterTargetNavigator () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::TargetNavigatorCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::TargetNavigatorCluster * cppCluster; - (chip::Controller::TargetNavigatorCluster **)cppClusterSlot; @end @interface MTRBaseClusterMediaPlayback () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::MediaPlaybackCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::MediaPlaybackCluster * cppCluster; - (chip::Controller::MediaPlaybackCluster **)cppClusterSlot; @end @interface MTRBaseClusterMediaInput () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::MediaInputCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::MediaInputCluster * cppCluster; - (chip::Controller::MediaInputCluster **)cppClusterSlot; @end @interface MTRBaseClusterLowPower () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::LowPowerCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::LowPowerCluster * cppCluster; - (chip::Controller::LowPowerCluster **)cppClusterSlot; @end @interface MTRBaseClusterKeypadInput () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::KeypadInputCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::KeypadInputCluster * cppCluster; - (chip::Controller::KeypadInputCluster **)cppClusterSlot; @end @interface MTRBaseClusterContentLauncher () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ContentLauncherCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ContentLauncherCluster * cppCluster; - (chip::Controller::ContentLauncherCluster **)cppClusterSlot; @end @interface MTRBaseClusterAudioOutput () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::AudioOutputCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::AudioOutputCluster * cppCluster; - (chip::Controller::AudioOutputCluster **)cppClusterSlot; @end @interface MTRBaseClusterApplicationLauncher () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ApplicationLauncherCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ApplicationLauncherCluster * cppCluster; - (chip::Controller::ApplicationLauncherCluster **)cppClusterSlot; @end @interface MTRBaseClusterApplicationBasic () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ApplicationBasicCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ApplicationBasicCluster * cppCluster; - (chip::Controller::ApplicationBasicCluster **)cppClusterSlot; @end @interface MTRBaseClusterAccountLogin () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::AccountLoginCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::AccountLoginCluster * cppCluster; - (chip::Controller::AccountLoginCluster **)cppClusterSlot; @end @interface MTRBaseClusterElectricalMeasurement () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::ElectricalMeasurementCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::ElectricalMeasurementCluster * cppCluster; - (chip::Controller::ElectricalMeasurementCluster **)cppClusterSlot; @end @interface MTRBaseClusterTestCluster () // Must only touch cppCluster on the Matter queue. -@property (readonly) chip::Controller::TestClusterCluster * cppCluster; +@property (nonatomic, readonly) chip::Controller::TestClusterCluster * cppCluster; - (chip::Controller::TestClusterCluster **)cppClusterSlot; @end diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h new file mode 100644 index 00000000000000..155ad0dc23f6f3 --- /dev/null +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -0,0 +1,5284 @@ +/* + * + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#import + +#import + +#import +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * Cluster Identify + * + */ +@interface MTRClusterIdentify : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)identifyWithParams:(MTRIdentifyClusterIdentifyParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)triggerEffectWithParams:(MTRIdentifyClusterTriggerEffectParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeIdentifyTimeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeIdentifyTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeIdentifyTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeIdentifyTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Groups + * + */ +@interface MTRClusterGroups : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)addGroupWithParams:(MTRGroupsClusterAddGroupParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGroupsClusterAddGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)viewGroupWithParams:(MTRGroupsClusterViewGroupParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGroupsClusterViewGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)getGroupMembershipWithParams:(MTRGroupsClusterGetGroupMembershipParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)removeGroupWithParams:(MTRGroupsClusterRemoveGroupParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGroupsClusterRemoveGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)removeAllGroupsWithParams:(MTRGroupsClusterRemoveAllGroupsParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)removeAllGroupsWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)addGroupIfIdentifyingWithParams:(MTRGroupsClusterAddGroupIfIdentifyingParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeNameSupportWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Scenes + * + */ +@interface MTRClusterScenes : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)addSceneWithParams:(MTRScenesClusterAddSceneParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterAddSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)viewSceneWithParams:(MTRScenesClusterViewSceneParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterViewSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)removeSceneWithParams:(MTRScenesClusterRemoveSceneParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterRemoveSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)removeAllScenesWithParams:(MTRScenesClusterRemoveAllScenesParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRScenesClusterRemoveAllScenesResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)storeSceneWithParams:(MTRScenesClusterStoreSceneParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterStoreSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)recallSceneWithParams:(MTRScenesClusterRecallSceneParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)getSceneMembershipWithParams:(MTRScenesClusterGetSceneMembershipParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRScenesClusterGetSceneMembershipResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)enhancedAddSceneWithParams:(MTRScenesClusterEnhancedAddSceneParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRScenesClusterEnhancedAddSceneResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)enhancedViewSceneWithParams:(MTRScenesClusterEnhancedViewSceneParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRScenesClusterEnhancedViewSceneResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)copySceneWithParams:(MTRScenesClusterCopySceneParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterCopySceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeSceneCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentSceneWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentGroupWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSceneValidWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNameSupportWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLastConfiguredByWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster On/Off + * + */ +@interface MTRClusterOnOff : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)offWithParams:(MTROnOffClusterOffParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)offWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)onWithParams:(MTROnOffClusterOnParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)onWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)toggleWithParams:(MTROnOffClusterToggleParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)toggleWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)offWithEffectWithParams:(MTROnOffClusterOffWithEffectParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)onWithRecallGlobalSceneWithParams:(MTROnOffClusterOnWithRecallGlobalSceneParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)onWithRecallGlobalSceneWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)onWithTimedOffWithParams:(MTROnOffClusterOnWithTimedOffParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeOnOffWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGlobalSceneControlWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOnTimeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOnTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOnTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOffWaitTimeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOffWaitTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOffWaitTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeStartUpOnOffWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeStartUpOnOffWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeStartUpOnOffWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster On/off Switch Configuration + * + */ +@interface MTRClusterOnOffSwitchConfiguration : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeSwitchTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSwitchActionsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeSwitchActionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeSwitchActionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Level Control + * + */ +@interface MTRClusterLevelControl : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)moveToLevelWithParams:(MTRLevelControlClusterMoveToLevelParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveWithParams:(MTRLevelControlClusterMoveParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stepWithParams:(MTRLevelControlClusterStepParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stopWithParams:(MTRLevelControlClusterStopParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveToLevelWithOnOffWithParams:(MTRLevelControlClusterMoveToLevelWithOnOffParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveWithOnOffWithParams:(MTRLevelControlClusterMoveWithOnOffParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stepWithOnOffWithParams:(MTRLevelControlClusterStepWithOnOffParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stopWithOnOffWithParams:(MTRLevelControlClusterStopWithOnOffParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stopWithOnOffWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveToClosestFrequencyWithParams:(MTRLevelControlClusterMoveToClosestFrequencyParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeCurrentLevelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRemainingTimeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinLevelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxLevelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentFrequencyWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinFrequencyWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxFrequencyWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOptionsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOptionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOptionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOnOffTransitionTimeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOnOffTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOnOffTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOnLevelWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOnLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOnLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOnTransitionTimeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOnTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOnTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOffTransitionTimeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOffTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOffTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeDefaultMoveRateWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeDefaultMoveRateWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeDefaultMoveRateWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeStartUpCurrentLevelWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeStartUpCurrentLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeStartUpCurrentLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Binary Input (Basic) + * + */ +@interface MTRClusterBinaryInputBasic : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeActiveTextWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeActiveTextWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeActiveTextWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeDescriptionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeDescriptionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInactiveTextWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInactiveTextWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInactiveTextWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOutOfServiceWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOutOfServiceWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOutOfServiceWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePolarityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePresentValueWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributePresentValueWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributePresentValueWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeReliabilityWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeReliabilityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeReliabilityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeStatusFlagsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeApplicationTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Descriptor + * + */ +@interface MTRClusterDescriptor : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeDeviceListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeServerListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClientListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePartsListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Binding + * + */ +@interface MTRClusterBinding : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeBindingWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBindingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBindingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Access Control + * + */ +@interface MTRClusterAccessControl : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeAclWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeAclWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeAclWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeExtensionWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeExtensionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeExtensionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSubjectsPerAccessControlEntryWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTargetsPerAccessControlEntryWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAccessControlEntriesPerFabricWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Bridged Actions + * + */ +@interface MTRClusterBridgedActions : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)instantActionWithParams:(MTRBridgedActionsClusterInstantActionParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)instantActionWithTransitionWithParams:(MTRBridgedActionsClusterInstantActionWithTransitionParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)startActionWithParams:(MTRBridgedActionsClusterStartActionParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)startActionWithDurationWithParams:(MTRBridgedActionsClusterStartActionWithDurationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stopActionWithParams:(MTRBridgedActionsClusterStopActionParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)pauseActionWithParams:(MTRBridgedActionsClusterPauseActionParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)pauseActionWithDurationWithParams:(MTRBridgedActionsClusterPauseActionWithDurationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)resumeActionWithParams:(MTRBridgedActionsClusterResumeActionParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)enableActionWithParams:(MTRBridgedActionsClusterEnableActionParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)enableActionWithDurationWithParams:(MTRBridgedActionsClusterEnableActionWithDurationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)disableActionWithParams:(MTRBridgedActionsClusterDisableActionParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)disableActionWithDurationWithParams:(MTRBridgedActionsClusterDisableActionWithDurationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeActionListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeEndpointListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSetupUrlWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Basic + * + */ +@interface MTRClusterBasic : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)mfgSpecificPingWithParams:(MTRBasicClusterMfgSpecificPingParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)mfgSpecificPingWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeDataModelRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeProductNameWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeProductIDWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNodeLabelWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLocationWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLocationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLocationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeHardwareVersionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeHardwareVersionStringWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSoftwareVersionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSoftwareVersionStringWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeManufacturingDateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePartNumberWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeProductURLWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeProductLabelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSerialNumberWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLocalConfigDisabledWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLocalConfigDisabledWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLocalConfigDisabledWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeReachableWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeUniqueIDWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCapabilityMinimaWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster OTA Software Update Provider + * + */ +@interface MTRClusterOtaSoftwareUpdateProvider : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)queryImageWithParams:(MTROtaSoftwareUpdateProviderClusterQueryImageParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROtaSoftwareUpdateProviderClusterQueryImageResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)applyUpdateRequestWithParams:(MTROtaSoftwareUpdateProviderClusterApplyUpdateRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)notifyUpdateAppliedWithParams:(MTROtaSoftwareUpdateProviderClusterNotifyUpdateAppliedParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster OTA Software Update Requestor + * + */ +@interface MTRClusterOtaSoftwareUpdateRequestor : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)announceOtaProviderWithParams:(MTROtaSoftwareUpdateRequestorClusterAnnounceOtaProviderParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeDefaultOtaProvidersWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeDefaultOtaProvidersWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeDefaultOtaProvidersWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUpdatePossibleWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeUpdateStateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeUpdateStateProgressWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Localization Configuration + * + */ +@interface MTRClusterLocalizationConfiguration : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeActiveLocaleWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeActiveLocaleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeActiveLocaleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSupportedLocalesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Time Format Localization + * + */ +@interface MTRClusterTimeFormatLocalization : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeHourFormatWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeHourFormatWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeHourFormatWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveCalendarTypeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeActiveCalendarTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeActiveCalendarTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSupportedCalendarTypesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Unit Localization + * + */ +@interface MTRClusterUnitLocalization : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeTemperatureUnitWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeTemperatureUnitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeTemperatureUnitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Power Source Configuration + * + */ +@interface MTRClusterPowerSourceConfiguration : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeSourcesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Power Source + * + */ +@interface MTRClusterPowerSource : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOrderWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWiredAssessedInputVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWiredAssessedInputFrequencyWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWiredCurrentTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWiredAssessedCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWiredNominalVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWiredMaximumCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWiredPresentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveWiredFaultsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatPercentRemainingWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatTimeRemainingWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatChargeLevelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatReplacementNeededWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatReplaceabilityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatPresentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveBatFaultsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatReplacementDescriptionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatCommonDesignationWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatANSIDesignationWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatIECDesignationWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatApprovedChemistryWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatCapacityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatQuantityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatChargeStateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatTimeToFullChargeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatFunctionalWhileChargingWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBatChargingCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveBatChargeFaultsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster General Commissioning + * + */ +@interface MTRClusterGeneralCommissioning : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)armFailSafeWithParams:(MTRGeneralCommissioningClusterArmFailSafeParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)setRegulatoryConfigWithParams:(MTRGeneralCommissioningClusterSetRegulatoryConfigParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)commissioningCompleteWithParams:(MTRGeneralCommissioningClusterCommissioningCompleteParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)commissioningCompleteWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeBreadcrumbWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBreadcrumbWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBreadcrumbWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBasicCommissioningInfoWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRegulatoryConfigWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLocationCapabilityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSupportsConcurrentConnectionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Network Commissioning + * + */ +@interface MTRClusterNetworkCommissioning : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)scanNetworksWithParams:(MTRNetworkCommissioningClusterScanNetworksParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterScanNetworksResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)addOrUpdateWiFiNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpdateWiFiNetworkParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)addOrUpdateThreadNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpdateThreadNetworkParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)removeNetworkWithParams:(MTRNetworkCommissioningClusterRemoveNetworkParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)connectNetworkWithParams:(MTRNetworkCommissioningClusterConnectNetworkParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterConnectNetworkResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)reorderNetworkWithParams:(MTRNetworkCommissioningClusterReorderNetworkParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeMaxNetworksWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNetworksWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeScanMaxTimeSecondsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeConnectMaxTimeSecondsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInterfaceEnabledWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInterfaceEnabledWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInterfaceEnabledWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLastNetworkingStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLastNetworkIDWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLastConnectErrorValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Diagnostic Logs + * + */ +@interface MTRClusterDiagnosticLogs : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)retrieveLogsRequestWithParams:(MTRDiagnosticLogsClusterRetrieveLogsRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDiagnosticLogsClusterRetrieveLogsResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster General Diagnostics + * + */ +@interface MTRClusterGeneralDiagnostics : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)testEventTriggerWithParams:(MTRGeneralDiagnosticsClusterTestEventTriggerParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeNetworkInterfacesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRebootCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeUpTimeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTotalOperationalHoursWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBootReasonsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveHardwareFaultsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveRadioFaultsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveNetworkFaultsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTestEventTriggersEnabledWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Software Diagnostics + * + */ +@interface MTRClusterSoftwareDiagnostics : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)resetWatermarksWithParams:(MTRSoftwareDiagnosticsClusterResetWatermarksParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)resetWatermarksWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeThreadMetricsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentHeapFreeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentHeapUsedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentHeapHighWatermarkWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Thread Network Diagnostics + * + */ +@interface MTRClusterThreadNetworkDiagnostics : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)resetCountsWithParams:(MTRThreadNetworkDiagnosticsClusterResetCountsParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)resetCountsWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeChannelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRoutingRoleWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNetworkNameWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePanIdWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeExtendedPanIdWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeshLocalPrefixWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNeighborTableListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRouteTableListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePartitionIdWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWeightingWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDataVersionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeStableDataVersionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLeaderRouterIdWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDetachedRoleCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeChildRoleCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRouterRoleCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLeaderRoleCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttachAttemptCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePartitionIdChangeCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBetterPartitionAttachAttemptCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeParentChangeCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxTotalCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxUnicastCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxBroadcastCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxAckRequestedCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxAckedCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxNoAckRequestedCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxDataCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxDataPollCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxBeaconCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxBeaconRequestCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxOtherCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxRetryCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxDirectMaxRetryExpiryCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxIndirectMaxRetryExpiryCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxErrCcaCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxErrAbortCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxErrBusyChannelCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxTotalCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxUnicastCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxBroadcastCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxDataCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxDataPollCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxBeaconCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxBeaconRequestCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxOtherCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxAddressFilteredCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxDestAddrFilteredCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxDuplicatedCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxErrNoFrameCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxErrUnknownNeighborCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxErrInvalidSrcAddrCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxErrSecCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxErrFcsCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRxErrOtherCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveTimestampWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePendingTimestampWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDelayWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSecurityPolicyWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeChannelMaskWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOperationalDatasetComponentsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveNetworkFaultsListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster WiFi Network Diagnostics + * + */ +@interface MTRClusterWiFiNetworkDiagnostics : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)resetCountsWithParams:(MTRWiFiNetworkDiagnosticsClusterResetCountsParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)resetCountsWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeBssidWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSecurityTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWiFiVersionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeChannelNumberWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRssiWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBeaconLostCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBeaconRxCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePacketMulticastRxCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePacketMulticastTxCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePacketUnicastRxCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePacketUnicastTxCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentMaxRateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Ethernet Network Diagnostics + * + */ +@interface MTRClusterEthernetNetworkDiagnostics : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)resetCountsWithParams:(MTREthernetNetworkDiagnosticsClusterResetCountsParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)resetCountsWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributePHYRateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFullDuplexWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePacketRxCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePacketTxCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTxErrCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCollisionCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCarrierDetectWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTimeSinceResetWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Bridged Device Basic + * + */ +@interface MTRClusterBridgedDeviceBasic : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeProductNameWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNodeLabelWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeHardwareVersionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeHardwareVersionStringWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSoftwareVersionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSoftwareVersionStringWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeManufacturingDateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePartNumberWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeProductURLWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeProductLabelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSerialNumberWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeReachableWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeUniqueIDWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Switch + * + */ +@interface MTRClusterSwitch : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeNumberOfPositionsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentPositionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMultiPressMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster AdministratorCommissioning + * + */ +@interface MTRClusterAdministratorCommissioning : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)openCommissioningWindowWithParams:(MTRAdministratorCommissioningClusterOpenCommissioningWindowParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)openBasicCommissioningWindowWithParams:(MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)revokeCommissioningWithParams:(MTRAdministratorCommissioningClusterRevokeCommissioningParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)revokeCommissioningWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeWindowStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAdminFabricIndexWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAdminVendorIdWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Operational Credentials + * + */ +@interface MTRClusterOperationalCredentials : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)attestationRequestWithParams:(MTROperationalCredentialsClusterAttestationRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterAttestationResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)certificateChainRequestWithParams:(MTROperationalCredentialsClusterCertificateChainRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterCertificateChainResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)CSRRequestWithParams:(MTROperationalCredentialsClusterCSRRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterCSRResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)addNOCWithParams:(MTROperationalCredentialsClusterAddNOCParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)updateNOCWithParams:(MTROperationalCredentialsClusterUpdateNOCParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)updateFabricLabelWithParams:(MTROperationalCredentialsClusterUpdateFabricLabelParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)removeFabricWithParams:(MTROperationalCredentialsClusterRemoveFabricParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)addTrustedRootCertificateWithParams:(MTROperationalCredentialsClusterAddTrustedRootCertificateParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeNOCsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFabricsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSupportedFabricsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCommissionedFabricsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTrustedRootCertificatesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentFabricIndexWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Group Key Management + * + */ +@interface MTRClusterGroupKeyManagement : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)keySetWriteWithParams:(MTRGroupKeyManagementClusterKeySetWriteParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)keySetReadWithParams:(MTRGroupKeyManagementClusterKeySetReadParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)keySetRemoveWithParams:(MTRGroupKeyManagementClusterKeySetRemoveParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)keySetReadAllIndicesWithParams:(MTRGroupKeyManagementClusterKeySetReadAllIndicesParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeGroupKeyMapWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeGroupKeyMapWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeGroupKeyMapWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGroupTableWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxGroupsPerFabricWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxGroupKeysPerFabricWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Fixed Label + * + */ +@interface MTRClusterFixedLabel : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeLabelListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster User Label + * + */ +@interface MTRClusterUserLabel : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeLabelListWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLabelListWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLabelListWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Boolean State + * + */ +@interface MTRClusterBooleanState : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeStateValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Mode Select + * + */ +@interface MTRClusterModeSelect : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)changeToModeWithParams:(MTRModeSelectClusterChangeToModeParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeStandardNamespaceWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSupportedModesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentModeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeStartUpModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeStartUpModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeStartUpModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOnModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Door Lock + * + */ +@interface MTRClusterDoorLock : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)lockDoorWithParams:(MTRDoorLockClusterLockDoorParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)unlockDoorWithParams:(MTRDoorLockClusterUnlockDoorParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)unlockWithTimeoutWithParams:(MTRDoorLockClusterUnlockWithTimeoutParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)setWeekDayScheduleWithParams:(MTRDoorLockClusterSetWeekDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)getWeekDayScheduleWithParams:(MTRDoorLockClusterGetWeekDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)clearWeekDayScheduleWithParams:(MTRDoorLockClusterClearWeekDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)setYearDayScheduleWithParams:(MTRDoorLockClusterSetYearDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)getYearDayScheduleWithParams:(MTRDoorLockClusterGetYearDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)clearYearDayScheduleWithParams:(MTRDoorLockClusterClearYearDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)setHolidayScheduleWithParams:(MTRDoorLockClusterSetHolidayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)getHolidayScheduleWithParams:(MTRDoorLockClusterGetHolidayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)clearHolidayScheduleWithParams:(MTRDoorLockClusterClearHolidayScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)setUserWithParams:(MTRDoorLockClusterSetUserParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)getUserWithParams:(MTRDoorLockClusterGetUserParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRDoorLockClusterGetUserResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)clearUserWithParams:(MTRDoorLockClusterClearUserParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)setCredentialWithParams:(MTRDoorLockClusterSetCredentialParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterSetCredentialResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)getCredentialStatusWithParams:(MTRDoorLockClusterGetCredentialStatusParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)clearCredentialWithParams:(MTRDoorLockClusterClearCredentialParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeLockStateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLockTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActuatorEnabledWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDoorStateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDoorOpenEventsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeDoorOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeDoorOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeDoorClosedEventsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeDoorClosedEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeDoorClosedEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOpenPeriodWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOpenPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOpenPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfTotalUsersSupportedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfPINUsersSupportedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfRFIDUsersSupportedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfYearDaySchedulesSupportedPerUserWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfHolidaySchedulesSupportedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxPINCodeLengthWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinPINCodeLengthWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxRFIDCodeLengthWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinRFIDCodeLengthWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCredentialRulesSupportWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfCredentialsSupportedPerUserWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLanguageWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLanguageWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLanguageWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLEDSettingsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLEDSettingsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLEDSettingsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeAutoRelockTimeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeAutoRelockTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeAutoRelockTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSoundVolumeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeSoundVolumeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeSoundVolumeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOperatingModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOperatingModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOperatingModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSupportedOperatingModesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDefaultConfigurationRegisterWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnableLocalProgrammingWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEnableLocalProgrammingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEnableLocalProgrammingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnableOneTouchLockingWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEnableOneTouchLockingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEnableOneTouchLockingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnableInsideStatusLEDWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEnableInsideStatusLEDWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEnableInsideStatusLEDWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnablePrivacyModeButtonWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEnablePrivacyModeButtonWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEnablePrivacyModeButtonWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLocalProgrammingFeaturesWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLocalProgrammingFeaturesWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLocalProgrammingFeaturesWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeWrongCodeEntryLimitWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeWrongCodeEntryLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeWrongCodeEntryLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUserCodeTemporaryDisableTimeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeUserCodeTemporaryDisableTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeUserCodeTemporaryDisableTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSendPINOverTheAirWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeSendPINOverTheAirWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeSendPINOverTheAirWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRequirePINforRemoteOperationWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRequirePINforRemoteOperationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRequirePINforRemoteOperationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeExpiringUserTimeoutWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeExpiringUserTimeoutWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeExpiringUserTimeoutWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Window Covering + * + */ +@interface MTRClusterWindowCovering : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)upOrOpenWithParams:(MTRWindowCoveringClusterUpOrOpenParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)upOrOpenWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)downOrCloseWithParams:(MTRWindowCoveringClusterDownOrCloseParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)downOrCloseWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stopMotionWithParams:(MTRWindowCoveringClusterStopMotionParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stopMotionWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)goToLiftValueWithParams:(MTRWindowCoveringClusterGoToLiftValueParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)goToLiftPercentageWithParams:(MTRWindowCoveringClusterGoToLiftPercentageParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)goToTiltValueWithParams:(MTRWindowCoveringClusterGoToTiltValueParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)goToTiltPercentageWithParams:(MTRWindowCoveringClusterGoToTiltPercentageParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePhysicalClosedLimitLiftWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePhysicalClosedLimitTiltWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentPositionLiftWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentPositionTiltWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfActuationsLiftWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfActuationsTiltWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeConfigStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentPositionLiftPercentageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentPositionTiltPercentageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOperationalStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTargetPositionLiftPercent100thsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTargetPositionTiltPercent100thsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeEndProductTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentPositionLiftPercent100thsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentPositionTiltPercent100thsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstalledOpenLimitLiftWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstalledClosedLimitLiftWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstalledOpenLimitTiltWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstalledClosedLimitTiltWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSafetyStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Barrier Control + * + */ +@interface MTRClusterBarrierControl : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)barrierControlGoToPercentWithParams:(MTRBarrierControlClusterBarrierControlGoToPercentParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)barrierControlStopWithParams:(MTRBarrierControlClusterBarrierControlStopParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)barrierControlStopWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeBarrierMovingStateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierSafetyStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierCapabilitiesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierOpenEventsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBarrierOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBarrierOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierCloseEventsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBarrierCloseEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBarrierCloseEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierCommandOpenEventsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBarrierCommandOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBarrierCommandOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierCommandCloseEventsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBarrierCommandCloseEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBarrierCommandCloseEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierOpenPeriodWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBarrierOpenPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBarrierOpenPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierClosePeriodWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBarrierClosePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBarrierClosePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBarrierPositionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Pump Configuration and Control + * + */ +@interface MTRClusterPumpConfigurationAndControl : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeMaxPressureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxSpeedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxFlowWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinConstPressureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxConstPressureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinCompPressureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxCompPressureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinConstSpeedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxConstSpeedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinConstFlowWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxConstFlowWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinConstTempWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxConstTempWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePumpStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeEffectiveOperationModeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeEffectiveControlModeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCapacityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSpeedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLifetimeRunningHoursWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLifetimeRunningHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLifetimeRunningHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLifetimeEnergyConsumedWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLifetimeEnergyConsumedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLifetimeEnergyConsumedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOperationModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOperationModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOperationModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeControlModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeControlModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeControlModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Thermostat + * + */ +@interface MTRClusterThermostat : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)setpointRaiseLowerWithParams:(MTRThermostatClusterSetpointRaiseLowerParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)setWeeklyScheduleWithParams:(MTRThermostatClusterSetWeeklyScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)getWeeklyScheduleWithParams:(MTRThermostatClusterGetWeeklyScheduleParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRThermostatClusterGetWeeklyScheduleResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)clearWeeklyScheduleWithParams:(MTRThermostatClusterClearWeeklyScheduleParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)clearWeeklyScheduleWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeLocalTemperatureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOutdoorTemperatureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOccupancyWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAbsMinHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAbsMaxHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAbsMinCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAbsMaxCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePICoolingDemandWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePIHeatingDemandWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeHVACSystemTypeConfigurationWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeHVACSystemTypeConfigurationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeHVACSystemTypeConfigurationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLocalTemperatureCalibrationWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLocalTemperatureCalibrationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLocalTemperatureCalibrationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOccupiedCoolingSetpointWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOccupiedCoolingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOccupiedCoolingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOccupiedHeatingSetpointWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOccupiedHeatingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOccupiedHeatingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUnoccupiedCoolingSetpointWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeUnoccupiedCoolingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeUnoccupiedCoolingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUnoccupiedHeatingSetpointWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeUnoccupiedHeatingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeUnoccupiedHeatingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeMinHeatSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeMinHeatSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeMaxHeatSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeMaxHeatSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeMinCoolSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeMinCoolSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeMaxCoolSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeMaxCoolSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinSetpointDeadBandWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeMinSetpointDeadBandWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeMinSetpointDeadBandWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRemoteSensingWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRemoteSensingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRemoteSensingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeControlSequenceOfOperationWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeControlSequenceOfOperationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeControlSequenceOfOperationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSystemModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeSystemModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeSystemModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeThermostatRunningModeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeStartOfWeekWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfWeeklyTransitionsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfDailyTransitionsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTemperatureSetpointHoldWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeTemperatureSetpointHoldWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeTemperatureSetpointHoldWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeTemperatureSetpointHoldDurationWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeTemperatureSetpointHoldDurationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeTemperatureSetpointHoldDurationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeThermostatProgrammingOperationModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeThermostatProgrammingOperationModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeThermostatProgrammingOperationModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeThermostatRunningStateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSetpointChangeSourceWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSetpointChangeAmountWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSetpointChangeSourceTimestampWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOccupiedSetbackWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOccupiedSetbackWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOccupiedSetbackWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOccupiedSetbackMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOccupiedSetbackMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeUnoccupiedSetbackWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeUnoccupiedSetbackWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeUnoccupiedSetbackWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUnoccupiedSetbackMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeUnoccupiedSetbackMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeEmergencyHeatDeltaWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEmergencyHeatDeltaWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEmergencyHeatDeltaWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeACTypeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeACTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeACTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeACCapacityWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeACCapacityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeACCapacityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeACRefrigerantTypeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeACRefrigerantTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeACRefrigerantTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeACCompressorTypeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeACCompressorTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeACCompressorTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeACErrorCodeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeACErrorCodeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeACErrorCodeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeACLouverPositionWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeACLouverPositionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeACLouverPositionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeACCoilTemperatureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeACCapacityformatWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeACCapacityformatWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeACCapacityformatWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Fan Control + * + */ +@interface MTRClusterFanControl : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeFanModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeFanModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeFanModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeFanModeSequenceWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeFanModeSequenceWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeFanModeSequenceWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePercentSettingWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributePercentSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributePercentSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePercentCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSpeedMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSpeedSettingWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeSpeedSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeSpeedSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeSpeedCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRockSupportWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRockSettingWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRockSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRockSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeWindSupportWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWindSettingWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeWindSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeWindSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Thermostat User Interface Configuration + * + */ +@interface MTRClusterThermostatUserInterfaceConfiguration : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeTemperatureDisplayModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeTemperatureDisplayModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeTemperatureDisplayModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeKeypadLockoutWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeKeypadLockoutWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeKeypadLockoutWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeScheduleProgrammingVisibilityWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeScheduleProgrammingVisibilityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeScheduleProgrammingVisibilityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Color Control + * + */ +@interface MTRClusterColorControl : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)moveToHueWithParams:(MTRColorControlClusterMoveToHueParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveHueWithParams:(MTRColorControlClusterMoveHueParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stepHueWithParams:(MTRColorControlClusterStepHueParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveToSaturationWithParams:(MTRColorControlClusterMoveToSaturationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveSaturationWithParams:(MTRColorControlClusterMoveSaturationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stepSaturationWithParams:(MTRColorControlClusterStepSaturationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveToHueAndSaturationWithParams:(MTRColorControlClusterMoveToHueAndSaturationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveToColorWithParams:(MTRColorControlClusterMoveToColorParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveColorWithParams:(MTRColorControlClusterMoveColorParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stepColorWithParams:(MTRColorControlClusterStepColorParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveToColorTemperatureWithParams:(MTRColorControlClusterMoveToColorTemperatureParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)enhancedMoveToHueWithParams:(MTRColorControlClusterEnhancedMoveToHueParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)enhancedMoveHueWithParams:(MTRColorControlClusterEnhancedMoveHueParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)enhancedStepHueWithParams:(MTRColorControlClusterEnhancedStepHueParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)enhancedMoveToHueAndSaturationWithParams:(MTRColorControlClusterEnhancedMoveToHueAndSaturationParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)colorLoopSetWithParams:(MTRColorControlClusterColorLoopSetParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stopMoveStepWithParams:(MTRColorControlClusterStopMoveStepParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)moveColorTemperatureWithParams:(MTRColorControlClusterMoveColorTemperatureParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)stepColorTemperatureWithParams:(MTRColorControlClusterStepColorTemperatureParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeCurrentHueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentSaturationWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRemainingTimeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentXWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentYWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDriftCompensationWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCompensationTextWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorTemperatureWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorModeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOptionsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOptionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOptionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNumberOfPrimariesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary1XWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary1YWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary1IntensityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary2XWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary2YWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary2IntensityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary3XWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary3YWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary3IntensityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary4XWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary4YWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary4IntensityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary5XWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary5YWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary5IntensityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary6XWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary6YWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePrimary6IntensityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeWhitePointXWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeWhitePointXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeWhitePointXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeWhitePointYWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeWhitePointYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeWhitePointYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointRXWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointRXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointRXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointRYWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointRYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointRYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointRIntensityWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointRIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointRIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointGXWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointGXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointGXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointGYWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointGYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointGYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointGIntensityWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointGIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointGIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointBXWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointBXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointBXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointBYWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointBYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointBYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorPointBIntensityWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeColorPointBIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeColorPointBIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnhancedCurrentHueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnhancedColorModeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorLoopActiveWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorLoopDirectionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorLoopTimeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorLoopStartEnhancedHueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorLoopStoredEnhancedHueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorCapabilitiesWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorTempPhysicalMinMiredsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeColorTempPhysicalMaxMiredsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCoupleColorTempToLevelMinMiredsWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeStartUpColorTemperatureMiredsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeStartUpColorTemperatureMiredsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeStartUpColorTemperatureMiredsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Ballast Configuration + * + */ +@interface MTRClusterBallastConfiguration : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributePhysicalMinLevelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePhysicalMaxLevelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeBallastStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinLevelWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeMinLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeMinLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxLevelWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeMaxLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeMaxLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeIntrinsicBalanceFactorWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeIntrinsicBalanceFactorWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeIntrinsicBalanceFactorWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBallastFactorAdjustmentWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBallastFactorAdjustmentWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBallastFactorAdjustmentWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLampQuantityWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLampTypeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLampTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLampTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLampManufacturerWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLampManufacturerWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLampManufacturerWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLampRatedHoursWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLampRatedHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLampRatedHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLampBurnHoursWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLampBurnHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLampBurnHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLampAlarmModeWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLampAlarmModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLampAlarmModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLampBurnHoursTripPointWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLampBurnHoursTripPointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLampBurnHoursTripPointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Illuminance Measurement + * + */ +@interface MTRClusterIlluminanceMeasurement : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLightSensorTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Temperature Measurement + * + */ +@interface MTRClusterTemperatureMeasurement : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Pressure Measurement + * + */ +@interface MTRClusterPressureMeasurement : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeScaledValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinScaledValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxScaledValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeScaledToleranceWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeScaleWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Flow Measurement + * + */ +@interface MTRClusterFlowMeasurement : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Relative Humidity Measurement + * + */ +@interface MTRClusterRelativeHumidityMeasurement : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Occupancy Sensing + * + */ +@interface MTRClusterOccupancySensing : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeOccupancyWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOccupancySensorTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOccupancySensorTypeBitmapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePirOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributePirOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributePirOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePirUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributePirUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributePirUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePirUnoccupiedToOccupiedThresholdWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributePirUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributePirUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUltrasonicOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeUltrasonicOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeUltrasonicOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUltrasonicUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeUltrasonicUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeUltrasonicUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUltrasonicUnoccupiedToOccupiedThresholdWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeUltrasonicUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeUltrasonicUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePhysicalContactOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributePhysicalContactOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributePhysicalContactOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePhysicalContactUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributePhysicalContactUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributePhysicalContactUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributePhysicalContactUnoccupiedToOccupiedThresholdWithParams: + (MTRReadParams * _Nullable)params; +- (void)writeAttributePhysicalContactUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributePhysicalContactUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Wake on LAN + * + */ +@interface MTRClusterWakeOnLan : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeMACAddressWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Channel + * + */ +@interface MTRClusterChannel : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)changeChannelWithParams:(MTRChannelClusterChangeChannelParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRChannelClusterChangeChannelResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)changeChannelByNumberWithParams:(MTRChannelClusterChangeChannelByNumberParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)skipChannelWithParams:(MTRChannelClusterSkipChannelParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeChannelListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLineupWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentChannelWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Target Navigator + * + */ +@interface MTRClusterTargetNavigator : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)navigateTargetWithParams:(MTRTargetNavigatorClusterNavigateTargetParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeTargetListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentTargetWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Media Playback + * + */ +@interface MTRClusterMediaPlayback : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)playWithParams:(MTRMediaPlaybackClusterPlayParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)playWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)pauseWithParams:(MTRMediaPlaybackClusterPauseParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)pauseWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)stopPlaybackWithParams:(MTRMediaPlaybackClusterStopPlaybackParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)stopPlaybackWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)startOverWithParams:(MTRMediaPlaybackClusterStartOverParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)startOverWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)previousWithParams:(MTRMediaPlaybackClusterPreviousParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)previousWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)nextWithParams:(MTRMediaPlaybackClusterNextParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)nextWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)rewindWithParams:(MTRMediaPlaybackClusterRewindParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; +- (void)rewindWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)fastForwardWithParams:(MTRMediaPlaybackClusterFastForwardParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)fastForwardWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)skipForwardWithParams:(MTRMediaPlaybackClusterSkipForwardParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)skipBackwardWithParams:(MTRMediaPlaybackClusterSkipBackwardParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)seekWithParams:(MTRMediaPlaybackClusterSeekParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeCurrentStateWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeStartTimeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDurationWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSampledPositionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePlaybackSpeedWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSeekRangeEndWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSeekRangeStartWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Media Input + * + */ +@interface MTRClusterMediaInput : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)selectInputWithParams:(MTRMediaInputClusterSelectInputParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)showInputStatusWithParams:(MTRMediaInputClusterShowInputStatusParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)showInputStatusWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)hideInputStatusWithParams:(MTRMediaInputClusterHideInputStatusParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)hideInputStatusWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)renameInputWithParams:(MTRMediaInputClusterRenameInputParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeInputListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentInputWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Low Power + * + */ +@interface MTRClusterLowPower : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)sleepWithParams:(MTRLowPowerClusterSleepParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)sleepWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Keypad Input + * + */ +@interface MTRClusterKeypadInput : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)sendKeyWithParams:(MTRKeypadInputClusterSendKeyParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRKeypadInputClusterSendKeyResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Content Launcher + * + */ +@interface MTRClusterContentLauncher : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)launchContentWithParams:(MTRContentLauncherClusterLaunchContentParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRContentLauncherClusterLaunchResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)launchURLWithParams:(MTRContentLauncherClusterLaunchURLParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRContentLauncherClusterLaunchResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeAcceptHeaderWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeSupportedStreamingProtocolsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeSupportedStreamingProtocolsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeSupportedStreamingProtocolsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Audio Output + * + */ +@interface MTRClusterAudioOutput : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)selectOutputWithParams:(MTRAudioOutputClusterSelectOutputParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)renameOutputWithParams:(MTRAudioOutputClusterRenameOutputParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeOutputListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentOutputWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Application Launcher + * + */ +@interface MTRClusterApplicationLauncher : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)launchAppWithParams:(MTRApplicationLauncherClusterLaunchAppParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)stopAppWithParams:(MTRApplicationLauncherClusterStopAppParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)hideAppWithParams:(MTRApplicationLauncherClusterHideAppParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeCatalogListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentAppWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeCurrentAppWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeCurrentAppWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Application Basic + * + */ +@interface MTRClusterApplicationBasic : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (NSDictionary *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeApplicationNameWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeProductIDWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeApplicationWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeStatusWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeApplicationVersionWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAllowedVendorListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Account Login + * + */ +@interface MTRClusterAccountLogin : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)getSetupPINWithParams:(MTRAccountLoginClusterGetSetupPINParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)loginWithParams:(MTRAccountLoginClusterLoginParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)logoutWithParams:(MTRAccountLoginClusterLogoutParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)logoutWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Electrical Measurement + * + */ +@interface MTRClusterElectricalMeasurement : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)getProfileInfoCommandWithParams:(MTRElectricalMeasurementClusterGetProfileInfoCommandParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)getProfileInfoCommandWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)getMeasurementProfileCommandWithParams:(MTRElectricalMeasurementClusterGetMeasurementProfileCommandParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; + +- (NSDictionary *)readAttributeMeasurementTypeWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcVoltageMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcVoltageMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcCurrentMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcCurrentMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcPowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcPowerMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcPowerMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcVoltageMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcVoltageDivisorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcCurrentDivisorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcPowerMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeDcPowerDivisorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcFrequencyWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcFrequencyMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcFrequencyMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeNeutralCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTotalActivePowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTotalReactivePowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeTotalApparentPowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasured1stHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasured3rdHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasured5thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasured7thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasured9thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasured11thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasuredPhase1stHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasuredPhase3rdHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasuredPhase5thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasuredPhase7thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasuredPhase9thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeMeasuredPhase11thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcFrequencyMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcFrequencyDivisorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePowerMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePowerDivisorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeHarmonicCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePhaseHarmonicCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstantaneousVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstantaneousLineCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstantaneousActiveCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstantaneousReactiveCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeInstantaneousPowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerMinWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerMaxWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeReactivePowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeApparentPowerWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePowerFactorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsVoltageMeasurementPeriodWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeAverageRmsVoltageMeasurementPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeAverageRmsVoltageMeasurementPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsUnderVoltageCounterWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeAverageRmsUnderVoltageCounterWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeAverageRmsUnderVoltageCounterWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsExtremeOverVoltagePeriodWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRmsExtremeOverVoltagePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRmsExtremeOverVoltagePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsExtremeUnderVoltagePeriodWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRmsExtremeUnderVoltagePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRmsExtremeUnderVoltagePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageSagPeriodWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRmsVoltageSagPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRmsVoltageSagPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageSwellPeriodWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRmsVoltageSwellPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRmsVoltageSwellPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcVoltageMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcVoltageDivisorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcCurrentDivisorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcPowerMultiplierWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcPowerDivisorWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeOverloadAlarmsMaskWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOverloadAlarmsMaskWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOverloadAlarmsMaskWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeVoltageOverloadWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeCurrentOverloadWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcOverloadAlarmsMaskWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeAcOverloadAlarmsMaskWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeAcOverloadAlarmsMaskWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcVoltageOverloadWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcCurrentOverloadWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcActivePowerOverloadWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcReactivePowerOverloadWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsOverVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsUnderVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsExtremeOverVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsExtremeUnderVoltageWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageSagWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageSwellWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLineCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeReactiveCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltagePhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageMinPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageMaxPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentMinPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentMaxPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerMinPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerMaxPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeReactivePowerPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeApparentPowerPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePowerFactorPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsVoltageMeasurementPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsOverVoltageCounterPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsUnderVoltageCounterPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsExtremeOverVoltagePeriodPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsExtremeUnderVoltagePeriodPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageSagPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageSwellPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeLineCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActiveCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeReactiveCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltagePhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageMinPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageMaxPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentMinPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsCurrentMaxPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerMinPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeActivePowerMaxPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeReactivePowerPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeApparentPowerPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributePowerFactorPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsVoltageMeasurementPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsOverVoltageCounterPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAverageRmsUnderVoltageCounterPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsExtremeOverVoltagePeriodPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsExtremeUnderVoltagePeriodPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageSagPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeRmsVoltageSwellPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** + * Cluster Test Cluster + * + */ +@interface MTRClusterTestCluster : MTRCluster + +- (nullable instancetype)initWithDevice:(MTRDevice *)device + endpoint:(uint16_t)endpoint + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER; + +- (void)testWithParams:(MTRTestClusterClusterTestParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)testWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)testNotHandledWithParams:(MTRTestClusterClusterTestNotHandledParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)testNotHandledWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)testSpecificWithParams:(MTRTestClusterClusterTestSpecificParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestSpecificResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testSpecificWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestSpecificResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testUnknownCommandWithParams:(MTRTestClusterClusterTestUnknownCommandParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)testUnknownCommandWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)testAddArgumentsWithParams:(MTRTestClusterClusterTestAddArgumentsParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestAddArgumentsResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testSimpleArgumentRequestWithParams:(MTRTestClusterClusterTestSimpleArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestSimpleArgumentResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testStructArrayArgumentRequestWithParams:(MTRTestClusterClusterTestStructArrayArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRTestClusterClusterTestStructArrayArgumentResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testStructArgumentRequestWithParams:(MTRTestClusterClusterTestStructArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testNestedStructArgumentRequestWithParams:(MTRTestClusterClusterTestNestedStructArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testListStructArgumentRequestWithParams:(MTRTestClusterClusterTestListStructArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testListInt8UArgumentRequestWithParams:(MTRTestClusterClusterTestListInt8UArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testNestedStructListArgumentRequestWithParams:(MTRTestClusterClusterTestNestedStructListArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testListNestedStructListArgumentRequestWithParams: + (MTRTestClusterClusterTestListNestedStructListArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testListInt8UReverseRequestWithParams:(MTRTestClusterClusterTestListInt8UReverseRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestListInt8UReverseResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testEnumsRequestWithParams:(MTRTestClusterClusterTestEnumsRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestEnumsResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testNullableOptionalRequestWithParams:(MTRTestClusterClusterTestNullableOptionalRequestParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestNullableOptionalResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testComplexNullableOptionalRequestWithParams:(MTRTestClusterClusterTestComplexNullableOptionalRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRTestClusterClusterTestComplexNullableOptionalResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)simpleStructEchoRequestWithParams:(MTRTestClusterClusterSimpleStructEchoRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterSimpleStructResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)timedInvokeRequestWithParams:(MTRTestClusterClusterTimedInvokeRequestParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)timedInvokeRequestWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)testSimpleOptionalArgumentRequestWithParams:(MTRTestClusterClusterTestSimpleOptionalArgumentRequestParams * _Nullable)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler; +- (void)testEmitTestEventRequestWithParams:(MTRTestClusterClusterTestEmitTestEventRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestEmitTestEventResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; +- (void)testEmitTestFabricScopedEventRequestWithParams:(MTRTestClusterClusterTestEmitTestFabricScopedEventRequestParams *)params + expectedValues:(NSArray *> *)expectedDataValueDictionaries + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)( + MTRTestClusterClusterTestEmitTestFabricScopedEventResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler; + +- (NSDictionary *)readAttributeBooleanWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBitmap8WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBitmap8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBitmap8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBitmap16WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBitmap16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBitmap16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBitmap32WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBitmap32WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBitmap32WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeBitmap64WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeBitmap64WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeBitmap64WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt8uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt16uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt24uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt24uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt24uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt32uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt32uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt32uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt40uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt40uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt40uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt48uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt48uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt48uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt56uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt56uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt56uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt64uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt64uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt64uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt8sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt16sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt24sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt24sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt24sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt32sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt32sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt32sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt40sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt40sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt40sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt48sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt48sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt48sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt56sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt56sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt56sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeInt64sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeInt64sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeInt64sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnum8WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEnum8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEnum8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnum16WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEnum16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEnum16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeFloatSingleWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeFloatSingleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeFloatSingleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeFloatDoubleWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeFloatDoubleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeFloatDoubleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeOctetStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeListInt8uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeListInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeListInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeListOctetStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeListOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeListOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeListStructOctetStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeListStructOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeListStructOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLongOctetStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLongOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLongOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeCharStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeLongCharStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeLongCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeLongCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEpochUsWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEpochUsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEpochUsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEpochSWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEpochSWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEpochSWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeVendorIdWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeVendorIdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeVendorIdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeListNullablesAndOptionalsStructWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeEnumAttrWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeEnumAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeEnumAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeStructAttrWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeStructAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeStructAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRangeRestrictedInt8uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRangeRestrictedInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRangeRestrictedInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRangeRestrictedInt8sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRangeRestrictedInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRangeRestrictedInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRangeRestrictedInt16uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRangeRestrictedInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRangeRestrictedInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeRangeRestrictedInt16sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeRangeRestrictedInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeRangeRestrictedInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeListLongOctetStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeListLongOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeListLongOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeListFabricScopedWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeListFabricScopedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeListFabricScopedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeTimedWriteBooleanWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeTimedWriteBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeTimedWriteBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneralErrorBooleanWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeGeneralErrorBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeGeneralErrorBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterErrorBooleanWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeUnsupportedWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeUnsupportedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeUnsupportedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableBooleanWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableBitmap8WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableBitmap8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableBitmap8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableBitmap16WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableBitmap16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableBitmap16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableBitmap32WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableBitmap32WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableBitmap32WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableBitmap64WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableBitmap64WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableBitmap64WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt8uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt16uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt24uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt24uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt24uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt32uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt32uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt32uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt40uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt40uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt40uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt48uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt48uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt48uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt56uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt56uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt56uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt64uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt64uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt64uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt8sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt16sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt24sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt24sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt24sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt32sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt32sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt32sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt40sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt40sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt40sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt48sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt48sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt48sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt56sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt56sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt56sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableInt64sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableInt64sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableInt64sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableEnum8WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableEnum8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableEnum8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableEnum16WithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableEnum16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableEnum16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableFloatSingleWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableFloatSingleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableFloatSingleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableFloatDoubleWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableFloatDoubleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableFloatDoubleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableOctetStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableCharStringWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableEnumAttrWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableEnumAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableEnumAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableStructWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableStructWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableStructWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableRangeRestrictedInt8uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableRangeRestrictedInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableRangeRestrictedInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableRangeRestrictedInt8sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableRangeRestrictedInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableRangeRestrictedInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableRangeRestrictedInt16uWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableRangeRestrictedInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableRangeRestrictedInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeNullableRangeRestrictedInt16sWithParams:(MTRReadParams * _Nullable)params; +- (void)writeAttributeNullableRangeRestrictedInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs; +- (void)writeAttributeNullableRangeRestrictedInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm new file mode 100644 index 00000000000000..6b7258af239880 --- /dev/null +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -0,0 +1,23957 @@ +/* + * + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#import + +#import "MTRAttributeCacheContainer_Internal.h" +#import "MTRBaseDevice_internal.h" +#import "MTRCallbackBridge_internal.h" +#import "MTRClusterConstants.h" +#import "MTRCluster_internal.h" +#import "MTRClusters_internal.h" +#import "MTRCommandPayloadsObjc.h" +#import "MTRDevice.h" +#import "MTRDevice_Internal.h" +#import "MTRStructsObjc.h" + +#include +#include +#include + +using chip::Callback::Callback; +using chip::Callback::Cancelable; +using namespace chip::app::Clusters; +// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects. +@implementation MTRClusterIdentify + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::IdentifyCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::IdentifyCluster * cppCluster = new chip::Controller::IdentifyCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)identifyWithParams:(MTRIdentifyClusterIdentifyParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::IdentifyCluster * cppCluster) { + ListFreer listFreer; + Identify::Commands::Identify::Type request; + request.identifyTime = params.identifyTime.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)triggerEffectWithParams:(MTRIdentifyClusterTriggerEffectParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::IdentifyCluster * cppCluster) { + ListFreer listFreer; + Identify::Commands::TriggerEffect::Type request; + request.effectIdentifier + = static_cast>(params.effectIdentifier.unsignedCharValue); + request.effectVariant + = static_cast>(params.effectVariant.unsignedCharValue); + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeIdentifyTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIdentifyID) + attributeId:@(MTRClusterIdentifyAttributeIdentifyTimeID) + params:params]; +} + +- (void)writeAttributeIdentifyTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeIdentifyTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeIdentifyTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIdentifyID) + attributeId:@(MTRClusterIdentifyAttributeIdentifyTimeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeIdentifyTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIdentifyID) + attributeId:@(MTRClusterIdentifyAttributeIdentifyTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIdentifyID) + attributeId:@(MTRClusterIdentifyAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIdentifyID) + attributeId:@(MTRClusterIdentifyAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIdentifyID) + attributeId:@(MTRClusterIdentifyAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIdentifyID) + attributeId:@(MTRClusterIdentifyAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIdentifyID) + attributeId:@(MTRClusterIdentifyAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterGroups + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::GroupsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::GroupsCluster * cppCluster = new chip::Controller::GroupsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)addGroupWithParams:(MTRGroupsClusterAddGroupParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGroupsClusterAddGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupsCluster * cppCluster) { + ListFreer listFreer; + Groups::Commands::AddGroup::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.groupName = [self asCharSpan:params.groupName]; + + new MTRGroupsClusterAddGroupResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)viewGroupWithParams:(MTRGroupsClusterViewGroupParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGroupsClusterViewGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupsCluster * cppCluster) { + ListFreer listFreer; + Groups::Commands::ViewGroup::Type request; + request.groupId = params.groupId.unsignedShortValue; + + new MTRGroupsClusterViewGroupResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getGroupMembershipWithParams:(MTRGroupsClusterGetGroupMembershipParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupsCluster * cppCluster) { + ListFreer listFreer; + Groups::Commands::GetGroupMembership::Type request; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.groupList.count != 0) { + auto * listHolder_0 = new ListHolder(params.groupList.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.groupList.count; ++i_0) { + if (![params.groupList[i_0] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (NSNumber *) params.groupList[i_0]; + listHolder_0->mList[i_0] = element_0.unsignedShortValue; + } + request.groupList = ListType_0(listHolder_0->mList, params.groupList.count); + } else { + request.groupList = ListType_0(); + } + } + + new MTRGroupsClusterGetGroupMembershipResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)removeGroupWithParams:(MTRGroupsClusterRemoveGroupParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGroupsClusterRemoveGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupsCluster * cppCluster) { + ListFreer listFreer; + Groups::Commands::RemoveGroup::Type request; + request.groupId = params.groupId.unsignedShortValue; + + new MTRGroupsClusterRemoveGroupResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)removeAllGroupsWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self removeAllGroupsWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)removeAllGroupsWithParams:(MTRGroupsClusterRemoveAllGroupsParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupsCluster * cppCluster) { + ListFreer listFreer; + Groups::Commands::RemoveAllGroups::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)addGroupIfIdentifyingWithParams:(MTRGroupsClusterAddGroupIfIdentifyingParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupsCluster * cppCluster) { + ListFreer listFreer; + Groups::Commands::AddGroupIfIdentifying::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.groupName = [self asCharSpan:params.groupName]; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeNameSupportWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupsID) + attributeId:@(MTRClusterGroupsAttributeNameSupportID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupsID) + attributeId:@(MTRClusterGroupsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupsID) + attributeId:@(MTRClusterGroupsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupsID) + attributeId:@(MTRClusterGroupsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupsID) + attributeId:@(MTRClusterGroupsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupsID) + attributeId:@(MTRClusterGroupsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterScenes + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ScenesCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ScenesCluster * cppCluster = new chip::Controller::ScenesCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)addSceneWithParams:(MTRScenesClusterAddSceneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterAddSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::AddScene::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.sceneId = params.sceneId.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.sceneName = [self asCharSpan:params.sceneName]; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.extensionFieldSets.count != 0) { + auto * listHolder_0 = new ListHolder(params.extensionFieldSets.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.extensionFieldSets.count; ++i_0) { + if (![params.extensionFieldSets[i_0] isKindOfClass:[MTRScenesClusterExtensionFieldSet class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (MTRScenesClusterExtensionFieldSet *) params.extensionFieldSets[i_0]; + listHolder_0->mList[i_0].clusterId = element_0.clusterId.unsignedIntValue; + { + using ListType_2 = std::remove_reference_tmList[i_0].attributeValueList)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.attributeValueList.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.attributeValueList.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.attributeValueList.count; ++i_2) { + if (![element_0.attributeValueList[i_2] isKindOfClass:[MTRScenesClusterAttributeValuePair class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (MTRScenesClusterAttributeValuePair *) element_0.attributeValueList[i_2]; + if (element_2.attributeId != nil) { + auto & definedValue_4 = listHolder_2->mList[i_2].attributeId.Emplace(); + definedValue_4 = element_2.attributeId.unsignedIntValue; + } + { + using ListType_4 = std::remove_reference_tmList[i_2].attributeValue)>; + using ListMemberType_4 = ListMemberTypeGetter::Type; + if (element_2.attributeValue.count != 0) { + auto * listHolder_4 = new ListHolder(element_2.attributeValue.count); + if (listHolder_4 == nullptr || listHolder_4->mList == nullptr) { + return; + } + listFreer.add(listHolder_4); + for (size_t i_4 = 0; i_4 < element_2.attributeValue.count; ++i_4) { + if (![element_2.attributeValue[i_4] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_4 = (NSNumber *) element_2.attributeValue[i_4]; + listHolder_4->mList[i_4] = element_4.unsignedCharValue; + } + listHolder_2->mList[i_2].attributeValue + = ListType_4(listHolder_4->mList, element_2.attributeValue.count); + } else { + listHolder_2->mList[i_2].attributeValue = ListType_4(); + } + } + } + listHolder_0->mList[i_0].attributeValueList + = ListType_2(listHolder_2->mList, element_0.attributeValueList.count); + } else { + listHolder_0->mList[i_0].attributeValueList = ListType_2(); + } + } + } + request.extensionFieldSets = ListType_0(listHolder_0->mList, params.extensionFieldSets.count); + } else { + request.extensionFieldSets = ListType_0(); + } + } + + new MTRScenesClusterAddSceneResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)viewSceneWithParams:(MTRScenesClusterViewSceneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterViewSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::ViewScene::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.sceneId = params.sceneId.unsignedCharValue; + + new MTRScenesClusterViewSceneResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)removeSceneWithParams:(MTRScenesClusterRemoveSceneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterRemoveSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::RemoveScene::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.sceneId = params.sceneId.unsignedCharValue; + + new MTRScenesClusterRemoveSceneResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)removeAllScenesWithParams:(MTRScenesClusterRemoveAllScenesParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRScenesClusterRemoveAllScenesResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::RemoveAllScenes::Type request; + request.groupId = params.groupId.unsignedShortValue; + + new MTRScenesClusterRemoveAllScenesResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)storeSceneWithParams:(MTRScenesClusterStoreSceneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterStoreSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::StoreScene::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.sceneId = params.sceneId.unsignedCharValue; + + new MTRScenesClusterStoreSceneResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)recallSceneWithParams:(MTRScenesClusterRecallSceneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::RecallScene::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.sceneId = params.sceneId.unsignedCharValue; + if (params.transitionTime != nil) { + auto & definedValue_0 = request.transitionTime.Emplace(); + if (params.transitionTime == nil) { + definedValue_0.SetNull(); + } else { + auto & nonNullValue_1 = definedValue_0.SetNonNull(); + nonNullValue_1 = params.transitionTime.unsignedShortValue; + } + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getSceneMembershipWithParams:(MTRScenesClusterGetSceneMembershipParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRScenesClusterGetSceneMembershipResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::GetSceneMembership::Type request; + request.groupId = params.groupId.unsignedShortValue; + + new MTRScenesClusterGetSceneMembershipResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)enhancedAddSceneWithParams:(MTRScenesClusterEnhancedAddSceneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRScenesClusterEnhancedAddSceneResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::EnhancedAddScene::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.sceneId = params.sceneId.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.sceneName = [self asCharSpan:params.sceneName]; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.extensionFieldSets.count != 0) { + auto * listHolder_0 = new ListHolder(params.extensionFieldSets.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.extensionFieldSets.count; ++i_0) { + if (![params.extensionFieldSets[i_0] isKindOfClass:[MTRScenesClusterExtensionFieldSet class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (MTRScenesClusterExtensionFieldSet *) params.extensionFieldSets[i_0]; + listHolder_0->mList[i_0].clusterId = element_0.clusterId.unsignedIntValue; + { + using ListType_2 = std::remove_reference_tmList[i_0].attributeValueList)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.attributeValueList.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.attributeValueList.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.attributeValueList.count; ++i_2) { + if (![element_0.attributeValueList[i_2] isKindOfClass:[MTRScenesClusterAttributeValuePair class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (MTRScenesClusterAttributeValuePair *) element_0.attributeValueList[i_2]; + if (element_2.attributeId != nil) { + auto & definedValue_4 = listHolder_2->mList[i_2].attributeId.Emplace(); + definedValue_4 = element_2.attributeId.unsignedIntValue; + } + { + using ListType_4 = std::remove_reference_tmList[i_2].attributeValue)>; + using ListMemberType_4 = ListMemberTypeGetter::Type; + if (element_2.attributeValue.count != 0) { + auto * listHolder_4 = new ListHolder(element_2.attributeValue.count); + if (listHolder_4 == nullptr || listHolder_4->mList == nullptr) { + return; + } + listFreer.add(listHolder_4); + for (size_t i_4 = 0; i_4 < element_2.attributeValue.count; ++i_4) { + if (![element_2.attributeValue[i_4] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_4 = (NSNumber *) element_2.attributeValue[i_4]; + listHolder_4->mList[i_4] = element_4.unsignedCharValue; + } + listHolder_2->mList[i_2].attributeValue + = ListType_4(listHolder_4->mList, element_2.attributeValue.count); + } else { + listHolder_2->mList[i_2].attributeValue = ListType_4(); + } + } + } + listHolder_0->mList[i_0].attributeValueList + = ListType_2(listHolder_2->mList, element_0.attributeValueList.count); + } else { + listHolder_0->mList[i_0].attributeValueList = ListType_2(); + } + } + } + request.extensionFieldSets = ListType_0(listHolder_0->mList, params.extensionFieldSets.count); + } else { + request.extensionFieldSets = ListType_0(); + } + } + + new MTRScenesClusterEnhancedAddSceneResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)enhancedViewSceneWithParams:(MTRScenesClusterEnhancedViewSceneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRScenesClusterEnhancedViewSceneResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::EnhancedViewScene::Type request; + request.groupId = params.groupId.unsignedShortValue; + request.sceneId = params.sceneId.unsignedCharValue; + + new MTRScenesClusterEnhancedViewSceneResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)copySceneWithParams:(MTRScenesClusterCopySceneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRScenesClusterCopySceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ScenesCluster * cppCluster) { + ListFreer listFreer; + Scenes::Commands::CopyScene::Type request; + request.mode = static_cast>(params.mode.unsignedCharValue); + request.groupIdFrom = params.groupIdFrom.unsignedShortValue; + request.sceneIdFrom = params.sceneIdFrom.unsignedCharValue; + request.groupIdTo = params.groupIdTo.unsignedShortValue; + request.sceneIdTo = params.sceneIdTo.unsignedCharValue; + + new MTRScenesClusterCopySceneResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeSceneCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeSceneCountID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentSceneWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeCurrentSceneID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentGroupWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeCurrentGroupID) + params:params]; +} + +- (NSDictionary *)readAttributeSceneValidWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeSceneValidID) + params:params]; +} + +- (NSDictionary *)readAttributeNameSupportWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeNameSupportID) + params:params]; +} + +- (NSDictionary *)readAttributeLastConfiguredByWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeLastConfiguredByID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterScenesID) + attributeId:@(MTRClusterScenesAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterOnOff + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::OnOffCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::OnOffCluster * cppCluster = new chip::Controller::OnOffCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)offWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self offWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)offWithParams:(MTROnOffClusterOffParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OnOffCluster * cppCluster) { + ListFreer listFreer; + OnOff::Commands::Off::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)onWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self onWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)onWithParams:(MTROnOffClusterOnParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OnOffCluster * cppCluster) { + ListFreer listFreer; + OnOff::Commands::On::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)toggleWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self toggleWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)toggleWithParams:(MTROnOffClusterToggleParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OnOffCluster * cppCluster) { + ListFreer listFreer; + OnOff::Commands::Toggle::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)offWithEffectWithParams:(MTROnOffClusterOffWithEffectParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OnOffCluster * cppCluster) { + ListFreer listFreer; + OnOff::Commands::OffWithEffect::Type request; + request.effectId = static_cast>(params.effectId.unsignedCharValue); + request.effectVariant + = static_cast>(params.effectVariant.unsignedCharValue); + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)onWithRecallGlobalSceneWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self onWithRecallGlobalSceneWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)onWithRecallGlobalSceneWithParams:(MTROnOffClusterOnWithRecallGlobalSceneParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OnOffCluster * cppCluster) { + ListFreer listFreer; + OnOff::Commands::OnWithRecallGlobalScene::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)onWithTimedOffWithParams:(MTROnOffClusterOnWithTimedOffParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OnOffCluster * cppCluster) { + ListFreer listFreer; + OnOff::Commands::OnWithTimedOff::Type request; + request.onOffControl + = static_cast>(params.onOffControl.unsignedCharValue); + request.onTime = params.onTime.unsignedShortValue; + request.offWaitTime = params.offWaitTime.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeOnOffWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeOnOffID) + params:params]; +} + +- (NSDictionary *)readAttributeGlobalSceneControlWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeGlobalSceneControlID) + params:params]; +} + +- (NSDictionary *)readAttributeOnTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeOnTimeID) + params:params]; +} + +- (void)writeAttributeOnTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOnTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOnTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeOnTimeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOffWaitTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeOffWaitTimeID) + params:params]; +} + +- (void)writeAttributeOffWaitTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOffWaitTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOffWaitTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeOffWaitTimeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeStartUpOnOffWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeStartUpOnOffID) + params:params]; +} + +- (void)writeAttributeStartUpOnOffWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeStartUpOnOffWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeStartUpOnOffWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeStartUpOnOffID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffID) + attributeId:@(MTRClusterOnOffAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterOnOffSwitchConfiguration + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::OnOffSwitchConfigurationCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::OnOffSwitchConfigurationCluster * cppCluster = new chip::Controller::OnOffSwitchConfigurationCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeSwitchTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffSwitchConfigurationID) + attributeId:@(MTRClusterOnOffSwitchConfigurationAttributeSwitchTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeSwitchActionsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffSwitchConfigurationID) + attributeId:@(MTRClusterOnOffSwitchConfigurationAttributeSwitchActionsID) + params:params]; +} + +- (void)writeAttributeSwitchActionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeSwitchActionsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeSwitchActionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffSwitchConfigurationID) + attributeId:@(MTRClusterOnOffSwitchConfigurationAttributeSwitchActionsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffSwitchConfigurationID) + attributeId:@(MTRClusterOnOffSwitchConfigurationAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffSwitchConfigurationID) + attributeId:@(MTRClusterOnOffSwitchConfigurationAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffSwitchConfigurationID) + attributeId:@(MTRClusterOnOffSwitchConfigurationAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffSwitchConfigurationID) + attributeId:@(MTRClusterOnOffSwitchConfigurationAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOnOffSwitchConfigurationID) + attributeId:@(MTRClusterOnOffSwitchConfigurationAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterLevelControl + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::LevelControlCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::LevelControlCluster * cppCluster = new chip::Controller::LevelControlCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)moveToLevelWithParams:(MTRLevelControlClusterMoveToLevelParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::MoveToLevel::Type request; + request.level = params.level.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionMask = params.optionMask.unsignedCharValue; + request.optionOverride = params.optionOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveWithParams:(MTRLevelControlClusterMoveParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::Move::Type request; + request.moveMode = static_cast>(params.moveMode.unsignedCharValue); + request.rate = params.rate.unsignedCharValue; + request.optionMask = params.optionMask.unsignedCharValue; + request.optionOverride = params.optionOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stepWithParams:(MTRLevelControlClusterStepParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::Step::Type request; + request.stepMode = static_cast>(params.stepMode.unsignedCharValue); + request.stepSize = params.stepSize.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionMask = params.optionMask.unsignedCharValue; + request.optionOverride = params.optionOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stopWithParams:(MTRLevelControlClusterStopParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::Stop::Type request; + request.optionMask = params.optionMask.unsignedCharValue; + request.optionOverride = params.optionOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveToLevelWithOnOffWithParams:(MTRLevelControlClusterMoveToLevelWithOnOffParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::MoveToLevelWithOnOff::Type request; + request.level = params.level.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveWithOnOffWithParams:(MTRLevelControlClusterMoveWithOnOffParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::MoveWithOnOff::Type request; + request.moveMode = static_cast>(params.moveMode.unsignedCharValue); + request.rate = params.rate.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stepWithOnOffWithParams:(MTRLevelControlClusterStepWithOnOffParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::StepWithOnOff::Type request; + request.stepMode = static_cast>(params.stepMode.unsignedCharValue); + request.stepSize = params.stepSize.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stopWithOnOffWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self stopWithOnOffWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)stopWithOnOffWithParams:(MTRLevelControlClusterStopWithOnOffParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::StopWithOnOff::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveToClosestFrequencyWithParams:(MTRLevelControlClusterMoveToClosestFrequencyParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LevelControlCluster * cppCluster) { + ListFreer listFreer; + LevelControl::Commands::MoveToClosestFrequency::Type request; + request.frequency = params.frequency.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeCurrentLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeCurrentLevelID) + params:params]; +} + +- (NSDictionary *)readAttributeRemainingTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeRemainingTimeID) + params:params]; +} + +- (NSDictionary *)readAttributeMinLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeMinLevelID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeMaxLevelID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentFrequencyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeCurrentFrequencyID) + params:params]; +} + +- (NSDictionary *)readAttributeMinFrequencyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeMinFrequencyID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxFrequencyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeMaxFrequencyID) + params:params]; +} + +- (NSDictionary *)readAttributeOptionsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOptionsID) + params:params]; +} + +- (void)writeAttributeOptionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOptionsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOptionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOptionsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOnOffTransitionTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOnOffTransitionTimeID) + params:params]; +} + +- (void)writeAttributeOnOffTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOnOffTransitionTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOnOffTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOnOffTransitionTimeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOnLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOnLevelID) + params:params]; +} + +- (void)writeAttributeOnLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOnLevelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOnLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOnLevelID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOnTransitionTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOnTransitionTimeID) + params:params]; +} + +- (void)writeAttributeOnTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOnTransitionTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOnTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOnTransitionTimeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOffTransitionTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOffTransitionTimeID) + params:params]; +} + +- (void)writeAttributeOffTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOffTransitionTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOffTransitionTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeOffTransitionTimeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeDefaultMoveRateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeDefaultMoveRateID) + params:params]; +} + +- (void)writeAttributeDefaultMoveRateWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeDefaultMoveRateWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeDefaultMoveRateWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeDefaultMoveRateID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeStartUpCurrentLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeStartUpCurrentLevelID) + params:params]; +} + +- (void)writeAttributeStartUpCurrentLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeStartUpCurrentLevelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeStartUpCurrentLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeStartUpCurrentLevelID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLevelControlID) + attributeId:@(MTRClusterLevelControlAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterBinaryInputBasic + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::BinaryInputBasicCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::BinaryInputBasicCluster * cppCluster = new chip::Controller::BinaryInputBasicCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeActiveTextWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeActiveTextID) + params:params]; +} + +- (void)writeAttributeActiveTextWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeActiveTextWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeActiveTextWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeActiveTextID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeDescriptionID) + params:params]; +} + +- (void)writeAttributeDescriptionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeDescriptionWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeDescriptionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeDescriptionID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInactiveTextWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeInactiveTextID) + params:params]; +} + +- (void)writeAttributeInactiveTextWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInactiveTextWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInactiveTextWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeInactiveTextID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOutOfServiceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeOutOfServiceID) + params:params]; +} + +- (void)writeAttributeOutOfServiceWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOutOfServiceWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOutOfServiceWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeOutOfServiceID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePolarityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributePolarityID) + params:params]; +} + +- (NSDictionary *)readAttributePresentValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributePresentValueID) + params:params]; +} + +- (void)writeAttributePresentValueWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributePresentValueWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributePresentValueWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributePresentValueID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeReliabilityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeReliabilityID) + params:params]; +} + +- (void)writeAttributeReliabilityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeReliabilityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeReliabilityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeReliabilityID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeStatusFlagsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeStatusFlagsID) + params:params]; +} + +- (NSDictionary *)readAttributeApplicationTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeApplicationTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBinaryInputBasicID) + attributeId:@(MTRClusterBinaryInputBasicAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterDescriptor + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::DescriptorCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::DescriptorCluster * cppCluster = new chip::Controller::DescriptorCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeDeviceListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributeDeviceListID) + params:params]; +} + +- (NSDictionary *)readAttributeServerListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributeServerListID) + params:params]; +} + +- (NSDictionary *)readAttributeClientListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributeClientListID) + params:params]; +} + +- (NSDictionary *)readAttributePartsListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributePartsListID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDescriptorID) + attributeId:@(MTRClusterDescriptorAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterBinding + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::BindingCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::BindingCluster * cppCluster = new chip::Controller::BindingCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeBindingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBindingID) + attributeId:@(MTRClusterBindingAttributeBindingID) + params:params]; +} + +- (void)writeAttributeBindingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBindingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBindingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBindingID) + attributeId:@(MTRClusterBindingAttributeBindingID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBindingID) + attributeId:@(MTRClusterBindingAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBindingID) + attributeId:@(MTRClusterBindingAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBindingID) + attributeId:@(MTRClusterBindingAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBindingID) + attributeId:@(MTRClusterBindingAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBindingID) + attributeId:@(MTRClusterBindingAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterAccessControl + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::AccessControlCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::AccessControlCluster * cppCluster = new chip::Controller::AccessControlCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeAclWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeAclID) + params:params]; +} + +- (void)writeAttributeAclWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeAclWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeAclWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeAclID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeExtensionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeExtensionID) + params:params]; +} + +- (void)writeAttributeExtensionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeExtensionWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeExtensionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeExtensionID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSubjectsPerAccessControlEntryWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeSubjectsPerAccessControlEntryID) + params:params]; +} + +- (NSDictionary *)readAttributeTargetsPerAccessControlEntryWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeTargetsPerAccessControlEntryID) + params:params]; +} + +- (NSDictionary *)readAttributeAccessControlEntriesPerFabricWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeAccessControlEntriesPerFabricID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccessControlID) + attributeId:@(MTRClusterAccessControlAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterBridgedActions + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::BridgedActionsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::BridgedActionsCluster * cppCluster = new chip::Controller::BridgedActionsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)instantActionWithParams:(MTRBridgedActionsClusterInstantActionParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::InstantAction::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)instantActionWithTransitionWithParams:(MTRBridgedActionsClusterInstantActionWithTransitionParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::InstantActionWithTransition::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + request.transitionTime = params.transitionTime.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)startActionWithParams:(MTRBridgedActionsClusterStartActionParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::StartAction::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)startActionWithDurationWithParams:(MTRBridgedActionsClusterStartActionWithDurationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::StartActionWithDuration::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + request.duration = params.duration.unsignedIntValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stopActionWithParams:(MTRBridgedActionsClusterStopActionParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::StopAction::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)pauseActionWithParams:(MTRBridgedActionsClusterPauseActionParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::PauseAction::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)pauseActionWithDurationWithParams:(MTRBridgedActionsClusterPauseActionWithDurationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::PauseActionWithDuration::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + request.duration = params.duration.unsignedIntValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)resumeActionWithParams:(MTRBridgedActionsClusterResumeActionParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::ResumeAction::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)enableActionWithParams:(MTRBridgedActionsClusterEnableActionParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::EnableAction::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)enableActionWithDurationWithParams:(MTRBridgedActionsClusterEnableActionWithDurationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::EnableActionWithDuration::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + request.duration = params.duration.unsignedIntValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)disableActionWithParams:(MTRBridgedActionsClusterDisableActionParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::DisableAction::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)disableActionWithDurationWithParams:(MTRBridgedActionsClusterDisableActionWithDurationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BridgedActionsCluster * cppCluster) { + ListFreer listFreer; + BridgedActions::Commands::DisableActionWithDuration::Type request; + request.actionID = params.actionID.unsignedShortValue; + if (params.invokeID != nil) { + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = params.invokeID.unsignedIntValue; + } + request.duration = params.duration.unsignedIntValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeActionListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedActionsID) + attributeId:@(MTRClusterBridgedActionsAttributeActionListID) + params:params]; +} + +- (NSDictionary *)readAttributeEndpointListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedActionsID) + attributeId:@(MTRClusterBridgedActionsAttributeEndpointListID) + params:params]; +} + +- (NSDictionary *)readAttributeSetupUrlWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedActionsID) + attributeId:@(MTRClusterBridgedActionsAttributeSetupUrlID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedActionsID) + attributeId:@(MTRClusterBridgedActionsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedActionsID) + attributeId:@(MTRClusterBridgedActionsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedActionsID) + attributeId:@(MTRClusterBridgedActionsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedActionsID) + attributeId:@(MTRClusterBridgedActionsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedActionsID) + attributeId:@(MTRClusterBridgedActionsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterBasic + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::BasicCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::BasicCluster * cppCluster = new chip::Controller::BasicCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)mfgSpecificPingWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self mfgSpecificPingWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)mfgSpecificPingWithParams:(MTRBasicClusterMfgSpecificPingParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BasicCluster * cppCluster) { + ListFreer listFreer; + Basic::Commands::MfgSpecificPing::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeDataModelRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeDataModelRevisionID) + params:params]; +} + +- (NSDictionary *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeVendorNameID) + params:params]; +} + +- (NSDictionary *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeVendorIDID) + params:params]; +} + +- (NSDictionary *)readAttributeProductNameWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeProductNameID) + params:params]; +} + +- (NSDictionary *)readAttributeProductIDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeProductIDID) + params:params]; +} + +- (NSDictionary *)readAttributeNodeLabelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeNodeLabelID) + params:params]; +} + +- (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNodeLabelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeNodeLabelID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLocationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeLocationID) + params:params]; +} + +- (void)writeAttributeLocationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLocationWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLocationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeLocationID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeHardwareVersionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeHardwareVersionID) + params:params]; +} + +- (NSDictionary *)readAttributeHardwareVersionStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeHardwareVersionStringID) + params:params]; +} + +- (NSDictionary *)readAttributeSoftwareVersionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeSoftwareVersionID) + params:params]; +} + +- (NSDictionary *)readAttributeSoftwareVersionStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeSoftwareVersionStringID) + params:params]; +} + +- (NSDictionary *)readAttributeManufacturingDateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeManufacturingDateID) + params:params]; +} + +- (NSDictionary *)readAttributePartNumberWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributePartNumberID) + params:params]; +} + +- (NSDictionary *)readAttributeProductURLWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeProductURLID) + params:params]; +} + +- (NSDictionary *)readAttributeProductLabelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeProductLabelID) + params:params]; +} + +- (NSDictionary *)readAttributeSerialNumberWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeSerialNumberID) + params:params]; +} + +- (NSDictionary *)readAttributeLocalConfigDisabledWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeLocalConfigDisabledID) + params:params]; +} + +- (void)writeAttributeLocalConfigDisabledWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLocalConfigDisabledWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLocalConfigDisabledWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeLocalConfigDisabledID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeReachableWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeReachableID) + params:params]; +} + +- (NSDictionary *)readAttributeUniqueIDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeUniqueIDID) + params:params]; +} + +- (NSDictionary *)readAttributeCapabilityMinimaWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeCapabilityMinimaID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBasicID) + attributeId:@(MTRClusterBasicAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterOtaSoftwareUpdateProvider + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster = new chip::Controller::OtaSoftwareUpdateProviderCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)queryImageWithParams:(MTROtaSoftwareUpdateProviderClusterQueryImageParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROtaSoftwareUpdateProviderClusterQueryImageResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster) { + ListFreer listFreer; + OtaSoftwareUpdateProvider::Commands::QueryImage::Type request; + request.vendorId = static_cast>(params.vendorId.unsignedShortValue); + request.productId = params.productId.unsignedShortValue; + request.softwareVersion = params.softwareVersion.unsignedIntValue; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.protocolsSupported.count != 0) { + auto * listHolder_0 = new ListHolder(params.protocolsSupported.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.protocolsSupported.count; ++i_0) { + if (![params.protocolsSupported[i_0] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (NSNumber *) params.protocolsSupported[i_0]; + listHolder_0->mList[i_0] + = static_castmList[i_0])>>(element_0.unsignedCharValue); + } + request.protocolsSupported = ListType_0(listHolder_0->mList, params.protocolsSupported.count); + } else { + request.protocolsSupported = ListType_0(); + } + } + if (params.hardwareVersion != nil) { + auto & definedValue_0 = request.hardwareVersion.Emplace(); + definedValue_0 = params.hardwareVersion.unsignedShortValue; + } + if (params.location != nil) { + auto & definedValue_0 = request.location.Emplace(); + definedValue_0 = [self asCharSpan:params.location]; + } + if (params.requestorCanConsent != nil) { + auto & definedValue_0 = request.requestorCanConsent.Emplace(); + definedValue_0 = params.requestorCanConsent.boolValue; + } + if (params.metadataForProvider != nil) { + auto & definedValue_0 = request.metadataForProvider.Emplace(); + definedValue_0 = [self asByteSpan:params.metadataForProvider]; + } + + new MTROtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)applyUpdateRequestWithParams:(MTROtaSoftwareUpdateProviderClusterApplyUpdateRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster) { + ListFreer listFreer; + OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Type request; + request.updateToken = [self asByteSpan:params.updateToken]; + request.newVersion = params.newVersion.unsignedIntValue; + + new MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)notifyUpdateAppliedWithParams:(MTROtaSoftwareUpdateProviderClusterNotifyUpdateAppliedParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster) { + ListFreer listFreer; + OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Type request; + request.updateToken = [self asByteSpan:params.updateToken]; + request.softwareVersion = params.softwareVersion.unsignedIntValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateProviderID) + attributeId:@(MTRClusterOtaSoftwareUpdateProviderAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateProviderID) + attributeId:@(MTRClusterOtaSoftwareUpdateProviderAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateProviderID) + attributeId:@(MTRClusterOtaSoftwareUpdateProviderAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateProviderID) + attributeId:@(MTRClusterOtaSoftwareUpdateProviderAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateProviderID) + attributeId:@(MTRClusterOtaSoftwareUpdateProviderAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterOtaSoftwareUpdateRequestor + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = new chip::Controller::OtaSoftwareUpdateRequestorCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)announceOtaProviderWithParams:(MTROtaSoftwareUpdateRequestorClusterAnnounceOtaProviderParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster) { + ListFreer listFreer; + OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::Type request; + request.providerNodeId = params.providerNodeId.unsignedLongLongValue; + request.vendorId = static_cast>(params.vendorId.unsignedShortValue); + request.announcementReason = static_cast>( + params.announcementReason.unsignedCharValue); + if (params.metadataForNode != nil) { + auto & definedValue_0 = request.metadataForNode.Emplace(); + definedValue_0 = [self asByteSpan:params.metadataForNode]; + } + request.endpoint = params.endpoint.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeDefaultOtaProvidersWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeDefaultOtaProvidersID) + params:params]; +} + +- (void)writeAttributeDefaultOtaProvidersWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeDefaultOtaProvidersWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeDefaultOtaProvidersWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeDefaultOtaProvidersID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUpdatePossibleWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeUpdatePossibleID) + params:params]; +} + +- (NSDictionary *)readAttributeUpdateStateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeUpdateStateID) + params:params]; +} + +- (NSDictionary *)readAttributeUpdateStateProgressWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeUpdateStateProgressID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOtaSoftwareUpdateRequestorID) + attributeId:@(MTRClusterOtaSoftwareUpdateRequestorAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterLocalizationConfiguration + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::LocalizationConfigurationCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::LocalizationConfigurationCluster * cppCluster = new chip::Controller::LocalizationConfigurationCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeActiveLocaleWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLocalizationConfigurationID) + attributeId:@(MTRClusterLocalizationConfigurationAttributeActiveLocaleID) + params:params]; +} + +- (void)writeAttributeActiveLocaleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeActiveLocaleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeActiveLocaleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLocalizationConfigurationID) + attributeId:@(MTRClusterLocalizationConfigurationAttributeActiveLocaleID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSupportedLocalesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLocalizationConfigurationID) + attributeId:@(MTRClusterLocalizationConfigurationAttributeSupportedLocalesID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLocalizationConfigurationID) + attributeId:@(MTRClusterLocalizationConfigurationAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLocalizationConfigurationID) + attributeId:@(MTRClusterLocalizationConfigurationAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLocalizationConfigurationID) + attributeId:@(MTRClusterLocalizationConfigurationAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLocalizationConfigurationID) + attributeId:@(MTRClusterLocalizationConfigurationAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLocalizationConfigurationID) + attributeId:@(MTRClusterLocalizationConfigurationAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterTimeFormatLocalization + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::TimeFormatLocalizationCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::TimeFormatLocalizationCluster * cppCluster = new chip::Controller::TimeFormatLocalizationCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeHourFormatWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeHourFormatID) + params:params]; +} + +- (void)writeAttributeHourFormatWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeHourFormatWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeHourFormatWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeHourFormatID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeActiveCalendarTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeActiveCalendarTypeID) + params:params]; +} + +- (void)writeAttributeActiveCalendarTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeActiveCalendarTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeActiveCalendarTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeActiveCalendarTypeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSupportedCalendarTypesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeSupportedCalendarTypesID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTimeFormatLocalizationID) + attributeId:@(MTRClusterTimeFormatLocalizationAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterUnitLocalization + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::UnitLocalizationCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::UnitLocalizationCluster * cppCluster = new chip::Controller::UnitLocalizationCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeTemperatureUnitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUnitLocalizationID) + attributeId:@(MTRClusterUnitLocalizationAttributeTemperatureUnitID) + params:params]; +} + +- (void)writeAttributeTemperatureUnitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeTemperatureUnitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeTemperatureUnitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUnitLocalizationID) + attributeId:@(MTRClusterUnitLocalizationAttributeTemperatureUnitID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUnitLocalizationID) + attributeId:@(MTRClusterUnitLocalizationAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUnitLocalizationID) + attributeId:@(MTRClusterUnitLocalizationAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUnitLocalizationID) + attributeId:@(MTRClusterUnitLocalizationAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUnitLocalizationID) + attributeId:@(MTRClusterUnitLocalizationAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUnitLocalizationID) + attributeId:@(MTRClusterUnitLocalizationAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterPowerSourceConfiguration + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::PowerSourceConfigurationCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::PowerSourceConfigurationCluster * cppCluster = new chip::Controller::PowerSourceConfigurationCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeSourcesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceConfigurationID) + attributeId:@(MTRClusterPowerSourceConfigurationAttributeSourcesID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceConfigurationID) + attributeId:@(MTRClusterPowerSourceConfigurationAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceConfigurationID) + attributeId:@(MTRClusterPowerSourceConfigurationAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceConfigurationID) + attributeId:@(MTRClusterPowerSourceConfigurationAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceConfigurationID) + attributeId:@(MTRClusterPowerSourceConfigurationAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceConfigurationID) + attributeId:@(MTRClusterPowerSourceConfigurationAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterPowerSource + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::PowerSourceCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::PowerSourceCluster * cppCluster = new chip::Controller::PowerSourceCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeOrderWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeOrderID) + params:params]; +} + +- (NSDictionary *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeDescriptionID) + params:params]; +} + +- (NSDictionary *)readAttributeWiredAssessedInputVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeWiredAssessedInputVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeWiredAssessedInputFrequencyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeWiredAssessedInputFrequencyID) + params:params]; +} + +- (NSDictionary *)readAttributeWiredCurrentTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeWiredCurrentTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeWiredAssessedCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeWiredAssessedCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeWiredNominalVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeWiredNominalVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeWiredMaximumCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeWiredMaximumCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeWiredPresentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeWiredPresentID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveWiredFaultsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeActiveWiredFaultsID) + params:params]; +} + +- (NSDictionary *)readAttributeBatVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeBatPercentRemainingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatPercentRemainingID) + params:params]; +} + +- (NSDictionary *)readAttributeBatTimeRemainingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatTimeRemainingID) + params:params]; +} + +- (NSDictionary *)readAttributeBatChargeLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatChargeLevelID) + params:params]; +} + +- (NSDictionary *)readAttributeBatReplacementNeededWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatReplacementNeededID) + params:params]; +} + +- (NSDictionary *)readAttributeBatReplaceabilityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatReplaceabilityID) + params:params]; +} + +- (NSDictionary *)readAttributeBatPresentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatPresentID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveBatFaultsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeActiveBatFaultsID) + params:params]; +} + +- (NSDictionary *)readAttributeBatReplacementDescriptionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatReplacementDescriptionID) + params:params]; +} + +- (NSDictionary *)readAttributeBatCommonDesignationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatCommonDesignationID) + params:params]; +} + +- (NSDictionary *)readAttributeBatANSIDesignationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatANSIDesignationID) + params:params]; +} + +- (NSDictionary *)readAttributeBatIECDesignationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatIECDesignationID) + params:params]; +} + +- (NSDictionary *)readAttributeBatApprovedChemistryWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatApprovedChemistryID) + params:params]; +} + +- (NSDictionary *)readAttributeBatCapacityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatCapacityID) + params:params]; +} + +- (NSDictionary *)readAttributeBatQuantityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatQuantityID) + params:params]; +} + +- (NSDictionary *)readAttributeBatChargeStateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatChargeStateID) + params:params]; +} + +- (NSDictionary *)readAttributeBatTimeToFullChargeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatTimeToFullChargeID) + params:params]; +} + +- (NSDictionary *)readAttributeBatFunctionalWhileChargingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatFunctionalWhileChargingID) + params:params]; +} + +- (NSDictionary *)readAttributeBatChargingCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeBatChargingCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveBatChargeFaultsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeActiveBatChargeFaultsID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPowerSourceID) + attributeId:@(MTRClusterPowerSourceAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterGeneralCommissioning + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::GeneralCommissioningCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::GeneralCommissioningCluster * cppCluster = new chip::Controller::GeneralCommissioningCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)armFailSafeWithParams:(MTRGeneralCommissioningClusterArmFailSafeParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GeneralCommissioningCluster * cppCluster) { + ListFreer listFreer; + GeneralCommissioning::Commands::ArmFailSafe::Type request; + request.expiryLengthSeconds = params.expiryLengthSeconds.unsignedShortValue; + request.breadcrumb = params.breadcrumb.unsignedLongLongValue; + + new MTRGeneralCommissioningClusterArmFailSafeResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)setRegulatoryConfigWithParams:(MTRGeneralCommissioningClusterSetRegulatoryConfigParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GeneralCommissioningCluster * cppCluster) { + ListFreer listFreer; + GeneralCommissioning::Commands::SetRegulatoryConfig::Type request; + request.newRegulatoryConfig = static_cast>( + params.newRegulatoryConfig.unsignedCharValue); + request.countryCode = [self asCharSpan:params.countryCode]; + request.breadcrumb = params.breadcrumb.unsignedLongLongValue; + + new MTRGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn + = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)commissioningCompleteWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self commissioningCompleteWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)commissioningCompleteWithParams:(MTRGeneralCommissioningClusterCommissioningCompleteParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GeneralCommissioningCluster * cppCluster) { + ListFreer listFreer; + GeneralCommissioning::Commands::CommissioningComplete::Type request; + + new MTRGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn + = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeBreadcrumbWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeBreadcrumbID) + params:params]; +} + +- (void)writeAttributeBreadcrumbWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBreadcrumbWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBreadcrumbWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeBreadcrumbID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBasicCommissioningInfoWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeBasicCommissioningInfoID) + params:params]; +} + +- (NSDictionary *)readAttributeRegulatoryConfigWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeRegulatoryConfigID) + params:params]; +} + +- (NSDictionary *)readAttributeLocationCapabilityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeLocationCapabilityID) + params:params]; +} + +- (NSDictionary *)readAttributeSupportsConcurrentConnectionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeSupportsConcurrentConnectionID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralCommissioningID) + attributeId:@(MTRClusterGeneralCommissioningAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterNetworkCommissioning + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::NetworkCommissioningCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::NetworkCommissioningCluster * cppCluster = new chip::Controller::NetworkCommissioningCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)scanNetworksWithParams:(MTRNetworkCommissioningClusterScanNetworksParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterScanNetworksResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::NetworkCommissioningCluster * cppCluster) { + ListFreer listFreer; + NetworkCommissioning::Commands::ScanNetworks::Type request; + if (params != nil) { + if (params.ssid != nil) { + auto & definedValue_0 = request.ssid.Emplace(); + if (params.ssid == nil) { + definedValue_0.SetNull(); + } else { + auto & nonNullValue_1 = definedValue_0.SetNonNull(); + nonNullValue_1 = [self asByteSpan:params.ssid]; + } + } + if (params.breadcrumb != nil) { + auto & definedValue_0 = request.breadcrumb.Emplace(); + definedValue_0 = params.breadcrumb.unsignedLongLongValue; + } + } + + new MTRNetworkCommissioningClusterScanNetworksResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)addOrUpdateWiFiNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpdateWiFiNetworkParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::NetworkCommissioningCluster * cppCluster) { + ListFreer listFreer; + NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Type request; + request.ssid = [self asByteSpan:params.ssid]; + request.credentials = [self asByteSpan:params.credentials]; + if (params.breadcrumb != nil) { + auto & definedValue_0 = request.breadcrumb.Emplace(); + definedValue_0 = params.breadcrumb.unsignedLongLongValue; + } + + new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)addOrUpdateThreadNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpdateThreadNetworkParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::NetworkCommissioningCluster * cppCluster) { + ListFreer listFreer; + NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Type request; + request.operationalDataset = [self asByteSpan:params.operationalDataset]; + if (params.breadcrumb != nil) { + auto & definedValue_0 = request.breadcrumb.Emplace(); + definedValue_0 = params.breadcrumb.unsignedLongLongValue; + } + + new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)removeNetworkWithParams:(MTRNetworkCommissioningClusterRemoveNetworkParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::NetworkCommissioningCluster * cppCluster) { + ListFreer listFreer; + NetworkCommissioning::Commands::RemoveNetwork::Type request; + request.networkID = [self asByteSpan:params.networkID]; + if (params.breadcrumb != nil) { + auto & definedValue_0 = request.breadcrumb.Emplace(); + definedValue_0 = params.breadcrumb.unsignedLongLongValue; + } + + new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)connectNetworkWithParams:(MTRNetworkCommissioningClusterConnectNetworkParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterConnectNetworkResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::NetworkCommissioningCluster * cppCluster) { + ListFreer listFreer; + NetworkCommissioning::Commands::ConnectNetwork::Type request; + request.networkID = [self asByteSpan:params.networkID]; + if (params.breadcrumb != nil) { + auto & definedValue_0 = request.breadcrumb.Emplace(); + definedValue_0 = params.breadcrumb.unsignedLongLongValue; + } + + new MTRNetworkCommissioningClusterConnectNetworkResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)reorderNetworkWithParams:(MTRNetworkCommissioningClusterReorderNetworkParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::NetworkCommissioningCluster * cppCluster) { + ListFreer listFreer; + NetworkCommissioning::Commands::ReorderNetwork::Type request; + request.networkID = [self asByteSpan:params.networkID]; + request.networkIndex = params.networkIndex.unsignedCharValue; + if (params.breadcrumb != nil) { + auto & definedValue_0 = request.breadcrumb.Emplace(); + definedValue_0 = params.breadcrumb.unsignedLongLongValue; + } + + new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeMaxNetworksWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeMaxNetworksID) + params:params]; +} + +- (NSDictionary *)readAttributeNetworksWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeNetworksID) + params:params]; +} + +- (NSDictionary *)readAttributeScanMaxTimeSecondsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeScanMaxTimeSecondsID) + params:params]; +} + +- (NSDictionary *)readAttributeConnectMaxTimeSecondsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeConnectMaxTimeSecondsID) + params:params]; +} + +- (NSDictionary *)readAttributeInterfaceEnabledWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeInterfaceEnabledID) + params:params]; +} + +- (void)writeAttributeInterfaceEnabledWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInterfaceEnabledWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInterfaceEnabledWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeInterfaceEnabledID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLastNetworkingStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeLastNetworkingStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeLastNetworkIDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeLastNetworkIDID) + params:params]; +} + +- (NSDictionary *)readAttributeLastConnectErrorValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeLastConnectErrorValueID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterNetworkCommissioningID) + attributeId:@(MTRClusterNetworkCommissioningAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterDiagnosticLogs + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::DiagnosticLogsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::DiagnosticLogsCluster * cppCluster = new chip::Controller::DiagnosticLogsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)retrieveLogsRequestWithParams:(MTRDiagnosticLogsClusterRetrieveLogsRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDiagnosticLogsClusterRetrieveLogsResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DiagnosticLogsCluster * cppCluster) { + ListFreer listFreer; + DiagnosticLogs::Commands::RetrieveLogsRequest::Type request; + request.intent = static_cast>(params.intent.unsignedCharValue); + request.requestedProtocol + = static_cast>(params.requestedProtocol.unsignedCharValue); + request.transferFileDesignator = [self asByteSpan:params.transferFileDesignator]; + + new MTRDiagnosticLogsClusterRetrieveLogsResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDiagnosticLogsID) + attributeId:@(MTRClusterDiagnosticLogsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDiagnosticLogsID) + attributeId:@(MTRClusterDiagnosticLogsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDiagnosticLogsID) + attributeId:@(MTRClusterDiagnosticLogsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDiagnosticLogsID) + attributeId:@(MTRClusterDiagnosticLogsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDiagnosticLogsID) + attributeId:@(MTRClusterDiagnosticLogsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterGeneralDiagnostics + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::GeneralDiagnosticsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = new chip::Controller::GeneralDiagnosticsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)testEventTriggerWithParams:(MTRGeneralDiagnosticsClusterTestEventTriggerParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GeneralDiagnosticsCluster * cppCluster) { + ListFreer listFreer; + GeneralDiagnostics::Commands::TestEventTrigger::Type request; + request.enableKey = [self asByteSpan:params.enableKey]; + request.eventTrigger = params.eventTrigger.unsignedLongLongValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeNetworkInterfacesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeNetworkInterfacesID) + params:params]; +} + +- (NSDictionary *)readAttributeRebootCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeRebootCountID) + params:params]; +} + +- (NSDictionary *)readAttributeUpTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeUpTimeID) + params:params]; +} + +- (NSDictionary *)readAttributeTotalOperationalHoursWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeTotalOperationalHoursID) + params:params]; +} + +- (NSDictionary *)readAttributeBootReasonsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeBootReasonsID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveHardwareFaultsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeActiveHardwareFaultsID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveRadioFaultsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeActiveRadioFaultsID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveNetworkFaultsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeActiveNetworkFaultsID) + params:params]; +} + +- (NSDictionary *)readAttributeTestEventTriggersEnabledWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeTestEventTriggersEnabledID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGeneralDiagnosticsID) + attributeId:@(MTRClusterGeneralDiagnosticsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterSoftwareDiagnostics + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::SoftwareDiagnosticsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::SoftwareDiagnosticsCluster * cppCluster = new chip::Controller::SoftwareDiagnosticsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)resetWatermarksWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self resetWatermarksWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)resetWatermarksWithParams:(MTRSoftwareDiagnosticsClusterResetWatermarksParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::SoftwareDiagnosticsCluster * cppCluster) { + ListFreer listFreer; + SoftwareDiagnostics::Commands::ResetWatermarks::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeThreadMetricsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeThreadMetricsID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentHeapFreeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeCurrentHeapFreeID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentHeapUsedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeCurrentHeapUsedID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentHeapHighWatermarkWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeCurrentHeapHighWatermarkID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSoftwareDiagnosticsID) + attributeId:@(MTRClusterSoftwareDiagnosticsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterThreadNetworkDiagnostics + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = new chip::Controller::ThreadNetworkDiagnosticsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)resetCountsWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self resetCountsWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)resetCountsWithParams:(MTRThreadNetworkDiagnosticsClusterResetCountsParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster) { + ListFreer listFreer; + ThreadNetworkDiagnostics::Commands::ResetCounts::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeChannelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeChannelID) + params:params]; +} + +- (NSDictionary *)readAttributeRoutingRoleWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRoutingRoleID) + params:params]; +} + +- (NSDictionary *)readAttributeNetworkNameWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeNetworkNameID) + params:params]; +} + +- (NSDictionary *)readAttributePanIdWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributePanIdID) + params:params]; +} + +- (NSDictionary *)readAttributeExtendedPanIdWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeExtendedPanIdID) + params:params]; +} + +- (NSDictionary *)readAttributeMeshLocalPrefixWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeMeshLocalPrefixID) + params:params]; +} + +- (NSDictionary *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeOverrunCountID) + params:params]; +} + +- (NSDictionary *)readAttributeNeighborTableListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeNeighborTableListID) + params:params]; +} + +- (NSDictionary *)readAttributeRouteTableListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRouteTableListID) + params:params]; +} + +- (NSDictionary *)readAttributePartitionIdWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributePartitionIdID) + params:params]; +} + +- (NSDictionary *)readAttributeWeightingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeWeightingID) + params:params]; +} + +- (NSDictionary *)readAttributeDataVersionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeDataVersionID) + params:params]; +} + +- (NSDictionary *)readAttributeStableDataVersionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeStableDataVersionID) + params:params]; +} + +- (NSDictionary *)readAttributeLeaderRouterIdWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeLeaderRouterIdID) + params:params]; +} + +- (NSDictionary *)readAttributeDetachedRoleCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeDetachedRoleCountID) + params:params]; +} + +- (NSDictionary *)readAttributeChildRoleCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeChildRoleCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRouterRoleCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRouterRoleCountID) + params:params]; +} + +- (NSDictionary *)readAttributeLeaderRoleCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeLeaderRoleCountID) + params:params]; +} + +- (NSDictionary *)readAttributeAttachAttemptCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeAttachAttemptCountID) + params:params]; +} + +- (NSDictionary *)readAttributePartitionIdChangeCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributePartitionIdChangeCountID) + params:params]; +} + +- (NSDictionary *)readAttributeBetterPartitionAttachAttemptCountWithParams:(MTRReadParams * _Nullable)params +{ + return + [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeBetterPartitionAttachAttemptCountID) + params:params]; +} + +- (NSDictionary *)readAttributeParentChangeCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeParentChangeCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxTotalCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxTotalCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxUnicastCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxUnicastCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxBroadcastCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxBroadcastCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxAckRequestedCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxAckRequestedCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxAckedCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxAckedCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxNoAckRequestedCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxNoAckRequestedCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxDataCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxDataCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxDataPollCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxDataPollCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxBeaconCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxBeaconCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxBeaconRequestCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxBeaconRequestCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxOtherCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxOtherCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxRetryCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxRetryCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxDirectMaxRetryExpiryCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxDirectMaxRetryExpiryCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxIndirectMaxRetryExpiryCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxIndirectMaxRetryExpiryCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxErrCcaCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxErrCcaCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxErrAbortCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxErrAbortCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxErrBusyChannelCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeTxErrBusyChannelCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxTotalCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxTotalCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxUnicastCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxUnicastCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxBroadcastCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxBroadcastCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxDataCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxDataCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxDataPollCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxDataPollCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxBeaconCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxBeaconCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxBeaconRequestCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxBeaconRequestCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxOtherCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxOtherCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxAddressFilteredCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxAddressFilteredCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxDestAddrFilteredCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxDestAddrFilteredCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxDuplicatedCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxDuplicatedCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxErrNoFrameCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrNoFrameCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxErrUnknownNeighborCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrUnknownNeighborCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxErrInvalidSrcAddrCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrInvalidSrcAddrCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxErrSecCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrSecCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxErrFcsCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrFcsCountID) + params:params]; +} + +- (NSDictionary *)readAttributeRxErrOtherCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrOtherCountID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveTimestampWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeActiveTimestampID) + params:params]; +} + +- (NSDictionary *)readAttributePendingTimestampWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributePendingTimestampID) + params:params]; +} + +- (NSDictionary *)readAttributeDelayWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeDelayID) + params:params]; +} + +- (NSDictionary *)readAttributeSecurityPolicyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeSecurityPolicyID) + params:params]; +} + +- (NSDictionary *)readAttributeChannelMaskWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeChannelMaskID) + params:params]; +} + +- (NSDictionary *)readAttributeOperationalDatasetComponentsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeOperationalDatasetComponentsID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveNetworkFaultsListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeActiveNetworkFaultsListID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThreadNetworkDiagnosticsID) + attributeId:@(MTRClusterThreadNetworkDiagnosticsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterWiFiNetworkDiagnostics + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = new chip::Controller::WiFiNetworkDiagnosticsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)resetCountsWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self resetCountsWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)resetCountsWithParams:(MTRWiFiNetworkDiagnosticsClusterResetCountsParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster) { + ListFreer listFreer; + WiFiNetworkDiagnostics::Commands::ResetCounts::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeBssidWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeBssidID) + params:params]; +} + +- (NSDictionary *)readAttributeSecurityTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeSecurityTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeWiFiVersionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeWiFiVersionID) + params:params]; +} + +- (NSDictionary *)readAttributeChannelNumberWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeChannelNumberID) + params:params]; +} + +- (NSDictionary *)readAttributeRssiWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeRssiID) + params:params]; +} + +- (NSDictionary *)readAttributeBeaconLostCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeBeaconLostCountID) + params:params]; +} + +- (NSDictionary *)readAttributeBeaconRxCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeBeaconRxCountID) + params:params]; +} + +- (NSDictionary *)readAttributePacketMulticastRxCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributePacketMulticastRxCountID) + params:params]; +} + +- (NSDictionary *)readAttributePacketMulticastTxCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributePacketMulticastTxCountID) + params:params]; +} + +- (NSDictionary *)readAttributePacketUnicastRxCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributePacketUnicastRxCountID) + params:params]; +} + +- (NSDictionary *)readAttributePacketUnicastTxCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributePacketUnicastTxCountID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentMaxRateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeCurrentMaxRateID) + params:params]; +} + +- (NSDictionary *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeOverrunCountID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWiFiNetworkDiagnosticsID) + attributeId:@(MTRClusterWiFiNetworkDiagnosticsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterEthernetNetworkDiagnostics + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = new chip::Controller::EthernetNetworkDiagnosticsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)resetCountsWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self resetCountsWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)resetCountsWithParams:(MTREthernetNetworkDiagnosticsClusterResetCountsParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster) { + ListFreer listFreer; + EthernetNetworkDiagnostics::Commands::ResetCounts::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributePHYRateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributePHYRateID) + params:params]; +} + +- (NSDictionary *)readAttributeFullDuplexWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeFullDuplexID) + params:params]; +} + +- (NSDictionary *)readAttributePacketRxCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributePacketRxCountID) + params:params]; +} + +- (NSDictionary *)readAttributePacketTxCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributePacketTxCountID) + params:params]; +} + +- (NSDictionary *)readAttributeTxErrCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeTxErrCountID) + params:params]; +} + +- (NSDictionary *)readAttributeCollisionCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeCollisionCountID) + params:params]; +} + +- (NSDictionary *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeOverrunCountID) + params:params]; +} + +- (NSDictionary *)readAttributeCarrierDetectWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeCarrierDetectID) + params:params]; +} + +- (NSDictionary *)readAttributeTimeSinceResetWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeTimeSinceResetID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterEthernetNetworkDiagnosticsID) + attributeId:@(MTRClusterEthernetNetworkDiagnosticsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterBridgedDeviceBasic + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::BridgedDeviceBasicCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::BridgedDeviceBasicCluster * cppCluster = new chip::Controller::BridgedDeviceBasicCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeVendorNameID) + params:params]; +} + +- (NSDictionary *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeVendorIDID) + params:params]; +} + +- (NSDictionary *)readAttributeProductNameWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeProductNameID) + params:params]; +} + +- (NSDictionary *)readAttributeNodeLabelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeNodeLabelID) + params:params]; +} + +- (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNodeLabelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNodeLabelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeNodeLabelID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeHardwareVersionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeHardwareVersionID) + params:params]; +} + +- (NSDictionary *)readAttributeHardwareVersionStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeHardwareVersionStringID) + params:params]; +} + +- (NSDictionary *)readAttributeSoftwareVersionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeSoftwareVersionID) + params:params]; +} + +- (NSDictionary *)readAttributeSoftwareVersionStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeSoftwareVersionStringID) + params:params]; +} + +- (NSDictionary *)readAttributeManufacturingDateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeManufacturingDateID) + params:params]; +} + +- (NSDictionary *)readAttributePartNumberWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributePartNumberID) + params:params]; +} + +- (NSDictionary *)readAttributeProductURLWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeProductURLID) + params:params]; +} + +- (NSDictionary *)readAttributeProductLabelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeProductLabelID) + params:params]; +} + +- (NSDictionary *)readAttributeSerialNumberWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeSerialNumberID) + params:params]; +} + +- (NSDictionary *)readAttributeReachableWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeReachableID) + params:params]; +} + +- (NSDictionary *)readAttributeUniqueIDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeUniqueIDID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBridgedDeviceBasicID) + attributeId:@(MTRClusterBridgedDeviceBasicAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterSwitch + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::SwitchCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::SwitchCluster * cppCluster = new chip::Controller::SwitchCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeNumberOfPositionsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSwitchID) + attributeId:@(MTRClusterSwitchAttributeNumberOfPositionsID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentPositionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSwitchID) + attributeId:@(MTRClusterSwitchAttributeCurrentPositionID) + params:params]; +} + +- (NSDictionary *)readAttributeMultiPressMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSwitchID) + attributeId:@(MTRClusterSwitchAttributeMultiPressMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSwitchID) + attributeId:@(MTRClusterSwitchAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSwitchID) + attributeId:@(MTRClusterSwitchAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSwitchID) + attributeId:@(MTRClusterSwitchAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSwitchID) + attributeId:@(MTRClusterSwitchAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterSwitchID) + attributeId:@(MTRClusterSwitchAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterAdministratorCommissioning + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::AdministratorCommissioningCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::AdministratorCommissioningCluster * cppCluster = new chip::Controller::AdministratorCommissioningCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)openCommissioningWindowWithParams:(MTRAdministratorCommissioningClusterOpenCommissioningWindowParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::AdministratorCommissioningCluster * cppCluster) { + ListFreer listFreer; + AdministratorCommissioning::Commands::OpenCommissioningWindow::Type request; + request.commissioningTimeout = params.commissioningTimeout.unsignedShortValue; + request.PAKEVerifier = [self asByteSpan:params.pakeVerifier]; + request.discriminator = params.discriminator.unsignedShortValue; + request.iterations = params.iterations.unsignedIntValue; + request.salt = [self asByteSpan:params.salt]; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)openBasicCommissioningWindowWithParams:(MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::AdministratorCommissioningCluster * cppCluster) { + ListFreer listFreer; + AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type request; + request.commissioningTimeout = params.commissioningTimeout.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)revokeCommissioningWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self revokeCommissioningWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)revokeCommissioningWithParams:(MTRAdministratorCommissioningClusterRevokeCommissioningParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::AdministratorCommissioningCluster * cppCluster) { + ListFreer listFreer; + AdministratorCommissioning::Commands::RevokeCommissioning::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeWindowStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAdministratorCommissioningID) + attributeId:@(MTRClusterAdministratorCommissioningAttributeWindowStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeAdminFabricIndexWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAdministratorCommissioningID) + attributeId:@(MTRClusterAdministratorCommissioningAttributeAdminFabricIndexID) + params:params]; +} + +- (NSDictionary *)readAttributeAdminVendorIdWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAdministratorCommissioningID) + attributeId:@(MTRClusterAdministratorCommissioningAttributeAdminVendorIdID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAdministratorCommissioningID) + attributeId:@(MTRClusterAdministratorCommissioningAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAdministratorCommissioningID) + attributeId:@(MTRClusterAdministratorCommissioningAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAdministratorCommissioningID) + attributeId:@(MTRClusterAdministratorCommissioningAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAdministratorCommissioningID) + attributeId:@(MTRClusterAdministratorCommissioningAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAdministratorCommissioningID) + attributeId:@(MTRClusterAdministratorCommissioningAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterOperationalCredentials + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::OperationalCredentialsCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::OperationalCredentialsCluster * cppCluster = new chip::Controller::OperationalCredentialsCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)attestationRequestWithParams:(MTROperationalCredentialsClusterAttestationRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterAttestationResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OperationalCredentialsCluster * cppCluster) { + ListFreer listFreer; + OperationalCredentials::Commands::AttestationRequest::Type request; + request.attestationNonce = [self asByteSpan:params.attestationNonce]; + + new MTROperationalCredentialsClusterAttestationResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)certificateChainRequestWithParams:(MTROperationalCredentialsClusterCertificateChainRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterCertificateChainResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OperationalCredentialsCluster * cppCluster) { + ListFreer listFreer; + OperationalCredentials::Commands::CertificateChainRequest::Type request; + request.certificateType = params.certificateType.unsignedCharValue; + + new MTROperationalCredentialsClusterCertificateChainResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn + = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)CSRRequestWithParams:(MTROperationalCredentialsClusterCSRRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterCSRResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OperationalCredentialsCluster * cppCluster) { + ListFreer listFreer; + OperationalCredentials::Commands::CSRRequest::Type request; + request.CSRNonce = [self asByteSpan:params.csrNonce]; + if (params.isForUpdateNOC != nil) { + auto & definedValue_0 = request.isForUpdateNOC.Emplace(); + definedValue_0 = params.isForUpdateNOC.boolValue; + } + + new MTROperationalCredentialsClusterCSRResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)addNOCWithParams:(MTROperationalCredentialsClusterAddNOCParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OperationalCredentialsCluster * cppCluster) { + ListFreer listFreer; + OperationalCredentials::Commands::AddNOC::Type request; + request.NOCValue = [self asByteSpan:params.nocValue]; + if (params.icacValue != nil) { + auto & definedValue_0 = request.ICACValue.Emplace(); + definedValue_0 = [self asByteSpan:params.icacValue]; + } + request.IPKValue = [self asByteSpan:params.ipkValue]; + request.caseAdminSubject = params.caseAdminSubject.unsignedLongLongValue; + request.adminVendorId + = static_cast>(params.adminVendorId.unsignedShortValue); + + new MTROperationalCredentialsClusterNOCResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)updateNOCWithParams:(MTROperationalCredentialsClusterUpdateNOCParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OperationalCredentialsCluster * cppCluster) { + ListFreer listFreer; + OperationalCredentials::Commands::UpdateNOC::Type request; + request.NOCValue = [self asByteSpan:params.nocValue]; + if (params.icacValue != nil) { + auto & definedValue_0 = request.ICACValue.Emplace(); + definedValue_0 = [self asByteSpan:params.icacValue]; + } + + new MTROperationalCredentialsClusterNOCResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)updateFabricLabelWithParams:(MTROperationalCredentialsClusterUpdateFabricLabelParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OperationalCredentialsCluster * cppCluster) { + ListFreer listFreer; + OperationalCredentials::Commands::UpdateFabricLabel::Type request; + request.label = [self asCharSpan:params.label]; + + new MTROperationalCredentialsClusterNOCResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)removeFabricWithParams:(MTROperationalCredentialsClusterRemoveFabricParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OperationalCredentialsCluster * cppCluster) { + ListFreer listFreer; + OperationalCredentials::Commands::RemoveFabric::Type request; + request.fabricIndex = params.fabricIndex.unsignedCharValue; + + new MTROperationalCredentialsClusterNOCResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)addTrustedRootCertificateWithParams:(MTROperationalCredentialsClusterAddTrustedRootCertificateParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::OperationalCredentialsCluster * cppCluster) { + ListFreer listFreer; + OperationalCredentials::Commands::AddTrustedRootCertificate::Type request; + request.rootCertificate = [self asByteSpan:params.rootCertificate]; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeNOCsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeNOCsID) + params:params]; +} + +- (NSDictionary *)readAttributeFabricsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeFabricsID) + params:params]; +} + +- (NSDictionary *)readAttributeSupportedFabricsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeSupportedFabricsID) + params:params]; +} + +- (NSDictionary *)readAttributeCommissionedFabricsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeCommissionedFabricsID) + params:params]; +} + +- (NSDictionary *)readAttributeTrustedRootCertificatesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeTrustedRootCertificatesID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentFabricIndexWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeCurrentFabricIndexID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOperationalCredentialsID) + attributeId:@(MTRClusterOperationalCredentialsAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterGroupKeyManagement + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::GroupKeyManagementCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::GroupKeyManagementCluster * cppCluster = new chip::Controller::GroupKeyManagementCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)keySetWriteWithParams:(MTRGroupKeyManagementClusterKeySetWriteParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupKeyManagementCluster * cppCluster) { + ListFreer listFreer; + GroupKeyManagement::Commands::KeySetWrite::Type request; + request.groupKeySet.groupKeySetID = params.groupKeySet.groupKeySetID.unsignedShortValue; + request.groupKeySet.groupKeySecurityPolicy + = static_cast>( + params.groupKeySet.groupKeySecurityPolicy.unsignedCharValue); + if (params.groupKeySet.epochKey0 == nil) { + request.groupKeySet.epochKey0.SetNull(); + } else { + auto & nonNullValue_1 = request.groupKeySet.epochKey0.SetNonNull(); + nonNullValue_1 = [self asByteSpan:params.groupKeySet.epochKey0]; + } + if (params.groupKeySet.epochStartTime0 == nil) { + request.groupKeySet.epochStartTime0.SetNull(); + } else { + auto & nonNullValue_1 = request.groupKeySet.epochStartTime0.SetNonNull(); + nonNullValue_1 = params.groupKeySet.epochStartTime0.unsignedLongLongValue; + } + if (params.groupKeySet.epochKey1 == nil) { + request.groupKeySet.epochKey1.SetNull(); + } else { + auto & nonNullValue_1 = request.groupKeySet.epochKey1.SetNonNull(); + nonNullValue_1 = [self asByteSpan:params.groupKeySet.epochKey1]; + } + if (params.groupKeySet.epochStartTime1 == nil) { + request.groupKeySet.epochStartTime1.SetNull(); + } else { + auto & nonNullValue_1 = request.groupKeySet.epochStartTime1.SetNonNull(); + nonNullValue_1 = params.groupKeySet.epochStartTime1.unsignedLongLongValue; + } + if (params.groupKeySet.epochKey2 == nil) { + request.groupKeySet.epochKey2.SetNull(); + } else { + auto & nonNullValue_1 = request.groupKeySet.epochKey2.SetNonNull(); + nonNullValue_1 = [self asByteSpan:params.groupKeySet.epochKey2]; + } + if (params.groupKeySet.epochStartTime2 == nil) { + request.groupKeySet.epochStartTime2.SetNull(); + } else { + auto & nonNullValue_1 = request.groupKeySet.epochStartTime2.SetNonNull(); + nonNullValue_1 = params.groupKeySet.epochStartTime2.unsignedLongLongValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)keySetReadWithParams:(MTRGroupKeyManagementClusterKeySetReadParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupKeyManagementCluster * cppCluster) { + ListFreer listFreer; + GroupKeyManagement::Commands::KeySetRead::Type request; + request.groupKeySetID = params.groupKeySetID.unsignedShortValue; + + new MTRGroupKeyManagementClusterKeySetReadResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)keySetRemoveWithParams:(MTRGroupKeyManagementClusterKeySetRemoveParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupKeyManagementCluster * cppCluster) { + ListFreer listFreer; + GroupKeyManagement::Commands::KeySetRemove::Type request; + request.groupKeySetID = params.groupKeySetID.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)keySetReadAllIndicesWithParams:(MTRGroupKeyManagementClusterKeySetReadAllIndicesParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::GroupKeyManagementCluster * cppCluster) { + ListFreer listFreer; + GroupKeyManagement::Commands::KeySetReadAllIndices::Type request; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.groupKeySetIDs.count != 0) { + auto * listHolder_0 = new ListHolder(params.groupKeySetIDs.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.groupKeySetIDs.count; ++i_0) { + if (![params.groupKeySetIDs[i_0] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (NSNumber *) params.groupKeySetIDs[i_0]; + listHolder_0->mList[i_0] = element_0.unsignedShortValue; + } + request.groupKeySetIDs = ListType_0(listHolder_0->mList, params.groupKeySetIDs.count); + } else { + request.groupKeySetIDs = ListType_0(); + } + } + + new MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn + = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeGroupKeyMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeGroupKeyMapID) + params:params]; +} + +- (void)writeAttributeGroupKeyMapWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeGroupKeyMapWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeGroupKeyMapWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeGroupKeyMapID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGroupTableWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeGroupTableID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxGroupsPerFabricWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeMaxGroupsPerFabricID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxGroupKeysPerFabricWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeMaxGroupKeysPerFabricID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterGroupKeyManagementID) + attributeId:@(MTRClusterGroupKeyManagementAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterFixedLabel + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::FixedLabelCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::FixedLabelCluster * cppCluster = new chip::Controller::FixedLabelCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeLabelListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFixedLabelID) + attributeId:@(MTRClusterFixedLabelAttributeLabelListID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFixedLabelID) + attributeId:@(MTRClusterFixedLabelAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFixedLabelID) + attributeId:@(MTRClusterFixedLabelAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFixedLabelID) + attributeId:@(MTRClusterFixedLabelAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFixedLabelID) + attributeId:@(MTRClusterFixedLabelAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFixedLabelID) + attributeId:@(MTRClusterFixedLabelAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterUserLabel + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::UserLabelCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::UserLabelCluster * cppCluster = new chip::Controller::UserLabelCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeLabelListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUserLabelID) + attributeId:@(MTRClusterUserLabelAttributeLabelListID) + params:params]; +} + +- (void)writeAttributeLabelListWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLabelListWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLabelListWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUserLabelID) + attributeId:@(MTRClusterUserLabelAttributeLabelListID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUserLabelID) + attributeId:@(MTRClusterUserLabelAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUserLabelID) + attributeId:@(MTRClusterUserLabelAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUserLabelID) + attributeId:@(MTRClusterUserLabelAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUserLabelID) + attributeId:@(MTRClusterUserLabelAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterUserLabelID) + attributeId:@(MTRClusterUserLabelAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterBooleanState + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::BooleanStateCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::BooleanStateCluster * cppCluster = new chip::Controller::BooleanStateCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeStateValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBooleanStateID) + attributeId:@(MTRClusterBooleanStateAttributeStateValueID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBooleanStateID) + attributeId:@(MTRClusterBooleanStateAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBooleanStateID) + attributeId:@(MTRClusterBooleanStateAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBooleanStateID) + attributeId:@(MTRClusterBooleanStateAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBooleanStateID) + attributeId:@(MTRClusterBooleanStateAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBooleanStateID) + attributeId:@(MTRClusterBooleanStateAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterModeSelect + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ModeSelectCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ModeSelectCluster * cppCluster = new chip::Controller::ModeSelectCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)changeToModeWithParams:(MTRModeSelectClusterChangeToModeParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ModeSelectCluster * cppCluster) { + ListFreer listFreer; + ModeSelect::Commands::ChangeToMode::Type request; + request.newMode = params.newMode.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeDescriptionID) + params:params]; +} + +- (NSDictionary *)readAttributeStandardNamespaceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeStandardNamespaceID) + params:params]; +} + +- (NSDictionary *)readAttributeSupportedModesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeSupportedModesID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeCurrentModeID) + params:params]; +} + +- (NSDictionary *)readAttributeStartUpModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeStartUpModeID) + params:params]; +} + +- (void)writeAttributeStartUpModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeStartUpModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeStartUpModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeStartUpModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOnModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeOnModeID) + params:params]; +} + +- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOnModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOnModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeOnModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterModeSelectID) + attributeId:@(MTRClusterModeSelectAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterDoorLock + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::DoorLockCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::DoorLockCluster * cppCluster = new chip::Controller::DoorLockCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)lockDoorWithParams:(MTRDoorLockClusterLockDoorParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::LockDoor::Type request; + if (params != nil) { + if (params.pinCode != nil) { + auto & definedValue_0 = request.pinCode.Emplace(); + definedValue_0 = [self asByteSpan:params.pinCode]; + } + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)unlockDoorWithParams:(MTRDoorLockClusterUnlockDoorParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::UnlockDoor::Type request; + if (params != nil) { + if (params.pinCode != nil) { + auto & definedValue_0 = request.pinCode.Emplace(); + definedValue_0 = [self asByteSpan:params.pinCode]; + } + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)unlockWithTimeoutWithParams:(MTRDoorLockClusterUnlockWithTimeoutParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::UnlockWithTimeout::Type request; + request.timeout = params.timeout.unsignedShortValue; + if (params.pinCode != nil) { + auto & definedValue_0 = request.pinCode.Emplace(); + definedValue_0 = [self asByteSpan:params.pinCode]; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)setWeekDayScheduleWithParams:(MTRDoorLockClusterSetWeekDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::SetWeekDaySchedule::Type request; + request.weekDayIndex = params.weekDayIndex.unsignedCharValue; + request.userIndex = params.userIndex.unsignedShortValue; + request.daysMask = static_cast>(params.daysMask.unsignedCharValue); + request.startHour = params.startHour.unsignedCharValue; + request.startMinute = params.startMinute.unsignedCharValue; + request.endHour = params.endHour.unsignedCharValue; + request.endMinute = params.endMinute.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getWeekDayScheduleWithParams:(MTRDoorLockClusterGetWeekDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::GetWeekDaySchedule::Type request; + request.weekDayIndex = params.weekDayIndex.unsignedCharValue; + request.userIndex = params.userIndex.unsignedShortValue; + + new MTRDoorLockClusterGetWeekDayScheduleResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)clearWeekDayScheduleWithParams:(MTRDoorLockClusterClearWeekDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::ClearWeekDaySchedule::Type request; + request.weekDayIndex = params.weekDayIndex.unsignedCharValue; + request.userIndex = params.userIndex.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)setYearDayScheduleWithParams:(MTRDoorLockClusterSetYearDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::SetYearDaySchedule::Type request; + request.yearDayIndex = params.yearDayIndex.unsignedCharValue; + request.userIndex = params.userIndex.unsignedShortValue; + request.localStartTime = params.localStartTime.unsignedIntValue; + request.localEndTime = params.localEndTime.unsignedIntValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getYearDayScheduleWithParams:(MTRDoorLockClusterGetYearDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::GetYearDaySchedule::Type request; + request.yearDayIndex = params.yearDayIndex.unsignedCharValue; + request.userIndex = params.userIndex.unsignedShortValue; + + new MTRDoorLockClusterGetYearDayScheduleResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)clearYearDayScheduleWithParams:(MTRDoorLockClusterClearYearDayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::ClearYearDaySchedule::Type request; + request.yearDayIndex = params.yearDayIndex.unsignedCharValue; + request.userIndex = params.userIndex.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)setHolidayScheduleWithParams:(MTRDoorLockClusterSetHolidayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::SetHolidaySchedule::Type request; + request.holidayIndex = params.holidayIndex.unsignedCharValue; + request.localStartTime = params.localStartTime.unsignedIntValue; + request.localEndTime = params.localEndTime.unsignedIntValue; + request.operatingMode + = static_cast>(params.operatingMode.unsignedCharValue); + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getHolidayScheduleWithParams:(MTRDoorLockClusterGetHolidayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::GetHolidaySchedule::Type request; + request.holidayIndex = params.holidayIndex.unsignedCharValue; + + new MTRDoorLockClusterGetHolidayScheduleResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)clearHolidayScheduleWithParams:(MTRDoorLockClusterClearHolidayScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::ClearHolidaySchedule::Type request; + request.holidayIndex = params.holidayIndex.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)setUserWithParams:(MTRDoorLockClusterSetUserParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::SetUser::Type request; + request.operationType + = static_cast>(params.operationType.unsignedCharValue); + request.userIndex = params.userIndex.unsignedShortValue; + if (params.userName == nil) { + request.userName.SetNull(); + } else { + auto & nonNullValue_0 = request.userName.SetNonNull(); + nonNullValue_0 = [self asCharSpan:params.userName]; + } + if (params.userUniqueId == nil) { + request.userUniqueId.SetNull(); + } else { + auto & nonNullValue_0 = request.userUniqueId.SetNonNull(); + nonNullValue_0 = params.userUniqueId.unsignedIntValue; + } + if (params.userStatus == nil) { + request.userStatus.SetNull(); + } else { + auto & nonNullValue_0 = request.userStatus.SetNonNull(); + nonNullValue_0 = static_cast>(params.userStatus.unsignedCharValue); + } + if (params.userType == nil) { + request.userType.SetNull(); + } else { + auto & nonNullValue_0 = request.userType.SetNonNull(); + nonNullValue_0 = static_cast>(params.userType.unsignedCharValue); + } + if (params.credentialRule == nil) { + request.credentialRule.SetNull(); + } else { + auto & nonNullValue_0 = request.credentialRule.SetNonNull(); + nonNullValue_0 + = static_cast>(params.credentialRule.unsignedCharValue); + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getUserWithParams:(MTRDoorLockClusterGetUserParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRDoorLockClusterGetUserResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::GetUser::Type request; + request.userIndex = params.userIndex.unsignedShortValue; + + new MTRDoorLockClusterGetUserResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)clearUserWithParams:(MTRDoorLockClusterClearUserParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::ClearUser::Type request; + request.userIndex = params.userIndex.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)setCredentialWithParams:(MTRDoorLockClusterSetCredentialParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterSetCredentialResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::SetCredential::Type request; + request.operationType + = static_cast>(params.operationType.unsignedCharValue); + request.credential.credentialType = static_cast>( + params.credential.credentialType.unsignedCharValue); + request.credential.credentialIndex = params.credential.credentialIndex.unsignedShortValue; + request.credentialData = [self asByteSpan:params.credentialData]; + if (params.userIndex == nil) { + request.userIndex.SetNull(); + } else { + auto & nonNullValue_0 = request.userIndex.SetNonNull(); + nonNullValue_0 = params.userIndex.unsignedShortValue; + } + if (params.userStatus == nil) { + request.userStatus.SetNull(); + } else { + auto & nonNullValue_0 = request.userStatus.SetNonNull(); + nonNullValue_0 = static_cast>(params.userStatus.unsignedCharValue); + } + if (params.userType == nil) { + request.userType.SetNull(); + } else { + auto & nonNullValue_0 = request.userType.SetNonNull(); + nonNullValue_0 = static_cast>(params.userType.unsignedCharValue); + } + + new MTRDoorLockClusterSetCredentialResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getCredentialStatusWithParams:(MTRDoorLockClusterGetCredentialStatusParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::GetCredentialStatus::Type request; + request.credential.credentialType = static_cast>( + params.credential.credentialType.unsignedCharValue); + request.credential.credentialIndex = params.credential.credentialIndex.unsignedShortValue; + + new MTRDoorLockClusterGetCredentialStatusResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)clearCredentialWithParams:(MTRDoorLockClusterClearCredentialParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::DoorLockCluster * cppCluster) { + ListFreer listFreer; + DoorLock::Commands::ClearCredential::Type request; + if (params.credential == nil) { + request.credential.SetNull(); + } else { + auto & nonNullValue_0 = request.credential.SetNonNull(); + nonNullValue_0.credentialType = static_cast>( + params.credential.credentialType.unsignedCharValue); + nonNullValue_0.credentialIndex = params.credential.credentialIndex.unsignedShortValue; + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeLockStateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeLockStateID) + params:params]; +} + +- (NSDictionary *)readAttributeLockTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeLockTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeActuatorEnabledWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeActuatorEnabledID) + params:params]; +} + +- (NSDictionary *)readAttributeDoorStateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeDoorStateID) + params:params]; +} + +- (NSDictionary *)readAttributeDoorOpenEventsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeDoorOpenEventsID) + params:params]; +} + +- (void)writeAttributeDoorOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeDoorOpenEventsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeDoorOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeDoorOpenEventsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeDoorClosedEventsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeDoorClosedEventsID) + params:params]; +} + +- (void)writeAttributeDoorClosedEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeDoorClosedEventsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeDoorClosedEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeDoorClosedEventsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOpenPeriodWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeOpenPeriodID) + params:params]; +} + +- (void)writeAttributeOpenPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOpenPeriodWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOpenPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeOpenPeriodID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNumberOfTotalUsersSupportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeNumberOfTotalUsersSupportedID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfPINUsersSupportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeNumberOfPINUsersSupportedID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfRFIDUsersSupportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeNumberOfRFIDUsersSupportedID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeNumberOfWeekDaySchedulesSupportedPerUserID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfYearDaySchedulesSupportedPerUserWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeNumberOfYearDaySchedulesSupportedPerUserID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfHolidaySchedulesSupportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeNumberOfHolidaySchedulesSupportedID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxPINCodeLengthWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeMaxPINCodeLengthID) + params:params]; +} + +- (NSDictionary *)readAttributeMinPINCodeLengthWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeMinPINCodeLengthID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxRFIDCodeLengthWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeMaxRFIDCodeLengthID) + params:params]; +} + +- (NSDictionary *)readAttributeMinRFIDCodeLengthWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeMinRFIDCodeLengthID) + params:params]; +} + +- (NSDictionary *)readAttributeCredentialRulesSupportWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeCredentialRulesSupportID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfCredentialsSupportedPerUserWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeNumberOfCredentialsSupportedPerUserID) + params:params]; +} + +- (NSDictionary *)readAttributeLanguageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeLanguageID) + params:params]; +} + +- (void)writeAttributeLanguageWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLanguageWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLanguageWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeLanguageID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLEDSettingsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeLEDSettingsID) + params:params]; +} + +- (void)writeAttributeLEDSettingsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLEDSettingsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLEDSettingsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeLEDSettingsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeAutoRelockTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeAutoRelockTimeID) + params:params]; +} + +- (void)writeAttributeAutoRelockTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeAutoRelockTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeAutoRelockTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeAutoRelockTimeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSoundVolumeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeSoundVolumeID) + params:params]; +} + +- (void)writeAttributeSoundVolumeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeSoundVolumeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeSoundVolumeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeSoundVolumeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOperatingModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeOperatingModeID) + params:params]; +} + +- (void)writeAttributeOperatingModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOperatingModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOperatingModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeOperatingModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSupportedOperatingModesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeSupportedOperatingModesID) + params:params]; +} + +- (NSDictionary *)readAttributeDefaultConfigurationRegisterWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeDefaultConfigurationRegisterID) + params:params]; +} + +- (NSDictionary *)readAttributeEnableLocalProgrammingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeEnableLocalProgrammingID) + params:params]; +} + +- (void)writeAttributeEnableLocalProgrammingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEnableLocalProgrammingWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeEnableLocalProgrammingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeEnableLocalProgrammingID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEnableOneTouchLockingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeEnableOneTouchLockingID) + params:params]; +} + +- (void)writeAttributeEnableOneTouchLockingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEnableOneTouchLockingWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeEnableOneTouchLockingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeEnableOneTouchLockingID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEnableInsideStatusLEDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeEnableInsideStatusLEDID) + params:params]; +} + +- (void)writeAttributeEnableInsideStatusLEDWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEnableInsideStatusLEDWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeEnableInsideStatusLEDWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeEnableInsideStatusLEDID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEnablePrivacyModeButtonWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeEnablePrivacyModeButtonID) + params:params]; +} + +- (void)writeAttributeEnablePrivacyModeButtonWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEnablePrivacyModeButtonWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeEnablePrivacyModeButtonWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeEnablePrivacyModeButtonID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLocalProgrammingFeaturesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeLocalProgrammingFeaturesID) + params:params]; +} + +- (void)writeAttributeLocalProgrammingFeaturesWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLocalProgrammingFeaturesWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeLocalProgrammingFeaturesWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeLocalProgrammingFeaturesID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeWrongCodeEntryLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeWrongCodeEntryLimitID) + params:params]; +} + +- (void)writeAttributeWrongCodeEntryLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeWrongCodeEntryLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeWrongCodeEntryLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeWrongCodeEntryLimitID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUserCodeTemporaryDisableTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeUserCodeTemporaryDisableTimeID) + params:params]; +} + +- (void)writeAttributeUserCodeTemporaryDisableTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeUserCodeTemporaryDisableTimeWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeUserCodeTemporaryDisableTimeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeUserCodeTemporaryDisableTimeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSendPINOverTheAirWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeSendPINOverTheAirID) + params:params]; +} + +- (void)writeAttributeSendPINOverTheAirWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeSendPINOverTheAirWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeSendPINOverTheAirWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeSendPINOverTheAirID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRequirePINforRemoteOperationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeRequirePINforRemoteOperationID) + params:params]; +} + +- (void)writeAttributeRequirePINforRemoteOperationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRequirePINforRemoteOperationWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeRequirePINforRemoteOperationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeRequirePINforRemoteOperationID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeExpiringUserTimeoutWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeExpiringUserTimeoutID) + params:params]; +} + +- (void)writeAttributeExpiringUserTimeoutWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeExpiringUserTimeoutWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeExpiringUserTimeoutWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeExpiringUserTimeoutID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterDoorLockID) + attributeId:@(MTRClusterDoorLockAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterWindowCovering + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::WindowCoveringCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::WindowCoveringCluster * cppCluster = new chip::Controller::WindowCoveringCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)upOrOpenWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self upOrOpenWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)upOrOpenWithParams:(MTRWindowCoveringClusterUpOrOpenParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::WindowCoveringCluster * cppCluster) { + ListFreer listFreer; + WindowCovering::Commands::UpOrOpen::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)downOrCloseWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self downOrCloseWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)downOrCloseWithParams:(MTRWindowCoveringClusterDownOrCloseParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::WindowCoveringCluster * cppCluster) { + ListFreer listFreer; + WindowCovering::Commands::DownOrClose::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stopMotionWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self stopMotionWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)stopMotionWithParams:(MTRWindowCoveringClusterStopMotionParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::WindowCoveringCluster * cppCluster) { + ListFreer listFreer; + WindowCovering::Commands::StopMotion::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)goToLiftValueWithParams:(MTRWindowCoveringClusterGoToLiftValueParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::WindowCoveringCluster * cppCluster) { + ListFreer listFreer; + WindowCovering::Commands::GoToLiftValue::Type request; + request.liftValue = params.liftValue.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)goToLiftPercentageWithParams:(MTRWindowCoveringClusterGoToLiftPercentageParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::WindowCoveringCluster * cppCluster) { + ListFreer listFreer; + WindowCovering::Commands::GoToLiftPercentage::Type request; + request.liftPercent100thsValue = params.liftPercent100thsValue.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)goToTiltValueWithParams:(MTRWindowCoveringClusterGoToTiltValueParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::WindowCoveringCluster * cppCluster) { + ListFreer listFreer; + WindowCovering::Commands::GoToTiltValue::Type request; + request.tiltValue = params.tiltValue.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)goToTiltPercentageWithParams:(MTRWindowCoveringClusterGoToTiltPercentageParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::WindowCoveringCluster * cppCluster) { + ListFreer listFreer; + WindowCovering::Commands::GoToTiltPercentage::Type request; + request.tiltPercent100thsValue = params.tiltPercent100thsValue.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeTypeID) + params:params]; +} + +- (NSDictionary *)readAttributePhysicalClosedLimitLiftWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributePhysicalClosedLimitLiftID) + params:params]; +} + +- (NSDictionary *)readAttributePhysicalClosedLimitTiltWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributePhysicalClosedLimitTiltID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentPositionLiftWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeCurrentPositionLiftID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentPositionTiltWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeCurrentPositionTiltID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfActuationsLiftWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeNumberOfActuationsLiftID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfActuationsTiltWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeNumberOfActuationsTiltID) + params:params]; +} + +- (NSDictionary *)readAttributeConfigStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeConfigStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentPositionLiftPercentageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeCurrentPositionLiftPercentageID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentPositionTiltPercentageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeCurrentPositionTiltPercentageID) + params:params]; +} + +- (NSDictionary *)readAttributeOperationalStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeOperationalStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeTargetPositionLiftPercent100thsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeTargetPositionLiftPercent100thsID) + params:params]; +} + +- (NSDictionary *)readAttributeTargetPositionTiltPercent100thsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeTargetPositionTiltPercent100thsID) + params:params]; +} + +- (NSDictionary *)readAttributeEndProductTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeEndProductTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentPositionLiftPercent100thsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeCurrentPositionLiftPercent100thsID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentPositionTiltPercent100thsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeCurrentPositionTiltPercent100thsID) + params:params]; +} + +- (NSDictionary *)readAttributeInstalledOpenLimitLiftWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeInstalledOpenLimitLiftID) + params:params]; +} + +- (NSDictionary *)readAttributeInstalledClosedLimitLiftWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeInstalledClosedLimitLiftID) + params:params]; +} + +- (NSDictionary *)readAttributeInstalledOpenLimitTiltWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeInstalledOpenLimitTiltID) + params:params]; +} + +- (NSDictionary *)readAttributeInstalledClosedLimitTiltWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeInstalledClosedLimitTiltID) + params:params]; +} + +- (NSDictionary *)readAttributeModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeModeID) + params:params]; +} + +- (void)writeAttributeModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSafetyStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeSafetyStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWindowCoveringID) + attributeId:@(MTRClusterWindowCoveringAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterBarrierControl + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::BarrierControlCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::BarrierControlCluster * cppCluster = new chip::Controller::BarrierControlCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)barrierControlGoToPercentWithParams:(MTRBarrierControlClusterBarrierControlGoToPercentParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BarrierControlCluster * cppCluster) { + ListFreer listFreer; + BarrierControl::Commands::BarrierControlGoToPercent::Type request; + request.percentOpen = params.percentOpen.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)barrierControlStopWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self barrierControlStopWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)barrierControlStopWithParams:(MTRBarrierControlClusterBarrierControlStopParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::BarrierControlCluster * cppCluster) { + ListFreer listFreer; + BarrierControl::Commands::BarrierControlStop::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeBarrierMovingStateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierMovingStateID) + params:params]; +} + +- (NSDictionary *)readAttributeBarrierSafetyStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierSafetyStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeBarrierCapabilitiesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierCapabilitiesID) + params:params]; +} + +- (NSDictionary *)readAttributeBarrierOpenEventsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierOpenEventsID) + params:params]; +} + +- (void)writeAttributeBarrierOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBarrierOpenEventsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBarrierOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierOpenEventsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBarrierCloseEventsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierCloseEventsID) + params:params]; +} + +- (void)writeAttributeBarrierCloseEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBarrierCloseEventsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBarrierCloseEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierCloseEventsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBarrierCommandOpenEventsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierCommandOpenEventsID) + params:params]; +} + +- (void)writeAttributeBarrierCommandOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBarrierCommandOpenEventsWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeBarrierCommandOpenEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierCommandOpenEventsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBarrierCommandCloseEventsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierCommandCloseEventsID) + params:params]; +} + +- (void)writeAttributeBarrierCommandCloseEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBarrierCommandCloseEventsWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeBarrierCommandCloseEventsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierCommandCloseEventsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBarrierOpenPeriodWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierOpenPeriodID) + params:params]; +} + +- (void)writeAttributeBarrierOpenPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBarrierOpenPeriodWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBarrierOpenPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierOpenPeriodID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBarrierClosePeriodWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierClosePeriodID) + params:params]; +} + +- (void)writeAttributeBarrierClosePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBarrierClosePeriodWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBarrierClosePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierClosePeriodID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBarrierPositionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeBarrierPositionID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBarrierControlID) + attributeId:@(MTRClusterBarrierControlAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterPumpConfigurationAndControl + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::PumpConfigurationAndControlCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster + = new chip::Controller::PumpConfigurationAndControlCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeMaxPressureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMaxPressureID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxSpeedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMaxSpeedID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxFlowWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMaxFlowID) + params:params]; +} + +- (NSDictionary *)readAttributeMinConstPressureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMinConstPressureID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxConstPressureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMaxConstPressureID) + params:params]; +} + +- (NSDictionary *)readAttributeMinCompPressureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMinCompPressureID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxCompPressureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMaxCompPressureID) + params:params]; +} + +- (NSDictionary *)readAttributeMinConstSpeedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMinConstSpeedID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxConstSpeedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMaxConstSpeedID) + params:params]; +} + +- (NSDictionary *)readAttributeMinConstFlowWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMinConstFlowID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxConstFlowWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMaxConstFlowID) + params:params]; +} + +- (NSDictionary *)readAttributeMinConstTempWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMinConstTempID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxConstTempWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeMaxConstTempID) + params:params]; +} + +- (NSDictionary *)readAttributePumpStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributePumpStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeEffectiveOperationModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeEffectiveOperationModeID) + params:params]; +} + +- (NSDictionary *)readAttributeEffectiveControlModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeEffectiveControlModeID) + params:params]; +} + +- (NSDictionary *)readAttributeCapacityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeCapacityID) + params:params]; +} + +- (NSDictionary *)readAttributeSpeedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeSpeedID) + params:params]; +} + +- (NSDictionary *)readAttributeLifetimeRunningHoursWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeLifetimeRunningHoursID) + params:params]; +} + +- (void)writeAttributeLifetimeRunningHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLifetimeRunningHoursWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLifetimeRunningHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeLifetimeRunningHoursID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributePowerID) + params:params]; +} + +- (NSDictionary *)readAttributeLifetimeEnergyConsumedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeLifetimeEnergyConsumedID) + params:params]; +} + +- (void)writeAttributeLifetimeEnergyConsumedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLifetimeEnergyConsumedWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeLifetimeEnergyConsumedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeLifetimeEnergyConsumedID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOperationModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeOperationModeID) + params:params]; +} + +- (void)writeAttributeOperationModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOperationModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOperationModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeOperationModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeControlModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeControlModeID) + params:params]; +} + +- (void)writeAttributeControlModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeControlModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeControlModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeControlModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPumpConfigurationAndControlID) + attributeId:@(MTRClusterPumpConfigurationAndControlAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterThermostat + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ThermostatCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ThermostatCluster * cppCluster = new chip::Controller::ThermostatCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)setpointRaiseLowerWithParams:(MTRThermostatClusterSetpointRaiseLowerParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ThermostatCluster * cppCluster) { + ListFreer listFreer; + Thermostat::Commands::SetpointRaiseLower::Type request; + request.mode = static_cast>(params.mode.unsignedCharValue); + request.amount = params.amount.charValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)setWeeklyScheduleWithParams:(MTRThermostatClusterSetWeeklyScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ThermostatCluster * cppCluster) { + ListFreer listFreer; + Thermostat::Commands::SetWeeklySchedule::Type request; + request.numberOfTransitionsForSequence = params.numberOfTransitionsForSequence.unsignedCharValue; + request.dayOfWeekForSequence = static_cast>( + params.dayOfWeekForSequence.unsignedCharValue); + request.modeForSequence + = static_cast>(params.modeForSequence.unsignedCharValue); + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.transitions.count != 0) { + auto * listHolder_0 = new ListHolder(params.transitions.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.transitions.count; ++i_0) { + if (![params.transitions[i_0] isKindOfClass:[MTRThermostatClusterThermostatScheduleTransition class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (MTRThermostatClusterThermostatScheduleTransition *) params.transitions[i_0]; + listHolder_0->mList[i_0].transitionTime = element_0.transitionTime.unsignedShortValue; + if (element_0.heatSetpoint == nil) { + listHolder_0->mList[i_0].heatSetpoint.SetNull(); + } else { + auto & nonNullValue_2 = listHolder_0->mList[i_0].heatSetpoint.SetNonNull(); + nonNullValue_2 = element_0.heatSetpoint.shortValue; + } + if (element_0.coolSetpoint == nil) { + listHolder_0->mList[i_0].coolSetpoint.SetNull(); + } else { + auto & nonNullValue_2 = listHolder_0->mList[i_0].coolSetpoint.SetNonNull(); + nonNullValue_2 = element_0.coolSetpoint.shortValue; + } + } + request.transitions = ListType_0(listHolder_0->mList, params.transitions.count); + } else { + request.transitions = ListType_0(); + } + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getWeeklyScheduleWithParams:(MTRThermostatClusterGetWeeklyScheduleParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRThermostatClusterGetWeeklyScheduleResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ThermostatCluster * cppCluster) { + ListFreer listFreer; + Thermostat::Commands::GetWeeklySchedule::Type request; + request.daysToReturn + = static_cast>(params.daysToReturn.unsignedCharValue); + request.modeToReturn + = static_cast>(params.modeToReturn.unsignedCharValue); + + new MTRThermostatClusterGetWeeklyScheduleResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)clearWeeklyScheduleWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self clearWeeklyScheduleWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)clearWeeklyScheduleWithParams:(MTRThermostatClusterClearWeeklyScheduleParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ThermostatCluster * cppCluster) { + ListFreer listFreer; + Thermostat::Commands::ClearWeeklySchedule::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeLocalTemperatureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeLocalTemperatureID) + params:params]; +} + +- (NSDictionary *)readAttributeOutdoorTemperatureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOutdoorTemperatureID) + params:params]; +} + +- (NSDictionary *)readAttributeOccupancyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupancyID) + params:params]; +} + +- (NSDictionary *)readAttributeAbsMinHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeAbsMinHeatSetpointLimitID) + params:params]; +} + +- (NSDictionary *)readAttributeAbsMaxHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeAbsMaxHeatSetpointLimitID) + params:params]; +} + +- (NSDictionary *)readAttributeAbsMinCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeAbsMinCoolSetpointLimitID) + params:params]; +} + +- (NSDictionary *)readAttributeAbsMaxCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeAbsMaxCoolSetpointLimitID) + params:params]; +} + +- (NSDictionary *)readAttributePICoolingDemandWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributePICoolingDemandID) + params:params]; +} + +- (NSDictionary *)readAttributePIHeatingDemandWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributePIHeatingDemandID) + params:params]; +} + +- (NSDictionary *)readAttributeHVACSystemTypeConfigurationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeHVACSystemTypeConfigurationID) + params:params]; +} + +- (void)writeAttributeHVACSystemTypeConfigurationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeHVACSystemTypeConfigurationWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeHVACSystemTypeConfigurationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeHVACSystemTypeConfigurationID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLocalTemperatureCalibrationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeLocalTemperatureCalibrationID) + params:params]; +} + +- (void)writeAttributeLocalTemperatureCalibrationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLocalTemperatureCalibrationWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeLocalTemperatureCalibrationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeLocalTemperatureCalibrationID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOccupiedCoolingSetpointWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupiedCoolingSetpointID) + params:params]; +} + +- (void)writeAttributeOccupiedCoolingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOccupiedCoolingSetpointWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeOccupiedCoolingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupiedCoolingSetpointID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOccupiedHeatingSetpointWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupiedHeatingSetpointID) + params:params]; +} + +- (void)writeAttributeOccupiedHeatingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOccupiedHeatingSetpointWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeOccupiedHeatingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupiedHeatingSetpointID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUnoccupiedCoolingSetpointWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeUnoccupiedCoolingSetpointID) + params:params]; +} + +- (void)writeAttributeUnoccupiedCoolingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeUnoccupiedCoolingSetpointWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeUnoccupiedCoolingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeUnoccupiedCoolingSetpointID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUnoccupiedHeatingSetpointWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeUnoccupiedHeatingSetpointID) + params:params]; +} + +- (void)writeAttributeUnoccupiedHeatingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeUnoccupiedHeatingSetpointWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeUnoccupiedHeatingSetpointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeUnoccupiedHeatingSetpointID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeMinHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMinHeatSetpointLimitID) + params:params]; +} + +- (void)writeAttributeMinHeatSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeMinHeatSetpointLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeMinHeatSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMinHeatSetpointLimitID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeMaxHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMaxHeatSetpointLimitID) + params:params]; +} + +- (void)writeAttributeMaxHeatSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeMaxHeatSetpointLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeMaxHeatSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMaxHeatSetpointLimitID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeMinCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMinCoolSetpointLimitID) + params:params]; +} + +- (void)writeAttributeMinCoolSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeMinCoolSetpointLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeMinCoolSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMinCoolSetpointLimitID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeMaxCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMaxCoolSetpointLimitID) + params:params]; +} + +- (void)writeAttributeMaxCoolSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeMaxCoolSetpointLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeMaxCoolSetpointLimitWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMaxCoolSetpointLimitID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeMinSetpointDeadBandWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMinSetpointDeadBandID) + params:params]; +} + +- (void)writeAttributeMinSetpointDeadBandWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeMinSetpointDeadBandWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeMinSetpointDeadBandWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeMinSetpointDeadBandID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRemoteSensingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeRemoteSensingID) + params:params]; +} + +- (void)writeAttributeRemoteSensingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRemoteSensingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeRemoteSensingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeRemoteSensingID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeControlSequenceOfOperationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeControlSequenceOfOperationID) + params:params]; +} + +- (void)writeAttributeControlSequenceOfOperationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeControlSequenceOfOperationWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeControlSequenceOfOperationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeControlSequenceOfOperationID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSystemModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeSystemModeID) + params:params]; +} + +- (void)writeAttributeSystemModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeSystemModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeSystemModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeSystemModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeThermostatRunningModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeThermostatRunningModeID) + params:params]; +} + +- (NSDictionary *)readAttributeStartOfWeekWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeStartOfWeekID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfWeeklyTransitionsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeNumberOfWeeklyTransitionsID) + params:params]; +} + +- (NSDictionary *)readAttributeNumberOfDailyTransitionsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeNumberOfDailyTransitionsID) + params:params]; +} + +- (NSDictionary *)readAttributeTemperatureSetpointHoldWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeTemperatureSetpointHoldID) + params:params]; +} + +- (void)writeAttributeTemperatureSetpointHoldWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeTemperatureSetpointHoldWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeTemperatureSetpointHoldWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeTemperatureSetpointHoldID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeTemperatureSetpointHoldDurationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeTemperatureSetpointHoldDurationID) + params:params]; +} + +- (void)writeAttributeTemperatureSetpointHoldDurationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeTemperatureSetpointHoldDurationWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeTemperatureSetpointHoldDurationWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeTemperatureSetpointHoldDurationID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeThermostatProgrammingOperationModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeThermostatProgrammingOperationModeID) + params:params]; +} + +- (void)writeAttributeThermostatProgrammingOperationModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeThermostatProgrammingOperationModeWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeThermostatProgrammingOperationModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeThermostatProgrammingOperationModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeThermostatRunningStateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeThermostatRunningStateID) + params:params]; +} + +- (NSDictionary *)readAttributeSetpointChangeSourceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeSetpointChangeSourceID) + params:params]; +} + +- (NSDictionary *)readAttributeSetpointChangeAmountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeSetpointChangeAmountID) + params:params]; +} + +- (NSDictionary *)readAttributeSetpointChangeSourceTimestampWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeSetpointChangeSourceTimestampID) + params:params]; +} + +- (NSDictionary *)readAttributeOccupiedSetbackWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupiedSetbackID) + params:params]; +} + +- (void)writeAttributeOccupiedSetbackWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOccupiedSetbackWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOccupiedSetbackWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupiedSetbackID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOccupiedSetbackMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupiedSetbackMinID) + params:params]; +} + +- (NSDictionary *)readAttributeOccupiedSetbackMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeOccupiedSetbackMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeUnoccupiedSetbackWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeUnoccupiedSetbackID) + params:params]; +} + +- (void)writeAttributeUnoccupiedSetbackWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeUnoccupiedSetbackWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeUnoccupiedSetbackWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeUnoccupiedSetbackID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUnoccupiedSetbackMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeUnoccupiedSetbackMinID) + params:params]; +} + +- (NSDictionary *)readAttributeUnoccupiedSetbackMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeUnoccupiedSetbackMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeEmergencyHeatDeltaWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeEmergencyHeatDeltaID) + params:params]; +} + +- (void)writeAttributeEmergencyHeatDeltaWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEmergencyHeatDeltaWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeEmergencyHeatDeltaWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeEmergencyHeatDeltaID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeACTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACTypeID) + params:params]; +} + +- (void)writeAttributeACTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeACTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeACTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACTypeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeACCapacityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACCapacityID) + params:params]; +} + +- (void)writeAttributeACCapacityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeACCapacityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeACCapacityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACCapacityID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeACRefrigerantTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACRefrigerantTypeID) + params:params]; +} + +- (void)writeAttributeACRefrigerantTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeACRefrigerantTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeACRefrigerantTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACRefrigerantTypeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeACCompressorTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACCompressorTypeID) + params:params]; +} + +- (void)writeAttributeACCompressorTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeACCompressorTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeACCompressorTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACCompressorTypeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeACErrorCodeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACErrorCodeID) + params:params]; +} + +- (void)writeAttributeACErrorCodeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeACErrorCodeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeACErrorCodeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACErrorCodeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeACLouverPositionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACLouverPositionID) + params:params]; +} + +- (void)writeAttributeACLouverPositionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeACLouverPositionWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeACLouverPositionWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACLouverPositionID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeACCoilTemperatureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACCoilTemperatureID) + params:params]; +} + +- (NSDictionary *)readAttributeACCapacityformatWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACCapacityformatID) + params:params]; +} + +- (void)writeAttributeACCapacityformatWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeACCapacityformatWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeACCapacityformatWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeACCapacityformatID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatID) + attributeId:@(MTRClusterThermostatAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterFanControl + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::FanControlCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::FanControlCluster * cppCluster = new chip::Controller::FanControlCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeFanModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeFanModeID) + params:params]; +} + +- (void)writeAttributeFanModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeFanModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeFanModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeFanModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeFanModeSequenceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeFanModeSequenceID) + params:params]; +} + +- (void)writeAttributeFanModeSequenceWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeFanModeSequenceWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeFanModeSequenceWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeFanModeSequenceID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePercentSettingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributePercentSettingID) + params:params]; +} + +- (void)writeAttributePercentSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributePercentSettingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributePercentSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributePercentSettingID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePercentCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributePercentCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeSpeedMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeSpeedMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeSpeedSettingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeSpeedSettingID) + params:params]; +} + +- (void)writeAttributeSpeedSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeSpeedSettingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeSpeedSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeSpeedSettingID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeSpeedCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeSpeedCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeRockSupportWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeRockSupportID) + params:params]; +} + +- (NSDictionary *)readAttributeRockSettingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeRockSettingID) + params:params]; +} + +- (void)writeAttributeRockSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRockSettingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeRockSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeRockSettingID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeWindSupportWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeWindSupportID) + params:params]; +} + +- (NSDictionary *)readAttributeWindSettingWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeWindSettingID) + params:params]; +} + +- (void)writeAttributeWindSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeWindSettingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeWindSettingWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeWindSettingID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFanControlID) + attributeId:@(MTRClusterFanControlAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterThermostatUserInterfaceConfiguration + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster + = new chip::Controller::ThermostatUserInterfaceConfigurationCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeTemperatureDisplayModeWithParams:(MTRReadParams * _Nullable)params +{ + return + [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeTemperatureDisplayModeID) + params:params]; +} + +- (void)writeAttributeTemperatureDisplayModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeTemperatureDisplayModeWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeTemperatureDisplayModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeTemperatureDisplayModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeKeypadLockoutWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeKeypadLockoutID) + params:params]; +} + +- (void)writeAttributeKeypadLockoutWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeKeypadLockoutWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeKeypadLockoutWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeKeypadLockoutID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeScheduleProgrammingVisibilityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device + readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeScheduleProgrammingVisibilityID) + params:params]; +} + +- (void)writeAttributeScheduleProgrammingVisibilityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeScheduleProgrammingVisibilityWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeScheduleProgrammingVisibilityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device + writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeScheduleProgrammingVisibilityID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterThermostatUserInterfaceConfigurationID) + attributeId:@(MTRClusterThermostatUserInterfaceConfigurationAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterColorControl + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ColorControlCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ColorControlCluster * cppCluster = new chip::Controller::ColorControlCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)moveToHueWithParams:(MTRColorControlClusterMoveToHueParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveToHue::Type request; + request.hue = params.hue.unsignedCharValue; + request.direction = static_cast>(params.direction.unsignedCharValue); + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveHueWithParams:(MTRColorControlClusterMoveHueParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveHue::Type request; + request.moveMode = static_cast>(params.moveMode.unsignedCharValue); + request.rate = params.rate.unsignedCharValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stepHueWithParams:(MTRColorControlClusterStepHueParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::StepHue::Type request; + request.stepMode = static_cast>(params.stepMode.unsignedCharValue); + request.stepSize = params.stepSize.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedCharValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveToSaturationWithParams:(MTRColorControlClusterMoveToSaturationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveToSaturation::Type request; + request.saturation = params.saturation.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveSaturationWithParams:(MTRColorControlClusterMoveSaturationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveSaturation::Type request; + request.moveMode = static_cast>(params.moveMode.unsignedCharValue); + request.rate = params.rate.unsignedCharValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stepSaturationWithParams:(MTRColorControlClusterStepSaturationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::StepSaturation::Type request; + request.stepMode = static_cast>(params.stepMode.unsignedCharValue); + request.stepSize = params.stepSize.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedCharValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveToHueAndSaturationWithParams:(MTRColorControlClusterMoveToHueAndSaturationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveToHueAndSaturation::Type request; + request.hue = params.hue.unsignedCharValue; + request.saturation = params.saturation.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveToColorWithParams:(MTRColorControlClusterMoveToColorParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveToColor::Type request; + request.colorX = params.colorX.unsignedShortValue; + request.colorY = params.colorY.unsignedShortValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveColorWithParams:(MTRColorControlClusterMoveColorParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveColor::Type request; + request.rateX = params.rateX.shortValue; + request.rateY = params.rateY.shortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stepColorWithParams:(MTRColorControlClusterStepColorParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::StepColor::Type request; + request.stepX = params.stepX.shortValue; + request.stepY = params.stepY.shortValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveToColorTemperatureWithParams:(MTRColorControlClusterMoveToColorTemperatureParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveToColorTemperature::Type request; + request.colorTemperature = params.colorTemperature.unsignedShortValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)enhancedMoveToHueWithParams:(MTRColorControlClusterEnhancedMoveToHueParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::EnhancedMoveToHue::Type request; + request.enhancedHue = params.enhancedHue.unsignedShortValue; + request.direction = static_cast>(params.direction.unsignedCharValue); + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)enhancedMoveHueWithParams:(MTRColorControlClusterEnhancedMoveHueParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::EnhancedMoveHue::Type request; + request.moveMode = static_cast>(params.moveMode.unsignedCharValue); + request.rate = params.rate.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)enhancedStepHueWithParams:(MTRColorControlClusterEnhancedStepHueParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::EnhancedStepHue::Type request; + request.stepMode = static_cast>(params.stepMode.unsignedCharValue); + request.stepSize = params.stepSize.unsignedShortValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)enhancedMoveToHueAndSaturationWithParams:(MTRColorControlClusterEnhancedMoveToHueAndSaturationParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::EnhancedMoveToHueAndSaturation::Type request; + request.enhancedHue = params.enhancedHue.unsignedShortValue; + request.saturation = params.saturation.unsignedCharValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)colorLoopSetWithParams:(MTRColorControlClusterColorLoopSetParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::ColorLoopSet::Type request; + request.updateFlags + = static_cast>(params.updateFlags.unsignedCharValue); + request.action = static_cast>(params.action.unsignedCharValue); + request.direction = static_cast>(params.direction.unsignedCharValue); + request.time = params.time.unsignedShortValue; + request.startHue = params.startHue.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stopMoveStepWithParams:(MTRColorControlClusterStopMoveStepParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::StopMoveStep::Type request; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)moveColorTemperatureWithParams:(MTRColorControlClusterMoveColorTemperatureParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::MoveColorTemperature::Type request; + request.moveMode = static_cast>(params.moveMode.unsignedCharValue); + request.rate = params.rate.unsignedShortValue; + request.colorTemperatureMinimumMireds = params.colorTemperatureMinimumMireds.unsignedShortValue; + request.colorTemperatureMaximumMireds = params.colorTemperatureMaximumMireds.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stepColorTemperatureWithParams:(MTRColorControlClusterStepColorTemperatureParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ColorControlCluster * cppCluster) { + ListFreer listFreer; + ColorControl::Commands::StepColorTemperature::Type request; + request.stepMode = static_cast>(params.stepMode.unsignedCharValue); + request.stepSize = params.stepSize.unsignedShortValue; + request.transitionTime = params.transitionTime.unsignedShortValue; + request.colorTemperatureMinimumMireds = params.colorTemperatureMinimumMireds.unsignedShortValue; + request.colorTemperatureMaximumMireds = params.colorTemperatureMaximumMireds.unsignedShortValue; + request.optionsMask = params.optionsMask.unsignedCharValue; + request.optionsOverride = params.optionsOverride.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeCurrentHueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeCurrentHueID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentSaturationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeCurrentSaturationID) + params:params]; +} + +- (NSDictionary *)readAttributeRemainingTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeRemainingTimeID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentXWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeCurrentXID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentYWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeCurrentYID) + params:params]; +} + +- (NSDictionary *)readAttributeDriftCompensationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeDriftCompensationID) + params:params]; +} + +- (NSDictionary *)readAttributeCompensationTextWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeCompensationTextID) + params:params]; +} + +- (NSDictionary *)readAttributeColorTemperatureWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorTemperatureID) + params:params]; +} + +- (NSDictionary *)readAttributeColorModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorModeID) + params:params]; +} + +- (NSDictionary *)readAttributeOptionsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeOptionsID) + params:params]; +} + +- (void)writeAttributeOptionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOptionsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOptionsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeOptionsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNumberOfPrimariesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeNumberOfPrimariesID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary1XWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary1XID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary1YWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary1YID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary1IntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary1IntensityID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary2XWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary2XID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary2YWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary2YID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary2IntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary2IntensityID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary3XWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary3XID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary3YWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary3YID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary3IntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary3IntensityID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary4XWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary4XID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary4YWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary4YID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary4IntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary4IntensityID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary5XWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary5XID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary5YWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary5YID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary5IntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary5IntensityID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary6XWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary6XID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary6YWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary6YID) + params:params]; +} + +- (NSDictionary *)readAttributePrimary6IntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributePrimary6IntensityID) + params:params]; +} + +- (NSDictionary *)readAttributeWhitePointXWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeWhitePointXID) + params:params]; +} + +- (void)writeAttributeWhitePointXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeWhitePointXWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeWhitePointXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeWhitePointXID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeWhitePointYWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeWhitePointYID) + params:params]; +} + +- (void)writeAttributeWhitePointYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeWhitePointYWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeWhitePointYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeWhitePointYID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointRXWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointRXID) + params:params]; +} + +- (void)writeAttributeColorPointRXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointRXWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointRXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointRXID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointRYWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointRYID) + params:params]; +} + +- (void)writeAttributeColorPointRYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointRYWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointRYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointRYID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointRIntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointRIntensityID) + params:params]; +} + +- (void)writeAttributeColorPointRIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointRIntensityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointRIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointRIntensityID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointGXWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointGXID) + params:params]; +} + +- (void)writeAttributeColorPointGXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointGXWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointGXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointGXID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointGYWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointGYID) + params:params]; +} + +- (void)writeAttributeColorPointGYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointGYWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointGYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointGYID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointGIntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointGIntensityID) + params:params]; +} + +- (void)writeAttributeColorPointGIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointGIntensityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointGIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointGIntensityID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointBXWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointBXID) + params:params]; +} + +- (void)writeAttributeColorPointBXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointBXWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointBXWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointBXID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointBYWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointBYID) + params:params]; +} + +- (void)writeAttributeColorPointBYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointBYWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointBYWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointBYID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeColorPointBIntensityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointBIntensityID) + params:params]; +} + +- (void)writeAttributeColorPointBIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeColorPointBIntensityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeColorPointBIntensityWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorPointBIntensityID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEnhancedCurrentHueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeEnhancedCurrentHueID) + params:params]; +} + +- (NSDictionary *)readAttributeEnhancedColorModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeEnhancedColorModeID) + params:params]; +} + +- (NSDictionary *)readAttributeColorLoopActiveWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorLoopActiveID) + params:params]; +} + +- (NSDictionary *)readAttributeColorLoopDirectionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorLoopDirectionID) + params:params]; +} + +- (NSDictionary *)readAttributeColorLoopTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorLoopTimeID) + params:params]; +} + +- (NSDictionary *)readAttributeColorLoopStartEnhancedHueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorLoopStartEnhancedHueID) + params:params]; +} + +- (NSDictionary *)readAttributeColorLoopStoredEnhancedHueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorLoopStoredEnhancedHueID) + params:params]; +} + +- (NSDictionary *)readAttributeColorCapabilitiesWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorCapabilitiesID) + params:params]; +} + +- (NSDictionary *)readAttributeColorTempPhysicalMinMiredsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorTempPhysicalMinMiredsID) + params:params]; +} + +- (NSDictionary *)readAttributeColorTempPhysicalMaxMiredsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeColorTempPhysicalMaxMiredsID) + params:params]; +} + +- (NSDictionary *)readAttributeCoupleColorTempToLevelMinMiredsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeCoupleColorTempToLevelMinMiredsID) + params:params]; +} + +- (NSDictionary *)readAttributeStartUpColorTemperatureMiredsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeStartUpColorTemperatureMiredsID) + params:params]; +} + +- (void)writeAttributeStartUpColorTemperatureMiredsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeStartUpColorTemperatureMiredsWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeStartUpColorTemperatureMiredsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeStartUpColorTemperatureMiredsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterColorControlID) + attributeId:@(MTRClusterColorControlAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterBallastConfiguration + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::BallastConfigurationCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::BallastConfigurationCluster * cppCluster = new chip::Controller::BallastConfigurationCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributePhysicalMinLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributePhysicalMinLevelID) + params:params]; +} + +- (NSDictionary *)readAttributePhysicalMaxLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributePhysicalMaxLevelID) + params:params]; +} + +- (NSDictionary *)readAttributeBallastStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeBallastStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeMinLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeMinLevelID) + params:params]; +} + +- (void)writeAttributeMinLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeMinLevelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeMinLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeMinLevelID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeMaxLevelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeMaxLevelID) + params:params]; +} + +- (void)writeAttributeMaxLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeMaxLevelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeMaxLevelWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeMaxLevelID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeIntrinsicBalanceFactorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeIntrinsicBalanceFactorID) + params:params]; +} + +- (void)writeAttributeIntrinsicBalanceFactorWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeIntrinsicBalanceFactorWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeIntrinsicBalanceFactorWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeIntrinsicBalanceFactorID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBallastFactorAdjustmentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeBallastFactorAdjustmentID) + params:params]; +} + +- (void)writeAttributeBallastFactorAdjustmentWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBallastFactorAdjustmentWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeBallastFactorAdjustmentWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeBallastFactorAdjustmentID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLampQuantityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampQuantityID) + params:params]; +} + +- (NSDictionary *)readAttributeLampTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampTypeID) + params:params]; +} + +- (void)writeAttributeLampTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLampTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLampTypeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampTypeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLampManufacturerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampManufacturerID) + params:params]; +} + +- (void)writeAttributeLampManufacturerWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLampManufacturerWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLampManufacturerWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampManufacturerID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLampRatedHoursWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampRatedHoursID) + params:params]; +} + +- (void)writeAttributeLampRatedHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLampRatedHoursWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLampRatedHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampRatedHoursID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLampBurnHoursWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampBurnHoursID) + params:params]; +} + +- (void)writeAttributeLampBurnHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLampBurnHoursWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLampBurnHoursWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampBurnHoursID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLampAlarmModeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampAlarmModeID) + params:params]; +} + +- (void)writeAttributeLampAlarmModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLampAlarmModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLampAlarmModeWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampAlarmModeID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLampBurnHoursTripPointWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampBurnHoursTripPointID) + params:params]; +} + +- (void)writeAttributeLampBurnHoursTripPointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLampBurnHoursTripPointWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeLampBurnHoursTripPointWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeLampBurnHoursTripPointID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterBallastConfigurationID) + attributeId:@(MTRClusterBallastConfigurationAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterIlluminanceMeasurement + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::IlluminanceMeasurementCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::IlluminanceMeasurementCluster * cppCluster = new chip::Controller::IlluminanceMeasurementCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeMinMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeMaxMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeToleranceID) + params:params]; +} + +- (NSDictionary *)readAttributeLightSensorTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeLightSensorTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterIlluminanceMeasurementID) + attributeId:@(MTRClusterIlluminanceMeasurementAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterTemperatureMeasurement + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::TemperatureMeasurementCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::TemperatureMeasurementCluster * cppCluster = new chip::Controller::TemperatureMeasurementCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeMinMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeMaxMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeToleranceID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTemperatureMeasurementID) + attributeId:@(MTRClusterTemperatureMeasurementAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterPressureMeasurement + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::PressureMeasurementCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::PressureMeasurementCluster * cppCluster = new chip::Controller::PressureMeasurementCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeMinMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeMaxMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeToleranceID) + params:params]; +} + +- (NSDictionary *)readAttributeScaledValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeScaledValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMinScaledValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeMinScaledValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxScaledValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeMaxScaledValueID) + params:params]; +} + +- (NSDictionary *)readAttributeScaledToleranceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeScaledToleranceID) + params:params]; +} + +- (NSDictionary *)readAttributeScaleWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeScaleID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterPressureMeasurementID) + attributeId:@(MTRClusterPressureMeasurementAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterFlowMeasurement + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::FlowMeasurementCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::FlowMeasurementCluster * cppCluster = new chip::Controller::FlowMeasurementCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeMinMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeMaxMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeToleranceID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterFlowMeasurementID) + attributeId:@(MTRClusterFlowMeasurementAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterRelativeHumidityMeasurement + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::RelativeHumidityMeasurementCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::RelativeHumidityMeasurementCluster * cppCluster + = new chip::Controller::RelativeHumidityMeasurementCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeMinMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeMaxMeasuredValueID) + params:params]; +} + +- (NSDictionary *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeToleranceID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterRelativeHumidityMeasurementID) + attributeId:@(MTRClusterRelativeHumidityMeasurementAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterOccupancySensing + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::OccupancySensingCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::OccupancySensingCluster * cppCluster = new chip::Controller::OccupancySensingCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeOccupancyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeOccupancyID) + params:params]; +} + +- (NSDictionary *)readAttributeOccupancySensorTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeOccupancySensorTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeOccupancySensorTypeBitmapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeOccupancySensorTypeBitmapID) + params:params]; +} + +- (NSDictionary *)readAttributePirOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePirOccupiedToUnoccupiedDelayID) + params:params]; +} + +- (void)writeAttributePirOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributePirOccupiedToUnoccupiedDelayWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributePirOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePirOccupiedToUnoccupiedDelayID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePirUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePirUnoccupiedToOccupiedDelayID) + params:params]; +} + +- (void)writeAttributePirUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributePirUnoccupiedToOccupiedDelayWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributePirUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePirUnoccupiedToOccupiedDelayID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePirUnoccupiedToOccupiedThresholdWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePirUnoccupiedToOccupiedThresholdID) + params:params]; +} + +- (void)writeAttributePirUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributePirUnoccupiedToOccupiedThresholdWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributePirUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePirUnoccupiedToOccupiedThresholdID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUltrasonicOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeUltrasonicOccupiedToUnoccupiedDelayID) + params:params]; +} + +- (void)writeAttributeUltrasonicOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeUltrasonicOccupiedToUnoccupiedDelayWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeUltrasonicOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeUltrasonicOccupiedToUnoccupiedDelayID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUltrasonicUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedDelayID) + params:params]; +} + +- (void)writeAttributeUltrasonicUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeUltrasonicUnoccupiedToOccupiedDelayWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeUltrasonicUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedDelayID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUltrasonicUnoccupiedToOccupiedThresholdWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedThresholdID) + params:params]; +} + +- (void)writeAttributeUltrasonicUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeUltrasonicUnoccupiedToOccupiedThresholdWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeUltrasonicUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedThresholdID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePhysicalContactOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePhysicalContactOccupiedToUnoccupiedDelayID) + params:params]; +} + +- (void)writeAttributePhysicalContactOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributePhysicalContactOccupiedToUnoccupiedDelayWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributePhysicalContactOccupiedToUnoccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePhysicalContactOccupiedToUnoccupiedDelayID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePhysicalContactUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedDelayID) + params:params]; +} + +- (void)writeAttributePhysicalContactUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributePhysicalContactUnoccupiedToOccupiedDelayWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributePhysicalContactUnoccupiedToOccupiedDelayWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedDelayID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributePhysicalContactUnoccupiedToOccupiedThresholdWithParams: + (MTRReadParams * _Nullable)params +{ + return [self.device + readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedThresholdID) + params:params]; +} + +- (void)writeAttributePhysicalContactUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributePhysicalContactUnoccupiedToOccupiedThresholdWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributePhysicalContactUnoccupiedToOccupiedThresholdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedThresholdID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterOccupancySensingID) + attributeId:@(MTRClusterOccupancySensingAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterWakeOnLan + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::WakeOnLanCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::WakeOnLanCluster * cppCluster = new chip::Controller::WakeOnLanCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeMACAddressWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWakeOnLanID) + attributeId:@(MTRClusterWakeOnLanAttributeMACAddressID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWakeOnLanID) + attributeId:@(MTRClusterWakeOnLanAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWakeOnLanID) + attributeId:@(MTRClusterWakeOnLanAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWakeOnLanID) + attributeId:@(MTRClusterWakeOnLanAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWakeOnLanID) + attributeId:@(MTRClusterWakeOnLanAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterWakeOnLanID) + attributeId:@(MTRClusterWakeOnLanAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterChannel + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ChannelCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ChannelCluster * cppCluster = new chip::Controller::ChannelCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)changeChannelWithParams:(MTRChannelClusterChangeChannelParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRChannelClusterChangeChannelResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ChannelCluster * cppCluster) { + ListFreer listFreer; + Channel::Commands::ChangeChannel::Type request; + request.match = [self asCharSpan:params.match]; + + new MTRChannelClusterChangeChannelResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)changeChannelByNumberWithParams:(MTRChannelClusterChangeChannelByNumberParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ChannelCluster * cppCluster) { + ListFreer listFreer; + Channel::Commands::ChangeChannelByNumber::Type request; + request.majorNumber = params.majorNumber.unsignedShortValue; + request.minorNumber = params.minorNumber.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)skipChannelWithParams:(MTRChannelClusterSkipChannelParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ChannelCluster * cppCluster) { + ListFreer listFreer; + Channel::Commands::SkipChannel::Type request; + request.count = params.count.unsignedShortValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeChannelListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterChannelID) + attributeId:@(MTRClusterChannelAttributeChannelListID) + params:params]; +} + +- (NSDictionary *)readAttributeLineupWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterChannelID) + attributeId:@(MTRClusterChannelAttributeLineupID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentChannelWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterChannelID) + attributeId:@(MTRClusterChannelAttributeCurrentChannelID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterChannelID) + attributeId:@(MTRClusterChannelAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterChannelID) + attributeId:@(MTRClusterChannelAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterChannelID) + attributeId:@(MTRClusterChannelAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterChannelID) + attributeId:@(MTRClusterChannelAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterChannelID) + attributeId:@(MTRClusterChannelAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterTargetNavigator + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::TargetNavigatorCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::TargetNavigatorCluster * cppCluster = new chip::Controller::TargetNavigatorCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)navigateTargetWithParams:(MTRTargetNavigatorClusterNavigateTargetParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TargetNavigatorCluster * cppCluster) { + ListFreer listFreer; + TargetNavigator::Commands::NavigateTarget::Type request; + request.target = params.target.unsignedCharValue; + if (params.data != nil) { + auto & definedValue_0 = request.data.Emplace(); + definedValue_0 = [self asCharSpan:params.data]; + } + + new MTRTargetNavigatorClusterNavigateTargetResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeTargetListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTargetNavigatorID) + attributeId:@(MTRClusterTargetNavigatorAttributeTargetListID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentTargetWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTargetNavigatorID) + attributeId:@(MTRClusterTargetNavigatorAttributeCurrentTargetID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTargetNavigatorID) + attributeId:@(MTRClusterTargetNavigatorAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTargetNavigatorID) + attributeId:@(MTRClusterTargetNavigatorAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTargetNavigatorID) + attributeId:@(MTRClusterTargetNavigatorAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTargetNavigatorID) + attributeId:@(MTRClusterTargetNavigatorAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTargetNavigatorID) + attributeId:@(MTRClusterTargetNavigatorAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterMediaPlayback + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::MediaPlaybackCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::MediaPlaybackCluster * cppCluster = new chip::Controller::MediaPlaybackCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)playWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self playWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)playWithParams:(MTRMediaPlaybackClusterPlayParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::Play::Type request; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)pauseWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self pauseWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)pauseWithParams:(MTRMediaPlaybackClusterPauseParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::Pause::Type request; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stopPlaybackWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self stopPlaybackWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)stopPlaybackWithParams:(MTRMediaPlaybackClusterStopPlaybackParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::StopPlayback::Type request; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)startOverWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self startOverWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)startOverWithParams:(MTRMediaPlaybackClusterStartOverParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::StartOver::Type request; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)previousWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self previousWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)previousWithParams:(MTRMediaPlaybackClusterPreviousParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::Previous::Type request; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)nextWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self nextWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)nextWithParams:(MTRMediaPlaybackClusterNextParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::Next::Type request; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)rewindWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self rewindWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)rewindWithParams:(MTRMediaPlaybackClusterRewindParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::Rewind::Type request; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)fastForwardWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self fastForwardWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)fastForwardWithParams:(MTRMediaPlaybackClusterFastForwardParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::FastForward::Type request; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)skipForwardWithParams:(MTRMediaPlaybackClusterSkipForwardParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::SkipForward::Type request; + request.deltaPositionMilliseconds = params.deltaPositionMilliseconds.unsignedLongLongValue; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)skipBackwardWithParams:(MTRMediaPlaybackClusterSkipBackwardParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::SkipBackward::Type request; + request.deltaPositionMilliseconds = params.deltaPositionMilliseconds.unsignedLongLongValue; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)seekWithParams:(MTRMediaPlaybackClusterSeekParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaPlaybackCluster * cppCluster) { + ListFreer listFreer; + MediaPlayback::Commands::Seek::Type request; + request.position = params.position.unsignedLongLongValue; + + new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeCurrentStateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeCurrentStateID) + params:params]; +} + +- (NSDictionary *)readAttributeStartTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeStartTimeID) + params:params]; +} + +- (NSDictionary *)readAttributeDurationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeDurationID) + params:params]; +} + +- (NSDictionary *)readAttributeSampledPositionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeSampledPositionID) + params:params]; +} + +- (NSDictionary *)readAttributePlaybackSpeedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributePlaybackSpeedID) + params:params]; +} + +- (NSDictionary *)readAttributeSeekRangeEndWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeSeekRangeEndID) + params:params]; +} + +- (NSDictionary *)readAttributeSeekRangeStartWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeSeekRangeStartID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaPlaybackID) + attributeId:@(MTRClusterMediaPlaybackAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterMediaInput + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::MediaInputCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::MediaInputCluster * cppCluster = new chip::Controller::MediaInputCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)selectInputWithParams:(MTRMediaInputClusterSelectInputParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaInputCluster * cppCluster) { + ListFreer listFreer; + MediaInput::Commands::SelectInput::Type request; + request.index = params.index.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)showInputStatusWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self showInputStatusWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)showInputStatusWithParams:(MTRMediaInputClusterShowInputStatusParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaInputCluster * cppCluster) { + ListFreer listFreer; + MediaInput::Commands::ShowInputStatus::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)hideInputStatusWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self hideInputStatusWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)hideInputStatusWithParams:(MTRMediaInputClusterHideInputStatusParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaInputCluster * cppCluster) { + ListFreer listFreer; + MediaInput::Commands::HideInputStatus::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)renameInputWithParams:(MTRMediaInputClusterRenameInputParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::MediaInputCluster * cppCluster) { + ListFreer listFreer; + MediaInput::Commands::RenameInput::Type request; + request.index = params.index.unsignedCharValue; + request.name = [self asCharSpan:params.name]; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeInputListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaInputID) + attributeId:@(MTRClusterMediaInputAttributeInputListID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentInputWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaInputID) + attributeId:@(MTRClusterMediaInputAttributeCurrentInputID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaInputID) + attributeId:@(MTRClusterMediaInputAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaInputID) + attributeId:@(MTRClusterMediaInputAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaInputID) + attributeId:@(MTRClusterMediaInputAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaInputID) + attributeId:@(MTRClusterMediaInputAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterMediaInputID) + attributeId:@(MTRClusterMediaInputAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterLowPower + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::LowPowerCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::LowPowerCluster * cppCluster = new chip::Controller::LowPowerCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)sleepWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self sleepWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)sleepWithParams:(MTRLowPowerClusterSleepParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::LowPowerCluster * cppCluster) { + ListFreer listFreer; + LowPower::Commands::Sleep::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLowPowerID) + attributeId:@(MTRClusterLowPowerAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLowPowerID) + attributeId:@(MTRClusterLowPowerAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLowPowerID) + attributeId:@(MTRClusterLowPowerAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLowPowerID) + attributeId:@(MTRClusterLowPowerAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterLowPowerID) + attributeId:@(MTRClusterLowPowerAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterKeypadInput + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::KeypadInputCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::KeypadInputCluster * cppCluster = new chip::Controller::KeypadInputCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)sendKeyWithParams:(MTRKeypadInputClusterSendKeyParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRKeypadInputClusterSendKeyResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::KeypadInputCluster * cppCluster) { + ListFreer listFreer; + KeypadInput::Commands::SendKey::Type request; + request.keyCode = static_cast>(params.keyCode.unsignedCharValue); + + new MTRKeypadInputClusterSendKeyResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterKeypadInputID) + attributeId:@(MTRClusterKeypadInputAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterKeypadInputID) + attributeId:@(MTRClusterKeypadInputAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterKeypadInputID) + attributeId:@(MTRClusterKeypadInputAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterKeypadInputID) + attributeId:@(MTRClusterKeypadInputAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterKeypadInputID) + attributeId:@(MTRClusterKeypadInputAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterContentLauncher + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ContentLauncherCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ContentLauncherCluster * cppCluster = new chip::Controller::ContentLauncherCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)launchContentWithParams:(MTRContentLauncherClusterLaunchContentParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRContentLauncherClusterLaunchResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ContentLauncherCluster * cppCluster) { + ListFreer listFreer; + ContentLauncher::Commands::LaunchContent::Type request; + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + if (params.search.parameterList.count != 0) { + auto * listHolder_1 = new ListHolder(params.search.parameterList.count); + if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) { + return; + } + listFreer.add(listHolder_1); + for (size_t i_1 = 0; i_1 < params.search.parameterList.count; ++i_1) { + if (![params.search.parameterList[i_1] isKindOfClass:[MTRContentLauncherClusterParameter class]]) { + // Wrong kind of value. + return; + } + auto element_1 = (MTRContentLauncherClusterParameter *) params.search.parameterList[i_1]; + listHolder_1->mList[i_1].type = static_castmList[i_1].type)>>( + element_1.type.unsignedCharValue); + listHolder_1->mList[i_1].value = [self asCharSpan:element_1.value]; + if (element_1.externalIDList != nil) { + auto & definedValue_3 = listHolder_1->mList[i_1].externalIDList.Emplace(); + { + using ListType_4 = std::remove_reference_t; + using ListMemberType_4 = ListMemberTypeGetter::Type; + if (element_1.externalIDList.count != 0) { + auto * listHolder_4 = new ListHolder(element_1.externalIDList.count); + if (listHolder_4 == nullptr || listHolder_4->mList == nullptr) { + return; + } + listFreer.add(listHolder_4); + for (size_t i_4 = 0; i_4 < element_1.externalIDList.count; ++i_4) { + if (![element_1.externalIDList[i_4] + isKindOfClass:[MTRContentLauncherClusterAdditionalInfo class]]) { + // Wrong kind of value. + return; + } + auto element_4 = (MTRContentLauncherClusterAdditionalInfo *) element_1.externalIDList[i_4]; + listHolder_4->mList[i_4].name = [self asCharSpan:element_4.name]; + listHolder_4->mList[i_4].value = [self asCharSpan:element_4.value]; + } + definedValue_3 = ListType_4(listHolder_4->mList, element_1.externalIDList.count); + } else { + definedValue_3 = ListType_4(); + } + } + } + } + request.search.parameterList = ListType_1(listHolder_1->mList, params.search.parameterList.count); + } else { + request.search.parameterList = ListType_1(); + } + } + request.autoPlay = params.autoPlay.boolValue; + if (params.data != nil) { + auto & definedValue_0 = request.data.Emplace(); + definedValue_0 = [self asCharSpan:params.data]; + } + + new MTRContentLauncherClusterLaunchResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)launchURLWithParams:(MTRContentLauncherClusterLaunchURLParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRContentLauncherClusterLaunchResponseParams * _Nullable data, NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ContentLauncherCluster * cppCluster) { + ListFreer listFreer; + ContentLauncher::Commands::LaunchURL::Type request; + request.contentURL = [self asCharSpan:params.contentURL]; + if (params.displayString != nil) { + auto & definedValue_0 = request.displayString.Emplace(); + definedValue_0 = [self asCharSpan:params.displayString]; + } + if (params.brandingInformation != nil) { + auto & definedValue_0 = request.brandingInformation.Emplace(); + definedValue_0.providerName = [self asCharSpan:params.brandingInformation.providerName]; + if (params.brandingInformation.background != nil) { + auto & definedValue_2 = definedValue_0.background.Emplace(); + if (params.brandingInformation.background.imageUrl != nil) { + auto & definedValue_4 = definedValue_2.imageUrl.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.background.imageUrl]; + } + if (params.brandingInformation.background.color != nil) { + auto & definedValue_4 = definedValue_2.color.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.background.color]; + } + if (params.brandingInformation.background.size != nil) { + auto & definedValue_4 = definedValue_2.size.Emplace(); + definedValue_4.width = params.brandingInformation.background.size.width.doubleValue; + definedValue_4.height = params.brandingInformation.background.size.height.doubleValue; + definedValue_4.metric = static_cast>( + params.brandingInformation.background.size.metric.unsignedCharValue); + } + } + if (params.brandingInformation.logo != nil) { + auto & definedValue_2 = definedValue_0.logo.Emplace(); + if (params.brandingInformation.logo.imageUrl != nil) { + auto & definedValue_4 = definedValue_2.imageUrl.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.logo.imageUrl]; + } + if (params.brandingInformation.logo.color != nil) { + auto & definedValue_4 = definedValue_2.color.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.logo.color]; + } + if (params.brandingInformation.logo.size != nil) { + auto & definedValue_4 = definedValue_2.size.Emplace(); + definedValue_4.width = params.brandingInformation.logo.size.width.doubleValue; + definedValue_4.height = params.brandingInformation.logo.size.height.doubleValue; + definedValue_4.metric = static_cast>( + params.brandingInformation.logo.size.metric.unsignedCharValue); + } + } + if (params.brandingInformation.progressBar != nil) { + auto & definedValue_2 = definedValue_0.progressBar.Emplace(); + if (params.brandingInformation.progressBar.imageUrl != nil) { + auto & definedValue_4 = definedValue_2.imageUrl.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.progressBar.imageUrl]; + } + if (params.brandingInformation.progressBar.color != nil) { + auto & definedValue_4 = definedValue_2.color.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.progressBar.color]; + } + if (params.brandingInformation.progressBar.size != nil) { + auto & definedValue_4 = definedValue_2.size.Emplace(); + definedValue_4.width = params.brandingInformation.progressBar.size.width.doubleValue; + definedValue_4.height = params.brandingInformation.progressBar.size.height.doubleValue; + definedValue_4.metric = static_cast>( + params.brandingInformation.progressBar.size.metric.unsignedCharValue); + } + } + if (params.brandingInformation.splash != nil) { + auto & definedValue_2 = definedValue_0.splash.Emplace(); + if (params.brandingInformation.splash.imageUrl != nil) { + auto & definedValue_4 = definedValue_2.imageUrl.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.splash.imageUrl]; + } + if (params.brandingInformation.splash.color != nil) { + auto & definedValue_4 = definedValue_2.color.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.splash.color]; + } + if (params.brandingInformation.splash.size != nil) { + auto & definedValue_4 = definedValue_2.size.Emplace(); + definedValue_4.width = params.brandingInformation.splash.size.width.doubleValue; + definedValue_4.height = params.brandingInformation.splash.size.height.doubleValue; + definedValue_4.metric = static_cast>( + params.brandingInformation.splash.size.metric.unsignedCharValue); + } + } + if (params.brandingInformation.waterMark != nil) { + auto & definedValue_2 = definedValue_0.waterMark.Emplace(); + if (params.brandingInformation.waterMark.imageUrl != nil) { + auto & definedValue_4 = definedValue_2.imageUrl.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.waterMark.imageUrl]; + } + if (params.brandingInformation.waterMark.color != nil) { + auto & definedValue_4 = definedValue_2.color.Emplace(); + definedValue_4 = [self asCharSpan:params.brandingInformation.waterMark.color]; + } + if (params.brandingInformation.waterMark.size != nil) { + auto & definedValue_4 = definedValue_2.size.Emplace(); + definedValue_4.width = params.brandingInformation.waterMark.size.width.doubleValue; + definedValue_4.height = params.brandingInformation.waterMark.size.height.doubleValue; + definedValue_4.metric = static_cast>( + params.brandingInformation.waterMark.size.metric.unsignedCharValue); + } + } + } + + new MTRContentLauncherClusterLaunchResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeAcceptHeaderWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterContentLauncherID) + attributeId:@(MTRClusterContentLauncherAttributeAcceptHeaderID) + params:params]; +} + +- (NSDictionary *)readAttributeSupportedStreamingProtocolsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterContentLauncherID) + attributeId:@(MTRClusterContentLauncherAttributeSupportedStreamingProtocolsID) + params:params]; +} + +- (void)writeAttributeSupportedStreamingProtocolsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeSupportedStreamingProtocolsWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeSupportedStreamingProtocolsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterContentLauncherID) + attributeId:@(MTRClusterContentLauncherAttributeSupportedStreamingProtocolsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterContentLauncherID) + attributeId:@(MTRClusterContentLauncherAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterContentLauncherID) + attributeId:@(MTRClusterContentLauncherAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterContentLauncherID) + attributeId:@(MTRClusterContentLauncherAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterContentLauncherID) + attributeId:@(MTRClusterContentLauncherAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterContentLauncherID) + attributeId:@(MTRClusterContentLauncherAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterAudioOutput + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::AudioOutputCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::AudioOutputCluster * cppCluster = new chip::Controller::AudioOutputCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)selectOutputWithParams:(MTRAudioOutputClusterSelectOutputParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::AudioOutputCluster * cppCluster) { + ListFreer listFreer; + AudioOutput::Commands::SelectOutput::Type request; + request.index = params.index.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)renameOutputWithParams:(MTRAudioOutputClusterRenameOutputParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::AudioOutputCluster * cppCluster) { + ListFreer listFreer; + AudioOutput::Commands::RenameOutput::Type request; + request.index = params.index.unsignedCharValue; + request.name = [self asCharSpan:params.name]; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeOutputListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAudioOutputID) + attributeId:@(MTRClusterAudioOutputAttributeOutputListID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentOutputWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAudioOutputID) + attributeId:@(MTRClusterAudioOutputAttributeCurrentOutputID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAudioOutputID) + attributeId:@(MTRClusterAudioOutputAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAudioOutputID) + attributeId:@(MTRClusterAudioOutputAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAudioOutputID) + attributeId:@(MTRClusterAudioOutputAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAudioOutputID) + attributeId:@(MTRClusterAudioOutputAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAudioOutputID) + attributeId:@(MTRClusterAudioOutputAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterApplicationLauncher + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ApplicationLauncherCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ApplicationLauncherCluster * cppCluster = new chip::Controller::ApplicationLauncherCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)launchAppWithParams:(MTRApplicationLauncherClusterLaunchAppParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ApplicationLauncherCluster * cppCluster) { + ListFreer listFreer; + ApplicationLauncher::Commands::LaunchApp::Type request; + request.application.catalogVendorId = params.application.catalogVendorId.unsignedShortValue; + request.application.applicationId = [self asCharSpan:params.application.applicationId]; + if (params.data != nil) { + auto & definedValue_0 = request.data.Emplace(); + definedValue_0 = [self asByteSpan:params.data]; + } + + new MTRApplicationLauncherClusterLauncherResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)stopAppWithParams:(MTRApplicationLauncherClusterStopAppParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ApplicationLauncherCluster * cppCluster) { + ListFreer listFreer; + ApplicationLauncher::Commands::StopApp::Type request; + request.application.catalogVendorId = params.application.catalogVendorId.unsignedShortValue; + request.application.applicationId = [self asCharSpan:params.application.applicationId]; + + new MTRApplicationLauncherClusterLauncherResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)hideAppWithParams:(MTRApplicationLauncherClusterHideAppParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ApplicationLauncherCluster * cppCluster) { + ListFreer listFreer; + ApplicationLauncher::Commands::HideApp::Type request; + request.application.catalogVendorId = params.application.catalogVendorId.unsignedShortValue; + request.application.applicationId = [self asCharSpan:params.application.applicationId]; + + new MTRApplicationLauncherClusterLauncherResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeCatalogListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationLauncherID) + attributeId:@(MTRClusterApplicationLauncherAttributeCatalogListID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentAppWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationLauncherID) + attributeId:@(MTRClusterApplicationLauncherAttributeCurrentAppID) + params:params]; +} + +- (void)writeAttributeCurrentAppWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeCurrentAppWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeCurrentAppWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationLauncherID) + attributeId:@(MTRClusterApplicationLauncherAttributeCurrentAppID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationLauncherID) + attributeId:@(MTRClusterApplicationLauncherAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationLauncherID) + attributeId:@(MTRClusterApplicationLauncherAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationLauncherID) + attributeId:@(MTRClusterApplicationLauncherAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationLauncherID) + attributeId:@(MTRClusterApplicationLauncherAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationLauncherID) + attributeId:@(MTRClusterApplicationLauncherAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterApplicationBasic + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ApplicationBasicCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ApplicationBasicCluster * cppCluster = new chip::Controller::ApplicationBasicCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (NSDictionary *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeVendorNameID) + params:params]; +} + +- (NSDictionary *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeVendorIDID) + params:params]; +} + +- (NSDictionary *)readAttributeApplicationNameWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeApplicationNameID) + params:params]; +} + +- (NSDictionary *)readAttributeProductIDWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeProductIDID) + params:params]; +} + +- (NSDictionary *)readAttributeApplicationWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeApplicationID) + params:params]; +} + +- (NSDictionary *)readAttributeStatusWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeStatusID) + params:params]; +} + +- (NSDictionary *)readAttributeApplicationVersionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeApplicationVersionID) + params:params]; +} + +- (NSDictionary *)readAttributeAllowedVendorListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeAllowedVendorListID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterApplicationBasicID) + attributeId:@(MTRClusterApplicationBasicAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterAccountLogin + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::AccountLoginCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::AccountLoginCluster * cppCluster = new chip::Controller::AccountLoginCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)getSetupPINWithParams:(MTRAccountLoginClusterGetSetupPINParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::AccountLoginCluster * cppCluster) { + ListFreer listFreer; + AccountLogin::Commands::GetSetupPIN::Type request; + request.tempAccountIdentifier = [self asCharSpan:params.tempAccountIdentifier]; + + new MTRAccountLoginClusterGetSetupPINResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)loginWithParams:(MTRAccountLoginClusterLoginParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::AccountLoginCluster * cppCluster) { + ListFreer listFreer; + AccountLogin::Commands::Login::Type request; + request.tempAccountIdentifier = [self asCharSpan:params.tempAccountIdentifier]; + request.setupPIN = [self asCharSpan:params.setupPIN]; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)logoutWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self logoutWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)logoutWithParams:(MTRAccountLoginClusterLogoutParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::AccountLoginCluster * cppCluster) { + ListFreer listFreer; + AccountLogin::Commands::Logout::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccountLoginID) + attributeId:@(MTRClusterAccountLoginAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccountLoginID) + attributeId:@(MTRClusterAccountLoginAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccountLoginID) + attributeId:@(MTRClusterAccountLoginAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccountLoginID) + attributeId:@(MTRClusterAccountLoginAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterAccountLoginID) + attributeId:@(MTRClusterAccountLoginAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterElectricalMeasurement + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::ElectricalMeasurementCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::ElectricalMeasurementCluster * cppCluster = new chip::Controller::ElectricalMeasurementCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)getProfileInfoCommandWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self getProfileInfoCommandWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)getProfileInfoCommandWithParams:(MTRElectricalMeasurementClusterGetProfileInfoCommandParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ElectricalMeasurementCluster * cppCluster) { + ListFreer listFreer; + ElectricalMeasurement::Commands::GetProfileInfoCommand::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)getMeasurementProfileCommandWithParams:(MTRElectricalMeasurementClusterGetMeasurementProfileCommandParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::ElectricalMeasurementCluster * cppCluster) { + ListFreer listFreer; + ElectricalMeasurement::Commands::GetMeasurementProfileCommand::Type request; + request.attributeId = params.attributeId.unsignedShortValue; + request.startTime = params.startTime.unsignedIntValue; + request.numberOfIntervals = params.numberOfIntervals.unsignedCharValue; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeMeasurementTypeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasurementTypeID) + params:params]; +} + +- (NSDictionary *)readAttributeDcVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeDcVoltageMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcVoltageMinID) + params:params]; +} + +- (NSDictionary *)readAttributeDcVoltageMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcVoltageMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeDcCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeDcCurrentMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcCurrentMinID) + params:params]; +} + +- (NSDictionary *)readAttributeDcCurrentMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcCurrentMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeDcPowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcPowerID) + params:params]; +} + +- (NSDictionary *)readAttributeDcPowerMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcPowerMinID) + params:params]; +} + +- (NSDictionary *)readAttributeDcPowerMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcPowerMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeDcVoltageMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcVoltageMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributeDcVoltageDivisorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcVoltageDivisorID) + params:params]; +} + +- (NSDictionary *)readAttributeDcCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcCurrentMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributeDcCurrentDivisorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcCurrentDivisorID) + params:params]; +} + +- (NSDictionary *)readAttributeDcPowerMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcPowerMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributeDcPowerDivisorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeDcPowerDivisorID) + params:params]; +} + +- (NSDictionary *)readAttributeAcFrequencyWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcFrequencyID) + params:params]; +} + +- (NSDictionary *)readAttributeAcFrequencyMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcFrequencyMinID) + params:params]; +} + +- (NSDictionary *)readAttributeAcFrequencyMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcFrequencyMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeNeutralCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeNeutralCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeTotalActivePowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeTotalActivePowerID) + params:params]; +} + +- (NSDictionary *)readAttributeTotalReactivePowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeTotalReactivePowerID) + params:params]; +} + +- (NSDictionary *)readAttributeTotalApparentPowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeTotalApparentPowerID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasured1stHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasured1stHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasured3rdHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasured3rdHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasured5thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasured5thHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasured7thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasured7thHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasured9thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasured9thHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasured11thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasured11thHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasuredPhase1stHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase1stHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasuredPhase3rdHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase3rdHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasuredPhase5thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase5thHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasuredPhase7thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase7thHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasuredPhase9thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase9thHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeMeasuredPhase11thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase11thHarmonicCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeAcFrequencyMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcFrequencyMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributeAcFrequencyDivisorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcFrequencyDivisorID) + params:params]; +} + +- (NSDictionary *)readAttributePowerMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributePowerMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributePowerDivisorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributePowerDivisorID) + params:params]; +} + +- (NSDictionary *)readAttributeHarmonicCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeHarmonicCurrentMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributePhaseHarmonicCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributePhaseHarmonicCurrentMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributeInstantaneousVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeInstantaneousVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeInstantaneousLineCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeInstantaneousLineCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeInstantaneousActiveCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeInstantaneousActiveCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeInstantaneousReactiveCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeInstantaneousReactiveCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeInstantaneousPowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeInstantaneousPowerID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMinID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMinID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerMinWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerMinID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerMaxWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerMaxID) + params:params]; +} + +- (NSDictionary *)readAttributeReactivePowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeReactivePowerID) + params:params]; +} + +- (NSDictionary *)readAttributeApparentPowerWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeApparentPowerID) + params:params]; +} + +- (NSDictionary *)readAttributePowerFactorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributePowerFactorID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsVoltageMeasurementPeriodWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodID) + params:params]; +} + +- (void)writeAttributeAverageRmsVoltageMeasurementPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeAverageRmsVoltageMeasurementPeriodWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeAverageRmsVoltageMeasurementPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeAverageRmsUnderVoltageCounterWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterID) + params:params]; +} + +- (void)writeAttributeAverageRmsUnderVoltageCounterWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeAverageRmsUnderVoltageCounterWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeAverageRmsUnderVoltageCounterWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRmsExtremeOverVoltagePeriodWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodID) + params:params]; +} + +- (void)writeAttributeRmsExtremeOverVoltagePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRmsExtremeOverVoltagePeriodWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeRmsExtremeOverVoltagePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRmsExtremeUnderVoltagePeriodWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodID) + params:params]; +} + +- (void)writeAttributeRmsExtremeUnderVoltagePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRmsExtremeUnderVoltagePeriodWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeRmsExtremeUnderVoltagePeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRmsVoltageSagPeriodWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagPeriodID) + params:params]; +} + +- (void)writeAttributeRmsVoltageSagPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRmsVoltageSagPeriodWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeRmsVoltageSagPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagPeriodID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRmsVoltageSwellPeriodWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodID) + params:params]; +} + +- (void)writeAttributeRmsVoltageSwellPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRmsVoltageSwellPeriodWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeRmsVoltageSwellPeriodWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeAcVoltageMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcVoltageMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributeAcVoltageDivisorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcVoltageDivisorID) + params:params]; +} + +- (NSDictionary *)readAttributeAcCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcCurrentMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributeAcCurrentDivisorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcCurrentDivisorID) + params:params]; +} + +- (NSDictionary *)readAttributeAcPowerMultiplierWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcPowerMultiplierID) + params:params]; +} + +- (NSDictionary *)readAttributeAcPowerDivisorWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcPowerDivisorID) + params:params]; +} + +- (NSDictionary *)readAttributeOverloadAlarmsMaskWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeOverloadAlarmsMaskID) + params:params]; +} + +- (void)writeAttributeOverloadAlarmsMaskWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOverloadAlarmsMaskWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOverloadAlarmsMaskWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeOverloadAlarmsMaskID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeVoltageOverloadWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeVoltageOverloadID) + params:params]; +} + +- (NSDictionary *)readAttributeCurrentOverloadWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeCurrentOverloadID) + params:params]; +} + +- (NSDictionary *)readAttributeAcOverloadAlarmsMaskWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcOverloadAlarmsMaskID) + params:params]; +} + +- (void)writeAttributeAcOverloadAlarmsMaskWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeAcOverloadAlarmsMaskWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeAcOverloadAlarmsMaskWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcOverloadAlarmsMaskID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeAcVoltageOverloadWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcVoltageOverloadID) + params:params]; +} + +- (NSDictionary *)readAttributeAcCurrentOverloadWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcCurrentOverloadID) + params:params]; +} + +- (NSDictionary *)readAttributeAcActivePowerOverloadWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcActivePowerOverloadID) + params:params]; +} + +- (NSDictionary *)readAttributeAcReactivePowerOverloadWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcReactivePowerOverloadID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsOverVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsOverVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsUnderVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsExtremeOverVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsExtremeUnderVoltageWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltageID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageSagWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageSwellWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellID) + params:params]; +} + +- (NSDictionary *)readAttributeLineCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeLineCurrentPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActiveCurrentPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeReactiveCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeReactiveCurrentPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltagePhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltagePhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageMinPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMinPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageMaxPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMaxPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentMinPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMinPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentMaxPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMaxPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerMinPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerMinPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerMaxPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerMaxPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeReactivePowerPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeReactivePowerPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeApparentPowerPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeApparentPowerPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributePowerFactorPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributePowerFactorPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsVoltageMeasurementPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device + readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsOverVoltageCounterPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsOverVoltageCounterPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsUnderVoltageCounterPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsExtremeOverVoltagePeriodPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsExtremeUnderVoltagePeriodPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageSagPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagPeriodPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageSwellPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodPhaseBID) + params:params]; +} + +- (NSDictionary *)readAttributeLineCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeLineCurrentPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeActiveCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActiveCurrentPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeReactiveCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeReactiveCurrentPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltagePhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltagePhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageMinPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMinPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageMaxPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMaxPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentMinPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMinPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsCurrentMaxPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMaxPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerMinPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerMinPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeActivePowerMaxPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeActivePowerMaxPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeReactivePowerPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeReactivePowerPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeApparentPowerPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeApparentPowerPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributePowerFactorPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributePowerFactorPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsVoltageMeasurementPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device + readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsOverVoltageCounterPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsOverVoltageCounterPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeAverageRmsUnderVoltageCounterPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsExtremeOverVoltagePeriodPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsExtremeUnderVoltagePeriodPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageSagPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagPeriodPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeRmsVoltageSwellPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodPhaseCID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterElectricalMeasurementID) + attributeId:@(MTRClusterElectricalMeasurementAttributeClusterRevisionID) + params:params]; +} + +@end + +@implementation MTRClusterTestCluster + +- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = endpoint; + _device = device; + } + return self; +} + +- (void)connectAndPerformAsync:(void (^)(chip::Controller::TestClusterCluster * cppCluster))asyncBlock +{ + [self.device connectAndPerformAsync:^(MTRBaseDevice * baseDevice) { + chip::DeviceProxy * internalDevice = [baseDevice internalDevice]; + chip::Controller::TestClusterCluster * cppCluster = new chip::Controller::TestClusterCluster( + *internalDevice->GetExchangeManager(), internalDevice->GetSecureSession().Value(), self.endpoint); + asyncBlock(cppCluster); + }]; +} + +- (void)testWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self testWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)testWithParams:(MTRTestClusterClusterTestParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::Test::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testNotHandledWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self testNotHandledWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)testNotHandledWithParams:(MTRTestClusterClusterTestNotHandledParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestNotHandled::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testSpecificWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestSpecificResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + [self testSpecificWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)testSpecificWithParams:(MTRTestClusterClusterTestSpecificParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestSpecificResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestSpecific::Type request; + + new MTRTestClusterClusterTestSpecificResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testUnknownCommandWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self testUnknownCommandWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)testUnknownCommandWithParams:(MTRTestClusterClusterTestUnknownCommandParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestUnknownCommand::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testAddArgumentsWithParams:(MTRTestClusterClusterTestAddArgumentsParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestAddArgumentsResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestAddArguments::Type request; + request.arg1 = params.arg1.unsignedCharValue; + request.arg2 = params.arg2.unsignedCharValue; + + new MTRTestClusterClusterTestAddArgumentsResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testSimpleArgumentRequestWithParams:(MTRTestClusterClusterTestSimpleArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestSimpleArgumentResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestSimpleArgumentRequest::Type request; + request.arg1 = params.arg1.boolValue; + + new MTRTestClusterClusterTestSimpleArgumentResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testStructArrayArgumentRequestWithParams:(MTRTestClusterClusterTestStructArrayArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRTestClusterClusterTestStructArrayArgumentResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestStructArrayArgumentRequest::Type request; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.arg1.count != 0) { + auto * listHolder_0 = new ListHolder(params.arg1.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.arg1.count; ++i_0) { + if (![params.arg1[i_0] isKindOfClass:[MTRTestClusterClusterNestedStructList class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (MTRTestClusterClusterNestedStructList *) params.arg1[i_0]; + listHolder_0->mList[i_0].a = element_0.a.unsignedCharValue; + listHolder_0->mList[i_0].b = element_0.b.boolValue; + listHolder_0->mList[i_0].c.a = element_0.c.a.unsignedCharValue; + listHolder_0->mList[i_0].c.b = element_0.c.b.boolValue; + listHolder_0->mList[i_0].c.c = static_castmList[i_0].c.c)>>( + element_0.c.c.unsignedCharValue); + listHolder_0->mList[i_0].c.d = [self asByteSpan:element_0.c.d]; + listHolder_0->mList[i_0].c.e = [self asCharSpan:element_0.c.e]; + listHolder_0->mList[i_0].c.f = static_castmList[i_0].c.f)>>( + element_0.c.f.unsignedCharValue); + listHolder_0->mList[i_0].c.g = element_0.c.g.floatValue; + listHolder_0->mList[i_0].c.h = element_0.c.h.doubleValue; + { + using ListType_2 = std::remove_reference_tmList[i_0].d)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.d.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.d.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.d.count; ++i_2) { + if (![element_0.d[i_2] isKindOfClass:[MTRTestClusterClusterSimpleStruct class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (MTRTestClusterClusterSimpleStruct *) element_0.d[i_2]; + listHolder_2->mList[i_2].a = element_2.a.unsignedCharValue; + listHolder_2->mList[i_2].b = element_2.b.boolValue; + listHolder_2->mList[i_2].c + = static_castmList[i_2].c)>>( + element_2.c.unsignedCharValue); + listHolder_2->mList[i_2].d = [self asByteSpan:element_2.d]; + listHolder_2->mList[i_2].e = [self asCharSpan:element_2.e]; + listHolder_2->mList[i_2].f + = static_castmList[i_2].f)>>( + element_2.f.unsignedCharValue); + listHolder_2->mList[i_2].g = element_2.g.floatValue; + listHolder_2->mList[i_2].h = element_2.h.doubleValue; + } + listHolder_0->mList[i_0].d = ListType_2(listHolder_2->mList, element_0.d.count); + } else { + listHolder_0->mList[i_0].d = ListType_2(); + } + } + { + using ListType_2 = std::remove_reference_tmList[i_0].e)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.e.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.e.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.e.count; ++i_2) { + if (![element_0.e[i_2] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (NSNumber *) element_0.e[i_2]; + listHolder_2->mList[i_2] = element_2.unsignedIntValue; + } + listHolder_0->mList[i_0].e = ListType_2(listHolder_2->mList, element_0.e.count); + } else { + listHolder_0->mList[i_0].e = ListType_2(); + } + } + { + using ListType_2 = std::remove_reference_tmList[i_0].f)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.f.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.f.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.f.count; ++i_2) { + if (![element_0.f[i_2] isKindOfClass:[NSData class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (NSData *) element_0.f[i_2]; + listHolder_2->mList[i_2] = [self asByteSpan:element_2]; + } + listHolder_0->mList[i_0].f = ListType_2(listHolder_2->mList, element_0.f.count); + } else { + listHolder_0->mList[i_0].f = ListType_2(); + } + } + { + using ListType_2 = std::remove_reference_tmList[i_0].g)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.g.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.g.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.g.count; ++i_2) { + if (![element_0.g[i_2] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (NSNumber *) element_0.g[i_2]; + listHolder_2->mList[i_2] = element_2.unsignedCharValue; + } + listHolder_0->mList[i_0].g = ListType_2(listHolder_2->mList, element_0.g.count); + } else { + listHolder_0->mList[i_0].g = ListType_2(); + } + } + } + request.arg1 = ListType_0(listHolder_0->mList, params.arg1.count); + } else { + request.arg1 = ListType_0(); + } + } + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.arg2.count != 0) { + auto * listHolder_0 = new ListHolder(params.arg2.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.arg2.count; ++i_0) { + if (![params.arg2[i_0] isKindOfClass:[MTRTestClusterClusterSimpleStruct class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (MTRTestClusterClusterSimpleStruct *) params.arg2[i_0]; + listHolder_0->mList[i_0].a = element_0.a.unsignedCharValue; + listHolder_0->mList[i_0].b = element_0.b.boolValue; + listHolder_0->mList[i_0].c + = static_castmList[i_0].c)>>(element_0.c.unsignedCharValue); + listHolder_0->mList[i_0].d = [self asByteSpan:element_0.d]; + listHolder_0->mList[i_0].e = [self asCharSpan:element_0.e]; + listHolder_0->mList[i_0].f + = static_castmList[i_0].f)>>(element_0.f.unsignedCharValue); + listHolder_0->mList[i_0].g = element_0.g.floatValue; + listHolder_0->mList[i_0].h = element_0.h.doubleValue; + } + request.arg2 = ListType_0(listHolder_0->mList, params.arg2.count); + } else { + request.arg2 = ListType_0(); + } + } + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.arg3.count != 0) { + auto * listHolder_0 = new ListHolder(params.arg3.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.arg3.count; ++i_0) { + if (![params.arg3[i_0] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (NSNumber *) params.arg3[i_0]; + listHolder_0->mList[i_0] + = static_castmList[i_0])>>(element_0.unsignedCharValue); + } + request.arg3 = ListType_0(listHolder_0->mList, params.arg3.count); + } else { + request.arg3 = ListType_0(); + } + } + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.arg4.count != 0) { + auto * listHolder_0 = new ListHolder(params.arg4.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.arg4.count; ++i_0) { + if (![params.arg4[i_0] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (NSNumber *) params.arg4[i_0]; + listHolder_0->mList[i_0] = element_0.boolValue; + } + request.arg4 = ListType_0(listHolder_0->mList, params.arg4.count); + } else { + request.arg4 = ListType_0(); + } + } + request.arg5 = static_cast>(params.arg5.unsignedCharValue); + request.arg6 = params.arg6.boolValue; + + new MTRTestClusterClusterTestStructArrayArgumentResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testStructArgumentRequestWithParams:(MTRTestClusterClusterTestStructArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestStructArgumentRequest::Type request; + request.arg1.a = params.arg1.a.unsignedCharValue; + request.arg1.b = params.arg1.b.boolValue; + request.arg1.c = static_cast>(params.arg1.c.unsignedCharValue); + request.arg1.d = [self asByteSpan:params.arg1.d]; + request.arg1.e = [self asCharSpan:params.arg1.e]; + request.arg1.f = static_cast>(params.arg1.f.unsignedCharValue); + request.arg1.g = params.arg1.g.floatValue; + request.arg1.h = params.arg1.h.doubleValue; + + new MTRTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testNestedStructArgumentRequestWithParams:(MTRTestClusterClusterTestNestedStructArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestNestedStructArgumentRequest::Type request; + request.arg1.a = params.arg1.a.unsignedCharValue; + request.arg1.b = params.arg1.b.boolValue; + request.arg1.c.a = params.arg1.c.a.unsignedCharValue; + request.arg1.c.b = params.arg1.c.b.boolValue; + request.arg1.c.c = static_cast>(params.arg1.c.c.unsignedCharValue); + request.arg1.c.d = [self asByteSpan:params.arg1.c.d]; + request.arg1.c.e = [self asCharSpan:params.arg1.c.e]; + request.arg1.c.f = static_cast>(params.arg1.c.f.unsignedCharValue); + request.arg1.c.g = params.arg1.c.g.floatValue; + request.arg1.c.h = params.arg1.c.h.doubleValue; + + new MTRTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testListStructArgumentRequestWithParams:(MTRTestClusterClusterTestListStructArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestListStructArgumentRequest::Type request; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.arg1.count != 0) { + auto * listHolder_0 = new ListHolder(params.arg1.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.arg1.count; ++i_0) { + if (![params.arg1[i_0] isKindOfClass:[MTRTestClusterClusterSimpleStruct class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (MTRTestClusterClusterSimpleStruct *) params.arg1[i_0]; + listHolder_0->mList[i_0].a = element_0.a.unsignedCharValue; + listHolder_0->mList[i_0].b = element_0.b.boolValue; + listHolder_0->mList[i_0].c + = static_castmList[i_0].c)>>(element_0.c.unsignedCharValue); + listHolder_0->mList[i_0].d = [self asByteSpan:element_0.d]; + listHolder_0->mList[i_0].e = [self asCharSpan:element_0.e]; + listHolder_0->mList[i_0].f + = static_castmList[i_0].f)>>(element_0.f.unsignedCharValue); + listHolder_0->mList[i_0].g = element_0.g.floatValue; + listHolder_0->mList[i_0].h = element_0.h.doubleValue; + } + request.arg1 = ListType_0(listHolder_0->mList, params.arg1.count); + } else { + request.arg1 = ListType_0(); + } + } + + new MTRTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testListInt8UArgumentRequestWithParams:(MTRTestClusterClusterTestListInt8UArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestListInt8UArgumentRequest::Type request; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.arg1.count != 0) { + auto * listHolder_0 = new ListHolder(params.arg1.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.arg1.count; ++i_0) { + if (![params.arg1[i_0] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (NSNumber *) params.arg1[i_0]; + listHolder_0->mList[i_0] = element_0.unsignedCharValue; + } + request.arg1 = ListType_0(listHolder_0->mList, params.arg1.count); + } else { + request.arg1 = ListType_0(); + } + } + + new MTRTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testNestedStructListArgumentRequestWithParams:(MTRTestClusterClusterTestNestedStructListArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestNestedStructListArgumentRequest::Type request; + request.arg1.a = params.arg1.a.unsignedCharValue; + request.arg1.b = params.arg1.b.boolValue; + request.arg1.c.a = params.arg1.c.a.unsignedCharValue; + request.arg1.c.b = params.arg1.c.b.boolValue; + request.arg1.c.c = static_cast>(params.arg1.c.c.unsignedCharValue); + request.arg1.c.d = [self asByteSpan:params.arg1.c.d]; + request.arg1.c.e = [self asCharSpan:params.arg1.c.e]; + request.arg1.c.f = static_cast>(params.arg1.c.f.unsignedCharValue); + request.arg1.c.g = params.arg1.c.g.floatValue; + request.arg1.c.h = params.arg1.c.h.doubleValue; + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + if (params.arg1.d.count != 0) { + auto * listHolder_1 = new ListHolder(params.arg1.d.count); + if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) { + return; + } + listFreer.add(listHolder_1); + for (size_t i_1 = 0; i_1 < params.arg1.d.count; ++i_1) { + if (![params.arg1.d[i_1] isKindOfClass:[MTRTestClusterClusterSimpleStruct class]]) { + // Wrong kind of value. + return; + } + auto element_1 = (MTRTestClusterClusterSimpleStruct *) params.arg1.d[i_1]; + listHolder_1->mList[i_1].a = element_1.a.unsignedCharValue; + listHolder_1->mList[i_1].b = element_1.b.boolValue; + listHolder_1->mList[i_1].c + = static_castmList[i_1].c)>>(element_1.c.unsignedCharValue); + listHolder_1->mList[i_1].d = [self asByteSpan:element_1.d]; + listHolder_1->mList[i_1].e = [self asCharSpan:element_1.e]; + listHolder_1->mList[i_1].f + = static_castmList[i_1].f)>>(element_1.f.unsignedCharValue); + listHolder_1->mList[i_1].g = element_1.g.floatValue; + listHolder_1->mList[i_1].h = element_1.h.doubleValue; + } + request.arg1.d = ListType_1(listHolder_1->mList, params.arg1.d.count); + } else { + request.arg1.d = ListType_1(); + } + } + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + if (params.arg1.e.count != 0) { + auto * listHolder_1 = new ListHolder(params.arg1.e.count); + if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) { + return; + } + listFreer.add(listHolder_1); + for (size_t i_1 = 0; i_1 < params.arg1.e.count; ++i_1) { + if (![params.arg1.e[i_1] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_1 = (NSNumber *) params.arg1.e[i_1]; + listHolder_1->mList[i_1] = element_1.unsignedIntValue; + } + request.arg1.e = ListType_1(listHolder_1->mList, params.arg1.e.count); + } else { + request.arg1.e = ListType_1(); + } + } + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + if (params.arg1.f.count != 0) { + auto * listHolder_1 = new ListHolder(params.arg1.f.count); + if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) { + return; + } + listFreer.add(listHolder_1); + for (size_t i_1 = 0; i_1 < params.arg1.f.count; ++i_1) { + if (![params.arg1.f[i_1] isKindOfClass:[NSData class]]) { + // Wrong kind of value. + return; + } + auto element_1 = (NSData *) params.arg1.f[i_1]; + listHolder_1->mList[i_1] = [self asByteSpan:element_1]; + } + request.arg1.f = ListType_1(listHolder_1->mList, params.arg1.f.count); + } else { + request.arg1.f = ListType_1(); + } + } + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + if (params.arg1.g.count != 0) { + auto * listHolder_1 = new ListHolder(params.arg1.g.count); + if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) { + return; + } + listFreer.add(listHolder_1); + for (size_t i_1 = 0; i_1 < params.arg1.g.count; ++i_1) { + if (![params.arg1.g[i_1] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_1 = (NSNumber *) params.arg1.g[i_1]; + listHolder_1->mList[i_1] = element_1.unsignedCharValue; + } + request.arg1.g = ListType_1(listHolder_1->mList, params.arg1.g.count); + } else { + request.arg1.g = ListType_1(); + } + } + + new MTRTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testListNestedStructListArgumentRequestWithParams: + (MTRTestClusterClusterTestListNestedStructListArgumentRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterBooleanResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestListNestedStructListArgumentRequest::Type request; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.arg1.count != 0) { + auto * listHolder_0 = new ListHolder(params.arg1.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.arg1.count; ++i_0) { + if (![params.arg1[i_0] isKindOfClass:[MTRTestClusterClusterNestedStructList class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (MTRTestClusterClusterNestedStructList *) params.arg1[i_0]; + listHolder_0->mList[i_0].a = element_0.a.unsignedCharValue; + listHolder_0->mList[i_0].b = element_0.b.boolValue; + listHolder_0->mList[i_0].c.a = element_0.c.a.unsignedCharValue; + listHolder_0->mList[i_0].c.b = element_0.c.b.boolValue; + listHolder_0->mList[i_0].c.c = static_castmList[i_0].c.c)>>( + element_0.c.c.unsignedCharValue); + listHolder_0->mList[i_0].c.d = [self asByteSpan:element_0.c.d]; + listHolder_0->mList[i_0].c.e = [self asCharSpan:element_0.c.e]; + listHolder_0->mList[i_0].c.f = static_castmList[i_0].c.f)>>( + element_0.c.f.unsignedCharValue); + listHolder_0->mList[i_0].c.g = element_0.c.g.floatValue; + listHolder_0->mList[i_0].c.h = element_0.c.h.doubleValue; + { + using ListType_2 = std::remove_reference_tmList[i_0].d)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.d.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.d.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.d.count; ++i_2) { + if (![element_0.d[i_2] isKindOfClass:[MTRTestClusterClusterSimpleStruct class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (MTRTestClusterClusterSimpleStruct *) element_0.d[i_2]; + listHolder_2->mList[i_2].a = element_2.a.unsignedCharValue; + listHolder_2->mList[i_2].b = element_2.b.boolValue; + listHolder_2->mList[i_2].c + = static_castmList[i_2].c)>>( + element_2.c.unsignedCharValue); + listHolder_2->mList[i_2].d = [self asByteSpan:element_2.d]; + listHolder_2->mList[i_2].e = [self asCharSpan:element_2.e]; + listHolder_2->mList[i_2].f + = static_castmList[i_2].f)>>( + element_2.f.unsignedCharValue); + listHolder_2->mList[i_2].g = element_2.g.floatValue; + listHolder_2->mList[i_2].h = element_2.h.doubleValue; + } + listHolder_0->mList[i_0].d = ListType_2(listHolder_2->mList, element_0.d.count); + } else { + listHolder_0->mList[i_0].d = ListType_2(); + } + } + { + using ListType_2 = std::remove_reference_tmList[i_0].e)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.e.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.e.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.e.count; ++i_2) { + if (![element_0.e[i_2] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (NSNumber *) element_0.e[i_2]; + listHolder_2->mList[i_2] = element_2.unsignedIntValue; + } + listHolder_0->mList[i_0].e = ListType_2(listHolder_2->mList, element_0.e.count); + } else { + listHolder_0->mList[i_0].e = ListType_2(); + } + } + { + using ListType_2 = std::remove_reference_tmList[i_0].f)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.f.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.f.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.f.count; ++i_2) { + if (![element_0.f[i_2] isKindOfClass:[NSData class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (NSData *) element_0.f[i_2]; + listHolder_2->mList[i_2] = [self asByteSpan:element_2]; + } + listHolder_0->mList[i_0].f = ListType_2(listHolder_2->mList, element_0.f.count); + } else { + listHolder_0->mList[i_0].f = ListType_2(); + } + } + { + using ListType_2 = std::remove_reference_tmList[i_0].g)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (element_0.g.count != 0) { + auto * listHolder_2 = new ListHolder(element_0.g.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < element_0.g.count; ++i_2) { + if (![element_0.g[i_2] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (NSNumber *) element_0.g[i_2]; + listHolder_2->mList[i_2] = element_2.unsignedCharValue; + } + listHolder_0->mList[i_0].g = ListType_2(listHolder_2->mList, element_0.g.count); + } else { + listHolder_0->mList[i_0].g = ListType_2(); + } + } + } + request.arg1 = ListType_0(listHolder_0->mList, params.arg1.count); + } else { + request.arg1 = ListType_0(); + } + } + + new MTRTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testListInt8UReverseRequestWithParams:(MTRTestClusterClusterTestListInt8UReverseRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestListInt8UReverseResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestListInt8UReverseRequest::Type request; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.arg1.count != 0) { + auto * listHolder_0 = new ListHolder(params.arg1.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.arg1.count; ++i_0) { + if (![params.arg1[i_0] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_0 = (NSNumber *) params.arg1[i_0]; + listHolder_0->mList[i_0] = element_0.unsignedCharValue; + } + request.arg1 = ListType_0(listHolder_0->mList, params.arg1.count); + } else { + request.arg1 = ListType_0(); + } + } + + new MTRTestClusterClusterTestListInt8UReverseResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testEnumsRequestWithParams:(MTRTestClusterClusterTestEnumsRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestEnumsResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestEnumsRequest::Type request; + request.arg1 = static_cast>(params.arg1.unsignedShortValue); + request.arg2 = static_cast>(params.arg2.unsignedCharValue); + + new MTRTestClusterClusterTestEnumsResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testNullableOptionalRequestWithParams:(MTRTestClusterClusterTestNullableOptionalRequestParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestNullableOptionalResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestNullableOptionalRequest::Type request; + if (params != nil) { + if (params.arg1 != nil) { + auto & definedValue_0 = request.arg1.Emplace(); + if (params.arg1 == nil) { + definedValue_0.SetNull(); + } else { + auto & nonNullValue_1 = definedValue_0.SetNonNull(); + nonNullValue_1 = params.arg1.unsignedCharValue; + } + } + } + + new MTRTestClusterClusterTestNullableOptionalResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testComplexNullableOptionalRequestWithParams:(MTRTestClusterClusterTestComplexNullableOptionalRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)(MTRTestClusterClusterTestComplexNullableOptionalResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestComplexNullableOptionalRequest::Type request; + if (params.nullableInt == nil) { + request.nullableInt.SetNull(); + } else { + auto & nonNullValue_0 = request.nullableInt.SetNonNull(); + nonNullValue_0 = params.nullableInt.unsignedShortValue; + } + if (params.optionalInt != nil) { + auto & definedValue_0 = request.optionalInt.Emplace(); + definedValue_0 = params.optionalInt.unsignedShortValue; + } + if (params.nullableOptionalInt != nil) { + auto & definedValue_0 = request.nullableOptionalInt.Emplace(); + if (params.nullableOptionalInt == nil) { + definedValue_0.SetNull(); + } else { + auto & nonNullValue_1 = definedValue_0.SetNonNull(); + nonNullValue_1 = params.nullableOptionalInt.unsignedShortValue; + } + } + if (params.nullableString == nil) { + request.nullableString.SetNull(); + } else { + auto & nonNullValue_0 = request.nullableString.SetNonNull(); + nonNullValue_0 = [self asCharSpan:params.nullableString]; + } + if (params.optionalString != nil) { + auto & definedValue_0 = request.optionalString.Emplace(); + definedValue_0 = [self asCharSpan:params.optionalString]; + } + if (params.nullableOptionalString != nil) { + auto & definedValue_0 = request.nullableOptionalString.Emplace(); + if (params.nullableOptionalString == nil) { + definedValue_0.SetNull(); + } else { + auto & nonNullValue_1 = definedValue_0.SetNonNull(); + nonNullValue_1 = [self asCharSpan:params.nullableOptionalString]; + } + } + if (params.nullableStruct == nil) { + request.nullableStruct.SetNull(); + } else { + auto & nonNullValue_0 = request.nullableStruct.SetNonNull(); + nonNullValue_0.a = params.nullableStruct.a.unsignedCharValue; + nonNullValue_0.b = params.nullableStruct.b.boolValue; + nonNullValue_0.c + = static_cast>(params.nullableStruct.c.unsignedCharValue); + nonNullValue_0.d = [self asByteSpan:params.nullableStruct.d]; + nonNullValue_0.e = [self asCharSpan:params.nullableStruct.e]; + nonNullValue_0.f + = static_cast>(params.nullableStruct.f.unsignedCharValue); + nonNullValue_0.g = params.nullableStruct.g.floatValue; + nonNullValue_0.h = params.nullableStruct.h.doubleValue; + } + if (params.optionalStruct != nil) { + auto & definedValue_0 = request.optionalStruct.Emplace(); + definedValue_0.a = params.optionalStruct.a.unsignedCharValue; + definedValue_0.b = params.optionalStruct.b.boolValue; + definedValue_0.c + = static_cast>(params.optionalStruct.c.unsignedCharValue); + definedValue_0.d = [self asByteSpan:params.optionalStruct.d]; + definedValue_0.e = [self asCharSpan:params.optionalStruct.e]; + definedValue_0.f + = static_cast>(params.optionalStruct.f.unsignedCharValue); + definedValue_0.g = params.optionalStruct.g.floatValue; + definedValue_0.h = params.optionalStruct.h.doubleValue; + } + if (params.nullableOptionalStruct != nil) { + auto & definedValue_0 = request.nullableOptionalStruct.Emplace(); + if (params.nullableOptionalStruct == nil) { + definedValue_0.SetNull(); + } else { + auto & nonNullValue_1 = definedValue_0.SetNonNull(); + nonNullValue_1.a = params.nullableOptionalStruct.a.unsignedCharValue; + nonNullValue_1.b = params.nullableOptionalStruct.b.boolValue; + nonNullValue_1.c = static_cast>( + params.nullableOptionalStruct.c.unsignedCharValue); + nonNullValue_1.d = [self asByteSpan:params.nullableOptionalStruct.d]; + nonNullValue_1.e = [self asCharSpan:params.nullableOptionalStruct.e]; + nonNullValue_1.f = static_cast>( + params.nullableOptionalStruct.f.unsignedCharValue); + nonNullValue_1.g = params.nullableOptionalStruct.g.floatValue; + nonNullValue_1.h = params.nullableOptionalStruct.h.doubleValue; + } + } + if (params.nullableList == nil) { + request.nullableList.SetNull(); + } else { + auto & nonNullValue_0 = request.nullableList.SetNonNull(); + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + if (params.nullableList.count != 0) { + auto * listHolder_1 = new ListHolder(params.nullableList.count); + if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) { + return; + } + listFreer.add(listHolder_1); + for (size_t i_1 = 0; i_1 < params.nullableList.count; ++i_1) { + if (![params.nullableList[i_1] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_1 = (NSNumber *) params.nullableList[i_1]; + listHolder_1->mList[i_1] + = static_castmList[i_1])>>(element_1.unsignedCharValue); + } + nonNullValue_0 = ListType_1(listHolder_1->mList, params.nullableList.count); + } else { + nonNullValue_0 = ListType_1(); + } + } + } + if (params.optionalList != nil) { + auto & definedValue_0 = request.optionalList.Emplace(); + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + if (params.optionalList.count != 0) { + auto * listHolder_1 = new ListHolder(params.optionalList.count); + if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) { + return; + } + listFreer.add(listHolder_1); + for (size_t i_1 = 0; i_1 < params.optionalList.count; ++i_1) { + if (![params.optionalList[i_1] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_1 = (NSNumber *) params.optionalList[i_1]; + listHolder_1->mList[i_1] + = static_castmList[i_1])>>(element_1.unsignedCharValue); + } + definedValue_0 = ListType_1(listHolder_1->mList, params.optionalList.count); + } else { + definedValue_0 = ListType_1(); + } + } + } + if (params.nullableOptionalList != nil) { + auto & definedValue_0 = request.nullableOptionalList.Emplace(); + if (params.nullableOptionalList == nil) { + definedValue_0.SetNull(); + } else { + auto & nonNullValue_1 = definedValue_0.SetNonNull(); + { + using ListType_2 = std::remove_reference_t; + using ListMemberType_2 = ListMemberTypeGetter::Type; + if (params.nullableOptionalList.count != 0) { + auto * listHolder_2 = new ListHolder(params.nullableOptionalList.count); + if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) { + return; + } + listFreer.add(listHolder_2); + for (size_t i_2 = 0; i_2 < params.nullableOptionalList.count; ++i_2) { + if (![params.nullableOptionalList[i_2] isKindOfClass:[NSNumber class]]) { + // Wrong kind of value. + return; + } + auto element_2 = (NSNumber *) params.nullableOptionalList[i_2]; + listHolder_2->mList[i_2] = static_castmList[i_2])>>( + element_2.unsignedCharValue); + } + nonNullValue_1 = ListType_2(listHolder_2->mList, params.nullableOptionalList.count); + } else { + nonNullValue_1 = ListType_2(); + } + } + } + } + + new MTRTestClusterClusterTestComplexNullableOptionalResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn + = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)simpleStructEchoRequestWithParams:(MTRTestClusterClusterSimpleStructEchoRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterSimpleStructResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::SimpleStructEchoRequest::Type request; + request.arg1.a = params.arg1.a.unsignedCharValue; + request.arg1.b = params.arg1.b.boolValue; + request.arg1.c = static_cast>(params.arg1.c.unsignedCharValue); + request.arg1.d = [self asByteSpan:params.arg1.d]; + request.arg1.e = [self asCharSpan:params.arg1.e]; + request.arg1.f = static_cast>(params.arg1.f.unsignedCharValue); + request.arg1.g = params.arg1.g.floatValue; + request.arg1.h = params.arg1.h.doubleValue; + + new MTRTestClusterClusterSimpleStructResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)timedInvokeRequestWithExpectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + [self timedInvokeRequestWithParams:nil + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + completionHandler:completionHandler]; +} +- (void)timedInvokeRequestWithParams:(MTRTestClusterClusterTimedInvokeRequestParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TimedInvokeRequest::Type request; + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + if (!waitTimeInMs) { + waitTimeInMs = @(10000); + } + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testSimpleOptionalArgumentRequestWithParams:(MTRTestClusterClusterTestSimpleOptionalArgumentRequestParams * _Nullable)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(StatusCompletion)completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestSimpleOptionalArgumentRequest::Type request; + if (params != nil) { + if (params.arg1 != nil) { + auto & definedValue_0 = request.arg1.Emplace(); + definedValue_0 = params.arg1.boolValue; + } + } + + new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testEmitTestEventRequestWithParams:(MTRTestClusterClusterTestEmitTestEventRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler:(void (^)(MTRTestClusterClusterTestEmitTestEventResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestEmitTestEventRequest::Type request; + request.arg1 = params.arg1.unsignedCharValue; + request.arg2 = static_cast>(params.arg2.unsignedCharValue); + request.arg3 = params.arg3.boolValue; + + new MTRTestClusterClusterTestEmitTestEventResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (void)testEmitTestFabricScopedEventRequestWithParams:(MTRTestClusterClusterTestEmitTestFabricScopedEventRequestParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completionHandler: + (void (^)( + MTRTestClusterClusterTestEmitTestFabricScopedEventResponseParams * _Nullable data, + NSError * _Nullable error))completionHandler +{ + NSDate * waitStartTime = [NSDate date]; + [self connectAndPerformAsync:^(chip::Controller::TestClusterCluster * cppCluster) { + ListFreer listFreer; + TestCluster::Commands::TestEmitTestFabricScopedEventRequest::Type request; + request.arg1 = params.arg1.unsignedCharValue; + + new MTRTestClusterClusterTestEmitTestFabricScopedEventResponseCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + NSNumber * waitTimeInMs = params.timedInvokeTimeoutMs; + NSTimeInterval timeSinceWaitStartInMs = [[NSDate date] timeIntervalSinceDate:waitStartTime] * 1000; + if (waitTimeInMs && waitTimeInMs.unsignedShortValue < timeSinceWaitStartInMs) { + return CHIP_ERROR_TIMEOUT; + } + + unsigned short newWaitTimeInMs = waitTimeInMs.unsignedShortValue - timeSinceWaitStartInMs; + + chip::Optional timedInvokeTimeoutMs; + if (waitTimeInMs) { + timedInvokeTimeoutMs.SetValue(newWaitTimeInMs); + } + + auto successFn + = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return cppCluster->InvokeCommand( + request, successFn->mContext, successFn->mCall, failureFn->mCall, timedInvokeTimeoutMs); + }); + + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + }]; +} + +- (NSDictionary *)readAttributeBooleanWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBooleanID) + params:params]; +} + +- (void)writeAttributeBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBooleanID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBitmap8WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBitmap8ID) + params:params]; +} + +- (void)writeAttributeBitmap8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBitmap8WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBitmap8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBitmap8ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBitmap16WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBitmap16ID) + params:params]; +} + +- (void)writeAttributeBitmap16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBitmap16WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBitmap16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBitmap16ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBitmap32WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBitmap32ID) + params:params]; +} + +- (void)writeAttributeBitmap32WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBitmap32WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBitmap32WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBitmap32ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeBitmap64WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBitmap64ID) + params:params]; +} + +- (void)writeAttributeBitmap64WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeBitmap64WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeBitmap64WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeBitmap64ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt8uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt8uID) + params:params]; +} + +- (void)writeAttributeInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt8uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt16uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt16uID) + params:params]; +} + +- (void)writeAttributeInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt16uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt16uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt24uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt24uID) + params:params]; +} + +- (void)writeAttributeInt24uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt24uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt24uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt24uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt32uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt32uID) + params:params]; +} + +- (void)writeAttributeInt32uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt32uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt32uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt32uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt40uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt40uID) + params:params]; +} + +- (void)writeAttributeInt40uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt40uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt40uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt40uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt48uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt48uID) + params:params]; +} + +- (void)writeAttributeInt48uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt48uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt48uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt48uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt56uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt56uID) + params:params]; +} + +- (void)writeAttributeInt56uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt56uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt56uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt56uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt64uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt64uID) + params:params]; +} + +- (void)writeAttributeInt64uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt64uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt64uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt64uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt8sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt8sID) + params:params]; +} + +- (void)writeAttributeInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt8sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt8sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt16sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt16sID) + params:params]; +} + +- (void)writeAttributeInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt16sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt16sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt24sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt24sID) + params:params]; +} + +- (void)writeAttributeInt24sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt24sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt24sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt24sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt32sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt32sID) + params:params]; +} + +- (void)writeAttributeInt32sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt32sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt32sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt32sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt40sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt40sID) + params:params]; +} + +- (void)writeAttributeInt40sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt40sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt40sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt40sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt48sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt48sID) + params:params]; +} + +- (void)writeAttributeInt48sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt48sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt48sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt48sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt56sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt56sID) + params:params]; +} + +- (void)writeAttributeInt56sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt56sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt56sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt56sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeInt64sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt64sID) + params:params]; +} + +- (void)writeAttributeInt64sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeInt64sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeInt64sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeInt64sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEnum8WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEnum8ID) + params:params]; +} + +- (void)writeAttributeEnum8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEnum8WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeEnum8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEnum8ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEnum16WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEnum16ID) + params:params]; +} + +- (void)writeAttributeEnum16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEnum16WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeEnum16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEnum16ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeFloatSingleWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeFloatSingleID) + params:params]; +} + +- (void)writeAttributeFloatSingleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeFloatSingleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeFloatSingleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeFloatSingleID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeFloatDoubleWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeFloatDoubleID) + params:params]; +} + +- (void)writeAttributeFloatDoubleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeFloatDoubleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeFloatDoubleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeFloatDoubleID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeOctetStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeOctetStringID) + params:params]; +} + +- (void)writeAttributeOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeOctetStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeListInt8uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListInt8uID) + params:params]; +} + +- (void)writeAttributeListInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeListInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeListInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListInt8uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeListOctetStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListOctetStringID) + params:params]; +} + +- (void)writeAttributeListOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeListOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeListOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListOctetStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeListStructOctetStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListStructOctetStringID) + params:params]; +} + +- (void)writeAttributeListStructOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeListStructOctetStringWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeListStructOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListStructOctetStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLongOctetStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeLongOctetStringID) + params:params]; +} + +- (void)writeAttributeLongOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLongOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLongOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeLongOctetStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeCharStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeCharStringID) + params:params]; +} + +- (void)writeAttributeCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeCharStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeCharStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeLongCharStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeLongCharStringID) + params:params]; +} + +- (void)writeAttributeLongCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeLongCharStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeLongCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeLongCharStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEpochUsWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEpochUsID) + params:params]; +} + +- (void)writeAttributeEpochUsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEpochUsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeEpochUsWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEpochUsID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEpochSWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEpochSID) + params:params]; +} + +- (void)writeAttributeEpochSWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEpochSWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeEpochSWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEpochSID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeVendorIdWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeVendorIdID) + params:params]; +} + +- (void)writeAttributeVendorIdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeVendorIdWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeVendorIdWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeVendorIdID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeListNullablesAndOptionalsStructWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListNullablesAndOptionalsStructID) + params:params]; +} + +- (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeListNullablesAndOptionalsStructWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListNullablesAndOptionalsStructID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeEnumAttrWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEnumAttrID) + params:params]; +} + +- (void)writeAttributeEnumAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeEnumAttrWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeEnumAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeEnumAttrID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeStructAttrWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeStructAttrID) + params:params]; +} + +- (void)writeAttributeStructAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeStructAttrWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeStructAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeStructAttrID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRangeRestrictedInt8uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeRangeRestrictedInt8uID) + params:params]; +} + +- (void)writeAttributeRangeRestrictedInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRangeRestrictedInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeRangeRestrictedInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeRangeRestrictedInt8uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRangeRestrictedInt8sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeRangeRestrictedInt8sID) + params:params]; +} + +- (void)writeAttributeRangeRestrictedInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRangeRestrictedInt8sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeRangeRestrictedInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeRangeRestrictedInt8sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRangeRestrictedInt16uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeRangeRestrictedInt16uID) + params:params]; +} + +- (void)writeAttributeRangeRestrictedInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRangeRestrictedInt16uWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeRangeRestrictedInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeRangeRestrictedInt16uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeRangeRestrictedInt16sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeRangeRestrictedInt16sID) + params:params]; +} + +- (void)writeAttributeRangeRestrictedInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeRangeRestrictedInt16sWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeRangeRestrictedInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeRangeRestrictedInt16sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeListLongOctetStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListLongOctetStringID) + params:params]; +} + +- (void)writeAttributeListLongOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeListLongOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeListLongOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListLongOctetStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeListFabricScopedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListFabricScopedID) + params:params]; +} + +- (void)writeAttributeListFabricScopedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeListFabricScopedWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeListFabricScopedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeListFabricScopedID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeTimedWriteBooleanWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeTimedWriteBooleanID) + params:params]; +} + +- (void)writeAttributeTimedWriteBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeTimedWriteBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeTimedWriteBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeTimedWriteBooleanID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneralErrorBooleanWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeGeneralErrorBooleanID) + params:params]; +} + +- (void)writeAttributeGeneralErrorBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeGeneralErrorBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeGeneralErrorBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeGeneralErrorBooleanID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeClusterErrorBooleanWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeClusterErrorBooleanID) + params:params]; +} + +- (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeClusterErrorBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeClusterErrorBooleanID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeUnsupportedWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeUnsupportedID) + params:params]; +} + +- (void)writeAttributeUnsupportedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeUnsupportedWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeUnsupportedWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeUnsupportedID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableBooleanWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBooleanID) + params:params]; +} + +- (void)writeAttributeNullableBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableBooleanWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBooleanID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableBitmap8WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBitmap8ID) + params:params]; +} + +- (void)writeAttributeNullableBitmap8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableBitmap8WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableBitmap8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBitmap8ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableBitmap16WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBitmap16ID) + params:params]; +} + +- (void)writeAttributeNullableBitmap16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableBitmap16WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableBitmap16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBitmap16ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableBitmap32WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBitmap32ID) + params:params]; +} + +- (void)writeAttributeNullableBitmap32WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableBitmap32WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableBitmap32WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBitmap32ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableBitmap64WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBitmap64ID) + params:params]; +} + +- (void)writeAttributeNullableBitmap64WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableBitmap64WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableBitmap64WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableBitmap64ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt8uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt8uID) + params:params]; +} + +- (void)writeAttributeNullableInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt8uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt16uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt16uID) + params:params]; +} + +- (void)writeAttributeNullableInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt16uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt16uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt24uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt24uID) + params:params]; +} + +- (void)writeAttributeNullableInt24uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt24uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt24uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt24uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt32uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt32uID) + params:params]; +} + +- (void)writeAttributeNullableInt32uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt32uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt32uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt32uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt40uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt40uID) + params:params]; +} + +- (void)writeAttributeNullableInt40uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt40uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt40uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt40uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt48uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt48uID) + params:params]; +} + +- (void)writeAttributeNullableInt48uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt48uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt48uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt48uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt56uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt56uID) + params:params]; +} + +- (void)writeAttributeNullableInt56uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt56uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt56uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt56uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt64uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt64uID) + params:params]; +} + +- (void)writeAttributeNullableInt64uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt64uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt64uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt64uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt8sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt8sID) + params:params]; +} + +- (void)writeAttributeNullableInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt8sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt8sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt16sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt16sID) + params:params]; +} + +- (void)writeAttributeNullableInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt16sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt16sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt24sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt24sID) + params:params]; +} + +- (void)writeAttributeNullableInt24sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt24sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt24sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt24sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt32sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt32sID) + params:params]; +} + +- (void)writeAttributeNullableInt32sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt32sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt32sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt32sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt40sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt40sID) + params:params]; +} + +- (void)writeAttributeNullableInt40sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt40sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt40sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt40sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt48sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt48sID) + params:params]; +} + +- (void)writeAttributeNullableInt48sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt48sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt48sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt48sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt56sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt56sID) + params:params]; +} + +- (void)writeAttributeNullableInt56sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt56sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt56sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt56sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableInt64sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt64sID) + params:params]; +} + +- (void)writeAttributeNullableInt64sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableInt64sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableInt64sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableInt64sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableEnum8WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableEnum8ID) + params:params]; +} + +- (void)writeAttributeNullableEnum8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableEnum8WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableEnum8WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableEnum8ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableEnum16WithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableEnum16ID) + params:params]; +} + +- (void)writeAttributeNullableEnum16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableEnum16WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableEnum16WithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableEnum16ID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableFloatSingleWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableFloatSingleID) + params:params]; +} + +- (void)writeAttributeNullableFloatSingleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableFloatSingleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableFloatSingleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableFloatSingleID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableFloatDoubleWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableFloatDoubleID) + params:params]; +} + +- (void)writeAttributeNullableFloatDoubleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableFloatDoubleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableFloatDoubleWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableFloatDoubleID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableOctetStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableOctetStringID) + params:params]; +} + +- (void)writeAttributeNullableOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableOctetStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableOctetStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableCharStringWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableCharStringID) + params:params]; +} + +- (void)writeAttributeNullableCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableCharStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableCharStringWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableCharStringID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableEnumAttrWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableEnumAttrID) + params:params]; +} + +- (void)writeAttributeNullableEnumAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableEnumAttrWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableEnumAttrWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableEnumAttrID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableStructWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableStructID) + params:params]; +} + +- (void)writeAttributeNullableStructWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableStructWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableStructWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableStructID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableRangeRestrictedInt8uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableRangeRestrictedInt8uID) + params:params]; +} + +- (void)writeAttributeNullableRangeRestrictedInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableRangeRestrictedInt8uWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeNullableRangeRestrictedInt8uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableRangeRestrictedInt8uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableRangeRestrictedInt8sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableRangeRestrictedInt8sID) + params:params]; +} + +- (void)writeAttributeNullableRangeRestrictedInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableRangeRestrictedInt8sWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeNullableRangeRestrictedInt8sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableRangeRestrictedInt8sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableRangeRestrictedInt16uWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableRangeRestrictedInt16uID) + params:params]; +} + +- (void)writeAttributeNullableRangeRestrictedInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableRangeRestrictedInt16uWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeNullableRangeRestrictedInt16uWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableRangeRestrictedInt16uID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeNullableRangeRestrictedInt16sWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableRangeRestrictedInt16sID) + params:params]; +} + +- (void)writeAttributeNullableRangeRestrictedInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableRangeRestrictedInt16sWithValue:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + params:nil]; +} +- (void)writeAttributeNullableRangeRestrictedInt16sWithValue:(NSDictionary *)dataValueDictionary + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + params:(MTRWriteParams * _Nullable)params +{ + NSNumber * waitTimeInMs = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeNullableRangeRestrictedInt16sID) + value:dataValueDictionary + expectedValueInterval:expectedValueIntervalMs + timedWriteTimeout:waitTimeInMs]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointId:@(_endpoint) + clusterId:@(MTRClusterTestClusterID) + attributeId:@(MTRClusterTestClusterAttributeClusterRevisionID) + params:params]; +} + +@end + +// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters_internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters_internal.h new file mode 100644 index 00000000000000..40e9861d3abb0b --- /dev/null +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters_internal.h @@ -0,0 +1,352 @@ +/* + * + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#import +#import + +#import "MTRClusters.h" +#import "MTRDevice.h" +#import "MTRDevice_Internal.h" + +#include + +@interface MTRClusterIdentify () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterGroups () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterScenes () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterOnOff () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterOnOffSwitchConfiguration () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterLevelControl () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterBinaryInputBasic () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterDescriptor () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterBinding () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterAccessControl () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterBridgedActions () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterBasic () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterOtaSoftwareUpdateProvider () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterOtaSoftwareUpdateRequestor () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterLocalizationConfiguration () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterTimeFormatLocalization () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterUnitLocalization () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterPowerSourceConfiguration () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterPowerSource () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterGeneralCommissioning () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterNetworkCommissioning () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterDiagnosticLogs () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterGeneralDiagnostics () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterSoftwareDiagnostics () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterThreadNetworkDiagnostics () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterWiFiNetworkDiagnostics () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterEthernetNetworkDiagnostics () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterBridgedDeviceBasic () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterSwitch () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterAdministratorCommissioning () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterOperationalCredentials () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterGroupKeyManagement () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterFixedLabel () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterUserLabel () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterBooleanState () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterModeSelect () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterDoorLock () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterWindowCovering () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterBarrierControl () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterPumpConfigurationAndControl () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterThermostat () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterFanControl () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterThermostatUserInterfaceConfiguration () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterColorControl () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterBallastConfiguration () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterIlluminanceMeasurement () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterTemperatureMeasurement () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterPressureMeasurement () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterFlowMeasurement () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterRelativeHumidityMeasurement () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterOccupancySensing () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterWakeOnLan () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterChannel () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterTargetNavigator () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterMediaPlayback () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterMediaInput () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterLowPower () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterKeypadInput () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterContentLauncher () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterAudioOutput () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterApplicationLauncher () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterApplicationBasic () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterAccountLogin () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterElectricalMeasurement () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + +@interface MTRClusterTestCluster () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end diff --git a/src/darwin/Framework/CHIPTests/MTRAsyncCallbackQueueTests.m b/src/darwin/Framework/CHIPTests/MTRAsyncCallbackQueueTests.m new file mode 100644 index 00000000000000..b21ce78002d26e --- /dev/null +++ b/src/darwin/Framework/CHIPTests/MTRAsyncCallbackQueueTests.m @@ -0,0 +1,147 @@ +/** + * 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 + +// system dependencies +#import + +#import "MTRAsyncCallbackWorkQueue_Internal.h" + +@interface MTRAsyncCallbackQueueTests : XCTestCase + +@end + +@implementation MTRAsyncCallbackQueueTests + +- (void)testRunItem +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Work item called"]; + + MTRAsyncCallbackWorkQueue * workQueue = [[MTRAsyncCallbackWorkQueue alloc] initWithDevice:nil queue:dispatch_get_main_queue()]; + + MTRAsyncCallbackQueueWorkItem * workItem1 = + [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; + __block int counter = 0; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + counter++; + [expectation fulfill]; + [workItem1 endWork]; + }; + workItem1.readyHandler = readyHandler; + workItem1.cancelHandler = ^{ + }; + [workQueue enqueueWorkItem:workItem1]; + + [self waitForExpectationsWithTimeout:5 handler:nil]; + + // see that it only ran once + XCTAssertEqual(counter, 1); +} + +- (void)testRunItemsSerialized +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Work item called in order"]; + + MTRAsyncCallbackWorkQueue * workQueue = [[MTRAsyncCallbackWorkQueue alloc] initWithDevice:nil queue:dispatch_get_main_queue()]; + + MTRAsyncCallbackQueueWorkItem * workItem1 = + [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; + __block int counter = 0; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + NSLog(@"Item 1 called with counter %d", counter); + sleep(1); + counter++; + NSLog(@"Item 1 woke after sleep with counter %d", counter); + [workItem1 endWork]; + }; + workItem1.readyHandler = readyHandler; + workItem1.cancelHandler = ^{ + }; + [workQueue enqueueWorkItem:workItem1]; + + MTRAsyncCallbackQueueWorkItem * workItem2 = + [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; + workItem2.readyHandler = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + // expect this to have waited until workItem1's sleep(1) finished and incremented counter + NSLog(@"Item 2 called with counter %d", counter); + if (counter == 1) { + [expectation fulfill]; + } + [workItem2 endWork]; + }; + workItem2.cancelHandler = ^{ + }; + [workQueue enqueueWorkItem:workItem2]; + + NSLog(@"2Items start wait %@", [NSDate date]); + [self waitForExpectationsWithTimeout:5 handler:nil]; + NSLog(@"2Items finished wait %@", [NSDate date]); + + // see that workItem1 only ran once + XCTAssertEqual(counter, 1); +} + +- (void)testRunItemsRetry +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Work item called in order"]; + + MTRAsyncCallbackWorkQueue * workQueue = [[MTRAsyncCallbackWorkQueue alloc] initWithDevice:nil queue:dispatch_get_main_queue()]; + + MTRAsyncCallbackQueueWorkItem * workItem1 = + [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; + __block int counter = 0; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + NSLog(@"Item 1 called with counter %d retryCount %d", counter, retryCount); + sleep(1); + counter++; + NSLog(@"Item 1 woke after sleep with counter %d", counter); + + if (retryCount) { + // only end after retried once + [workItem1 endWork]; + } else { + [workItem1 retryWork]; + } + }; + workItem1.readyHandler = readyHandler; + workItem1.cancelHandler = ^{ + }; + [workQueue enqueueWorkItem:workItem1]; + + MTRAsyncCallbackQueueWorkItem * workItem2 = + [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)]; + workItem2.readyHandler = ^(MTRDevice * _Nonnull device, NSUInteger retryCount) { + // expect this to have waited until workItem1's sleep(1) finished and incremented counter + NSLog(@"Item 2 called with counter %d", counter); + if (counter == 2) { + [expectation fulfill]; + } + [workItem2 endWork]; + }; + workItem2.cancelHandler = ^{ + }; + [workQueue enqueueWorkItem:workItem2]; + + NSLog(@"2Items start wait %@", [NSDate date]); + [self waitForExpectationsWithTimeout:5 handler:nil]; + NSLog(@"2Items finished wait %@", [NSDate date]); + + // see that workItem1 only ran once + XCTAssertEqual(counter, 1); +} + +@end diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index ee9e61a22d06c9..60e732f125524c 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -1249,7 +1249,7 @@ - (void)testSignedInteger NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:input]); + XCTAssertTrue([output isEqual:input]); } - (void)testSignedInteger64Bits @@ -1260,7 +1260,7 @@ - (void)testSignedInteger64Bits NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:input]); + XCTAssertTrue([output isEqual:input]); } - (void)testUnsignedInteger @@ -1271,7 +1271,7 @@ - (void)testUnsignedInteger NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:input]); + XCTAssertTrue([output isEqual:input]); } - (void)testUnsignedInteger64Bits @@ -1282,7 +1282,7 @@ - (void)testUnsignedInteger64Bits NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:input]); + XCTAssertTrue([output isEqual:input]); } - (void)testBoolean @@ -1293,7 +1293,7 @@ - (void)testBoolean NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:input]); + XCTAssertTrue([output isEqual:input]); } - (void)testUTF8String @@ -1303,7 +1303,7 @@ - (void)testUTF8String NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:input]); + XCTAssertTrue([output isEqual:input]); } - (void)testOctetString @@ -1315,7 +1315,7 @@ - (void)testOctetString NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:input]); + XCTAssertTrue([output isEqual:input]); } - (void)testFloat @@ -1349,7 +1349,7 @@ - (void)testNull NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:input]); + XCTAssertTrue([output isEqual:input]); } - (void)testStructure @@ -1371,7 +1371,7 @@ - (void)testStructure XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:inputValue]); + XCTAssertTrue([output isEqual:inputValue]); } - (void)testArray @@ -1385,7 +1385,7 @@ - (void)testArray NSLog(@"Conversion input: %@\nOutput: %@", inputValue, output); XCTAssertNotNil(output); XCTAssertTrue([output isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([output isEqualTo:inputValue]); + XCTAssertTrue([output isEqual:inputValue]); } @end diff --git a/src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m b/src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m index c029f9479b7dd2..3b93b4e046ba01 100644 --- a/src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m +++ b/src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m @@ -378,7 +378,7 @@ - (void)testReadAttributeSuccess NSLog(@"Read value: %@", value); XCTAssertNotNil(value); XCTAssertNil(error); - XCTAssertTrue([myValues isEqualTo:value]); + XCTAssertTrue([myValues isEqual:value]); [responseExpectation fulfill]; self.xpcDisconnectExpectation = [self expectationWithDescription:@"XPC Disconnected"]; @@ -440,7 +440,7 @@ - (void)testReadAttributeWithParamsSuccess NSLog(@"Read value: %@", value); XCTAssertNotNil(value); XCTAssertNil(error); - XCTAssertTrue([myValues isEqualTo:value]); + XCTAssertTrue([myValues isEqual:value]); [responseExpectation fulfill]; self.xpcDisconnectExpectation = [self expectationWithDescription:@"XPC Disconnected"]; @@ -531,7 +531,7 @@ - (void)testWriteAttributeSuccess XCTAssertEqual([endpointId unsignedShortValue], [myEndpointId unsignedShortValue]); XCTAssertEqual([clusterId unsignedLongValue], [myClusterId unsignedLongValue]); XCTAssertEqual([attributeId unsignedLongValue], [myAttributeId unsignedLongValue]); - XCTAssertTrue([value isEqualTo:myValue]); + XCTAssertTrue([value isEqual:myValue]); XCTAssertNil(timedWriteTimeout); [callExpectation fulfill]; completion([MTRDeviceController encodeXPCResponseValues:myResults], nil); @@ -553,7 +553,7 @@ - (void)testWriteAttributeSuccess NSLog(@"Write response: %@", value); XCTAssertNotNil(value); XCTAssertNil(error); - XCTAssertTrue([myResults isEqualTo:value]); + XCTAssertTrue([myResults isEqual:value]); [responseExpectation fulfill]; self.xpcDisconnectExpectation = [self expectationWithDescription:@"XPC Disconnected"]; @@ -593,7 +593,7 @@ - (void)testTimedWriteAttributeSuccess XCTAssertEqual([endpointId unsignedShortValue], [myEndpointId unsignedShortValue]); XCTAssertEqual([clusterId unsignedLongValue], [myClusterId unsignedLongValue]); XCTAssertEqual([attributeId unsignedLongValue], [myAttributeId unsignedLongValue]); - XCTAssertTrue([value isEqualTo:myValue]); + XCTAssertTrue([value isEqual:myValue]); XCTAssertNotNil(timedWriteTimeout); XCTAssertEqual([timedWriteTimeout unsignedShortValue], [myTimedWriteTimeout unsignedShortValue]); [callExpectation fulfill]; @@ -616,7 +616,7 @@ - (void)testTimedWriteAttributeSuccess NSLog(@"Write response: %@", value); XCTAssertNotNil(value); XCTAssertNil(error); - XCTAssertTrue([myResults isEqualTo:value]); + XCTAssertTrue([myResults isEqual:value]); [responseExpectation fulfill]; self.xpcDisconnectExpectation = [self expectationWithDescription:@"XPC Disconnected"]; @@ -650,7 +650,7 @@ - (void)testWriteAttributeFailure XCTAssertEqual([endpointId unsignedShortValue], [myEndpointId unsignedShortValue]); XCTAssertEqual([clusterId unsignedLongValue], [myClusterId unsignedLongValue]); XCTAssertEqual([attributeId unsignedLongValue], [myAttributeId unsignedLongValue]); - XCTAssertTrue([value isEqualTo:myValue]); + XCTAssertTrue([value isEqual:myValue]); XCTAssertNil(timedWriteTimeout); [callExpectation fulfill]; completion(nil, myError); @@ -710,7 +710,7 @@ - (void)testInvokeCommandSuccess XCTAssertEqual([endpointId unsignedShortValue], [myEndpointId unsignedShortValue]); XCTAssertEqual([clusterId unsignedLongValue], [myClusterId unsignedLongValue]); XCTAssertEqual([commandId unsignedLongValue], [myCommandId unsignedLongValue]); - XCTAssertTrue([commandFields isEqualTo:myFields]); + XCTAssertTrue([commandFields isEqual:myFields]); XCTAssertNil(timedInvokeTimeout); [callExpectation fulfill]; completion([MTRDeviceController encodeXPCResponseValues:myResults], nil); @@ -732,7 +732,7 @@ - (void)testInvokeCommandSuccess NSLog(@"Command response: %@", value); XCTAssertNotNil(value); XCTAssertNil(error); - XCTAssertTrue([myResults isEqualTo:value]); + XCTAssertTrue([myResults isEqual:value]); [responseExpectation fulfill]; self.xpcDisconnectExpectation = [self expectationWithDescription:@"XPC Disconnected"]; @@ -772,7 +772,7 @@ - (void)testTimedInvokeCommandSuccess XCTAssertEqual([endpointId unsignedShortValue], [myEndpointId unsignedShortValue]); XCTAssertEqual([clusterId unsignedLongValue], [myClusterId unsignedLongValue]); XCTAssertEqual([commandId unsignedLongValue], [myCommandId unsignedLongValue]); - XCTAssertTrue([commandFields isEqualTo:myFields]); + XCTAssertTrue([commandFields isEqual:myFields]); XCTAssertNotNil(timedInvokeTimeout); XCTAssertEqual([timedInvokeTimeout unsignedShortValue], [myTimedInvokeTimeout unsignedShortValue]); [callExpectation fulfill]; @@ -795,7 +795,7 @@ - (void)testTimedInvokeCommandSuccess NSLog(@"Command response: %@", value); XCTAssertNotNil(value); XCTAssertNil(error); - XCTAssertTrue([myResults isEqualTo:value]); + XCTAssertTrue([myResults isEqual:value]); [responseExpectation fulfill]; self.xpcDisconnectExpectation = [self expectationWithDescription:@"XPC Disconnected"]; @@ -832,7 +832,7 @@ - (void)testInvokeCommandFailure XCTAssertEqual([endpointId unsignedShortValue], [myEndpointId unsignedShortValue]); XCTAssertEqual([clusterId unsignedLongValue], [myClusterId unsignedLongValue]); XCTAssertEqual([commandId unsignedLongValue], [myCommandId unsignedLongValue]); - XCTAssertTrue([commandFields isEqualTo:myFields]); + XCTAssertTrue([commandFields isEqual:myFields]); XCTAssertNil(timedInvokeTimeout); [callExpectation fulfill]; completion(nil, myError); @@ -921,7 +921,7 @@ - (void)testSubscribeAttributeSuccess NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1041,7 +1041,7 @@ - (void)testSubscribeAttributeWithParamsSuccess NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1156,7 +1156,7 @@ - (void)testBadlyFormattedReport NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1270,7 +1270,7 @@ - (void)testReportWithUnrelatedEndpointId NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1386,7 +1386,7 @@ - (void)testReportWithUnrelatedClusterId NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1502,7 +1502,7 @@ - (void)testReportWithUnrelatedAttributeId NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1618,7 +1618,7 @@ - (void)testReportWithUnrelatedNode NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1733,7 +1733,7 @@ - (void)testSubscribeMultiEndpoints NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1848,7 +1848,7 @@ - (void)testSubscribeMultiClusters NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -1963,7 +1963,7 @@ - (void)testSubscribeMultiAttributes NSLog(@"Report value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReport isEqualTo:values]); + XCTAssertTrue([myReport isEqual:values]); [reportExpectation fulfill]; } subscriptionEstablished:^{ @@ -2089,7 +2089,7 @@ - (void)testMutiSubscriptions NSLog(@"Subscriber [%d] report value: %@", i, values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myReports[i] isEqualTo:values]); + XCTAssertTrue([myReports[i] isEqual:values]); [reportExpectations[i] fulfill]; } subscriptionEstablished:^{ @@ -2452,7 +2452,7 @@ - (void)testReadAttributeCacheSuccess NSLog(@"Read cached value: %@", values); XCTAssertNotNil(values); XCTAssertNil(error); - XCTAssertTrue([myValues isEqualTo:values]); + XCTAssertTrue([myValues isEqual:values]); [responseExpectation fulfill]; }]; [self waitForExpectations:@[ callExpectation, responseExpectation, _xpcDisconnectExpectation ] timeout:kTimeoutInSeconds]; diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index 7e19b0328b55a0..cda67367ae1c34 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -80,6 +80,17 @@ 754F3DF427FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 754F3DF327FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h */; }; 7560FD1C27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7560FD1B27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm */; }; 7596A83E28751220004DAE0E /* MTRBaseClusters_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A83D28751220004DAE0E /* MTRBaseClusters_internal.h */; }; + 7596A84428762729004DAE0E /* MTRDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84228762729004DAE0E /* MTRDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7596A84528762729004DAE0E /* MTRDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7596A84328762729004DAE0E /* MTRDevice.mm */; }; + 7596A84828762783004DAE0E /* MTRAsyncCallbackWorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84628762783004DAE0E /* MTRAsyncCallbackWorkQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7596A84928762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7596A84728762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm */; }; + 7596A84B287636C1004DAE0E /* MTRDevice_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */; }; + 7596A84D287782EF004DAE0E /* MTRAsyncCallbackWorkQueue_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84C287782E8004DAE0E /* MTRAsyncCallbackWorkQueue_Internal.h */; }; + 7596A84F2877E6A9004DAE0E /* MTRCluster_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84E2877E6A9004DAE0E /* MTRCluster_internal.h */; }; + 7596A8512878709F004DAE0E /* MTRAsyncCallbackQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7596A8502878709F004DAE0E /* MTRAsyncCallbackQueueTests.m */; }; + 7596A85528788557004DAE0E /* MTRClusters.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7596A85228788557004DAE0E /* MTRClusters.mm */; }; + 7596A85628788557004DAE0E /* MTRClustersObjc_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A85328788557004DAE0E /* MTRClustersObjc_internal.h */; }; + 7596A85728788557004DAE0E /* MTRClusters.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A85428788557004DAE0E /* MTRClusters.h */; settings = {ATTRIBUTES = (Public, ); }; }; 88EBF8CE27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EBF8CB27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 88EBF8CF27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 88EBF8CC27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm */; }; 88EBF8D027FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EBF8CD27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h */; }; @@ -200,6 +211,17 @@ 754F3DF327FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTREventTLVValueDecoder_Internal.h; sourceTree = ""; }; 7560FD1B27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MTREventTLVValueDecoder.mm; path = "zap-generated/MTREventTLVValueDecoder.mm"; sourceTree = ""; }; 7596A83D28751220004DAE0E /* MTRBaseClusters_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTRBaseClusters_internal.h; path = "zap-generated/MTRBaseClusters_internal.h"; sourceTree = ""; }; + 7596A84228762729004DAE0E /* MTRDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDevice.h; sourceTree = ""; }; + 7596A84328762729004DAE0E /* MTRDevice.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDevice.mm; sourceTree = ""; }; + 7596A84628762783004DAE0E /* MTRAsyncCallbackWorkQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRAsyncCallbackWorkQueue.h; sourceTree = ""; }; + 7596A84728762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRAsyncCallbackWorkQueue.mm; sourceTree = ""; }; + 7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDevice_Internal.h; sourceTree = ""; }; + 7596A84C287782E8004DAE0E /* MTRAsyncCallbackWorkQueue_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRAsyncCallbackWorkQueue_Internal.h; sourceTree = ""; }; + 7596A84E2877E6A9004DAE0E /* MTRCluster_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRCluster_internal.h; sourceTree = ""; }; + 7596A8502878709F004DAE0E /* MTRAsyncCallbackQueueTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MTRAsyncCallbackQueueTests.m; sourceTree = ""; }; + 7596A85228788557004DAE0E /* MTRClusters.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MTRClusters.mm; path = "zap-generated/MTRClusters.mm"; sourceTree = ""; }; + 7596A85328788557004DAE0E /* MTRClustersObjc_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTRClustersObjc_internal.h; path = "zap-generated/MTRClustersObjc_internal.h"; sourceTree = ""; }; + 7596A85428788557004DAE0E /* MTRClusters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MTRClusters.h; path = "zap-generated/MTRClusters.h"; sourceTree = ""; }; 88EBF8CB27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceAttestationDelegate.h; sourceTree = ""; }; 88EBF8CC27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceAttestationDelegateBridge.mm; sourceTree = ""; }; 88EBF8CD27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRDeviceAttestationDelegateBridge.h; sourceTree = ""; }; @@ -289,6 +311,9 @@ 1EC4CE6325CC276600D7304F /* MTRBaseClusters.h */, 1EC4CE5925CC26E900D7304F /* MTRBaseClusters.mm */, 7596A83D28751220004DAE0E /* MTRBaseClusters_internal.h */, + 7596A85428788557004DAE0E /* MTRClusters.h */, + 7596A85228788557004DAE0E /* MTRClusters.mm */, + 7596A85328788557004DAE0E /* MTRClustersObjc_internal.h */, D4772A45285AE98300383630 /* MTRClusterConstants.h */, ); name = CHIPGeneratedFiles; @@ -326,6 +351,7 @@ 88EBF8CC27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm */, 513DDB852761F69300DAA01A /* MTRAttributeTLVValueDecoder_Internal.h */, 754F3DF327FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h */, + 7596A84E2877E6A9004DAE0E /* MTRCluster_internal.h */, 1ED276E326C5832500547A89 /* MTRCluster.h */, 1ED276E126C5812A00547A89 /* MTRCluster.mm */, 2C5EEEF4268A85C400CAE3D3 /* MTRDeviceConnectionBridge.h */, @@ -340,6 +366,12 @@ 2C222ADE255C811800E446B9 /* MTRBaseDevice_Internal.h */, 2C222ACE255C620600E446B9 /* MTRBaseDevice.h */, 2C222ACF255C620600E446B9 /* MTRBaseDevice.mm */, + 7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */, + 7596A84228762729004DAE0E /* MTRDevice.h */, + 7596A84328762729004DAE0E /* MTRDevice.mm */, + 7596A84C287782E8004DAE0E /* MTRAsyncCallbackWorkQueue_Internal.h */, + 7596A84628762783004DAE0E /* MTRAsyncCallbackWorkQueue.h */, + 7596A84728762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm */, 2C8C8FBE253E0C2100797F05 /* MTRPersistentStorageDelegate.h */, 5ACDDD7927CD129700EFD68A /* MTRAttributeCacheContainer.h */, 5A60370727EA1FF60020DB79 /* MTRAttributeCacheContainer+XPC.h */, @@ -418,6 +450,7 @@ B2F53AF1245B0DCF0010745E /* MTRSetupPayloadParserTests.m */, 997DED1926955D0200975E97 /* MTRThreadOperationalDatasetTests.mm */, 517BF3F2282B62CB00A8B7DB /* MTRCertificateTests.m */, + 7596A8502878709F004DAE0E /* MTRAsyncCallbackQueueTests.m */, B202529D2459E34F00F97062 /* Info.plist */, ); path = CHIPTests; @@ -442,6 +475,7 @@ 517BF3F0282B62B800A8B7DB /* MTRCertificates.h in Headers */, 51E51FBF282AD37A00FC978D /* MTRDeviceControllerStartupParams.h in Headers */, 5136661628067D550025EDAE /* MTRControllerFactory.h in Headers */, + 7596A84B287636C1004DAE0E /* MTRDevice_Internal.h in Headers */, 5A6FEC9927B5C88900F25F42 /* MTRDeviceOverXPC.h in Headers */, 51B22C222740CB1D008D5055 /* MTRCommandPayloadsObjc.h in Headers */, 51B22C1E2740CB0A008D5055 /* MTRStructsObjc.h in Headers */, @@ -449,6 +483,7 @@ 5ACDDD7A27CD129700EFD68A /* MTRAttributeCacheContainer.h in Headers */, 5A6FEC9227B5669C00F25F42 /* MTRDeviceControllerOverXPC.h in Headers */, 2C1B027B2641DB4E00780EF1 /* MTROperationalCredentialsDelegate.h in Headers */, + 7596A85728788557004DAE0E /* MTRClusters.h in Headers */, 99D466E12798936D0089A18F /* MTRCommissioningParameters.h in Headers */, 5136661528067D550025EDAE /* MTRControllerFactory_Internal.h in Headers */, 515C1C70284F9FFB00A48F0C /* MTRMemory.h in Headers */, @@ -458,12 +493,15 @@ 2CB7163F252F731E0026E2BB /* MTRDevicePairingDelegate.h in Headers */, 88EBF8CE27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h in Headers */, 2C222AD0255C620600E446B9 /* MTRBaseDevice.h in Headers */, + 7596A84F2877E6A9004DAE0E /* MTRCluster_internal.h in Headers */, 991DC0842475F45400C13860 /* MTRDeviceController.h in Headers */, AF1CB86E2874B03B00865A96 /* MTROTAProviderDelegate.h in Headers */, 754F3DF427FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h in Headers */, B2E0D7B2245B0B5C003C5B48 /* MTRManualSetupPayloadParser.h in Headers */, B2E0D7B1245B0B5C003C5B48 /* Matter.h in Headers */, + 7596A84428762729004DAE0E /* MTRDevice.h in Headers */, B2E0D7B8245B0B5C003C5B48 /* MTRSetupPayload.h in Headers */, + 7596A84D287782EF004DAE0E /* MTRAsyncCallbackWorkQueue_Internal.h in Headers */, 7596A83E28751220004DAE0E /* MTRBaseClusters_internal.h in Headers */, 997DED182695344800975E97 /* MTRThreadOperationalDataset.h in Headers */, 9956064426420367000C28DE /* MTRSetupPayload_Internal.h in Headers */, @@ -487,7 +525,9 @@ 998F286F26D55EC5001846C6 /* MTRP256KeypairBridge.h in Headers */, 2C222ADF255C811800E446B9 /* MTRBaseDevice_Internal.h in Headers */, 51E0310027EA20D20083DC9C /* MTRControllerAccessControl.h in Headers */, + 7596A85628788557004DAE0E /* MTRClustersObjc_internal.h in Headers */, 991DC08B247704DC00C13860 /* MTRLogging.h in Headers */, + 7596A84828762783004DAE0E /* MTRAsyncCallbackWorkQueue.h in Headers */, 5A7947E527C0129F00434CF2 /* MTRDeviceController+XPC.h in Headers */, B2E0D7B4245B0B5C003C5B48 /* MTRError_Internal.h in Headers */, 1EDCE545289049A100E41EC9 /* MTROTAHeaderParser.h in Headers */, @@ -649,12 +689,15 @@ 5112F606287CD2C100B827E7 /* privilege-storage.cpp in Sources */, 2C1B027A2641DB4E00780EF1 /* MTROperationalCredentialsDelegate.mm in Sources */, 7560FD1C27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm in Sources */, + 7596A84928762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm in Sources */, B2E0D7B9245B0B5C003C5B48 /* MTRSetupPayload.mm in Sources */, B2E0D7B6245B0B5C003C5B48 /* MTRManualSetupPayloadParser.mm in Sources */, + 7596A85528788557004DAE0E /* MTRClusters.mm in Sources */, 88EBF8CF27FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.mm in Sources */, 5A6FEC9827B5C6AF00F25F42 /* MTRDeviceOverXPC.m in Sources */, 51431AF927D2973E008A7943 /* MTRIMDispatch.mm in Sources */, 51431AFB27D29CA4008A7943 /* ota-provider.cpp in Sources */, + 7596A84528762729004DAE0E /* MTRDevice.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -663,6 +706,7 @@ buildActionMask = 2147483647; files = ( 51D10D2E2808E2CA00E8CA3D /* MTRTestStorage.m in Sources */, + 7596A8512878709F004DAE0E /* MTRAsyncCallbackQueueTests.m in Sources */, 1EB41B7B263C4CC60048E4C1 /* MTRClustersTests.m in Sources */, 997DED1A26955D0200975E97 /* MTRThreadOperationalDatasetTests.mm in Sources */, 51C8E3F82825CDB600D47D00 /* MTRTestKeys.m in Sources */,