blob: 9216de3aeeed19bd68366c534591cc37f219e32b [file] [log] [blame]
/*
*
* 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 <Foundation/Foundation.h>
#import "MTRAsyncCallbackWorkQueue.h"
#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 <lib/support/CHIPListUtils.h>
#include <platform/CHIPDeviceLayer.h>
#include <type_traits>
using chip::Callback::Callback;
using chip::Callback::Cancelable;
using namespace chip::app::Clusters;
using chip::Messaging::ExchangeManager;
using chip::SessionHandle;
// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects.
@implementation MTRClusterIdentify
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)identifyWithParams:(MTRIdentifyClusterIdentifyParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Identify::Commands::Identify::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.identifyTime = params.identifyTime.unsignedShortValue;
chip::Controller::IdentifyCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)triggerEffectWithParams:(MTRIdentifyClusterTriggerEffectParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Identify::Commands::TriggerEffect::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.effectIdentifier = static_cast<std::remove_reference_t<decltype(request.effectIdentifier)>>(
params.effectIdentifier.unsignedCharValue);
request.effectVariant
= static_cast<std::remove_reference_t<decltype(request.effectVariant)>>(params.effectVariant.unsignedCharValue);
chip::Controller::IdentifyCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeIdentifyTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIdentifyID)
attributeID:@(MTRClusterIdentifyAttributeIdentifyTimeID)
params:params];
}
- (void)writeAttributeIdentifyTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeIdentifyTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeIdentifyTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIdentifyID)
attributeID:@(MTRClusterIdentifyAttributeIdentifyTimeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeIdentifyTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIdentifyID)
attributeID:@(MTRClusterIdentifyAttributeIdentifyTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIdentifyID)
attributeID:@(MTRClusterIdentifyAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIdentifyID)
attributeID:@(MTRClusterIdentifyAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIdentifyID)
attributeID:@(MTRClusterIdentifyAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIdentifyID)
attributeID:@(MTRClusterIdentifyAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIdentifyID)
attributeID:@(MTRClusterIdentifyAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterIdentify (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)identifyWithParams:(MTRIdentifyClusterIdentifyParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self identifyWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)triggerEffectWithParams:(MTRIdentifyClusterTriggerEffectParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self triggerEffectWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterGroups
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)addGroupWithParams:(MTRGroupsClusterAddGroupParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRGroupsClusterAddGroupResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRGroupsClusterAddGroupResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session, GroupsClusterAddGroupResponseCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Groups::Commands::AddGroup::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
request.groupName = [self asCharSpan:params.groupName];
chip::Controller::GroupsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)viewGroupWithParams:(MTRGroupsClusterViewGroupParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRGroupsClusterViewGroupResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRGroupsClusterViewGroupResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
GroupsClusterViewGroupResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Groups::Commands::ViewGroup::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
chip::Controller::GroupsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getGroupMembershipWithParams:(MTRGroupsClusterGetGroupMembershipParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRGroupsClusterGetGroupMembershipResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
GroupsClusterGetGroupMembershipResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Groups::Commands::GetGroupMembership::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
{
using ListType_0 = std::remove_reference_t<decltype(request.groupList)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.groupList.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.groupList.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::GroupsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)removeGroupWithParams:(MTRGroupsClusterRemoveGroupParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRGroupsClusterRemoveGroupResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRGroupsClusterRemoveGroupResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
GroupsClusterRemoveGroupResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Groups::Commands::RemoveGroup::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
chip::Controller::GroupsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)removeAllGroupsWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self removeAllGroupsWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)removeAllGroupsWithParams:(MTRGroupsClusterRemoveAllGroupsParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Groups::Commands::RemoveAllGroups::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::GroupsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)addGroupIfIdentifyingWithParams:(MTRGroupsClusterAddGroupIfIdentifyingParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Groups::Commands::AddGroupIfIdentifying::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
request.groupName = [self asCharSpan:params.groupName];
chip::Controller::GroupsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeNameSupportWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupsID)
attributeID:@(MTRClusterGroupsAttributeNameSupportID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupsID)
attributeID:@(MTRClusterGroupsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupsID)
attributeID:@(MTRClusterGroupsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupsID)
attributeID:@(MTRClusterGroupsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupsID)
attributeID:@(MTRClusterGroupsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupsID)
attributeID:@(MTRClusterGroupsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterGroups (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)addGroupWithParams:(MTRGroupsClusterAddGroupParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRGroupsClusterAddGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self addGroupWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)viewGroupWithParams:(MTRGroupsClusterViewGroupParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRGroupsClusterViewGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self viewGroupWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getGroupMembershipWithParams:(MTRGroupsClusterGetGroupMembershipParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self getGroupMembershipWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)removeGroupWithParams:(MTRGroupsClusterRemoveGroupParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRGroupsClusterRemoveGroupResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self removeGroupWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)removeAllGroupsWithParams:(MTRGroupsClusterRemoveAllGroupsParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self removeAllGroupsWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)removeAllGroupsWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self removeAllGroupsWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)addGroupIfIdentifyingWithParams:(MTRGroupsClusterAddGroupIfIdentifyingParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self addGroupIfIdentifyingWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterScenes
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)addSceneWithParams:(MTRScenesClusterAddSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRScenesClusterAddSceneResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterAddSceneResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterAddSceneResponseCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::AddScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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<decltype(request.extensionFieldSets)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.extensionFieldSets.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.extensionFieldSets.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_0 = (MTRScenesClusterExtensionFieldSet *) params.extensionFieldSets[i_0];
listHolder_0->mList[i_0].clusterId = element_0.clusterId.unsignedIntValue;
{
using ListType_2 = std::remove_reference_t<decltype(listHolder_0->mList[i_0].attributeValueList)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.attributeValueList.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.attributeValueList.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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_t<decltype(listHolder_2->mList[i_2].attributeValue)>;
using ListMemberType_4 = ListMemberTypeGetter<ListType_4>::Type;
if (element_2.attributeValue.count != 0) {
auto * listHolder_4
= new ListHolder<ListMemberType_4>(element_2.attributeValue.count);
if (listHolder_4 == nullptr || listHolder_4->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)viewSceneWithParams:(MTRScenesClusterViewSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRScenesClusterViewSceneResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterViewSceneResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ScenesClusterViewSceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::ViewScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
request.sceneId = params.sceneId.unsignedCharValue;
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)removeSceneWithParams:(MTRScenesClusterRemoveSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRScenesClusterRemoveSceneResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterRemoveSceneResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ScenesClusterRemoveSceneResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::RemoveScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
request.sceneId = params.sceneId.unsignedCharValue;
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)removeAllScenesWithParams:(MTRScenesClusterRemoveAllScenesParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRScenesClusterRemoveAllScenesResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterRemoveAllScenesResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ScenesClusterRemoveAllScenesResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::RemoveAllScenes::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)storeSceneWithParams:(MTRScenesClusterStoreSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRScenesClusterStoreSceneResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterStoreSceneResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ScenesClusterStoreSceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::StoreScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
request.sceneId = params.sceneId.unsignedCharValue;
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)recallSceneWithParams:(MTRScenesClusterRecallSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::RecallScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
}
}
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getSceneMembershipWithParams:(MTRScenesClusterGetSceneMembershipParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRScenesClusterGetSceneMembershipResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterGetSceneMembershipResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ScenesClusterGetSceneMembershipResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::GetSceneMembership::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)enhancedAddSceneWithParams:(MTRScenesClusterEnhancedAddSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRScenesClusterEnhancedAddSceneResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterEnhancedAddSceneResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ScenesClusterEnhancedAddSceneResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::EnhancedAddScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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<decltype(request.extensionFieldSets)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.extensionFieldSets.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.extensionFieldSets.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_0 = (MTRScenesClusterExtensionFieldSet *) params.extensionFieldSets[i_0];
listHolder_0->mList[i_0].clusterId = element_0.clusterId.unsignedIntValue;
{
using ListType_2 = std::remove_reference_t<decltype(listHolder_0->mList[i_0].attributeValueList)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.attributeValueList.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.attributeValueList.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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_t<decltype(listHolder_2->mList[i_2].attributeValue)>;
using ListMemberType_4 = ListMemberTypeGetter<ListType_4>::Type;
if (element_2.attributeValue.count != 0) {
auto * listHolder_4
= new ListHolder<ListMemberType_4>(element_2.attributeValue.count);
if (listHolder_4 == nullptr || listHolder_4->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)enhancedViewSceneWithParams:(MTRScenesClusterEnhancedViewSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRScenesClusterEnhancedViewSceneResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterEnhancedViewSceneResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ScenesClusterEnhancedViewSceneResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::EnhancedViewScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupId = params.groupId.unsignedShortValue;
request.sceneId = params.sceneId.unsignedCharValue;
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)copySceneWithParams:(MTRScenesClusterCopySceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRScenesClusterCopySceneResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRScenesClusterCopySceneResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ScenesClusterCopySceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Scenes::Commands::CopyScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.mode = static_cast<std::remove_reference_t<decltype(request.mode)>>(params.mode.unsignedCharValue);
request.groupIdFrom = params.groupIdFrom.unsignedShortValue;
request.sceneIdFrom = params.sceneIdFrom.unsignedCharValue;
request.groupIdTo = params.groupIdTo.unsignedShortValue;
request.sceneIdTo = params.sceneIdTo.unsignedCharValue;
chip::Controller::ScenesCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeSceneCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeSceneCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentSceneWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeCurrentSceneID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentGroupWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeCurrentGroupID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSceneValidWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeSceneValidID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNameSupportWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeNameSupportID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLastConfiguredByWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeLastConfiguredByID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterScenesID)
attributeID:@(MTRClusterScenesAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterScenes (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)addSceneWithParams:(MTRScenesClusterAddSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRScenesClusterAddSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self addSceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)viewSceneWithParams:(MTRScenesClusterViewSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRScenesClusterViewSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self viewSceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)removeSceneWithParams:(MTRScenesClusterRemoveSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRScenesClusterRemoveSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self removeSceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)removeAllScenesWithParams:(MTRScenesClusterRemoveAllScenesParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRScenesClusterRemoveAllScenesResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self removeAllScenesWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)storeSceneWithParams:(MTRScenesClusterStoreSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRScenesClusterStoreSceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self storeSceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)recallSceneWithParams:(MTRScenesClusterRecallSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self recallSceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getSceneMembershipWithParams:(MTRScenesClusterGetSceneMembershipParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRScenesClusterGetSceneMembershipResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self getSceneMembershipWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)enhancedAddSceneWithParams:(MTRScenesClusterEnhancedAddSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRScenesClusterEnhancedAddSceneResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self enhancedAddSceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)enhancedViewSceneWithParams:(MTRScenesClusterEnhancedViewSceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRScenesClusterEnhancedViewSceneResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self enhancedViewSceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)copySceneWithParams:(MTRScenesClusterCopySceneParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRScenesClusterCopySceneResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self copySceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterOnOff
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)offWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self offWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)offWithParams:(MTROnOffClusterOffParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OnOff::Commands::Off::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::OnOffCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)onWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self onWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)onWithParams:(MTROnOffClusterOnParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OnOff::Commands::On::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::OnOffCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)toggleWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self toggleWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)toggleWithParams:(MTROnOffClusterToggleParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OnOff::Commands::Toggle::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::OnOffCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)offWithEffectWithParams:(MTROnOffClusterOffWithEffectParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OnOff::Commands::OffWithEffect::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.effectId
= static_cast<std::remove_reference_t<decltype(request.effectId)>>(params.effectId.unsignedCharValue);
request.effectVariant
= static_cast<std::remove_reference_t<decltype(request.effectVariant)>>(params.effectVariant.unsignedCharValue);
chip::Controller::OnOffCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)onWithRecallGlobalSceneWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self onWithRecallGlobalSceneWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)onWithRecallGlobalSceneWithParams:(MTROnOffClusterOnWithRecallGlobalSceneParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OnOff::Commands::OnWithRecallGlobalScene::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::OnOffCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)onWithTimedOffWithParams:(MTROnOffClusterOnWithTimedOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OnOff::Commands::OnWithTimedOff::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.onOffControl
= static_cast<std::remove_reference_t<decltype(request.onOffControl)>>(params.onOffControl.unsignedCharValue);
request.onTime = params.onTime.unsignedShortValue;
request.offWaitTime = params.offWaitTime.unsignedShortValue;
chip::Controller::OnOffCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeOnOffWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeOnOffID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGlobalSceneControlWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeGlobalSceneControlID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOnTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeOnTimeID)
params:params];
}
- (void)writeAttributeOnTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOnTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOnTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeOnTimeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOffWaitTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeOffWaitTimeID)
params:params];
}
- (void)writeAttributeOffWaitTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOffWaitTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOffWaitTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeOffWaitTimeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeStartUpOnOffWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeStartUpOnOffID)
params:params];
}
- (void)writeAttributeStartUpOnOffWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeStartUpOnOffWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeStartUpOnOffWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeStartUpOnOffID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffID)
attributeID:@(MTRClusterOnOffAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterOnOff (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)offWithParams:(MTROnOffClusterOffParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self offWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)offWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self offWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)onWithParams:(MTROnOffClusterOnParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self onWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)onWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self onWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)toggleWithParams:(MTROnOffClusterToggleParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self toggleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)toggleWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self toggleWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)offWithEffectWithParams:(MTROnOffClusterOffWithEffectParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self offWithEffectWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)onWithRecallGlobalSceneWithParams:(MTROnOffClusterOnWithRecallGlobalSceneParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self onWithRecallGlobalSceneWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)onWithRecallGlobalSceneWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self onWithRecallGlobalSceneWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)onWithTimedOffWithParams:(MTROnOffClusterOnWithTimedOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self onWithTimedOffWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterOnOffSwitchConfiguration
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeSwitchTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffSwitchConfigurationID)
attributeID:@(MTRClusterOnOffSwitchConfigurationAttributeSwitchTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSwitchActionsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffSwitchConfigurationID)
attributeID:@(MTRClusterOnOffSwitchConfigurationAttributeSwitchActionsID)
params:params];
}
- (void)writeAttributeSwitchActionsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeSwitchActionsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeSwitchActionsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffSwitchConfigurationID)
attributeID:@(MTRClusterOnOffSwitchConfigurationAttributeSwitchActionsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffSwitchConfigurationID)
attributeID:@(MTRClusterOnOffSwitchConfigurationAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffSwitchConfigurationID)
attributeID:@(MTRClusterOnOffSwitchConfigurationAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffSwitchConfigurationID)
attributeID:@(MTRClusterOnOffSwitchConfigurationAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffSwitchConfigurationID)
attributeID:@(MTRClusterOnOffSwitchConfigurationAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOnOffSwitchConfigurationID)
attributeID:@(MTRClusterOnOffSwitchConfigurationAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterOnOffSwitchConfiguration (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterLevelControl
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)moveToLevelWithParams:(MTRLevelControlClusterMoveToLevelParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::MoveToLevel::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.level = params.level.unsignedCharValue;
if (params.transitionTime == nil) {
request.transitionTime.SetNull();
} else {
auto & nonNullValue_0 = request.transitionTime.SetNonNull();
nonNullValue_0 = params.transitionTime.unsignedShortValue;
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveWithParams:(MTRLevelControlClusterMoveParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::Move::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.moveMode
= static_cast<std::remove_reference_t<decltype(request.moveMode)>>(params.moveMode.unsignedCharValue);
if (params.rate == nil) {
request.rate.SetNull();
} else {
auto & nonNullValue_0 = request.rate.SetNonNull();
nonNullValue_0 = params.rate.unsignedCharValue;
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stepWithParams:(MTRLevelControlClusterStepParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::Step::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.stepMode
= static_cast<std::remove_reference_t<decltype(request.stepMode)>>(params.stepMode.unsignedCharValue);
request.stepSize = params.stepSize.unsignedCharValue;
if (params.transitionTime == nil) {
request.transitionTime.SetNull();
} else {
auto & nonNullValue_0 = request.transitionTime.SetNonNull();
nonNullValue_0 = params.transitionTime.unsignedShortValue;
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stopWithParams:(MTRLevelControlClusterStopParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::Stop::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveToLevelWithOnOffWithParams:(MTRLevelControlClusterMoveToLevelWithOnOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::MoveToLevelWithOnOff::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.level = params.level.unsignedCharValue;
if (params.transitionTime == nil) {
request.transitionTime.SetNull();
} else {
auto & nonNullValue_0 = request.transitionTime.SetNonNull();
nonNullValue_0 = params.transitionTime.unsignedShortValue;
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveWithOnOffWithParams:(MTRLevelControlClusterMoveWithOnOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::MoveWithOnOff::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.moveMode
= static_cast<std::remove_reference_t<decltype(request.moveMode)>>(params.moveMode.unsignedCharValue);
if (params.rate == nil) {
request.rate.SetNull();
} else {
auto & nonNullValue_0 = request.rate.SetNonNull();
nonNullValue_0 = params.rate.unsignedCharValue;
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stepWithOnOffWithParams:(MTRLevelControlClusterStepWithOnOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::StepWithOnOff::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.stepMode
= static_cast<std::remove_reference_t<decltype(request.stepMode)>>(params.stepMode.unsignedCharValue);
request.stepSize = params.stepSize.unsignedCharValue;
if (params.transitionTime == nil) {
request.transitionTime.SetNull();
} else {
auto & nonNullValue_0 = request.transitionTime.SetNonNull();
nonNullValue_0 = params.transitionTime.unsignedShortValue;
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stopWithOnOffWithParams:(MTRLevelControlClusterStopWithOnOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::StopWithOnOff::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveToClosestFrequencyWithParams:(MTRLevelControlClusterMoveToClosestFrequencyParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LevelControl::Commands::MoveToClosestFrequency::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.frequency = params.frequency.unsignedShortValue;
chip::Controller::LevelControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeCurrentLevelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRemainingTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeRemainingTimeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeMinLevelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeMaxLevelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentFrequencyWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeCurrentFrequencyID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinFrequencyWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeMinFrequencyID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxFrequencyWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeMaxFrequencyID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOptionsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOptionsID)
params:params];
}
- (void)writeAttributeOptionsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOptionsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOptionsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOptionsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOnOffTransitionTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOnOffTransitionTimeID)
params:params];
}
- (void)writeAttributeOnOffTransitionTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOnOffTransitionTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOnOffTransitionTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOnOffTransitionTimeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOnLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOnLevelID)
params:params];
}
- (void)writeAttributeOnLevelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOnLevelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOnLevelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOnLevelID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOnTransitionTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOnTransitionTimeID)
params:params];
}
- (void)writeAttributeOnTransitionTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOnTransitionTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOnTransitionTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOnTransitionTimeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOffTransitionTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOffTransitionTimeID)
params:params];
}
- (void)writeAttributeOffTransitionTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOffTransitionTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOffTransitionTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeOffTransitionTimeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeDefaultMoveRateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeDefaultMoveRateID)
params:params];
}
- (void)writeAttributeDefaultMoveRateWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeDefaultMoveRateWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeDefaultMoveRateWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeDefaultMoveRateID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeStartUpCurrentLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeStartUpCurrentLevelID)
params:params];
}
- (void)writeAttributeStartUpCurrentLevelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeStartUpCurrentLevelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeStartUpCurrentLevelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeStartUpCurrentLevelID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLevelControlID)
attributeID:@(MTRClusterLevelControlAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterLevelControl (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)moveToLevelWithParams:(MTRLevelControlClusterMoveToLevelParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveToLevelWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveWithParams:(MTRLevelControlClusterMoveParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stepWithParams:(MTRLevelControlClusterStepParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stepWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stopWithParams:(MTRLevelControlClusterStopParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stopWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveToLevelWithOnOffWithParams:(MTRLevelControlClusterMoveToLevelWithOnOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveToLevelWithOnOffWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveWithOnOffWithParams:(MTRLevelControlClusterMoveWithOnOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveWithOnOffWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stepWithOnOffWithParams:(MTRLevelControlClusterStepWithOnOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stepWithOnOffWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stopWithOnOffWithParams:(MTRLevelControlClusterStopWithOnOffParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stopWithOnOffWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveToClosestFrequencyWithParams:(MTRLevelControlClusterMoveToClosestFrequencyParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveToClosestFrequencyWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterBinaryInputBasic
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeActiveTextWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeActiveTextID)
params:params];
}
- (void)writeAttributeActiveTextWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeActiveTextWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeActiveTextWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeActiveTextID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeDescriptionID)
params:params];
}
- (void)writeAttributeDescriptionWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeDescriptionWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeDescriptionWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeDescriptionID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInactiveTextWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeInactiveTextID)
params:params];
}
- (void)writeAttributeInactiveTextWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInactiveTextWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInactiveTextWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeInactiveTextID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOutOfServiceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeOutOfServiceID)
params:params];
}
- (void)writeAttributeOutOfServiceWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOutOfServiceWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOutOfServiceWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeOutOfServiceID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePolarityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributePolarityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePresentValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributePresentValueID)
params:params];
}
- (void)writeAttributePresentValueWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributePresentValueWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributePresentValueWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributePresentValueID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeReliabilityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeReliabilityID)
params:params];
}
- (void)writeAttributeReliabilityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeReliabilityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeReliabilityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeReliabilityID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeStatusFlagsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeStatusFlagsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeApplicationTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeApplicationTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBinaryInputBasicID)
attributeID:@(MTRClusterBinaryInputBasicAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterBinaryInputBasic (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterDescriptor
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeDeviceListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributeDeviceTypeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeServerListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributeServerListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClientListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributeClientListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePartsListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributePartsListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDescriptorID)
attributeID:@(MTRClusterDescriptorAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterDescriptor (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterBinding
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeBindingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBindingID)
attributeID:@(MTRClusterBindingAttributeBindingID)
params:params];
}
- (void)writeAttributeBindingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBindingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBindingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBindingID)
attributeID:@(MTRClusterBindingAttributeBindingID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBindingID)
attributeID:@(MTRClusterBindingAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBindingID)
attributeID:@(MTRClusterBindingAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBindingID)
attributeID:@(MTRClusterBindingAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBindingID)
attributeID:@(MTRClusterBindingAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBindingID)
attributeID:@(MTRClusterBindingAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterBinding (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterAccessControl
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeAclWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeAclID)
params:params];
}
- (void)writeAttributeAclWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeAclWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeAclWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeAclID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeExtensionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeExtensionID)
params:params];
}
- (void)writeAttributeExtensionWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeExtensionWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeExtensionWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeExtensionID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSubjectsPerAccessControlEntryWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeSubjectsPerAccessControlEntryID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTargetsPerAccessControlEntryWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeTargetsPerAccessControlEntryID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAccessControlEntriesPerFabricWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeAccessControlEntriesPerFabricID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccessControlID)
attributeID:@(MTRClusterAccessControlAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterAccessControl (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterActions
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)instantActionWithParams:(MTRActionsClusterInstantActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::InstantAction::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.actionID = params.actionID.unsignedShortValue;
if (params.invokeID != nil) {
auto & definedValue_0 = request.invokeID.Emplace();
definedValue_0 = params.invokeID.unsignedIntValue;
}
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)instantActionWithTransitionWithParams:(MTRActionsClusterInstantActionWithTransitionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::InstantActionWithTransition::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)startActionWithParams:(MTRActionsClusterStartActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::StartAction::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.actionID = params.actionID.unsignedShortValue;
if (params.invokeID != nil) {
auto & definedValue_0 = request.invokeID.Emplace();
definedValue_0 = params.invokeID.unsignedIntValue;
}
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)startActionWithDurationWithParams:(MTRActionsClusterStartActionWithDurationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::StartActionWithDuration::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stopActionWithParams:(MTRActionsClusterStopActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::StopAction::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.actionID = params.actionID.unsignedShortValue;
if (params.invokeID != nil) {
auto & definedValue_0 = request.invokeID.Emplace();
definedValue_0 = params.invokeID.unsignedIntValue;
}
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)pauseActionWithParams:(MTRActionsClusterPauseActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::PauseAction::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.actionID = params.actionID.unsignedShortValue;
if (params.invokeID != nil) {
auto & definedValue_0 = request.invokeID.Emplace();
definedValue_0 = params.invokeID.unsignedIntValue;
}
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)pauseActionWithDurationWithParams:(MTRActionsClusterPauseActionWithDurationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::PauseActionWithDuration::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)resumeActionWithParams:(MTRActionsClusterResumeActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::ResumeAction::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.actionID = params.actionID.unsignedShortValue;
if (params.invokeID != nil) {
auto & definedValue_0 = request.invokeID.Emplace();
definedValue_0 = params.invokeID.unsignedIntValue;
}
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)enableActionWithParams:(MTRActionsClusterEnableActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::EnableAction::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.actionID = params.actionID.unsignedShortValue;
if (params.invokeID != nil) {
auto & definedValue_0 = request.invokeID.Emplace();
definedValue_0 = params.invokeID.unsignedIntValue;
}
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)enableActionWithDurationWithParams:(MTRActionsClusterEnableActionWithDurationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::EnableActionWithDuration::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)disableActionWithParams:(MTRActionsClusterDisableActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::DisableAction::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.actionID = params.actionID.unsignedShortValue;
if (params.invokeID != nil) {
auto & definedValue_0 = request.invokeID.Emplace();
definedValue_0 = params.invokeID.unsignedIntValue;
}
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)disableActionWithDurationWithParams:(MTRActionsClusterDisableActionWithDurationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Actions::Commands::DisableActionWithDuration::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ActionsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeActionListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterActionsID)
attributeID:@(MTRClusterActionsAttributeActionListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeEndpointListsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterActionsID)
attributeID:@(MTRClusterActionsAttributeEndpointListsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSetupURLWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterActionsID)
attributeID:@(MTRClusterActionsAttributeSetupURLID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterActionsID)
attributeID:@(MTRClusterActionsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterActionsID)
attributeID:@(MTRClusterActionsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterActionsID)
attributeID:@(MTRClusterActionsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterActionsID)
attributeID:@(MTRClusterActionsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterActionsID)
attributeID:@(MTRClusterActionsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterActions (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)instantActionWithParams:(MTRActionsClusterInstantActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self instantActionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)instantActionWithTransitionWithParams:(MTRActionsClusterInstantActionWithTransitionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self instantActionWithTransitionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)startActionWithParams:(MTRActionsClusterStartActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self startActionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)startActionWithDurationWithParams:(MTRActionsClusterStartActionWithDurationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self startActionWithDurationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stopActionWithParams:(MTRActionsClusterStopActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stopActionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)pauseActionWithParams:(MTRActionsClusterPauseActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self pauseActionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)pauseActionWithDurationWithParams:(MTRActionsClusterPauseActionWithDurationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self pauseActionWithDurationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)resumeActionWithParams:(MTRActionsClusterResumeActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resumeActionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)enableActionWithParams:(MTRActionsClusterEnableActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self enableActionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)enableActionWithDurationWithParams:(MTRActionsClusterEnableActionWithDurationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self enableActionWithDurationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)disableActionWithParams:(MTRActionsClusterDisableActionParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self disableActionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)disableActionWithDurationWithParams:(MTRActionsClusterDisableActionWithDurationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self disableActionWithDurationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterBasic
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)mfgSpecificPingWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self mfgSpecificPingWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)mfgSpecificPingWithParams:(MTRBasicClusterMfgSpecificPingParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Basic::Commands::MfgSpecificPing::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::BasicCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeDataModelRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeDataModelRevisionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeVendorNameID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeVendorIDID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeProductNameWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeProductNameID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeProductIDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeProductIDID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNodeLabelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeNodeLabelID)
params:params];
}
- (void)writeAttributeNodeLabelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNodeLabelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNodeLabelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeNodeLabelID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLocationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeLocationID)
params:params];
}
- (void)writeAttributeLocationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLocationWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLocationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeLocationID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeHardwareVersionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeHardwareVersionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeHardwareVersionStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeHardwareVersionStringID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSoftwareVersionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeSoftwareVersionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSoftwareVersionStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeSoftwareVersionStringID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeManufacturingDateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeManufacturingDateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePartNumberWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributePartNumberID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeProductURLWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeProductURLID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeProductLabelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeProductLabelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSerialNumberWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeSerialNumberID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLocalConfigDisabledWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeLocalConfigDisabledID)
params:params];
}
- (void)writeAttributeLocalConfigDisabledWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLocalConfigDisabledWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLocalConfigDisabledWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeLocalConfigDisabledID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeReachableWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeReachableID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeUniqueIDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeUniqueIDID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCapabilityMinimaWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeCapabilityMinimaID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBasicID)
attributeID:@(MTRClusterBasicAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterBasic (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)mfgSpecificPingWithParams:(MTRBasicClusterMfgSpecificPingParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self mfgSpecificPingWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)mfgSpecificPingWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self mfgSpecificPingWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterOtaSoftwareUpdateProvider
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)queryImageWithParams:(MTROtaSoftwareUpdateProviderClusterQueryImageParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROtaSoftwareUpdateProviderClusterQueryImageResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OtaSoftwareUpdateProviderClusterQueryImageResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OtaSoftwareUpdateProvider::Commands::QueryImage::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.vendorId
= static_cast<std::remove_reference_t<decltype(request.vendorId)>>(params.vendorId.unsignedShortValue);
request.productId = params.productId.unsignedShortValue;
request.softwareVersion = params.softwareVersion.unsignedIntValue;
{
using ListType_0 = std::remove_reference_t<decltype(request.protocolsSupported)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.protocolsSupported.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.protocolsSupported.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_0 = (NSNumber *) params.protocolsSupported[i_0];
listHolder_0->mList[i_0] = static_cast<std::remove_reference_t<decltype(listHolder_0->mList[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];
}
chip::Controller::OtaSoftwareUpdateProviderCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)applyUpdateRequestWithParams:(MTROtaSoftwareUpdateProviderClusterApplyUpdateRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.updateToken = [self asByteSpan:params.updateToken];
request.newVersion = params.newVersion.unsignedIntValue;
chip::Controller::OtaSoftwareUpdateProviderCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)notifyUpdateAppliedWithParams:(MTROtaSoftwareUpdateProviderClusterNotifyUpdateAppliedParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.updateToken = [self asByteSpan:params.updateToken];
request.softwareVersion = params.softwareVersion.unsignedIntValue;
chip::Controller::OtaSoftwareUpdateProviderCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateProviderID)
attributeID:@(MTRClusterOtaSoftwareUpdateProviderAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateProviderID)
attributeID:@(MTRClusterOtaSoftwareUpdateProviderAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateProviderID)
attributeID:@(MTRClusterOtaSoftwareUpdateProviderAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateProviderID)
attributeID:@(MTRClusterOtaSoftwareUpdateProviderAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateProviderID)
attributeID:@(MTRClusterOtaSoftwareUpdateProviderAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterOtaSoftwareUpdateProvider (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)queryImageWithParams:(MTROtaSoftwareUpdateProviderClusterQueryImageParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROtaSoftwareUpdateProviderClusterQueryImageResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self queryImageWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)applyUpdateRequestWithParams:(MTROtaSoftwareUpdateProviderClusterApplyUpdateRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self applyUpdateRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)notifyUpdateAppliedWithParams:(MTROtaSoftwareUpdateProviderClusterNotifyUpdateAppliedParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self notifyUpdateAppliedWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterOtaSoftwareUpdateRequestor
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)announceOtaProviderWithParams:(MTROtaSoftwareUpdateRequestorClusterAnnounceOtaProviderParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.providerNodeId = params.providerNodeId.unsignedLongLongValue;
request.vendorId
= static_cast<std::remove_reference_t<decltype(request.vendorId)>>(params.vendorId.unsignedShortValue);
request.announcementReason = static_cast<std::remove_reference_t<decltype(request.announcementReason)>>(
params.announcementReason.unsignedCharValue);
if (params.metadataForNode != nil) {
auto & definedValue_0 = request.metadataForNode.Emplace();
definedValue_0 = [self asByteSpan:params.metadataForNode];
}
request.endpoint = params.endpoint.unsignedShortValue;
chip::Controller::OtaSoftwareUpdateRequestorCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeDefaultOtaProvidersWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeDefaultOtaProvidersID)
params:params];
}
- (void)writeAttributeDefaultOtaProvidersWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeDefaultOtaProvidersWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeDefaultOtaProvidersWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeDefaultOtaProvidersID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUpdatePossibleWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeUpdatePossibleID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeUpdateStateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeUpdateStateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeUpdateStateProgressWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeUpdateStateProgressID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOtaSoftwareUpdateRequestorID)
attributeID:@(MTRClusterOtaSoftwareUpdateRequestorAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterOtaSoftwareUpdateRequestor (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)announceOtaProviderWithParams:(MTROtaSoftwareUpdateRequestorClusterAnnounceOtaProviderParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self announceOtaProviderWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterLocalizationConfiguration
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeActiveLocaleWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLocalizationConfigurationID)
attributeID:@(MTRClusterLocalizationConfigurationAttributeActiveLocaleID)
params:params];
}
- (void)writeAttributeActiveLocaleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeActiveLocaleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeActiveLocaleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLocalizationConfigurationID)
attributeID:@(MTRClusterLocalizationConfigurationAttributeActiveLocaleID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSupportedLocalesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLocalizationConfigurationID)
attributeID:@(MTRClusterLocalizationConfigurationAttributeSupportedLocalesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLocalizationConfigurationID)
attributeID:@(MTRClusterLocalizationConfigurationAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLocalizationConfigurationID)
attributeID:@(MTRClusterLocalizationConfigurationAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLocalizationConfigurationID)
attributeID:@(MTRClusterLocalizationConfigurationAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLocalizationConfigurationID)
attributeID:@(MTRClusterLocalizationConfigurationAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLocalizationConfigurationID)
attributeID:@(MTRClusterLocalizationConfigurationAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterLocalizationConfiguration (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterTimeFormatLocalization
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeHourFormatWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeHourFormatID)
params:params];
}
- (void)writeAttributeHourFormatWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeHourFormatWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeHourFormatWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeHourFormatID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveCalendarTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeActiveCalendarTypeID)
params:params];
}
- (void)writeAttributeActiveCalendarTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeActiveCalendarTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeActiveCalendarTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeActiveCalendarTypeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSupportedCalendarTypesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeSupportedCalendarTypesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTimeFormatLocalizationID)
attributeID:@(MTRClusterTimeFormatLocalizationAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterTimeFormatLocalization (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterUnitLocalization
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeTemperatureUnitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitLocalizationID)
attributeID:@(MTRClusterUnitLocalizationAttributeTemperatureUnitID)
params:params];
}
- (void)writeAttributeTemperatureUnitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeTemperatureUnitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeTemperatureUnitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitLocalizationID)
attributeID:@(MTRClusterUnitLocalizationAttributeTemperatureUnitID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitLocalizationID)
attributeID:@(MTRClusterUnitLocalizationAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitLocalizationID)
attributeID:@(MTRClusterUnitLocalizationAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitLocalizationID)
attributeID:@(MTRClusterUnitLocalizationAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitLocalizationID)
attributeID:@(MTRClusterUnitLocalizationAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitLocalizationID)
attributeID:@(MTRClusterUnitLocalizationAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterUnitLocalization (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterPowerSourceConfiguration
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeSourcesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceConfigurationID)
attributeID:@(MTRClusterPowerSourceConfigurationAttributeSourcesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceConfigurationID)
attributeID:@(MTRClusterPowerSourceConfigurationAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceConfigurationID)
attributeID:@(MTRClusterPowerSourceConfigurationAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceConfigurationID)
attributeID:@(MTRClusterPowerSourceConfigurationAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceConfigurationID)
attributeID:@(MTRClusterPowerSourceConfigurationAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceConfigurationID)
attributeID:@(MTRClusterPowerSourceConfigurationAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterPowerSourceConfiguration (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterPowerSource
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOrderWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeOrderID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeDescriptionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWiredAssessedInputVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeWiredAssessedInputVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWiredAssessedInputFrequencyWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeWiredAssessedInputFrequencyID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWiredCurrentTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeWiredCurrentTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWiredAssessedCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeWiredAssessedCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWiredNominalVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeWiredNominalVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWiredMaximumCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeWiredMaximumCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWiredPresentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeWiredPresentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveWiredFaultsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeActiveWiredFaultsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatPercentRemainingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatPercentRemainingID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatTimeRemainingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatTimeRemainingID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatChargeLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatChargeLevelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatReplacementNeededWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatReplacementNeededID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatReplaceabilityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatReplaceabilityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatPresentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatPresentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveBatFaultsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeActiveBatFaultsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatReplacementDescriptionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatReplacementDescriptionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatCommonDesignationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatCommonDesignationID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatANSIDesignationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatANSIDesignationID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatIECDesignationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatIECDesignationID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatApprovedChemistryWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatApprovedChemistryID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatCapacityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatCapacityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatQuantityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatQuantityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatChargeStateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatChargeStateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatTimeToFullChargeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatTimeToFullChargeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatFunctionalWhileChargingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatFunctionalWhileChargingID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBatChargingCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeBatChargingCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveBatChargeFaultsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeActiveBatChargeFaultsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPowerSourceID)
attributeID:@(MTRClusterPowerSourceAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterPowerSource (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterGeneralCommissioning
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)armFailSafeWithParams:(MTRGeneralCommissioningClusterArmFailSafeParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRGeneralCommissioningClusterArmFailSafeResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
GeneralCommissioningClusterArmFailSafeResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
GeneralCommissioning::Commands::ArmFailSafe::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.expiryLengthSeconds = params.expiryLengthSeconds.unsignedShortValue;
request.breadcrumb = params.breadcrumb.unsignedLongLongValue;
chip::Controller::GeneralCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)setRegulatoryConfigWithParams:(MTRGeneralCommissioningClusterSetRegulatoryConfigParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
GeneralCommissioningClusterSetRegulatoryConfigResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
GeneralCommissioning::Commands::SetRegulatoryConfig::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.newRegulatoryConfig = static_cast<std::remove_reference_t<decltype(request.newRegulatoryConfig)>>(
params.newRegulatoryConfig.unsignedCharValue);
request.countryCode = [self asCharSpan:params.countryCode];
request.breadcrumb = params.breadcrumb.unsignedLongLongValue;
chip::Controller::GeneralCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)commissioningCompleteWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(
MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self commissioningCompleteWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)commissioningCompleteWithParams:(MTRGeneralCommissioningClusterCommissioningCompleteParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge
= new MTRGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
GeneralCommissioningClusterCommissioningCompleteResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
GeneralCommissioning::Commands::CommissioningComplete::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::GeneralCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeBreadcrumbWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeBreadcrumbID)
params:params];
}
- (void)writeAttributeBreadcrumbWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBreadcrumbWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBreadcrumbWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeBreadcrumbID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBasicCommissioningInfoWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeBasicCommissioningInfoID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRegulatoryConfigWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeRegulatoryConfigID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLocationCapabilityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeLocationCapabilityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSupportsConcurrentConnectionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeSupportsConcurrentConnectionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralCommissioningID)
attributeID:@(MTRClusterGeneralCommissioningAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterGeneralCommissioning (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)armFailSafeWithParams:(MTRGeneralCommissioningClusterArmFailSafeParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self armFailSafeWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)setRegulatoryConfigWithParams:(MTRGeneralCommissioningClusterSetRegulatoryConfigParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self setRegulatoryConfigWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)commissioningCompleteWithParams:(MTRGeneralCommissioningClusterCommissioningCompleteParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self commissioningCompleteWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)commissioningCompleteWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:
(void (^)(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self commissioningCompleteWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterNetworkCommissioning
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)scanNetworksWithParams:(MTRNetworkCommissioningClusterScanNetworksParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRNetworkCommissioningClusterScanNetworksResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRNetworkCommissioningClusterScanNetworksResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
NetworkCommissioningClusterScanNetworksResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
NetworkCommissioning::Commands::ScanNetworks::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
}
}
chip::Controller::NetworkCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)addOrUpdateWiFiNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpdateWiFiNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
NetworkCommissioningClusterNetworkConfigResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
}
chip::Controller::NetworkCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)addOrUpdateThreadNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpdateThreadNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
NetworkCommissioningClusterNetworkConfigResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.operationalDataset = [self asByteSpan:params.operationalDataset];
if (params.breadcrumb != nil) {
auto & definedValue_0 = request.breadcrumb.Emplace();
definedValue_0 = params.breadcrumb.unsignedLongLongValue;
}
chip::Controller::NetworkCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)removeNetworkWithParams:(MTRNetworkCommissioningClusterRemoveNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
NetworkCommissioningClusterNetworkConfigResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
NetworkCommissioning::Commands::RemoveNetwork::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.networkID = [self asByteSpan:params.networkID];
if (params.breadcrumb != nil) {
auto & definedValue_0 = request.breadcrumb.Emplace();
definedValue_0 = params.breadcrumb.unsignedLongLongValue;
}
chip::Controller::NetworkCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)connectNetworkWithParams:(MTRNetworkCommissioningClusterConnectNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRNetworkCommissioningClusterConnectNetworkResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRNetworkCommissioningClusterConnectNetworkResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
NetworkCommissioningClusterConnectNetworkResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
NetworkCommissioning::Commands::ConnectNetwork::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.networkID = [self asByteSpan:params.networkID];
if (params.breadcrumb != nil) {
auto & definedValue_0 = request.breadcrumb.Emplace();
definedValue_0 = params.breadcrumb.unsignedLongLongValue;
}
chip::Controller::NetworkCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)reorderNetworkWithParams:(MTRNetworkCommissioningClusterReorderNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
NetworkCommissioningClusterNetworkConfigResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
NetworkCommissioning::Commands::ReorderNetwork::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
}
chip::Controller::NetworkCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeMaxNetworksWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeMaxNetworksID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNetworksWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeNetworksID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeScanMaxTimeSecondsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeScanMaxTimeSecondsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeConnectMaxTimeSecondsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeConnectMaxTimeSecondsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInterfaceEnabledWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeInterfaceEnabledID)
params:params];
}
- (void)writeAttributeInterfaceEnabledWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInterfaceEnabledWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInterfaceEnabledWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeInterfaceEnabledID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLastNetworkingStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeLastNetworkingStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLastNetworkIDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeLastNetworkIDID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLastConnectErrorValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeLastConnectErrorValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterNetworkCommissioningID)
attributeID:@(MTRClusterNetworkCommissioningAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterNetworkCommissioning (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)scanNetworksWithParams:(MTRNetworkCommissioningClusterScanNetworksParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRNetworkCommissioningClusterScanNetworksResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self scanNetworksWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)addOrUpdateWiFiNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpdateWiFiNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self addOrUpdateWiFiNetworkWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)addOrUpdateThreadNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpdateThreadNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self addOrUpdateThreadNetworkWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)removeNetworkWithParams:(MTRNetworkCommissioningClusterRemoveNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self removeNetworkWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)connectNetworkWithParams:(MTRNetworkCommissioningClusterConnectNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRNetworkCommissioningClusterConnectNetworkResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self connectNetworkWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)reorderNetworkWithParams:(MTRNetworkCommissioningClusterReorderNetworkParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self reorderNetworkWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterDiagnosticLogs
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)retrieveLogsRequestWithParams:(MTRDiagnosticLogsClusterRetrieveLogsRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRDiagnosticLogsClusterRetrieveLogsResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRDiagnosticLogsClusterRetrieveLogsResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
DiagnosticLogsClusterRetrieveLogsResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DiagnosticLogs::Commands::RetrieveLogsRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.intent = static_cast<std::remove_reference_t<decltype(request.intent)>>(params.intent.unsignedCharValue);
request.requestedProtocol = static_cast<std::remove_reference_t<decltype(request.requestedProtocol)>>(
params.requestedProtocol.unsignedCharValue);
request.transferFileDesignator = [self asByteSpan:params.transferFileDesignator];
chip::Controller::DiagnosticLogsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDiagnosticLogsID)
attributeID:@(MTRClusterDiagnosticLogsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDiagnosticLogsID)
attributeID:@(MTRClusterDiagnosticLogsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDiagnosticLogsID)
attributeID:@(MTRClusterDiagnosticLogsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDiagnosticLogsID)
attributeID:@(MTRClusterDiagnosticLogsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDiagnosticLogsID)
attributeID:@(MTRClusterDiagnosticLogsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterDiagnosticLogs (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)retrieveLogsRequestWithParams:(MTRDiagnosticLogsClusterRetrieveLogsRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRDiagnosticLogsClusterRetrieveLogsResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self retrieveLogsRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterGeneralDiagnostics
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)testEventTriggerWithParams:(MTRGeneralDiagnosticsClusterTestEventTriggerParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
GeneralDiagnostics::Commands::TestEventTrigger::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.enableKey = [self asByteSpan:params.enableKey];
request.eventTrigger = params.eventTrigger.unsignedLongLongValue;
chip::Controller::GeneralDiagnosticsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeNetworkInterfacesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeNetworkInterfacesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRebootCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeRebootCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeUpTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeUpTimeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTotalOperationalHoursWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeTotalOperationalHoursID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBootReasonsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeBootReasonsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveHardwareFaultsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeActiveHardwareFaultsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveRadioFaultsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeActiveRadioFaultsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveNetworkFaultsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeActiveNetworkFaultsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTestEventTriggersEnabledWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeTestEventTriggersEnabledID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGeneralDiagnosticsID)
attributeID:@(MTRClusterGeneralDiagnosticsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterGeneralDiagnostics (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)testEventTriggerWithParams:(MTRGeneralDiagnosticsClusterTestEventTriggerParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self testEventTriggerWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterSoftwareDiagnostics
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)resetWatermarksWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self resetWatermarksWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)resetWatermarksWithParams:(MTRSoftwareDiagnosticsClusterResetWatermarksParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
SoftwareDiagnostics::Commands::ResetWatermarks::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::SoftwareDiagnosticsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeThreadMetricsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeThreadMetricsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentHeapFreeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeCurrentHeapFreeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentHeapUsedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeCurrentHeapUsedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentHeapHighWatermarkWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeCurrentHeapHighWatermarkID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSoftwareDiagnosticsID)
attributeID:@(MTRClusterSoftwareDiagnosticsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterSoftwareDiagnostics (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)resetWatermarksWithParams:(MTRSoftwareDiagnosticsClusterResetWatermarksParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resetWatermarksWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)resetWatermarksWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resetWatermarksWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterThreadNetworkDiagnostics
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)resetCountsWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self resetCountsWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)resetCountsWithParams:(MTRThreadNetworkDiagnosticsClusterResetCountsParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ThreadNetworkDiagnostics::Commands::ResetCounts::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::ThreadNetworkDiagnosticsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeChannelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeChannelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRoutingRoleWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRoutingRoleID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNetworkNameWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeNetworkNameID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePanIdWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributePanIdID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeExtendedPanIdWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeExtendedPanIdID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeshLocalPrefixWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeMeshLocalPrefixID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeOverrunCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNeighborTableListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeNeighborTableListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRouteTableListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRouteTableListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePartitionIdWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributePartitionIdID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWeightingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeWeightingID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDataVersionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeDataVersionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeStableDataVersionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeStableDataVersionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLeaderRouterIdWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeLeaderRouterIdID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDetachedRoleCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeDetachedRoleCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeChildRoleCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeChildRoleCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRouterRoleCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRouterRoleCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLeaderRoleCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeLeaderRoleCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttachAttemptCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeAttachAttemptCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePartitionIdChangeCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributePartitionIdChangeCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBetterPartitionAttachAttemptCountWithParams:(MTRReadParams * _Nullable)params
{
return
[self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeBetterPartitionAttachAttemptCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeParentChangeCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeParentChangeCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxTotalCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxTotalCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxUnicastCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxUnicastCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxBroadcastCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxBroadcastCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxAckRequestedCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxAckRequestedCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxAckedCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxAckedCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxNoAckRequestedCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxNoAckRequestedCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxDataCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxDataCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxDataPollCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxDataPollCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxBeaconCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxBeaconCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxBeaconRequestCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxBeaconRequestCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxOtherCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxOtherCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxRetryCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxRetryCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxDirectMaxRetryExpiryCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxDirectMaxRetryExpiryCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxIndirectMaxRetryExpiryCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxIndirectMaxRetryExpiryCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxErrCcaCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxErrCcaCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxErrAbortCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxErrAbortCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxErrBusyChannelCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeTxErrBusyChannelCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxTotalCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxTotalCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxUnicastCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxUnicastCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxBroadcastCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxBroadcastCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxDataCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxDataCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxDataPollCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxDataPollCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxBeaconCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxBeaconCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxBeaconRequestCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxBeaconRequestCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxOtherCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxOtherCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxAddressFilteredCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxAddressFilteredCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxDestAddrFilteredCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxDestAddrFilteredCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxDuplicatedCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxDuplicatedCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxErrNoFrameCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrNoFrameCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxErrUnknownNeighborCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrUnknownNeighborCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxErrInvalidSrcAddrCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrInvalidSrcAddrCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxErrSecCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrSecCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxErrFcsCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrFcsCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRxErrOtherCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeRxErrOtherCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveTimestampWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeActiveTimestampID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePendingTimestampWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributePendingTimestampID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDelayWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeDelayID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSecurityPolicyWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeSecurityPolicyID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeChannelPage0MaskWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeChannelPage0MaskID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOperationalDatasetComponentsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeOperationalDatasetComponentsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveNetworkFaultsListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeActiveNetworkFaultsListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThreadNetworkDiagnosticsID)
attributeID:@(MTRClusterThreadNetworkDiagnosticsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterThreadNetworkDiagnostics (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)resetCountsWithParams:(MTRThreadNetworkDiagnosticsClusterResetCountsParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resetCountsWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)resetCountsWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resetCountsWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
@end
@implementation MTRClusterWiFiNetworkDiagnostics
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)resetCountsWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self resetCountsWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)resetCountsWithParams:(MTRWiFiNetworkDiagnosticsClusterResetCountsParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
WiFiNetworkDiagnostics::Commands::ResetCounts::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::WiFiNetworkDiagnosticsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeBssidWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeBssidID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSecurityTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeSecurityTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWiFiVersionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeWiFiVersionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeChannelNumberWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeChannelNumberID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRssiWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeRssiID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBeaconLostCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeBeaconLostCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBeaconRxCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeBeaconRxCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePacketMulticastRxCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributePacketMulticastRxCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePacketMulticastTxCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributePacketMulticastTxCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePacketUnicastRxCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributePacketUnicastRxCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePacketUnicastTxCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributePacketUnicastTxCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentMaxRateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeCurrentMaxRateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeOverrunCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWiFiNetworkDiagnosticsID)
attributeID:@(MTRClusterWiFiNetworkDiagnosticsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterWiFiNetworkDiagnostics (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)resetCountsWithParams:(MTRWiFiNetworkDiagnosticsClusterResetCountsParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resetCountsWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)resetCountsWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resetCountsWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
@end
@implementation MTRClusterEthernetNetworkDiagnostics
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)resetCountsWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self resetCountsWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)resetCountsWithParams:(MTREthernetNetworkDiagnosticsClusterResetCountsParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
EthernetNetworkDiagnostics::Commands::ResetCounts::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::EthernetNetworkDiagnosticsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributePHYRateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributePHYRateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFullDuplexWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeFullDuplexID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePacketRxCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributePacketRxCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePacketTxCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributePacketTxCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTxErrCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeTxErrCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCollisionCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeCollisionCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOverrunCountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeOverrunCountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCarrierDetectWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeCarrierDetectID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTimeSinceResetWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeTimeSinceResetID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterEthernetNetworkDiagnosticsID)
attributeID:@(MTRClusterEthernetNetworkDiagnosticsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterEthernetNetworkDiagnostics (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)resetCountsWithParams:(MTREthernetNetworkDiagnosticsClusterResetCountsParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resetCountsWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)resetCountsWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self resetCountsWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
@end
@implementation MTRClusterBridgedDeviceBasic
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeVendorNameID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeVendorIDID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeProductNameWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeProductNameID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNodeLabelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeNodeLabelID)
params:params];
}
- (void)writeAttributeNodeLabelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNodeLabelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNodeLabelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeNodeLabelID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeHardwareVersionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeHardwareVersionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeHardwareVersionStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeHardwareVersionStringID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSoftwareVersionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeSoftwareVersionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSoftwareVersionStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeSoftwareVersionStringID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeManufacturingDateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeManufacturingDateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePartNumberWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributePartNumberID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeProductURLWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeProductURLID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeProductLabelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeProductLabelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSerialNumberWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeSerialNumberID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeReachableWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeReachableID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeUniqueIDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeUniqueIDID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBridgedDeviceBasicID)
attributeID:@(MTRClusterBridgedDeviceBasicAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterBridgedDeviceBasic (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterSwitch
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfPositionsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSwitchID)
attributeID:@(MTRClusterSwitchAttributeNumberOfPositionsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentPositionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSwitchID)
attributeID:@(MTRClusterSwitchAttributeCurrentPositionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMultiPressMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSwitchID)
attributeID:@(MTRClusterSwitchAttributeMultiPressMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSwitchID)
attributeID:@(MTRClusterSwitchAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSwitchID)
attributeID:@(MTRClusterSwitchAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSwitchID)
attributeID:@(MTRClusterSwitchAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSwitchID)
attributeID:@(MTRClusterSwitchAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterSwitchID)
attributeID:@(MTRClusterSwitchAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterSwitch (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterAdministratorCommissioning
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)openCommissioningWindowWithParams:(MTRAdministratorCommissioningClusterOpenCommissioningWindowParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
AdministratorCommissioning::Commands::OpenCommissioningWindow::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
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];
chip::Controller::AdministratorCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)openBasicCommissioningWindowWithParams:(MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
request.commissioningTimeout = params.commissioningTimeout.unsignedShortValue;
chip::Controller::AdministratorCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)revokeCommissioningWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self revokeCommissioningWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)revokeCommissioningWithParams:(MTRAdministratorCommissioningClusterRevokeCommissioningParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
AdministratorCommissioning::Commands::RevokeCommissioning::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
chip::Controller::AdministratorCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeWindowStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAdministratorCommissioningID)
attributeID:@(MTRClusterAdministratorCommissioningAttributeWindowStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAdminFabricIndexWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAdministratorCommissioningID)
attributeID:@(MTRClusterAdministratorCommissioningAttributeAdminFabricIndexID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAdminVendorIdWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAdministratorCommissioningID)
attributeID:@(MTRClusterAdministratorCommissioningAttributeAdminVendorIdID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAdministratorCommissioningID)
attributeID:@(MTRClusterAdministratorCommissioningAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAdministratorCommissioningID)
attributeID:@(MTRClusterAdministratorCommissioningAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAdministratorCommissioningID)
attributeID:@(MTRClusterAdministratorCommissioningAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAdministratorCommissioningID)
attributeID:@(MTRClusterAdministratorCommissioningAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAdministratorCommissioningID)
attributeID:@(MTRClusterAdministratorCommissioningAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterAdministratorCommissioning (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)openCommissioningWindowWithParams:(MTRAdministratorCommissioningClusterOpenCommissioningWindowParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self openCommissioningWindowWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)openBasicCommissioningWindowWithParams:(MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self openBasicCommissioningWindowWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)revokeCommissioningWithParams:(MTRAdministratorCommissioningClusterRevokeCommissioningParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self revokeCommissioningWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)revokeCommissioningWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self revokeCommissioningWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterOperationalCredentials
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)attestationRequestWithParams:(MTROperationalCredentialsClusterAttestationRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROperationalCredentialsClusterAttestationResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROperationalCredentialsClusterAttestationResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OperationalCredentialsClusterAttestationResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OperationalCredentials::Commands::AttestationRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.attestationNonce = [self asByteSpan:params.attestationNonce];
chip::Controller::OperationalCredentialsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)certificateChainRequestWithParams:(MTROperationalCredentialsClusterCertificateChainRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROperationalCredentialsClusterCertificateChainResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROperationalCredentialsClusterCertificateChainResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OperationalCredentialsClusterCertificateChainResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OperationalCredentials::Commands::CertificateChainRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.certificateType = params.certificateType.unsignedCharValue;
chip::Controller::OperationalCredentialsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)CSRRequestWithParams:(MTROperationalCredentialsClusterCSRRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROperationalCredentialsClusterCSRResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROperationalCredentialsClusterCSRResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OperationalCredentialsClusterCSRResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OperationalCredentials::Commands::CSRRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.CSRNonce = [self asByteSpan:params.csrNonce];
if (params.isForUpdateNOC != nil) {
auto & definedValue_0 = request.isForUpdateNOC.Emplace();
definedValue_0 = params.isForUpdateNOC.boolValue;
}
chip::Controller::OperationalCredentialsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)addNOCWithParams:(MTROperationalCredentialsClusterAddNOCParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OperationalCredentialsClusterNOCResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OperationalCredentials::Commands::AddNOC::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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<std::remove_reference_t<decltype(request.adminVendorId)>>(
params.adminVendorId.unsignedShortValue);
chip::Controller::OperationalCredentialsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)updateNOCWithParams:(MTROperationalCredentialsClusterUpdateNOCParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OperationalCredentialsClusterNOCResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OperationalCredentials::Commands::UpdateNOC::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.NOCValue = [self asByteSpan:params.nocValue];
if (params.icacValue != nil) {
auto & definedValue_0 = request.ICACValue.Emplace();
definedValue_0 = [self asByteSpan:params.icacValue];
}
chip::Controller::OperationalCredentialsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)updateFabricLabelWithParams:(MTROperationalCredentialsClusterUpdateFabricLabelParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OperationalCredentialsClusterNOCResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OperationalCredentials::Commands::UpdateFabricLabel::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.label = [self asCharSpan:params.label];
chip::Controller::OperationalCredentialsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)removeFabricWithParams:(MTROperationalCredentialsClusterRemoveFabricParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
OperationalCredentialsClusterNOCResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OperationalCredentials::Commands::RemoveFabric::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.fabricIndex = params.fabricIndex.unsignedCharValue;
chip::Controller::OperationalCredentialsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)addTrustedRootCertificateWithParams:(MTROperationalCredentialsClusterAddTrustedRootCertificateParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
OperationalCredentials::Commands::AddTrustedRootCertificate::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.rootCertificate = [self asByteSpan:params.rootCertificate];
chip::Controller::OperationalCredentialsCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeNOCsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeNOCsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFabricsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeFabricsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSupportedFabricsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeSupportedFabricsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCommissionedFabricsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeCommissionedFabricsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTrustedRootCertificatesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeTrustedRootCertificatesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentFabricIndexWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeCurrentFabricIndexID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOperationalCredentialsID)
attributeID:@(MTRClusterOperationalCredentialsAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterOperationalCredentials (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)attestationRequestWithParams:(MTROperationalCredentialsClusterAttestationRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROperationalCredentialsClusterAttestationResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self attestationRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)certificateChainRequestWithParams:(MTROperationalCredentialsClusterCertificateChainRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROperationalCredentialsClusterCertificateChainResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self certificateChainRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)CSRRequestWithParams:(MTROperationalCredentialsClusterCSRRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROperationalCredentialsClusterCSRResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self CSRRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)addNOCWithParams:(MTROperationalCredentialsClusterAddNOCParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self addNOCWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)updateNOCWithParams:(MTROperationalCredentialsClusterUpdateNOCParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self updateNOCWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)updateFabricLabelWithParams:(MTROperationalCredentialsClusterUpdateFabricLabelParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self updateFabricLabelWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)removeFabricWithParams:(MTROperationalCredentialsClusterRemoveFabricParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self removeFabricWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)addTrustedRootCertificateWithParams:(MTROperationalCredentialsClusterAddTrustedRootCertificateParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self addTrustedRootCertificateWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterGroupKeyManagement
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)keySetWriteWithParams:(MTRGroupKeyManagementClusterKeySetWriteParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
GroupKeyManagement::Commands::KeySetWrite::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupKeySet.groupKeySetID = params.groupKeySet.groupKeySetID.unsignedShortValue;
request.groupKeySet.groupKeySecurityPolicy
= static_cast<std::remove_reference_t<decltype(request.groupKeySet.groupKeySecurityPolicy)>>(
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;
}
chip::Controller::GroupKeyManagementCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)keySetReadWithParams:(MTRGroupKeyManagementClusterKeySetReadParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRGroupKeyManagementClusterKeySetReadResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
GroupKeyManagementClusterKeySetReadResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
GroupKeyManagement::Commands::KeySetRead::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupKeySetID = params.groupKeySetID.unsignedShortValue;
chip::Controller::GroupKeyManagementCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)keySetRemoveWithParams:(MTRGroupKeyManagementClusterKeySetRemoveParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
GroupKeyManagement::Commands::KeySetRemove::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.groupKeySetID = params.groupKeySetID.unsignedShortValue;
chip::Controller::GroupKeyManagementCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)keySetReadAllIndicesWithParams:(MTRGroupKeyManagementClusterKeySetReadAllIndicesParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
GroupKeyManagementClusterKeySetReadAllIndicesResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
GroupKeyManagement::Commands::KeySetReadAllIndices::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
{
using ListType_0 = std::remove_reference_t<decltype(request.groupKeySetIDs)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.groupKeySetIDs.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.groupKeySetIDs.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::GroupKeyManagementCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeGroupKeyMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeGroupKeyMapID)
params:params];
}
- (void)writeAttributeGroupKeyMapWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeGroupKeyMapWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeGroupKeyMapWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeGroupKeyMapID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGroupTableWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeGroupTableID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxGroupsPerFabricWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeMaxGroupsPerFabricID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxGroupKeysPerFabricWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeMaxGroupKeysPerFabricID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterGroupKeyManagementID)
attributeID:@(MTRClusterGroupKeyManagementAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterGroupKeyManagement (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)keySetWriteWithParams:(MTRGroupKeyManagementClusterKeySetWriteParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self keySetWriteWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)keySetReadWithParams:(MTRGroupKeyManagementClusterKeySetReadParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self keySetReadWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)keySetRemoveWithParams:(MTRGroupKeyManagementClusterKeySetRemoveParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self keySetRemoveWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)keySetReadAllIndicesWithParams:(MTRGroupKeyManagementClusterKeySetReadAllIndicesParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self keySetReadAllIndicesWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterFixedLabel
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeLabelListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFixedLabelID)
attributeID:@(MTRClusterFixedLabelAttributeLabelListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFixedLabelID)
attributeID:@(MTRClusterFixedLabelAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFixedLabelID)
attributeID:@(MTRClusterFixedLabelAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFixedLabelID)
attributeID:@(MTRClusterFixedLabelAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFixedLabelID)
attributeID:@(MTRClusterFixedLabelAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFixedLabelID)
attributeID:@(MTRClusterFixedLabelAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterFixedLabel (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterUserLabel
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeLabelListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUserLabelID)
attributeID:@(MTRClusterUserLabelAttributeLabelListID)
params:params];
}
- (void)writeAttributeLabelListWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLabelListWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLabelListWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUserLabelID)
attributeID:@(MTRClusterUserLabelAttributeLabelListID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUserLabelID)
attributeID:@(MTRClusterUserLabelAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUserLabelID)
attributeID:@(MTRClusterUserLabelAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUserLabelID)
attributeID:@(MTRClusterUserLabelAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUserLabelID)
attributeID:@(MTRClusterUserLabelAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUserLabelID)
attributeID:@(MTRClusterUserLabelAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterUserLabel (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterBooleanState
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeStateValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBooleanStateID)
attributeID:@(MTRClusterBooleanStateAttributeStateValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBooleanStateID)
attributeID:@(MTRClusterBooleanStateAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBooleanStateID)
attributeID:@(MTRClusterBooleanStateAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBooleanStateID)
attributeID:@(MTRClusterBooleanStateAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBooleanStateID)
attributeID:@(MTRClusterBooleanStateAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBooleanStateID)
attributeID:@(MTRClusterBooleanStateAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterBooleanState (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterModeSelect
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)changeToModeWithParams:(MTRModeSelectClusterChangeToModeParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ModeSelect::Commands::ChangeToMode::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.newMode = params.newMode.unsignedCharValue;
chip::Controller::ModeSelectCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeDescriptionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeDescriptionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeStandardNamespaceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeStandardNamespaceID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSupportedModesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeSupportedModesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeCurrentModeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeStartUpModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeStartUpModeID)
params:params];
}
- (void)writeAttributeStartUpModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeStartUpModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeStartUpModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeStartUpModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOnModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeOnModeID)
params:params];
}
- (void)writeAttributeOnModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOnModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOnModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeOnModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterModeSelectID)
attributeID:@(MTRClusterModeSelectAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterModeSelect (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)changeToModeWithParams:(MTRModeSelectClusterChangeToModeParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self changeToModeWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterDoorLock
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)lockDoorWithParams:(MTRDoorLockClusterLockDoorParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::LockDoor::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
if (params != nil) {
if (params.pinCode != nil) {
auto & definedValue_0 = request.pinCode.Emplace();
definedValue_0 = [self asByteSpan:params.pinCode];
}
}
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)unlockDoorWithParams:(MTRDoorLockClusterUnlockDoorParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::UnlockDoor::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
if (params != nil) {
if (params.pinCode != nil) {
auto & definedValue_0 = request.pinCode.Emplace();
definedValue_0 = [self asByteSpan:params.pinCode];
}
}
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)unlockWithTimeoutWithParams:(MTRDoorLockClusterUnlockWithTimeoutParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::UnlockWithTimeout::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
request.timeout = params.timeout.unsignedShortValue;
if (params.pinCode != nil) {
auto & definedValue_0 = request.pinCode.Emplace();
definedValue_0 = [self asByteSpan:params.pinCode];
}
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)setWeekDayScheduleWithParams:(MTRDoorLockClusterSetWeekDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::SetWeekDaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.weekDayIndex = params.weekDayIndex.unsignedCharValue;
request.userIndex = params.userIndex.unsignedShortValue;
request.daysMask
= static_cast<std::remove_reference_t<decltype(request.daysMask)>>(params.daysMask.unsignedCharValue);
request.startHour = params.startHour.unsignedCharValue;
request.startMinute = params.startMinute.unsignedCharValue;
request.endHour = params.endHour.unsignedCharValue;
request.endMinute = params.endMinute.unsignedCharValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getWeekDayScheduleWithParams:(MTRDoorLockClusterGetWeekDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRDoorLockClusterGetWeekDayScheduleResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
DoorLockClusterGetWeekDayScheduleResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::GetWeekDaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.weekDayIndex = params.weekDayIndex.unsignedCharValue;
request.userIndex = params.userIndex.unsignedShortValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)clearWeekDayScheduleWithParams:(MTRDoorLockClusterClearWeekDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::ClearWeekDaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.weekDayIndex = params.weekDayIndex.unsignedCharValue;
request.userIndex = params.userIndex.unsignedShortValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)setYearDayScheduleWithParams:(MTRDoorLockClusterSetYearDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::SetYearDaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.yearDayIndex = params.yearDayIndex.unsignedCharValue;
request.userIndex = params.userIndex.unsignedShortValue;
request.localStartTime = params.localStartTime.unsignedIntValue;
request.localEndTime = params.localEndTime.unsignedIntValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getYearDayScheduleWithParams:(MTRDoorLockClusterGetYearDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRDoorLockClusterGetYearDayScheduleResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
DoorLockClusterGetYearDayScheduleResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::GetYearDaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.yearDayIndex = params.yearDayIndex.unsignedCharValue;
request.userIndex = params.userIndex.unsignedShortValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)clearYearDayScheduleWithParams:(MTRDoorLockClusterClearYearDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::ClearYearDaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.yearDayIndex = params.yearDayIndex.unsignedCharValue;
request.userIndex = params.userIndex.unsignedShortValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)setHolidayScheduleWithParams:(MTRDoorLockClusterSetHolidayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::SetHolidaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.holidayIndex = params.holidayIndex.unsignedCharValue;
request.localStartTime = params.localStartTime.unsignedIntValue;
request.localEndTime = params.localEndTime.unsignedIntValue;
request.operatingMode
= static_cast<std::remove_reference_t<decltype(request.operatingMode)>>(params.operatingMode.unsignedCharValue);
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getHolidayScheduleWithParams:(MTRDoorLockClusterGetHolidayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRDoorLockClusterGetHolidayScheduleResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
DoorLockClusterGetHolidayScheduleResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::GetHolidaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.holidayIndex = params.holidayIndex.unsignedCharValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)clearHolidayScheduleWithParams:(MTRDoorLockClusterClearHolidayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::ClearHolidaySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.holidayIndex = params.holidayIndex.unsignedCharValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)setUserWithParams:(MTRDoorLockClusterSetUserParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::SetUser::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
request.operationType
= static_cast<std::remove_reference_t<decltype(request.operationType)>>(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<std::remove_reference_t<decltype(nonNullValue_0)>>(params.userStatus.unsignedCharValue);
}
if (params.userType == nil) {
request.userType.SetNull();
} else {
auto & nonNullValue_0 = request.userType.SetNonNull();
nonNullValue_0
= static_cast<std::remove_reference_t<decltype(nonNullValue_0)>>(params.userType.unsignedCharValue);
}
if (params.credentialRule == nil) {
request.credentialRule.SetNull();
} else {
auto & nonNullValue_0 = request.credentialRule.SetNonNull();
nonNullValue_0
= static_cast<std::remove_reference_t<decltype(nonNullValue_0)>>(params.credentialRule.unsignedCharValue);
}
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getUserWithParams:(MTRDoorLockClusterGetUserParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRDoorLockClusterGetUserResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRDoorLockClusterGetUserResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
DoorLockClusterGetUserResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::GetUser::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.userIndex = params.userIndex.unsignedShortValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)clearUserWithParams:(MTRDoorLockClusterClearUserParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::ClearUser::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
request.userIndex = params.userIndex.unsignedShortValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)setCredentialWithParams:(MTRDoorLockClusterSetCredentialParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRDoorLockClusterSetCredentialResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRDoorLockClusterSetCredentialResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
DoorLockClusterSetCredentialResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::SetCredential::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
request.operationType
= static_cast<std::remove_reference_t<decltype(request.operationType)>>(params.operationType.unsignedCharValue);
request.credential.credentialType
= static_cast<std::remove_reference_t<decltype(request.credential.credentialType)>>(
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<std::remove_reference_t<decltype(nonNullValue_0)>>(params.userStatus.unsignedCharValue);
}
if (params.userType == nil) {
request.userType.SetNull();
} else {
auto & nonNullValue_0 = request.userType.SetNonNull();
nonNullValue_0
= static_cast<std::remove_reference_t<decltype(nonNullValue_0)>>(params.userType.unsignedCharValue);
}
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getCredentialStatusWithParams:(MTRDoorLockClusterGetCredentialStatusParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRDoorLockClusterGetCredentialStatusResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
DoorLockClusterGetCredentialStatusResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::GetCredentialStatus::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.credential.credentialType
= static_cast<std::remove_reference_t<decltype(request.credential.credentialType)>>(
params.credential.credentialType.unsignedCharValue);
request.credential.credentialIndex = params.credential.credentialIndex.unsignedShortValue;
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)clearCredentialWithParams:(MTRDoorLockClusterClearCredentialParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
DoorLock::Commands::ClearCredential::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
if (params.credential == nil) {
request.credential.SetNull();
} else {
auto & nonNullValue_0 = request.credential.SetNonNull();
nonNullValue_0.credentialType = static_cast<std::remove_reference_t<decltype(nonNullValue_0.credentialType)>>(
params.credential.credentialType.unsignedCharValue);
nonNullValue_0.credentialIndex = params.credential.credentialIndex.unsignedShortValue;
}
chip::Controller::DoorLockCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeLockStateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeLockStateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLockTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeLockTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActuatorEnabledWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeActuatorEnabledID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDoorStateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeDoorStateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDoorOpenEventsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeDoorOpenEventsID)
params:params];
}
- (void)writeAttributeDoorOpenEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeDoorOpenEventsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeDoorOpenEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeDoorOpenEventsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeDoorClosedEventsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeDoorClosedEventsID)
params:params];
}
- (void)writeAttributeDoorClosedEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeDoorClosedEventsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeDoorClosedEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeDoorClosedEventsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOpenPeriodWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeOpenPeriodID)
params:params];
}
- (void)writeAttributeOpenPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOpenPeriodWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOpenPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeOpenPeriodID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfTotalUsersSupportedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeNumberOfTotalUsersSupportedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfPINUsersSupportedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeNumberOfPINUsersSupportedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfRFIDUsersSupportedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeNumberOfRFIDUsersSupportedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeNumberOfWeekDaySchedulesSupportedPerUserID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfYearDaySchedulesSupportedPerUserWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeNumberOfYearDaySchedulesSupportedPerUserID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfHolidaySchedulesSupportedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeNumberOfHolidaySchedulesSupportedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxPINCodeLengthWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeMaxPINCodeLengthID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinPINCodeLengthWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeMinPINCodeLengthID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxRFIDCodeLengthWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeMaxRFIDCodeLengthID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinRFIDCodeLengthWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeMinRFIDCodeLengthID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCredentialRulesSupportWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeCredentialRulesSupportID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfCredentialsSupportedPerUserWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeNumberOfCredentialsSupportedPerUserID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLanguageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeLanguageID)
params:params];
}
- (void)writeAttributeLanguageWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLanguageWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLanguageWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeLanguageID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLEDSettingsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeLEDSettingsID)
params:params];
}
- (void)writeAttributeLEDSettingsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLEDSettingsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLEDSettingsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeLEDSettingsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeAutoRelockTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeAutoRelockTimeID)
params:params];
}
- (void)writeAttributeAutoRelockTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeAutoRelockTimeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeAutoRelockTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeAutoRelockTimeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSoundVolumeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeSoundVolumeID)
params:params];
}
- (void)writeAttributeSoundVolumeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeSoundVolumeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeSoundVolumeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeSoundVolumeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOperatingModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeOperatingModeID)
params:params];
}
- (void)writeAttributeOperatingModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOperatingModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOperatingModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeOperatingModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSupportedOperatingModesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeSupportedOperatingModesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDefaultConfigurationRegisterWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeDefaultConfigurationRegisterID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeEnableLocalProgrammingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeEnableLocalProgrammingID)
params:params];
}
- (void)writeAttributeEnableLocalProgrammingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEnableLocalProgrammingWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeEnableLocalProgrammingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeEnableLocalProgrammingID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEnableOneTouchLockingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeEnableOneTouchLockingID)
params:params];
}
- (void)writeAttributeEnableOneTouchLockingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEnableOneTouchLockingWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeEnableOneTouchLockingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeEnableOneTouchLockingID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEnableInsideStatusLEDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeEnableInsideStatusLEDID)
params:params];
}
- (void)writeAttributeEnableInsideStatusLEDWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEnableInsideStatusLEDWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeEnableInsideStatusLEDWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeEnableInsideStatusLEDID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEnablePrivacyModeButtonWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeEnablePrivacyModeButtonID)
params:params];
}
- (void)writeAttributeEnablePrivacyModeButtonWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEnablePrivacyModeButtonWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeEnablePrivacyModeButtonWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeEnablePrivacyModeButtonID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLocalProgrammingFeaturesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeLocalProgrammingFeaturesID)
params:params];
}
- (void)writeAttributeLocalProgrammingFeaturesWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLocalProgrammingFeaturesWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeLocalProgrammingFeaturesWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeLocalProgrammingFeaturesID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeWrongCodeEntryLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeWrongCodeEntryLimitID)
params:params];
}
- (void)writeAttributeWrongCodeEntryLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeWrongCodeEntryLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeWrongCodeEntryLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeWrongCodeEntryLimitID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUserCodeTemporaryDisableTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeUserCodeTemporaryDisableTimeID)
params:params];
}
- (void)writeAttributeUserCodeTemporaryDisableTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeUserCodeTemporaryDisableTimeWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeUserCodeTemporaryDisableTimeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeUserCodeTemporaryDisableTimeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSendPINOverTheAirWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeSendPINOverTheAirID)
params:params];
}
- (void)writeAttributeSendPINOverTheAirWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeSendPINOverTheAirWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeSendPINOverTheAirWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeSendPINOverTheAirID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRequirePINforRemoteOperationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeRequirePINforRemoteOperationID)
params:params];
}
- (void)writeAttributeRequirePINforRemoteOperationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRequirePINforRemoteOperationWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeRequirePINforRemoteOperationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeRequirePINforRemoteOperationID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeExpiringUserTimeoutWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeExpiringUserTimeoutID)
params:params];
}
- (void)writeAttributeExpiringUserTimeoutWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeExpiringUserTimeoutWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeExpiringUserTimeoutWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeExpiringUserTimeoutID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterDoorLockID)
attributeID:@(MTRClusterDoorLockAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterDoorLock (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)lockDoorWithParams:(MTRDoorLockClusterLockDoorParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self lockDoorWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)unlockDoorWithParams:(MTRDoorLockClusterUnlockDoorParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self unlockDoorWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)unlockWithTimeoutWithParams:(MTRDoorLockClusterUnlockWithTimeoutParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self unlockWithTimeoutWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)setWeekDayScheduleWithParams:(MTRDoorLockClusterSetWeekDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self setWeekDayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getWeekDayScheduleWithParams:(MTRDoorLockClusterGetWeekDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self getWeekDayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)clearWeekDayScheduleWithParams:(MTRDoorLockClusterClearWeekDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self clearWeekDayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)setYearDayScheduleWithParams:(MTRDoorLockClusterSetYearDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self setYearDayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getYearDayScheduleWithParams:(MTRDoorLockClusterGetYearDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self getYearDayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)clearYearDayScheduleWithParams:(MTRDoorLockClusterClearYearDayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self clearYearDayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)setHolidayScheduleWithParams:(MTRDoorLockClusterSetHolidayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self setHolidayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getHolidayScheduleWithParams:(MTRDoorLockClusterGetHolidayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self getHolidayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)clearHolidayScheduleWithParams:(MTRDoorLockClusterClearHolidayScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self clearHolidayScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)setUserWithParams:(MTRDoorLockClusterSetUserParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self setUserWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getUserWithParams:(MTRDoorLockClusterGetUserParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRDoorLockClusterGetUserResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self getUserWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)clearUserWithParams:(MTRDoorLockClusterClearUserParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self clearUserWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)setCredentialWithParams:(MTRDoorLockClusterSetCredentialParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRDoorLockClusterSetCredentialResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self setCredentialWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getCredentialStatusWithParams:(MTRDoorLockClusterGetCredentialStatusParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self getCredentialStatusWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)clearCredentialWithParams:(MTRDoorLockClusterClearCredentialParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self clearCredentialWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterWindowCovering
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)upOrOpenWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self upOrOpenWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)upOrOpenWithParams:(MTRWindowCoveringClusterUpOrOpenParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
WindowCovering::Commands::UpOrOpen::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::WindowCoveringCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)downOrCloseWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self downOrCloseWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)downOrCloseWithParams:(MTRWindowCoveringClusterDownOrCloseParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
WindowCovering::Commands::DownOrClose::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::WindowCoveringCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stopMotionWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self stopMotionWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)stopMotionWithParams:(MTRWindowCoveringClusterStopMotionParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
WindowCovering::Commands::StopMotion::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::WindowCoveringCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)goToLiftValueWithParams:(MTRWindowCoveringClusterGoToLiftValueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
WindowCovering::Commands::GoToLiftValue::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.liftValue = params.liftValue.unsignedShortValue;
chip::Controller::WindowCoveringCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)goToLiftPercentageWithParams:(MTRWindowCoveringClusterGoToLiftPercentageParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
WindowCovering::Commands::GoToLiftPercentage::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.liftPercent100thsValue = params.liftPercent100thsValue.unsignedShortValue;
chip::Controller::WindowCoveringCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)goToTiltValueWithParams:(MTRWindowCoveringClusterGoToTiltValueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
WindowCovering::Commands::GoToTiltValue::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.tiltValue = params.tiltValue.unsignedShortValue;
chip::Controller::WindowCoveringCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)goToTiltPercentageWithParams:(MTRWindowCoveringClusterGoToTiltPercentageParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
WindowCovering::Commands::GoToTiltPercentage::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.tiltPercent100thsValue = params.tiltPercent100thsValue.unsignedShortValue;
chip::Controller::WindowCoveringCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePhysicalClosedLimitLiftWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributePhysicalClosedLimitLiftID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePhysicalClosedLimitTiltWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributePhysicalClosedLimitTiltID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentPositionLiftWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeCurrentPositionLiftID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentPositionTiltWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeCurrentPositionTiltID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfActuationsLiftWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeNumberOfActuationsLiftID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfActuationsTiltWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeNumberOfActuationsTiltID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeConfigStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeConfigStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentPositionLiftPercentageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeCurrentPositionLiftPercentageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentPositionTiltPercentageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeCurrentPositionTiltPercentageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOperationalStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeOperationalStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTargetPositionLiftPercent100thsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeTargetPositionLiftPercent100thsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTargetPositionTiltPercent100thsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeTargetPositionTiltPercent100thsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeEndProductTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeEndProductTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentPositionLiftPercent100thsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeCurrentPositionLiftPercent100thsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentPositionTiltPercent100thsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeCurrentPositionTiltPercent100thsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstalledOpenLimitLiftWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeInstalledOpenLimitLiftID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstalledClosedLimitLiftWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeInstalledClosedLimitLiftID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstalledOpenLimitTiltWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeInstalledOpenLimitTiltID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstalledClosedLimitTiltWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeInstalledClosedLimitTiltID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeModeID)
params:params];
}
- (void)writeAttributeModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSafetyStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeSafetyStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWindowCoveringID)
attributeID:@(MTRClusterWindowCoveringAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterWindowCovering (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)upOrOpenWithParams:(MTRWindowCoveringClusterUpOrOpenParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self upOrOpenWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)upOrOpenWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self upOrOpenWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)downOrCloseWithParams:(MTRWindowCoveringClusterDownOrCloseParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self downOrCloseWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)downOrCloseWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self downOrCloseWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)stopMotionWithParams:(MTRWindowCoveringClusterStopMotionParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stopMotionWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stopMotionWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stopMotionWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)goToLiftValueWithParams:(MTRWindowCoveringClusterGoToLiftValueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self goToLiftValueWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)goToLiftPercentageWithParams:(MTRWindowCoveringClusterGoToLiftPercentageParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self goToLiftPercentageWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)goToTiltValueWithParams:(MTRWindowCoveringClusterGoToTiltValueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self goToTiltValueWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)goToTiltPercentageWithParams:(MTRWindowCoveringClusterGoToTiltPercentageParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self goToTiltPercentageWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterBarrierControl
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)barrierControlGoToPercentWithParams:(MTRBarrierControlClusterBarrierControlGoToPercentParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
BarrierControl::Commands::BarrierControlGoToPercent::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.percentOpen = params.percentOpen.unsignedCharValue;
chip::Controller::BarrierControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)barrierControlStopWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self barrierControlStopWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)barrierControlStopWithParams:(MTRBarrierControlClusterBarrierControlStopParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
BarrierControl::Commands::BarrierControlStop::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::BarrierControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierMovingStateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierMovingStateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierSafetyStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierSafetyStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierCapabilitiesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierCapabilitiesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierOpenEventsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierOpenEventsID)
params:params];
}
- (void)writeAttributeBarrierOpenEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBarrierOpenEventsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBarrierOpenEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierOpenEventsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierCloseEventsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierCloseEventsID)
params:params];
}
- (void)writeAttributeBarrierCloseEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBarrierCloseEventsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBarrierCloseEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierCloseEventsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierCommandOpenEventsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierCommandOpenEventsID)
params:params];
}
- (void)writeAttributeBarrierCommandOpenEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBarrierCommandOpenEventsWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeBarrierCommandOpenEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierCommandOpenEventsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierCommandCloseEventsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierCommandCloseEventsID)
params:params];
}
- (void)writeAttributeBarrierCommandCloseEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBarrierCommandCloseEventsWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeBarrierCommandCloseEventsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierCommandCloseEventsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierOpenPeriodWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierOpenPeriodID)
params:params];
}
- (void)writeAttributeBarrierOpenPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBarrierOpenPeriodWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBarrierOpenPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierOpenPeriodID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierClosePeriodWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierClosePeriodID)
params:params];
}
- (void)writeAttributeBarrierClosePeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBarrierClosePeriodWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBarrierClosePeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierClosePeriodID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBarrierPositionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeBarrierPositionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBarrierControlID)
attributeID:@(MTRClusterBarrierControlAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterBarrierControl (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)barrierControlGoToPercentWithParams:(MTRBarrierControlClusterBarrierControlGoToPercentParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self barrierControlGoToPercentWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)barrierControlStopWithParams:(MTRBarrierControlClusterBarrierControlStopParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self barrierControlStopWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)barrierControlStopWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self barrierControlStopWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterPumpConfigurationAndControl
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeMaxPressureWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMaxPressureID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxSpeedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMaxSpeedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxFlowWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMaxFlowID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinConstPressureWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMinConstPressureID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxConstPressureWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMaxConstPressureID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinCompPressureWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMinCompPressureID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxCompPressureWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMaxCompPressureID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinConstSpeedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMinConstSpeedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxConstSpeedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMaxConstSpeedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinConstFlowWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMinConstFlowID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxConstFlowWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMaxConstFlowID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinConstTempWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMinConstTempID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxConstTempWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeMaxConstTempID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePumpStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributePumpStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeEffectiveOperationModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeEffectiveOperationModeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeEffectiveControlModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeEffectiveControlModeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCapacityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeCapacityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSpeedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeSpeedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLifetimeRunningHoursWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeLifetimeRunningHoursID)
params:params];
}
- (void)writeAttributeLifetimeRunningHoursWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLifetimeRunningHoursWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLifetimeRunningHoursWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeLifetimeRunningHoursID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributePowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLifetimeEnergyConsumedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeLifetimeEnergyConsumedID)
params:params];
}
- (void)writeAttributeLifetimeEnergyConsumedWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLifetimeEnergyConsumedWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeLifetimeEnergyConsumedWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeLifetimeEnergyConsumedID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOperationModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeOperationModeID)
params:params];
}
- (void)writeAttributeOperationModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOperationModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOperationModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeOperationModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeControlModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeControlModeID)
params:params];
}
- (void)writeAttributeControlModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeControlModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeControlModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeControlModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPumpConfigurationAndControlID)
attributeID:@(MTRClusterPumpConfigurationAndControlAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterPumpConfigurationAndControl (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterThermostat
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)setpointRaiseLowerWithParams:(MTRThermostatClusterSetpointRaiseLowerParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Thermostat::Commands::SetpointRaiseLower::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.mode = static_cast<std::remove_reference_t<decltype(request.mode)>>(params.mode.unsignedCharValue);
request.amount = params.amount.charValue;
chip::Controller::ThermostatCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)setWeeklyScheduleWithParams:(MTRThermostatClusterSetWeeklyScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Thermostat::Commands::SetWeeklySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.numberOfTransitionsForSequence = params.numberOfTransitionsForSequence.unsignedCharValue;
request.dayOfWeekForSequence = static_cast<std::remove_reference_t<decltype(request.dayOfWeekForSequence)>>(
params.dayOfWeekForSequence.unsignedCharValue);
request.modeForSequence = static_cast<std::remove_reference_t<decltype(request.modeForSequence)>>(
params.modeForSequence.unsignedCharValue);
{
using ListType_0 = std::remove_reference_t<decltype(request.transitions)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.transitions.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.transitions.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::ThermostatCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getWeeklyScheduleWithParams:(MTRThermostatClusterGetWeeklyScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRThermostatClusterGetWeeklyScheduleResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRThermostatClusterGetWeeklyScheduleResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ThermostatClusterGetWeeklyScheduleResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Thermostat::Commands::GetWeeklySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.daysToReturn
= static_cast<std::remove_reference_t<decltype(request.daysToReturn)>>(params.daysToReturn.unsignedCharValue);
request.modeToReturn
= static_cast<std::remove_reference_t<decltype(request.modeToReturn)>>(params.modeToReturn.unsignedCharValue);
chip::Controller::ThermostatCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)clearWeeklyScheduleWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self clearWeeklyScheduleWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)clearWeeklyScheduleWithParams:(MTRThermostatClusterClearWeeklyScheduleParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Thermostat::Commands::ClearWeeklySchedule::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::ThermostatCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeLocalTemperatureWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeLocalTemperatureID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOutdoorTemperatureWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOutdoorTemperatureID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOccupancyWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupancyID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAbsMinHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeAbsMinHeatSetpointLimitID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAbsMaxHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeAbsMaxHeatSetpointLimitID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAbsMinCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeAbsMinCoolSetpointLimitID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAbsMaxCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeAbsMaxCoolSetpointLimitID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePICoolingDemandWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributePICoolingDemandID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePIHeatingDemandWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributePIHeatingDemandID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeHVACSystemTypeConfigurationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeHVACSystemTypeConfigurationID)
params:params];
}
- (void)writeAttributeHVACSystemTypeConfigurationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeHVACSystemTypeConfigurationWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeHVACSystemTypeConfigurationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeHVACSystemTypeConfigurationID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLocalTemperatureCalibrationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeLocalTemperatureCalibrationID)
params:params];
}
- (void)writeAttributeLocalTemperatureCalibrationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLocalTemperatureCalibrationWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeLocalTemperatureCalibrationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeLocalTemperatureCalibrationID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOccupiedCoolingSetpointWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupiedCoolingSetpointID)
params:params];
}
- (void)writeAttributeOccupiedCoolingSetpointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOccupiedCoolingSetpointWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeOccupiedCoolingSetpointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupiedCoolingSetpointID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOccupiedHeatingSetpointWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupiedHeatingSetpointID)
params:params];
}
- (void)writeAttributeOccupiedHeatingSetpointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOccupiedHeatingSetpointWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeOccupiedHeatingSetpointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupiedHeatingSetpointID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUnoccupiedCoolingSetpointWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeUnoccupiedCoolingSetpointID)
params:params];
}
- (void)writeAttributeUnoccupiedCoolingSetpointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeUnoccupiedCoolingSetpointWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeUnoccupiedCoolingSetpointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeUnoccupiedCoolingSetpointID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUnoccupiedHeatingSetpointWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeUnoccupiedHeatingSetpointID)
params:params];
}
- (void)writeAttributeUnoccupiedHeatingSetpointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeUnoccupiedHeatingSetpointWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeUnoccupiedHeatingSetpointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeUnoccupiedHeatingSetpointID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeMinHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMinHeatSetpointLimitID)
params:params];
}
- (void)writeAttributeMinHeatSetpointLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeMinHeatSetpointLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeMinHeatSetpointLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMinHeatSetpointLimitID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxHeatSetpointLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMaxHeatSetpointLimitID)
params:params];
}
- (void)writeAttributeMaxHeatSetpointLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeMaxHeatSetpointLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeMaxHeatSetpointLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMaxHeatSetpointLimitID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeMinCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMinCoolSetpointLimitID)
params:params];
}
- (void)writeAttributeMinCoolSetpointLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeMinCoolSetpointLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeMinCoolSetpointLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMinCoolSetpointLimitID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxCoolSetpointLimitWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMaxCoolSetpointLimitID)
params:params];
}
- (void)writeAttributeMaxCoolSetpointLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeMaxCoolSetpointLimitWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeMaxCoolSetpointLimitWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMaxCoolSetpointLimitID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeMinSetpointDeadBandWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMinSetpointDeadBandID)
params:params];
}
- (void)writeAttributeMinSetpointDeadBandWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeMinSetpointDeadBandWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeMinSetpointDeadBandWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeMinSetpointDeadBandID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRemoteSensingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeRemoteSensingID)
params:params];
}
- (void)writeAttributeRemoteSensingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRemoteSensingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeRemoteSensingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeRemoteSensingID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeControlSequenceOfOperationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeControlSequenceOfOperationID)
params:params];
}
- (void)writeAttributeControlSequenceOfOperationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeControlSequenceOfOperationWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeControlSequenceOfOperationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeControlSequenceOfOperationID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSystemModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeSystemModeID)
params:params];
}
- (void)writeAttributeSystemModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeSystemModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeSystemModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeSystemModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeThermostatRunningModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeThermostatRunningModeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeStartOfWeekWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeStartOfWeekID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfWeeklyTransitionsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeNumberOfWeeklyTransitionsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfDailyTransitionsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeNumberOfDailyTransitionsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTemperatureSetpointHoldWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeTemperatureSetpointHoldID)
params:params];
}
- (void)writeAttributeTemperatureSetpointHoldWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeTemperatureSetpointHoldWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeTemperatureSetpointHoldWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeTemperatureSetpointHoldID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeTemperatureSetpointHoldDurationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeTemperatureSetpointHoldDurationID)
params:params];
}
- (void)writeAttributeTemperatureSetpointHoldDurationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeTemperatureSetpointHoldDurationWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeTemperatureSetpointHoldDurationWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeTemperatureSetpointHoldDurationID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeThermostatProgrammingOperationModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeThermostatProgrammingOperationModeID)
params:params];
}
- (void)writeAttributeThermostatProgrammingOperationModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeThermostatProgrammingOperationModeWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeThermostatProgrammingOperationModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeThermostatProgrammingOperationModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeThermostatRunningStateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeThermostatRunningStateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSetpointChangeSourceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeSetpointChangeSourceID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSetpointChangeAmountWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeSetpointChangeAmountID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSetpointChangeSourceTimestampWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeSetpointChangeSourceTimestampID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOccupiedSetbackWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupiedSetbackID)
params:params];
}
- (void)writeAttributeOccupiedSetbackWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOccupiedSetbackWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOccupiedSetbackWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupiedSetbackID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOccupiedSetbackMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupiedSetbackMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOccupiedSetbackMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeOccupiedSetbackMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeUnoccupiedSetbackWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeUnoccupiedSetbackID)
params:params];
}
- (void)writeAttributeUnoccupiedSetbackWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeUnoccupiedSetbackWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeUnoccupiedSetbackWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeUnoccupiedSetbackID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUnoccupiedSetbackMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeUnoccupiedSetbackMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeUnoccupiedSetbackMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeUnoccupiedSetbackMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeEmergencyHeatDeltaWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeEmergencyHeatDeltaID)
params:params];
}
- (void)writeAttributeEmergencyHeatDeltaWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEmergencyHeatDeltaWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeEmergencyHeatDeltaWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeEmergencyHeatDeltaID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeACTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACTypeID)
params:params];
}
- (void)writeAttributeACTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeACTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeACTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACTypeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeACCapacityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACCapacityID)
params:params];
}
- (void)writeAttributeACCapacityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeACCapacityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeACCapacityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACCapacityID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeACRefrigerantTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACRefrigerantTypeID)
params:params];
}
- (void)writeAttributeACRefrigerantTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeACRefrigerantTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeACRefrigerantTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACRefrigerantTypeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeACCompressorTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACCompressorTypeID)
params:params];
}
- (void)writeAttributeACCompressorTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeACCompressorTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeACCompressorTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACCompressorTypeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeACErrorCodeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACErrorCodeID)
params:params];
}
- (void)writeAttributeACErrorCodeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeACErrorCodeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeACErrorCodeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACErrorCodeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeACLouverPositionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACLouverPositionID)
params:params];
}
- (void)writeAttributeACLouverPositionWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeACLouverPositionWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeACLouverPositionWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACLouverPositionID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeACCoilTemperatureWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACCoilTemperatureID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeACCapacityformatWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACCapacityformatID)
params:params];
}
- (void)writeAttributeACCapacityformatWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeACCapacityformatWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeACCapacityformatWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeACCapacityformatID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatID)
attributeID:@(MTRClusterThermostatAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterThermostat (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)setpointRaiseLowerWithParams:(MTRThermostatClusterSetpointRaiseLowerParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self setpointRaiseLowerWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)setWeeklyScheduleWithParams:(MTRThermostatClusterSetWeeklyScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self setWeeklyScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getWeeklyScheduleWithParams:(MTRThermostatClusterGetWeeklyScheduleParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRThermostatClusterGetWeeklyScheduleResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self getWeeklyScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)clearWeeklyScheduleWithParams:(MTRThermostatClusterClearWeeklyScheduleParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self clearWeeklyScheduleWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)clearWeeklyScheduleWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self clearWeeklyScheduleWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterFanControl
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeFanModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeFanModeID)
params:params];
}
- (void)writeAttributeFanModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeFanModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeFanModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeFanModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeFanModeSequenceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeFanModeSequenceID)
params:params];
}
- (void)writeAttributeFanModeSequenceWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeFanModeSequenceWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeFanModeSequenceWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeFanModeSequenceID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePercentSettingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributePercentSettingID)
params:params];
}
- (void)writeAttributePercentSettingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributePercentSettingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributePercentSettingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributePercentSettingID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePercentCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributePercentCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSpeedMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeSpeedMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSpeedSettingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeSpeedSettingID)
params:params];
}
- (void)writeAttributeSpeedSettingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeSpeedSettingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeSpeedSettingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeSpeedSettingID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeSpeedCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeSpeedCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRockSupportWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeRockSupportID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRockSettingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeRockSettingID)
params:params];
}
- (void)writeAttributeRockSettingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRockSettingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeRockSettingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeRockSettingID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeWindSupportWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeWindSupportID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWindSettingWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeWindSettingID)
params:params];
}
- (void)writeAttributeWindSettingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeWindSettingWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeWindSettingWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeWindSettingID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFanControlID)
attributeID:@(MTRClusterFanControlAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterFanControl (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterThermostatUserInterfaceConfiguration
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeTemperatureDisplayModeWithParams:(MTRReadParams * _Nullable)params
{
return
[self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeTemperatureDisplayModeID)
params:params];
}
- (void)writeAttributeTemperatureDisplayModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeTemperatureDisplayModeWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeTemperatureDisplayModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeTemperatureDisplayModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeKeypadLockoutWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeKeypadLockoutID)
params:params];
}
- (void)writeAttributeKeypadLockoutWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeKeypadLockoutWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeKeypadLockoutWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeKeypadLockoutID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeScheduleProgrammingVisibilityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device
readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeScheduleProgrammingVisibilityID)
params:params];
}
- (void)writeAttributeScheduleProgrammingVisibilityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeScheduleProgrammingVisibilityWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeScheduleProgrammingVisibilityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device
writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeScheduleProgrammingVisibilityID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterThermostatUserInterfaceConfigurationID)
attributeID:@(MTRClusterThermostatUserInterfaceConfigurationAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterThermostatUserInterfaceConfiguration (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterColorControl
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)moveToHueWithParams:(MTRColorControlClusterMoveToHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveToHue::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.hue = params.hue.unsignedCharValue;
request.direction
= static_cast<std::remove_reference_t<decltype(request.direction)>>(params.direction.unsignedCharValue);
request.transitionTime = params.transitionTime.unsignedShortValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveHueWithParams:(MTRColorControlClusterMoveHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveHue::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.moveMode
= static_cast<std::remove_reference_t<decltype(request.moveMode)>>(params.moveMode.unsignedCharValue);
request.rate = params.rate.unsignedCharValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stepHueWithParams:(MTRColorControlClusterStepHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::StepHue::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.stepMode
= static_cast<std::remove_reference_t<decltype(request.stepMode)>>(params.stepMode.unsignedCharValue);
request.stepSize = params.stepSize.unsignedCharValue;
request.transitionTime = params.transitionTime.unsignedCharValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveToSaturationWithParams:(MTRColorControlClusterMoveToSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveToSaturation::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.saturation = params.saturation.unsignedCharValue;
request.transitionTime = params.transitionTime.unsignedShortValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveSaturationWithParams:(MTRColorControlClusterMoveSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveSaturation::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.moveMode
= static_cast<std::remove_reference_t<decltype(request.moveMode)>>(params.moveMode.unsignedCharValue);
request.rate = params.rate.unsignedCharValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stepSaturationWithParams:(MTRColorControlClusterStepSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::StepSaturation::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.stepMode
= static_cast<std::remove_reference_t<decltype(request.stepMode)>>(params.stepMode.unsignedCharValue);
request.stepSize = params.stepSize.unsignedCharValue;
request.transitionTime = params.transitionTime.unsignedCharValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveToHueAndSaturationWithParams:(MTRColorControlClusterMoveToHueAndSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveToHueAndSaturation::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveToColorWithParams:(MTRColorControlClusterMoveToColorParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveToColor::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveColorWithParams:(MTRColorControlClusterMoveColorParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveColor::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.rateX = params.rateX.shortValue;
request.rateY = params.rateY.shortValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stepColorWithParams:(MTRColorControlClusterStepColorParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::StepColor::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveToColorTemperatureWithParams:(MTRColorControlClusterMoveToColorTemperatureParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveToColorTemperature::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.colorTemperature = params.colorTemperature.unsignedShortValue;
request.transitionTime = params.transitionTime.unsignedShortValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)enhancedMoveToHueWithParams:(MTRColorControlClusterEnhancedMoveToHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::EnhancedMoveToHue::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.enhancedHue = params.enhancedHue.unsignedShortValue;
request.direction
= static_cast<std::remove_reference_t<decltype(request.direction)>>(params.direction.unsignedCharValue);
request.transitionTime = params.transitionTime.unsignedShortValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)enhancedMoveHueWithParams:(MTRColorControlClusterEnhancedMoveHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::EnhancedMoveHue::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.moveMode
= static_cast<std::remove_reference_t<decltype(request.moveMode)>>(params.moveMode.unsignedCharValue);
request.rate = params.rate.unsignedShortValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)enhancedStepHueWithParams:(MTRColorControlClusterEnhancedStepHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::EnhancedStepHue::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.stepMode
= static_cast<std::remove_reference_t<decltype(request.stepMode)>>(params.stepMode.unsignedCharValue);
request.stepSize = params.stepSize.unsignedShortValue;
request.transitionTime = params.transitionTime.unsignedShortValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)enhancedMoveToHueAndSaturationWithParams:(MTRColorControlClusterEnhancedMoveToHueAndSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::EnhancedMoveToHueAndSaturation::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)colorLoopSetWithParams:(MTRColorControlClusterColorLoopSetParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::ColorLoopSet::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.updateFlags
= static_cast<std::remove_reference_t<decltype(request.updateFlags)>>(params.updateFlags.unsignedCharValue);
request.action = static_cast<std::remove_reference_t<decltype(request.action)>>(params.action.unsignedCharValue);
request.direction
= static_cast<std::remove_reference_t<decltype(request.direction)>>(params.direction.unsignedCharValue);
request.time = params.time.unsignedShortValue;
request.startHue = params.startHue.unsignedShortValue;
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stopMoveStepWithParams:(MTRColorControlClusterStopMoveStepParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::StopMoveStep::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.optionsMask = params.optionsMask.unsignedCharValue;
request.optionsOverride = params.optionsOverride.unsignedCharValue;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)moveColorTemperatureWithParams:(MTRColorControlClusterMoveColorTemperatureParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::MoveColorTemperature::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.moveMode
= static_cast<std::remove_reference_t<decltype(request.moveMode)>>(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;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stepColorTemperatureWithParams:(MTRColorControlClusterStepColorTemperatureParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ColorControl::Commands::StepColorTemperature::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.stepMode
= static_cast<std::remove_reference_t<decltype(request.stepMode)>>(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;
chip::Controller::ColorControlCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentHueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeCurrentHueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentSaturationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeCurrentSaturationID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRemainingTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeRemainingTimeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentXWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeCurrentXID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentYWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeCurrentYID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDriftCompensationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeDriftCompensationID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCompensationTextWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeCompensationTextID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorTemperatureMiredsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorTemperatureMiredsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorModeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOptionsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeOptionsID)
params:params];
}
- (void)writeAttributeOptionsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOptionsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOptionsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeOptionsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNumberOfPrimariesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeNumberOfPrimariesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary1XWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary1XID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary1YWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary1YID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary1IntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary1IntensityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary2XWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary2XID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary2YWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary2YID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary2IntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary2IntensityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary3XWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary3XID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary3YWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary3YID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary3IntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary3IntensityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary4XWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary4XID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary4YWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary4YID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary4IntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary4IntensityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary5XWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary5XID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary5YWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary5YID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary5IntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary5IntensityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary6XWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary6XID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary6YWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary6YID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePrimary6IntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributePrimary6IntensityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeWhitePointXWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeWhitePointXID)
params:params];
}
- (void)writeAttributeWhitePointXWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeWhitePointXWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeWhitePointXWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeWhitePointXID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeWhitePointYWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeWhitePointYID)
params:params];
}
- (void)writeAttributeWhitePointYWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeWhitePointYWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeWhitePointYWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeWhitePointYID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointRXWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointRXID)
params:params];
}
- (void)writeAttributeColorPointRXWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointRXWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointRXWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointRXID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointRYWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointRYID)
params:params];
}
- (void)writeAttributeColorPointRYWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointRYWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointRYWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointRYID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointRIntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointRIntensityID)
params:params];
}
- (void)writeAttributeColorPointRIntensityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointRIntensityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointRIntensityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointRIntensityID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointGXWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointGXID)
params:params];
}
- (void)writeAttributeColorPointGXWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointGXWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointGXWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointGXID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointGYWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointGYID)
params:params];
}
- (void)writeAttributeColorPointGYWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointGYWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointGYWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointGYID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointGIntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointGIntensityID)
params:params];
}
- (void)writeAttributeColorPointGIntensityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointGIntensityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointGIntensityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointGIntensityID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointBXWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointBXID)
params:params];
}
- (void)writeAttributeColorPointBXWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointBXWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointBXWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointBXID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointBYWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointBYID)
params:params];
}
- (void)writeAttributeColorPointBYWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointBYWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointBYWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointBYID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeColorPointBIntensityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointBIntensityID)
params:params];
}
- (void)writeAttributeColorPointBIntensityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeColorPointBIntensityWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeColorPointBIntensityWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorPointBIntensityID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEnhancedCurrentHueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeEnhancedCurrentHueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeEnhancedColorModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeEnhancedColorModeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorLoopActiveWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorLoopActiveID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorLoopDirectionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorLoopDirectionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorLoopTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorLoopTimeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorLoopStartEnhancedHueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorLoopStartEnhancedHueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorLoopStoredEnhancedHueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorLoopStoredEnhancedHueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorCapabilitiesWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorCapabilitiesID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorTempPhysicalMinMiredsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorTempPhysicalMinMiredsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeColorTempPhysicalMaxMiredsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeColorTempPhysicalMaxMiredsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCoupleColorTempToLevelMinMiredsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeCoupleColorTempToLevelMinMiredsID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeStartUpColorTemperatureMiredsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeStartUpColorTemperatureMiredsID)
params:params];
}
- (void)writeAttributeStartUpColorTemperatureMiredsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeStartUpColorTemperatureMiredsWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeStartUpColorTemperatureMiredsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeStartUpColorTemperatureMiredsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterColorControlID)
attributeID:@(MTRClusterColorControlAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterColorControl (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)moveToHueWithParams:(MTRColorControlClusterMoveToHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveToHueWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveHueWithParams:(MTRColorControlClusterMoveHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveHueWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stepHueWithParams:(MTRColorControlClusterStepHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stepHueWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveToSaturationWithParams:(MTRColorControlClusterMoveToSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveToSaturationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveSaturationWithParams:(MTRColorControlClusterMoveSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveSaturationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stepSaturationWithParams:(MTRColorControlClusterStepSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stepSaturationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveToHueAndSaturationWithParams:(MTRColorControlClusterMoveToHueAndSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveToHueAndSaturationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveToColorWithParams:(MTRColorControlClusterMoveToColorParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveToColorWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveColorWithParams:(MTRColorControlClusterMoveColorParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveColorWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stepColorWithParams:(MTRColorControlClusterStepColorParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stepColorWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveToColorTemperatureWithParams:(MTRColorControlClusterMoveToColorTemperatureParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveToColorTemperatureWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)enhancedMoveToHueWithParams:(MTRColorControlClusterEnhancedMoveToHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self enhancedMoveToHueWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)enhancedMoveHueWithParams:(MTRColorControlClusterEnhancedMoveHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self enhancedMoveHueWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)enhancedStepHueWithParams:(MTRColorControlClusterEnhancedStepHueParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self enhancedStepHueWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)enhancedMoveToHueAndSaturationWithParams:(MTRColorControlClusterEnhancedMoveToHueAndSaturationParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self enhancedMoveToHueAndSaturationWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)colorLoopSetWithParams:(MTRColorControlClusterColorLoopSetParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self colorLoopSetWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stopMoveStepWithParams:(MTRColorControlClusterStopMoveStepParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stopMoveStepWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)moveColorTemperatureWithParams:(MTRColorControlClusterMoveColorTemperatureParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self moveColorTemperatureWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stepColorTemperatureWithParams:(MTRColorControlClusterStepColorTemperatureParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self stepColorTemperatureWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterBallastConfiguration
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributePhysicalMinLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributePhysicalMinLevelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePhysicalMaxLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributePhysicalMaxLevelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeBallastStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeBallastStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeMinLevelID)
params:params];
}
- (void)writeAttributeMinLevelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeMinLevelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeMinLevelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeMinLevelID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxLevelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeMaxLevelID)
params:params];
}
- (void)writeAttributeMaxLevelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeMaxLevelWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeMaxLevelWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeMaxLevelID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeIntrinsicBalanceFactorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeIntrinsicBalanceFactorID)
params:params];
}
- (void)writeAttributeIntrinsicBalanceFactorWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeIntrinsicBalanceFactorWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeIntrinsicBalanceFactorWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeIntrinsicBalanceFactorID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBallastFactorAdjustmentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeBallastFactorAdjustmentID)
params:params];
}
- (void)writeAttributeBallastFactorAdjustmentWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBallastFactorAdjustmentWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeBallastFactorAdjustmentWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeBallastFactorAdjustmentID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLampQuantityWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampQuantityID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLampTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampTypeID)
params:params];
}
- (void)writeAttributeLampTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLampTypeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLampTypeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampTypeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLampManufacturerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampManufacturerID)
params:params];
}
- (void)writeAttributeLampManufacturerWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLampManufacturerWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLampManufacturerWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampManufacturerID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLampRatedHoursWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampRatedHoursID)
params:params];
}
- (void)writeAttributeLampRatedHoursWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLampRatedHoursWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLampRatedHoursWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampRatedHoursID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLampBurnHoursWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampBurnHoursID)
params:params];
}
- (void)writeAttributeLampBurnHoursWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLampBurnHoursWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLampBurnHoursWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampBurnHoursID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLampAlarmModeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampAlarmModeID)
params:params];
}
- (void)writeAttributeLampAlarmModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLampAlarmModeWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLampAlarmModeWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampAlarmModeID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLampBurnHoursTripPointWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampBurnHoursTripPointID)
params:params];
}
- (void)writeAttributeLampBurnHoursTripPointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLampBurnHoursTripPointWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeLampBurnHoursTripPointWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeLampBurnHoursTripPointID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterBallastConfigurationID)
attributeID:@(MTRClusterBallastConfigurationAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterBallastConfiguration (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterIlluminanceMeasurement
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeMinMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeMaxMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeToleranceID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLightSensorTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeLightSensorTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterIlluminanceMeasurementID)
attributeID:@(MTRClusterIlluminanceMeasurementAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterIlluminanceMeasurement (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterTemperatureMeasurement
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeMinMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeMaxMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeToleranceID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTemperatureMeasurementID)
attributeID:@(MTRClusterTemperatureMeasurementAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterTemperatureMeasurement (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterPressureMeasurement
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeMinMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeMaxMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeToleranceID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeScaledValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeScaledValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinScaledValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeMinScaledValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxScaledValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeMaxScaledValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeScaledToleranceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeScaledToleranceID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeScaleWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeScaleID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterPressureMeasurementID)
attributeID:@(MTRClusterPressureMeasurementAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterPressureMeasurement (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterFlowMeasurement
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeMinMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeMaxMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeToleranceID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterFlowMeasurementID)
attributeID:@(MTRClusterFlowMeasurementAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterFlowMeasurement (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterRelativeHumidityMeasurement
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMinMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeMinMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMaxMeasuredValueWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeMaxMeasuredValueID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeToleranceWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeToleranceID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterRelativeHumidityMeasurementID)
attributeID:@(MTRClusterRelativeHumidityMeasurementAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterRelativeHumidityMeasurement (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterOccupancySensing
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeOccupancyWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeOccupancyID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOccupancySensorTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeOccupancySensorTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOccupancySensorTypeBitmapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeOccupancySensorTypeBitmapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePirOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePirOccupiedToUnoccupiedDelayID)
params:params];
}
- (void)writeAttributePirOccupiedToUnoccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributePirOccupiedToUnoccupiedDelayWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributePirOccupiedToUnoccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePirOccupiedToUnoccupiedDelayID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePirUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePirUnoccupiedToOccupiedDelayID)
params:params];
}
- (void)writeAttributePirUnoccupiedToOccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributePirUnoccupiedToOccupiedDelayWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributePirUnoccupiedToOccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePirUnoccupiedToOccupiedDelayID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePirUnoccupiedToOccupiedThresholdWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePirUnoccupiedToOccupiedThresholdID)
params:params];
}
- (void)writeAttributePirUnoccupiedToOccupiedThresholdWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributePirUnoccupiedToOccupiedThresholdWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributePirUnoccupiedToOccupiedThresholdWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePirUnoccupiedToOccupiedThresholdID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUltrasonicOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeUltrasonicOccupiedToUnoccupiedDelayID)
params:params];
}
- (void)writeAttributeUltrasonicOccupiedToUnoccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeUltrasonicOccupiedToUnoccupiedDelayWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeUltrasonicOccupiedToUnoccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeUltrasonicOccupiedToUnoccupiedDelayID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUltrasonicUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedDelayID)
params:params];
}
- (void)writeAttributeUltrasonicUnoccupiedToOccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeUltrasonicUnoccupiedToOccupiedDelayWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeUltrasonicUnoccupiedToOccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedDelayID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUltrasonicUnoccupiedToOccupiedThresholdWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedThresholdID)
params:params];
}
- (void)writeAttributeUltrasonicUnoccupiedToOccupiedThresholdWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeUltrasonicUnoccupiedToOccupiedThresholdWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeUltrasonicUnoccupiedToOccupiedThresholdWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeUltrasonicUnoccupiedToOccupiedThresholdID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePhysicalContactOccupiedToUnoccupiedDelayWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePhysicalContactOccupiedToUnoccupiedDelayID)
params:params];
}
- (void)writeAttributePhysicalContactOccupiedToUnoccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributePhysicalContactOccupiedToUnoccupiedDelayWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributePhysicalContactOccupiedToUnoccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePhysicalContactOccupiedToUnoccupiedDelayID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePhysicalContactUnoccupiedToOccupiedDelayWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedDelayID)
params:params];
}
- (void)writeAttributePhysicalContactUnoccupiedToOccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributePhysicalContactUnoccupiedToOccupiedDelayWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributePhysicalContactUnoccupiedToOccupiedDelayWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedDelayID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributePhysicalContactUnoccupiedToOccupiedThresholdWithParams:
(MTRReadParams * _Nullable)params
{
return [self.device
readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedThresholdID)
params:params];
}
- (void)writeAttributePhysicalContactUnoccupiedToOccupiedThresholdWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributePhysicalContactUnoccupiedToOccupiedThresholdWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributePhysicalContactUnoccupiedToOccupiedThresholdWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributePhysicalContactUnoccupiedToOccupiedThresholdID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterOccupancySensingID)
attributeID:@(MTRClusterOccupancySensingAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterOccupancySensing (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterWakeOnLan
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeMACAddressWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWakeOnLanID)
attributeID:@(MTRClusterWakeOnLanAttributeMACAddressID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWakeOnLanID)
attributeID:@(MTRClusterWakeOnLanAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWakeOnLanID)
attributeID:@(MTRClusterWakeOnLanAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWakeOnLanID)
attributeID:@(MTRClusterWakeOnLanAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWakeOnLanID)
attributeID:@(MTRClusterWakeOnLanAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterWakeOnLanID)
attributeID:@(MTRClusterWakeOnLanAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterWakeOnLan (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterChannel
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)changeChannelWithParams:(MTRChannelClusterChangeChannelParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRChannelClusterChangeChannelResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRChannelClusterChangeChannelResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ChannelClusterChangeChannelResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Channel::Commands::ChangeChannel::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.match = [self asCharSpan:params.match];
chip::Controller::ChannelCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)changeChannelByNumberWithParams:(MTRChannelClusterChangeChannelByNumberParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Channel::Commands::ChangeChannelByNumber::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.majorNumber = params.majorNumber.unsignedShortValue;
request.minorNumber = params.minorNumber.unsignedShortValue;
chip::Controller::ChannelCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)skipChannelWithParams:(MTRChannelClusterSkipChannelParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
Channel::Commands::SkipChannel::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.count = params.count.unsignedShortValue;
chip::Controller::ChannelCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeChannelListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterChannelID)
attributeID:@(MTRClusterChannelAttributeChannelListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLineupWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterChannelID)
attributeID:@(MTRClusterChannelAttributeLineupID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentChannelWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterChannelID)
attributeID:@(MTRClusterChannelAttributeCurrentChannelID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterChannelID)
attributeID:@(MTRClusterChannelAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterChannelID)
attributeID:@(MTRClusterChannelAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterChannelID)
attributeID:@(MTRClusterChannelAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterChannelID)
attributeID:@(MTRClusterChannelAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterChannelID)
attributeID:@(MTRClusterChannelAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterChannel (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)changeChannelWithParams:(MTRChannelClusterChangeChannelParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRChannelClusterChangeChannelResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self changeChannelWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)changeChannelByNumberWithParams:(MTRChannelClusterChangeChannelByNumberParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self changeChannelByNumberWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)skipChannelWithParams:(MTRChannelClusterSkipChannelParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self skipChannelWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterTargetNavigator
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)navigateTargetWithParams:(MTRTargetNavigatorClusterNavigateTargetParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRTargetNavigatorClusterNavigateTargetResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
TargetNavigatorClusterNavigateTargetResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
TargetNavigator::Commands::NavigateTarget::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.target = params.target.unsignedCharValue;
if (params.data != nil) {
auto & definedValue_0 = request.data.Emplace();
definedValue_0 = [self asCharSpan:params.data];
}
chip::Controller::TargetNavigatorCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeTargetListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTargetNavigatorID)
attributeID:@(MTRClusterTargetNavigatorAttributeTargetListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentTargetWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTargetNavigatorID)
attributeID:@(MTRClusterTargetNavigatorAttributeCurrentTargetID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTargetNavigatorID)
attributeID:@(MTRClusterTargetNavigatorAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTargetNavigatorID)
attributeID:@(MTRClusterTargetNavigatorAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTargetNavigatorID)
attributeID:@(MTRClusterTargetNavigatorAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTargetNavigatorID)
attributeID:@(MTRClusterTargetNavigatorAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterTargetNavigatorID)
attributeID:@(MTRClusterTargetNavigatorAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterTargetNavigator (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)navigateTargetWithParams:(MTRTargetNavigatorClusterNavigateTargetParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self navigateTargetWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterMediaPlayback
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)playWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self playWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)playWithParams:(MTRMediaPlaybackClusterPlayParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::Play::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)pauseWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self pauseWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)pauseWithParams:(MTRMediaPlaybackClusterPauseParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::Pause::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stopPlaybackWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self stopPlaybackWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)stopPlaybackWithParams:(MTRMediaPlaybackClusterStopPlaybackParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::StopPlayback::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)startOverWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self startOverWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)startOverWithParams:(MTRMediaPlaybackClusterStartOverParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::StartOver::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)previousWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self previousWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)previousWithParams:(MTRMediaPlaybackClusterPreviousParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::Previous::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)nextWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self nextWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)nextWithParams:(MTRMediaPlaybackClusterNextParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::Next::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)rewindWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self rewindWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)rewindWithParams:(MTRMediaPlaybackClusterRewindParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::Rewind::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)fastForwardWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self fastForwardWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)fastForwardWithParams:(MTRMediaPlaybackClusterFastForwardParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::FastForward::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)skipForwardWithParams:(MTRMediaPlaybackClusterSkipForwardParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::SkipForward::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.deltaPositionMilliseconds = params.deltaPositionMilliseconds.unsignedLongLongValue;
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)skipBackwardWithParams:(MTRMediaPlaybackClusterSkipBackwardParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::SkipBackward::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.deltaPositionMilliseconds = params.deltaPositionMilliseconds.unsignedLongLongValue;
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)seekWithParams:(MTRMediaPlaybackClusterSeekParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaPlayback::Commands::Seek::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.position = params.position.unsignedLongLongValue;
chip::Controller::MediaPlaybackCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentStateWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeCurrentStateID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeStartTimeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeStartTimeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDurationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeDurationID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSampledPositionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeSampledPositionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePlaybackSpeedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributePlaybackSpeedID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSeekRangeEndWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeSeekRangeEndID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSeekRangeStartWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeSeekRangeStartID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaPlaybackID)
attributeID:@(MTRClusterMediaPlaybackAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterMediaPlayback (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)playWithParams:(MTRMediaPlaybackClusterPlayParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self playWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)playWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self playWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)pauseWithParams:(MTRMediaPlaybackClusterPauseParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self pauseWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)pauseWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self pauseWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)stopPlaybackWithParams:(MTRMediaPlaybackClusterStopPlaybackParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self stopPlaybackWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stopPlaybackWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self stopPlaybackWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)startOverWithParams:(MTRMediaPlaybackClusterStartOverParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self startOverWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)startOverWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self startOverWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)previousWithParams:(MTRMediaPlaybackClusterPreviousParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self previousWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)previousWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self previousWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)nextWithParams:(MTRMediaPlaybackClusterNextParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self nextWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)nextWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self nextWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)rewindWithParams:(MTRMediaPlaybackClusterRewindParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self rewindWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)rewindWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self rewindWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)fastForwardWithParams:(MTRMediaPlaybackClusterFastForwardParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self fastForwardWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)fastForwardWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self fastForwardWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)skipForwardWithParams:(MTRMediaPlaybackClusterSkipForwardParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self skipForwardWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)skipBackwardWithParams:(MTRMediaPlaybackClusterSkipBackwardParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self skipBackwardWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)seekWithParams:(MTRMediaPlaybackClusterSeekParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self seekWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterMediaInput
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)selectInputWithParams:(MTRMediaInputClusterSelectInputParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaInput::Commands::SelectInput::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.index = params.index.unsignedCharValue;
chip::Controller::MediaInputCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)showInputStatusWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self showInputStatusWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)showInputStatusWithParams:(MTRMediaInputClusterShowInputStatusParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaInput::Commands::ShowInputStatus::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaInputCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)hideInputStatusWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self hideInputStatusWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)hideInputStatusWithParams:(MTRMediaInputClusterHideInputStatusParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaInput::Commands::HideInputStatus::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::MediaInputCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)renameInputWithParams:(MTRMediaInputClusterRenameInputParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
MediaInput::Commands::RenameInput::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.index = params.index.unsignedCharValue;
request.name = [self asCharSpan:params.name];
chip::Controller::MediaInputCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeInputListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaInputID)
attributeID:@(MTRClusterMediaInputAttributeInputListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentInputWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaInputID)
attributeID:@(MTRClusterMediaInputAttributeCurrentInputID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaInputID)
attributeID:@(MTRClusterMediaInputAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaInputID)
attributeID:@(MTRClusterMediaInputAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaInputID)
attributeID:@(MTRClusterMediaInputAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaInputID)
attributeID:@(MTRClusterMediaInputAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterMediaInputID)
attributeID:@(MTRClusterMediaInputAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterMediaInput (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)selectInputWithParams:(MTRMediaInputClusterSelectInputParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self selectInputWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)showInputStatusWithParams:(MTRMediaInputClusterShowInputStatusParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self showInputStatusWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)showInputStatusWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self showInputStatusWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)hideInputStatusWithParams:(MTRMediaInputClusterHideInputStatusParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self hideInputStatusWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)hideInputStatusWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self hideInputStatusWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)renameInputWithParams:(MTRMediaInputClusterRenameInputParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self renameInputWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterLowPower
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)sleepWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self sleepWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)sleepWithParams:(MTRLowPowerClusterSleepParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
LowPower::Commands::Sleep::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::LowPowerCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLowPowerID)
attributeID:@(MTRClusterLowPowerAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLowPowerID)
attributeID:@(MTRClusterLowPowerAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLowPowerID)
attributeID:@(MTRClusterLowPowerAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLowPowerID)
attributeID:@(MTRClusterLowPowerAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterLowPowerID)
attributeID:@(MTRClusterLowPowerAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterLowPower (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)sleepWithParams:(MTRLowPowerClusterSleepParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self sleepWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)sleepWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self sleepWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
@end
@implementation MTRClusterKeypadInput
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)sendKeyWithParams:(MTRKeypadInputClusterSendKeyParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRKeypadInputClusterSendKeyResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRKeypadInputClusterSendKeyResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
KeypadInputClusterSendKeyResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
KeypadInput::Commands::SendKey::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.keyCode = static_cast<std::remove_reference_t<decltype(request.keyCode)>>(params.keyCode.unsignedCharValue);
chip::Controller::KeypadInputCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterKeypadInputID)
attributeID:@(MTRClusterKeypadInputAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterKeypadInputID)
attributeID:@(MTRClusterKeypadInputAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterKeypadInputID)
attributeID:@(MTRClusterKeypadInputAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterKeypadInputID)
attributeID:@(MTRClusterKeypadInputAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterKeypadInputID)
attributeID:@(MTRClusterKeypadInputAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterKeypadInput (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)sendKeyWithParams:(MTRKeypadInputClusterSendKeyParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRKeypadInputClusterSendKeyResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self sendKeyWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterContentLauncher
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)launchContentWithParams:(MTRContentLauncherClusterLaunchContentParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRContentLauncherClusterLaunchResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRContentLauncherClusterLaunchResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ContentLauncherClusterLaunchResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ContentLauncher::Commands::LaunchContent::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
{
using ListType_1 = std::remove_reference_t<decltype(request.search.parameterList)>;
using ListMemberType_1 = ListMemberTypeGetter<ListType_1>::Type;
if (params.search.parameterList.count != 0) {
auto * listHolder_1 = new ListHolder<ListMemberType_1>(params.search.parameterList.count);
if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_1 = (MTRContentLauncherClusterParameter *) params.search.parameterList[i_1];
listHolder_1->mList[i_1].type
= static_cast<std::remove_reference_t<decltype(listHolder_1->mList[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<decltype(definedValue_3)>;
using ListMemberType_4 = ListMemberTypeGetter<ListType_4>::Type;
if (element_1.externalIDList.count != 0) {
auto * listHolder_4 = new ListHolder<ListMemberType_4>(element_1.externalIDList.count);
if (listHolder_4 == nullptr || listHolder_4->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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];
}
chip::Controller::ContentLauncherCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)launchURLWithParams:(MTRContentLauncherClusterLaunchURLParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRContentLauncherClusterLaunchResponseParams * _Nullable data, NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRContentLauncherClusterLaunchResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ContentLauncherClusterLaunchResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ContentLauncher::Commands::LaunchURL::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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<std::remove_reference_t<decltype(definedValue_4.metric)>>(
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<std::remove_reference_t<decltype(definedValue_4.metric)>>(
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<std::remove_reference_t<decltype(definedValue_4.metric)>>(
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<std::remove_reference_t<decltype(definedValue_4.metric)>>(
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<std::remove_reference_t<decltype(definedValue_4.metric)>>(
params.brandingInformation.waterMark.size.metric.unsignedCharValue);
}
}
}
chip::Controller::ContentLauncherCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptHeaderWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterContentLauncherID)
attributeID:@(MTRClusterContentLauncherAttributeAcceptHeaderID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeSupportedStreamingProtocolsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterContentLauncherID)
attributeID:@(MTRClusterContentLauncherAttributeSupportedStreamingProtocolsID)
params:params];
}
- (void)writeAttributeSupportedStreamingProtocolsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeSupportedStreamingProtocolsWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeSupportedStreamingProtocolsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterContentLauncherID)
attributeID:@(MTRClusterContentLauncherAttributeSupportedStreamingProtocolsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterContentLauncherID)
attributeID:@(MTRClusterContentLauncherAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterContentLauncherID)
attributeID:@(MTRClusterContentLauncherAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterContentLauncherID)
attributeID:@(MTRClusterContentLauncherAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterContentLauncherID)
attributeID:@(MTRClusterContentLauncherAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterContentLauncherID)
attributeID:@(MTRClusterContentLauncherAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterContentLauncher (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)launchContentWithParams:(MTRContentLauncherClusterLaunchContentParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRContentLauncherClusterLaunchResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self launchContentWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)launchURLWithParams:(MTRContentLauncherClusterLaunchURLParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRContentLauncherClusterLaunchResponseParams * _Nullable data, NSError * _Nullable error))completionHandler
{
[self launchURLWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterAudioOutput
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)selectOutputWithParams:(MTRAudioOutputClusterSelectOutputParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
AudioOutput::Commands::SelectOutput::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.index = params.index.unsignedCharValue;
chip::Controller::AudioOutputCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)renameOutputWithParams:(MTRAudioOutputClusterRenameOutputParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
AudioOutput::Commands::RenameOutput::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.index = params.index.unsignedCharValue;
request.name = [self asCharSpan:params.name];
chip::Controller::AudioOutputCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeOutputListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAudioOutputID)
attributeID:@(MTRClusterAudioOutputAttributeOutputListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentOutputWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAudioOutputID)
attributeID:@(MTRClusterAudioOutputAttributeCurrentOutputID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAudioOutputID)
attributeID:@(MTRClusterAudioOutputAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAudioOutputID)
attributeID:@(MTRClusterAudioOutputAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAudioOutputID)
attributeID:@(MTRClusterAudioOutputAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAudioOutputID)
attributeID:@(MTRClusterAudioOutputAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAudioOutputID)
attributeID:@(MTRClusterAudioOutputAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterAudioOutput (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)selectOutputWithParams:(MTRAudioOutputClusterSelectOutputParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self selectOutputWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)renameOutputWithParams:(MTRAudioOutputClusterRenameOutputParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self renameOutputWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterApplicationLauncher
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)launchAppWithParams:(MTRApplicationLauncherClusterLaunchAppParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ApplicationLauncherClusterLauncherResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ApplicationLauncher::Commands::LaunchApp::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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];
}
chip::Controller::ApplicationLauncherCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)stopAppWithParams:(MTRApplicationLauncherClusterStopAppParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ApplicationLauncherClusterLauncherResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ApplicationLauncher::Commands::StopApp::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.application.catalogVendorId = params.application.catalogVendorId.unsignedShortValue;
request.application.applicationId = [self asCharSpan:params.application.applicationId];
chip::Controller::ApplicationLauncherCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)hideAppWithParams:(MTRApplicationLauncherClusterHideAppParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
ApplicationLauncherClusterLauncherResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ApplicationLauncher::Commands::HideApp::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.application.catalogVendorId = params.application.catalogVendorId.unsignedShortValue;
request.application.applicationId = [self asCharSpan:params.application.applicationId];
chip::Controller::ApplicationLauncherCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeCatalogListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationLauncherID)
attributeID:@(MTRClusterApplicationLauncherAttributeCatalogListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentAppWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationLauncherID)
attributeID:@(MTRClusterApplicationLauncherAttributeCurrentAppID)
params:params];
}
- (void)writeAttributeCurrentAppWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeCurrentAppWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeCurrentAppWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationLauncherID)
attributeID:@(MTRClusterApplicationLauncherAttributeCurrentAppID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationLauncherID)
attributeID:@(MTRClusterApplicationLauncherAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationLauncherID)
attributeID:@(MTRClusterApplicationLauncherAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationLauncherID)
attributeID:@(MTRClusterApplicationLauncherAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationLauncherID)
attributeID:@(MTRClusterApplicationLauncherAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationLauncherID)
attributeID:@(MTRClusterApplicationLauncherAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterApplicationLauncher (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)launchAppWithParams:(MTRApplicationLauncherClusterLaunchAppParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self launchAppWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)stopAppWithParams:(MTRApplicationLauncherClusterStopAppParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self stopAppWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)hideAppWithParams:(MTRApplicationLauncherClusterHideAppParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self hideAppWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterApplicationBasic
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (NSDictionary<NSString *, id> *)readAttributeVendorNameWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeVendorNameID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeVendorIDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeVendorIDID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeApplicationNameWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeApplicationNameID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeProductIDWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeProductIDID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeApplicationWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeApplicationID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeStatusWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeStatusID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeApplicationVersionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeApplicationVersionID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAllowedVendorListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeAllowedVendorListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterApplicationBasicID)
attributeID:@(MTRClusterApplicationBasicAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterApplicationBasic (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
@end
@implementation MTRClusterAccountLogin
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)getSetupPINWithParams:(MTRAccountLoginClusterGetSetupPINParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRAccountLoginClusterGetSetupPINResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
AccountLoginClusterGetSetupPINResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
AccountLogin::Commands::GetSetupPIN::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
request.tempAccountIdentifier = [self asCharSpan:params.tempAccountIdentifier];
chip::Controller::AccountLoginCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)loginWithParams:(MTRAccountLoginClusterLoginParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
AccountLogin::Commands::Login::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
request.tempAccountIdentifier = [self asCharSpan:params.tempAccountIdentifier];
request.setupPIN = [self asCharSpan:params.setupPIN];
chip::Controller::AccountLoginCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)logoutWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self logoutWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)logoutWithParams:(MTRAccountLoginClusterLogoutParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
AccountLogin::Commands::Logout::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
chip::Controller::AccountLoginCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccountLoginID)
attributeID:@(MTRClusterAccountLoginAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccountLoginID)
attributeID:@(MTRClusterAccountLoginAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccountLoginID)
attributeID:@(MTRClusterAccountLoginAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccountLoginID)
attributeID:@(MTRClusterAccountLoginAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterAccountLoginID)
attributeID:@(MTRClusterAccountLoginAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterAccountLogin (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)getSetupPINWithParams:(MTRAccountLoginClusterGetSetupPINParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self getSetupPINWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)loginWithParams:(MTRAccountLoginClusterLoginParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self loginWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)logoutWithParams:(MTRAccountLoginClusterLogoutParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self logoutWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)logoutWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self logoutWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
@end
@implementation MTRClusterElectricalMeasurement
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)getProfileInfoCommandWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self getProfileInfoCommandWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)getProfileInfoCommandWithParams:(MTRElectricalMeasurementClusterGetProfileInfoCommandParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ElectricalMeasurement::Commands::GetProfileInfoCommand::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::ElectricalMeasurementCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)getMeasurementProfileCommandWithParams:(MTRElectricalMeasurementClusterGetMeasurementProfileCommandParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
ElectricalMeasurement::Commands::GetMeasurementProfileCommand::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.attributeId = params.attributeId.unsignedShortValue;
request.startTime = params.startTime.unsignedIntValue;
request.numberOfIntervals = params.numberOfIntervals.unsignedCharValue;
chip::Controller::ElectricalMeasurementCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeMeasurementTypeWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasurementTypeID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcVoltageMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcVoltageMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcVoltageMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcVoltageMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcCurrentMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcCurrentMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcCurrentMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcCurrentMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcPowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcPowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcPowerMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcPowerMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcPowerMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcPowerMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcVoltageMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcVoltageMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcVoltageDivisorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcVoltageDivisorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcCurrentMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcCurrentDivisorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcCurrentDivisorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcPowerMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcPowerMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeDcPowerDivisorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeDcPowerDivisorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcFrequencyWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcFrequencyID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcFrequencyMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcFrequencyMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcFrequencyMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcFrequencyMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeNeutralCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeNeutralCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTotalActivePowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeTotalActivePowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTotalReactivePowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeTotalReactivePowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeTotalApparentPowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeTotalApparentPowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasured1stHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasured1stHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasured3rdHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasured3rdHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasured5thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasured5thHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasured7thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasured7thHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasured9thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasured9thHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasured11thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasured11thHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredPhase1stHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase1stHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredPhase3rdHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase3rdHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredPhase5thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase5thHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredPhase7thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase7thHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredPhase9thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase9thHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeMeasuredPhase11thHarmonicCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeMeasuredPhase11thHarmonicCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcFrequencyMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcFrequencyMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcFrequencyDivisorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcFrequencyDivisorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePowerMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributePowerMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePowerDivisorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributePowerDivisorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeHarmonicCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeHarmonicCurrentMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePhaseHarmonicCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributePhaseHarmonicCurrentMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstantaneousVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeInstantaneousVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstantaneousLineCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeInstantaneousLineCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstantaneousActiveCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeInstantaneousActiveCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstantaneousReactiveCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeInstantaneousReactiveCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeInstantaneousPowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeInstantaneousPowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerMinWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerMinID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerMaxWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerMaxID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeReactivePowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeReactivePowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeApparentPowerWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeApparentPowerID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePowerFactorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributePowerFactorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsVoltageMeasurementPeriodWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodID)
params:params];
}
- (void)writeAttributeAverageRmsVoltageMeasurementPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeAverageRmsVoltageMeasurementPeriodWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeAverageRmsVoltageMeasurementPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsUnderVoltageCounterWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterID)
params:params];
}
- (void)writeAttributeAverageRmsUnderVoltageCounterWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeAverageRmsUnderVoltageCounterWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeAverageRmsUnderVoltageCounterWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsExtremeOverVoltagePeriodWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodID)
params:params];
}
- (void)writeAttributeRmsExtremeOverVoltagePeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRmsExtremeOverVoltagePeriodWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeRmsExtremeOverVoltagePeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsExtremeUnderVoltagePeriodWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodID)
params:params];
}
- (void)writeAttributeRmsExtremeUnderVoltagePeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRmsExtremeUnderVoltagePeriodWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeRmsExtremeUnderVoltagePeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageSagPeriodWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagPeriodID)
params:params];
}
- (void)writeAttributeRmsVoltageSagPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRmsVoltageSagPeriodWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeRmsVoltageSagPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagPeriodID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageSwellPeriodWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodID)
params:params];
}
- (void)writeAttributeRmsVoltageSwellPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRmsVoltageSwellPeriodWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeRmsVoltageSwellPeriodWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeAcVoltageMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcVoltageMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcVoltageDivisorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcVoltageDivisorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcCurrentMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcCurrentMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcCurrentDivisorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcCurrentDivisorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcPowerMultiplierWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcPowerMultiplierID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcPowerDivisorWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcPowerDivisorID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeOverloadAlarmsMaskWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeOverloadAlarmsMaskID)
params:params];
}
- (void)writeAttributeOverloadAlarmsMaskWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOverloadAlarmsMaskWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOverloadAlarmsMaskWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeOverloadAlarmsMaskID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeVoltageOverloadWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeVoltageOverloadID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeCurrentOverloadWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeCurrentOverloadID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcOverloadAlarmsMaskWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcOverloadAlarmsMaskID)
params:params];
}
- (void)writeAttributeAcOverloadAlarmsMaskWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeAcOverloadAlarmsMaskWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeAcOverloadAlarmsMaskWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcOverloadAlarmsMaskID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeAcVoltageOverloadWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcVoltageOverloadID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcCurrentOverloadWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcCurrentOverloadID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcActivePowerOverloadWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcActivePowerOverloadID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcReactivePowerOverloadWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcReactivePowerOverloadID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsOverVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsOverVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsUnderVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsExtremeOverVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsExtremeUnderVoltageWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltageID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageSagWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageSwellWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLineCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeLineCurrentPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActiveCurrentPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeReactiveCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeReactiveCurrentPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltagePhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltagePhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageMinPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMinPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageMaxPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMaxPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentMinPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMinPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentMaxPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMaxPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerMinPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerMinPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerMaxPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerMaxPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeReactivePowerPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeReactivePowerPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeApparentPowerPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeApparentPowerPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePowerFactorPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributePowerFactorPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsVoltageMeasurementPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device
readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsOverVoltageCounterPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsOverVoltageCounterPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsUnderVoltageCounterPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsExtremeOverVoltagePeriodPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsExtremeUnderVoltagePeriodPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageSagPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagPeriodPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageSwellPeriodPhaseBWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodPhaseBID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeLineCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeLineCurrentPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActiveCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActiveCurrentPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeReactiveCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeReactiveCurrentPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltagePhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltagePhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageMinPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMinPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageMaxPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageMaxPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentMinPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMinPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsCurrentMaxPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsCurrentMaxPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerMinPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerMinPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeActivePowerMaxPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeActivePowerMaxPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeReactivePowerPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeReactivePowerPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeApparentPowerPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeApparentPowerPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributePowerFactorPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributePowerFactorPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsVoltageMeasurementPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device
readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsVoltageMeasurementPeriodPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsOverVoltageCounterPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsOverVoltageCounterPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAverageRmsUnderVoltageCounterPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAverageRmsUnderVoltageCounterPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsExtremeOverVoltagePeriodPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeOverVoltagePeriodPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsExtremeUnderVoltagePeriodPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsExtremeUnderVoltagePeriodPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageSagPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSagPeriodPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeRmsVoltageSwellPeriodPhaseCWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeRmsVoltageSwellPeriodPhaseCID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterElectricalMeasurementID)
attributeID:@(MTRClusterElectricalMeasurementAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterElectricalMeasurement (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)getProfileInfoCommandWithParams:(MTRElectricalMeasurementClusterGetProfileInfoCommandParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self getProfileInfoCommandWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getProfileInfoCommandWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self getProfileInfoCommandWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)getMeasurementProfileCommandWithParams:(MTRElectricalMeasurementClusterGetMeasurementProfileCommandParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self getMeasurementProfileCommandWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
@implementation MTRClusterUnitTesting
- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
{
if (self = [super initWithQueue:queue]) {
if (device == nil) {
return nil;
}
_endpoint = [endpointID unsignedShortValue];
_device = device;
}
return self;
}
- (void)testWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self testWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
}
- (void)testWithParams:(MTRUnitTestingClusterTestParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::Test::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testNotHandledWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self testNotHandledWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)testNotHandledWithParams:(MTRUnitTestingClusterTestNotHandledParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestNotHandled::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testSpecificWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterTestSpecificResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
[self testSpecificWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)testSpecificWithParams:(MTRUnitTestingClusterTestSpecificParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterTestSpecificResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestSpecificResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestSpecificResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestSpecific::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testUnknownCommandWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self testUnknownCommandWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)testUnknownCommandWithParams:(MTRUnitTestingClusterTestUnknownCommandParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestUnknownCommand::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testAddArgumentsWithParams:(MTRUnitTestingClusterTestAddArgumentsParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestAddArgumentsResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestAddArgumentsResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestAddArguments::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.arg1 = params.arg1.unsignedCharValue;
request.arg2 = params.arg2.unsignedCharValue;
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testSimpleArgumentRequestWithParams:(MTRUnitTestingClusterTestSimpleArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterTestSimpleArgumentResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestSimpleArgumentResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestSimpleArgumentResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestSimpleArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.arg1 = params.arg1.boolValue;
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testStructArrayArgumentRequestWithParams:(MTRUnitTestingClusterTestStructArrayArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(MTRUnitTestingClusterTestStructArrayArgumentResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestStructArrayArgumentResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestStructArrayArgumentResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestStructArrayArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
{
using ListType_0 = std::remove_reference_t<decltype(request.arg1)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.arg1.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.arg1.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
listFreer.add(listHolder_0);
for (size_t i_0 = 0; i_0 < params.arg1.count; ++i_0) {
if (![params.arg1[i_0] isKindOfClass:[MTRUnitTestingClusterNestedStructList class]]) {
// Wrong kind of value.
return CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_0 = (MTRUnitTestingClusterNestedStructList *) 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_cast<std::remove_reference_t<decltype(listHolder_0->mList[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_cast<std::remove_reference_t<decltype(listHolder_0->mList[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_t<decltype(listHolder_0->mList[i_0].d)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.d.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.d.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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:[MTRUnitTestingClusterSimpleStruct class]]) {
// Wrong kind of value.
return CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_2 = (MTRUnitTestingClusterSimpleStruct *) 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_cast<std::remove_reference_t<decltype(listHolder_2->mList[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_cast<std::remove_reference_t<decltype(listHolder_2->mList[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_t<decltype(listHolder_0->mList[i_0].e)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.e.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.e.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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_t<decltype(listHolder_0->mList[i_0].f)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.f.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.f.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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_t<decltype(listHolder_0->mList[i_0].g)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.g.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.g.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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<decltype(request.arg2)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.arg2.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.arg2.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
listFreer.add(listHolder_0);
for (size_t i_0 = 0; i_0 < params.arg2.count; ++i_0) {
if (![params.arg2[i_0] isKindOfClass:[MTRUnitTestingClusterSimpleStruct class]]) {
// Wrong kind of value.
return CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_0 = (MTRUnitTestingClusterSimpleStruct *) 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_cast<std::remove_reference_t<decltype(listHolder_0->mList[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_cast<std::remove_reference_t<decltype(listHolder_0->mList[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<decltype(request.arg3)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.arg3.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.arg3.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_0 = (NSNumber *) params.arg3[i_0];
listHolder_0->mList[i_0] = static_cast<std::remove_reference_t<decltype(listHolder_0->mList[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<decltype(request.arg4)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.arg4.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.arg4.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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<std::remove_reference_t<decltype(request.arg5)>>(params.arg5.unsignedCharValue);
request.arg6 = params.arg6.boolValue;
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testStructArgumentRequestWithParams:(MTRUnitTestingClusterTestStructArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestStructArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.arg1.a = params.arg1.a.unsignedCharValue;
request.arg1.b = params.arg1.b.boolValue;
request.arg1.c = static_cast<std::remove_reference_t<decltype(request.arg1.c)>>(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<std::remove_reference_t<decltype(request.arg1.f)>>(params.arg1.f.unsignedCharValue);
request.arg1.g = params.arg1.g.floatValue;
request.arg1.h = params.arg1.h.doubleValue;
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testNestedStructArgumentRequestWithParams:(MTRUnitTestingClusterTestNestedStructArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestNestedStructArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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<std::remove_reference_t<decltype(request.arg1.c.c)>>(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<std::remove_reference_t<decltype(request.arg1.c.f)>>(params.arg1.c.f.unsignedCharValue);
request.arg1.c.g = params.arg1.c.g.floatValue;
request.arg1.c.h = params.arg1.c.h.doubleValue;
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testListStructArgumentRequestWithParams:(MTRUnitTestingClusterTestListStructArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestListStructArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
{
using ListType_0 = std::remove_reference_t<decltype(request.arg1)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.arg1.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.arg1.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
listFreer.add(listHolder_0);
for (size_t i_0 = 0; i_0 < params.arg1.count; ++i_0) {
if (![params.arg1[i_0] isKindOfClass:[MTRUnitTestingClusterSimpleStruct class]]) {
// Wrong kind of value.
return CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_0 = (MTRUnitTestingClusterSimpleStruct *) 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_cast<std::remove_reference_t<decltype(listHolder_0->mList[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_cast<std::remove_reference_t<decltype(listHolder_0->mList[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();
}
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testListInt8UArgumentRequestWithParams:(MTRUnitTestingClusterTestListInt8UArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestListInt8UArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
{
using ListType_0 = std::remove_reference_t<decltype(request.arg1)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.arg1.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.arg1.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testNestedStructListArgumentRequestWithParams:(MTRUnitTestingClusterTestNestedStructListArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestNestedStructListArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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<std::remove_reference_t<decltype(request.arg1.c.c)>>(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<std::remove_reference_t<decltype(request.arg1.c.f)>>(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<decltype(request.arg1.d)>;
using ListMemberType_1 = ListMemberTypeGetter<ListType_1>::Type;
if (params.arg1.d.count != 0) {
auto * listHolder_1 = new ListHolder<ListMemberType_1>(params.arg1.d.count);
if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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:[MTRUnitTestingClusterSimpleStruct class]]) {
// Wrong kind of value.
return CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_1 = (MTRUnitTestingClusterSimpleStruct *) 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_cast<std::remove_reference_t<decltype(listHolder_1->mList[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_cast<std::remove_reference_t<decltype(listHolder_1->mList[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<decltype(request.arg1.e)>;
using ListMemberType_1 = ListMemberTypeGetter<ListType_1>::Type;
if (params.arg1.e.count != 0) {
auto * listHolder_1 = new ListHolder<ListMemberType_1>(params.arg1.e.count);
if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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<decltype(request.arg1.f)>;
using ListMemberType_1 = ListMemberTypeGetter<ListType_1>::Type;
if (params.arg1.f.count != 0) {
auto * listHolder_1 = new ListHolder<ListMemberType_1>(params.arg1.f.count);
if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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<decltype(request.arg1.g)>;
using ListMemberType_1 = ListMemberTypeGetter<ListType_1>::Type;
if (params.arg1.g.count != 0) {
auto * listHolder_1 = new ListHolder<ListMemberType_1>(params.arg1.g.count);
if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testListNestedStructListArgumentRequestWithParams:
(MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestListNestedStructListArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
{
using ListType_0 = std::remove_reference_t<decltype(request.arg1)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.arg1.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.arg1.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
listFreer.add(listHolder_0);
for (size_t i_0 = 0; i_0 < params.arg1.count; ++i_0) {
if (![params.arg1[i_0] isKindOfClass:[MTRUnitTestingClusterNestedStructList class]]) {
// Wrong kind of value.
return CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_0 = (MTRUnitTestingClusterNestedStructList *) 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_cast<std::remove_reference_t<decltype(listHolder_0->mList[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_cast<std::remove_reference_t<decltype(listHolder_0->mList[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_t<decltype(listHolder_0->mList[i_0].d)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.d.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.d.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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:[MTRUnitTestingClusterSimpleStruct class]]) {
// Wrong kind of value.
return CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_2 = (MTRUnitTestingClusterSimpleStruct *) 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_cast<std::remove_reference_t<decltype(listHolder_2->mList[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_cast<std::remove_reference_t<decltype(listHolder_2->mList[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_t<decltype(listHolder_0->mList[i_0].e)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.e.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.e.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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_t<decltype(listHolder_0->mList[i_0].f)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.f.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.f.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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_t<decltype(listHolder_0->mList[i_0].g)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (element_0.g.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(element_0.g.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testListInt8UReverseRequestWithParams:(MTRUnitTestingClusterTestListInt8UReverseRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestListInt8UReverseResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestListInt8UReverseResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestListInt8UReverseRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
{
using ListType_0 = std::remove_reference_t<decltype(request.arg1)>;
using ListMemberType_0 = ListMemberTypeGetter<ListType_0>::Type;
if (params.arg1.count != 0) {
auto * listHolder_0 = new ListHolder<ListMemberType_0>(params.arg1.count);
if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
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();
}
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testEnumsRequestWithParams:(MTRUnitTestingClusterTestEnumsRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestEnumsResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestEnumsResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestEnumsRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.arg1 = static_cast<std::remove_reference_t<decltype(request.arg1)>>(params.arg1.unsignedShortValue);
request.arg2 = static_cast<std::remove_reference_t<decltype(request.arg2)>>(params.arg2.unsignedCharValue);
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testNullableOptionalRequestWithParams:(MTRUnitTestingClusterTestNullableOptionalRequestParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestNullableOptionalResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestNullableOptionalResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestNullableOptionalRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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;
}
}
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testComplexNullableOptionalRequestWithParams:(MTRUnitTestingClusterTestComplexNullableOptionalRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(
MTRUnitTestingClusterTestComplexNullableOptionalResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestComplexNullableOptionalResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestComplexNullableOptionalResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestComplexNullableOptionalRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
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<std::remove_reference_t<decltype(nonNullValue_0.c)>>(
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<std::remove_reference_t<decltype(nonNullValue_0.f)>>(
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<std::remove_reference_t<decltype(definedValue_0.c)>>(
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<std::remove_reference_t<decltype(definedValue_0.f)>>(
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<std::remove_reference_t<decltype(nonNullValue_1.c)>>(
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<std::remove_reference_t<decltype(nonNullValue_1.f)>>(
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<decltype(nonNullValue_0)>;
using ListMemberType_1 = ListMemberTypeGetter<ListType_1>::Type;
if (params.nullableList.count != 0) {
auto * listHolder_1 = new ListHolder<ListMemberType_1>(params.nullableList.count);
if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_1 = (NSNumber *) params.nullableList[i_1];
listHolder_1->mList[i_1] = static_cast<std::remove_reference_t<decltype(listHolder_1->mList[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<decltype(definedValue_0)>;
using ListMemberType_1 = ListMemberTypeGetter<ListType_1>::Type;
if (params.optionalList.count != 0) {
auto * listHolder_1 = new ListHolder<ListMemberType_1>(params.optionalList.count);
if (listHolder_1 == nullptr || listHolder_1->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_1 = (NSNumber *) params.optionalList[i_1];
listHolder_1->mList[i_1] = static_cast<std::remove_reference_t<decltype(listHolder_1->mList[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<decltype(nonNullValue_1)>;
using ListMemberType_2 = ListMemberTypeGetter<ListType_2>::Type;
if (params.nullableOptionalList.count != 0) {
auto * listHolder_2 = new ListHolder<ListMemberType_2>(params.nullableOptionalList.count);
if (listHolder_2 == nullptr || listHolder_2->mList == nullptr) {
return CHIP_ERROR_INVALID_ARGUMENT;
}
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 CHIP_ERROR_INVALID_ARGUMENT;
}
auto element_2 = (NSNumber *) params.nullableOptionalList[i_2];
listHolder_2->mList[i_2]
= static_cast<std::remove_reference_t<decltype(listHolder_2->mList[i_2])>>(
element_2.unsignedCharValue);
}
nonNullValue_1 = ListType_2(listHolder_2->mList, params.nullableOptionalList.count);
} else {
nonNullValue_1 = ListType_2();
}
}
}
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)simpleStructEchoRequestWithParams:(MTRUnitTestingClusterSimpleStructEchoRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterSimpleStructResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterSimpleStructResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterSimpleStructResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::SimpleStructEchoRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.arg1.a = params.arg1.a.unsignedCharValue;
request.arg1.b = params.arg1.b.boolValue;
request.arg1.c = static_cast<std::remove_reference_t<decltype(request.arg1.c)>>(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<std::remove_reference_t<decltype(request.arg1.f)>>(params.arg1.f.unsignedCharValue);
request.arg1.g = params.arg1.g.floatValue;
request.arg1.h = params.arg1.h.doubleValue;
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)timedInvokeRequestWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
[self timedInvokeRequestWithParams:nil
expectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completion];
}
- (void)timedInvokeRequestWithParams:(MTRUnitTestingClusterTimedInvokeRequestParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TimedInvokeRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (!timedInvokeTimeoutMs.HasValue()) {
timedInvokeTimeoutMs.SetValue(10000);
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testSimpleOptionalArgumentRequestWithParams:(MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(MTRStatusCompletion)completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRCommandSuccessCallbackBridge(
self.callbackQueue,
^(id _Nullable value, NSError * _Nullable error) {
completion(error);
[workItem endWork];
},
^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestSimpleOptionalArgumentRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
if (params != nil) {
if (params.arg1 != nil) {
auto & definedValue_0 = request.arg1.Emplace();
definedValue_0 = params.arg1.boolValue;
}
}
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)testEmitTestEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestEventRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:(void (^)(MTRUnitTestingClusterTestEmitTestEventResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestEmitTestEventResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestEmitTestEventResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestEmitTestEventRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.arg1 = params.arg1.unsignedCharValue;
request.arg2 = static_cast<std::remove_reference_t<decltype(request.arg2)>>(params.arg2.unsignedCharValue);
request.arg3 = params.arg3.boolValue;
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (void)
testEmitTestFabricScopedEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestFabricScopedEventRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completion:
(void (^)(
MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams * _Nullable data,
NSError * _Nullable error))completion
{
// Make a copy of params before we go async.
params = [params copy];
NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
if (timedInvokeTimeoutMsParam) {
timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
}
MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.callbackQueue];
MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
controller:self.device.deviceController];
auto * bridge = new MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseCallbackBridge(self.callbackQueue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session,
UnitTestingClusterTestEmitTestFabricScopedEventResponseCallbackType successCb, MTRErrorCallback failureCb,
MTRCallbackBridgeBase * bridge) {
chip::Optional<uint16_t> timedInvokeTimeoutMs;
ListFreer listFreer;
UnitTesting::Commands::TestEmitTestFabricScopedEventRequest::Type request;
if (timedInvokeTimeoutMsParam != nil) {
timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
}
request.arg1 = params.arg1.unsignedCharValue;
chip::Controller::UnitTestingCluster cppCluster(exchangeManager, session, self->_endpoint);
return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs);
});
std::move(*bridge).DispatchAction(baseDevice);
};
workItem.readyHandler = readyHandler;
[self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
expectedValues = nil;
} else {
expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
}
if (expectedValues) {
[self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
}
}
- (NSDictionary<NSString *, id> *)readAttributeBooleanWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBooleanID)
params:params];
}
- (void)writeAttributeBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBooleanID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBitmap8WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBitmap8ID)
params:params];
}
- (void)writeAttributeBitmap8WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBitmap8WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBitmap8WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBitmap8ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBitmap16WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBitmap16ID)
params:params];
}
- (void)writeAttributeBitmap16WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBitmap16WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBitmap16WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBitmap16ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBitmap32WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBitmap32ID)
params:params];
}
- (void)writeAttributeBitmap32WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBitmap32WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBitmap32WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBitmap32ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeBitmap64WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBitmap64ID)
params:params];
}
- (void)writeAttributeBitmap64WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeBitmap64WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeBitmap64WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeBitmap64ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt8uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt8uID)
params:params];
}
- (void)writeAttributeInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt8uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt16uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt16uID)
params:params];
}
- (void)writeAttributeInt16uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt16uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt16uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt16uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt24uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt24uID)
params:params];
}
- (void)writeAttributeInt24uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt24uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt24uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt24uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt32uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt32uID)
params:params];
}
- (void)writeAttributeInt32uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt32uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt32uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt32uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt40uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt40uID)
params:params];
}
- (void)writeAttributeInt40uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt40uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt40uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt40uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt48uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt48uID)
params:params];
}
- (void)writeAttributeInt48uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt48uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt48uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt48uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt56uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt56uID)
params:params];
}
- (void)writeAttributeInt56uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt56uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt56uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt56uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt64uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt64uID)
params:params];
}
- (void)writeAttributeInt64uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt64uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt64uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt64uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt8sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt8sID)
params:params];
}
- (void)writeAttributeInt8sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt8sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt8sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt8sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt16sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt16sID)
params:params];
}
- (void)writeAttributeInt16sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt16sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt16sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt16sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt24sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt24sID)
params:params];
}
- (void)writeAttributeInt24sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt24sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt24sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt24sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt32sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt32sID)
params:params];
}
- (void)writeAttributeInt32sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt32sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt32sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt32sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt40sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt40sID)
params:params];
}
- (void)writeAttributeInt40sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt40sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt40sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt40sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt48sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt48sID)
params:params];
}
- (void)writeAttributeInt48sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt48sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt48sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt48sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt56sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt56sID)
params:params];
}
- (void)writeAttributeInt56sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt56sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt56sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt56sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeInt64sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt64sID)
params:params];
}
- (void)writeAttributeInt64sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeInt64sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeInt64sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeInt64sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEnum8WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEnum8ID)
params:params];
}
- (void)writeAttributeEnum8WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEnum8WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeEnum8WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEnum8ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEnum16WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEnum16ID)
params:params];
}
- (void)writeAttributeEnum16WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEnum16WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeEnum16WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEnum16ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeFloatSingleWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeFloatSingleID)
params:params];
}
- (void)writeAttributeFloatSingleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeFloatSingleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeFloatSingleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeFloatSingleID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeFloatDoubleWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeFloatDoubleID)
params:params];
}
- (void)writeAttributeFloatDoubleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeFloatDoubleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeFloatDoubleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeFloatDoubleID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeOctetStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeOctetStringID)
params:params];
}
- (void)writeAttributeOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeOctetStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeListInt8uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListInt8uID)
params:params];
}
- (void)writeAttributeListInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeListInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeListInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListInt8uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeListOctetStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListOctetStringID)
params:params];
}
- (void)writeAttributeListOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeListOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeListOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListOctetStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeListStructOctetStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListStructOctetStringID)
params:params];
}
- (void)writeAttributeListStructOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeListStructOctetStringWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeListStructOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListStructOctetStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLongOctetStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeLongOctetStringID)
params:params];
}
- (void)writeAttributeLongOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLongOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLongOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeLongOctetStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeCharStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeCharStringID)
params:params];
}
- (void)writeAttributeCharStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeCharStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeCharStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeCharStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeLongCharStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeLongCharStringID)
params:params];
}
- (void)writeAttributeLongCharStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeLongCharStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeLongCharStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeLongCharStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEpochUsWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEpochUsID)
params:params];
}
- (void)writeAttributeEpochUsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEpochUsWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeEpochUsWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEpochUsID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEpochSWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEpochSID)
params:params];
}
- (void)writeAttributeEpochSWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEpochSWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeEpochSWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEpochSID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeVendorIdWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeVendorIdID)
params:params];
}
- (void)writeAttributeVendorIdWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeVendorIdWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeVendorIdWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeVendorIdID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeListNullablesAndOptionalsStructWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListNullablesAndOptionalsStructID)
params:params];
}
- (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeListNullablesAndOptionalsStructWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListNullablesAndOptionalsStructID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeEnumAttrWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEnumAttrID)
params:params];
}
- (void)writeAttributeEnumAttrWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeEnumAttrWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeEnumAttrWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeEnumAttrID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeStructAttrWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeStructAttrID)
params:params];
}
- (void)writeAttributeStructAttrWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeStructAttrWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeStructAttrWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeStructAttrID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRangeRestrictedInt8uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeRangeRestrictedInt8uID)
params:params];
}
- (void)writeAttributeRangeRestrictedInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRangeRestrictedInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeRangeRestrictedInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeRangeRestrictedInt8uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRangeRestrictedInt8sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeRangeRestrictedInt8sID)
params:params];
}
- (void)writeAttributeRangeRestrictedInt8sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRangeRestrictedInt8sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeRangeRestrictedInt8sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeRangeRestrictedInt8sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRangeRestrictedInt16uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeRangeRestrictedInt16uID)
params:params];
}
- (void)writeAttributeRangeRestrictedInt16uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRangeRestrictedInt16uWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeRangeRestrictedInt16uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeRangeRestrictedInt16uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeRangeRestrictedInt16sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeRangeRestrictedInt16sID)
params:params];
}
- (void)writeAttributeRangeRestrictedInt16sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeRangeRestrictedInt16sWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeRangeRestrictedInt16sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeRangeRestrictedInt16sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeListLongOctetStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListLongOctetStringID)
params:params];
}
- (void)writeAttributeListLongOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeListLongOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeListLongOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListLongOctetStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeListFabricScopedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListFabricScopedID)
params:params];
}
- (void)writeAttributeListFabricScopedWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeListFabricScopedWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeListFabricScopedWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeListFabricScopedID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeTimedWriteBooleanWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeTimedWriteBooleanID)
params:params];
}
- (void)writeAttributeTimedWriteBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeTimedWriteBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeTimedWriteBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeTimedWriteBooleanID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneralErrorBooleanWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeGeneralErrorBooleanID)
params:params];
}
- (void)writeAttributeGeneralErrorBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeGeneralErrorBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeGeneralErrorBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeGeneralErrorBooleanID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterErrorBooleanWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeClusterErrorBooleanID)
params:params];
}
- (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeClusterErrorBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeClusterErrorBooleanID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeUnsupportedWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeUnsupportedID)
params:params];
}
- (void)writeAttributeUnsupportedWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeUnsupportedWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeUnsupportedWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeUnsupportedID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableBooleanWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBooleanID)
params:params];
}
- (void)writeAttributeNullableBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableBooleanWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableBooleanWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBooleanID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableBitmap8WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBitmap8ID)
params:params];
}
- (void)writeAttributeNullableBitmap8WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableBitmap8WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableBitmap8WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBitmap8ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableBitmap16WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBitmap16ID)
params:params];
}
- (void)writeAttributeNullableBitmap16WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableBitmap16WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableBitmap16WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBitmap16ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableBitmap32WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBitmap32ID)
params:params];
}
- (void)writeAttributeNullableBitmap32WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableBitmap32WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableBitmap32WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBitmap32ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableBitmap64WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBitmap64ID)
params:params];
}
- (void)writeAttributeNullableBitmap64WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableBitmap64WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableBitmap64WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableBitmap64ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt8uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt8uID)
params:params];
}
- (void)writeAttributeNullableInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt8uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt16uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt16uID)
params:params];
}
- (void)writeAttributeNullableInt16uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt16uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt16uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt16uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt24uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt24uID)
params:params];
}
- (void)writeAttributeNullableInt24uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt24uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt24uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt24uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt32uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt32uID)
params:params];
}
- (void)writeAttributeNullableInt32uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt32uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt32uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt32uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt40uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt40uID)
params:params];
}
- (void)writeAttributeNullableInt40uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt40uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt40uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt40uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt48uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt48uID)
params:params];
}
- (void)writeAttributeNullableInt48uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt48uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt48uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt48uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt56uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt56uID)
params:params];
}
- (void)writeAttributeNullableInt56uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt56uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt56uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt56uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt64uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt64uID)
params:params];
}
- (void)writeAttributeNullableInt64uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt64uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt64uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt64uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt8sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt8sID)
params:params];
}
- (void)writeAttributeNullableInt8sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt8sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt8sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt8sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt16sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt16sID)
params:params];
}
- (void)writeAttributeNullableInt16sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt16sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt16sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt16sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt24sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt24sID)
params:params];
}
- (void)writeAttributeNullableInt24sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt24sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt24sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt24sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt32sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt32sID)
params:params];
}
- (void)writeAttributeNullableInt32sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt32sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt32sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt32sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt40sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt40sID)
params:params];
}
- (void)writeAttributeNullableInt40sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt40sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt40sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt40sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt48sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt48sID)
params:params];
}
- (void)writeAttributeNullableInt48sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt48sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt48sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt48sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt56sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt56sID)
params:params];
}
- (void)writeAttributeNullableInt56sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt56sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt56sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt56sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableInt64sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt64sID)
params:params];
}
- (void)writeAttributeNullableInt64sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableInt64sWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableInt64sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableInt64sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableEnum8WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableEnum8ID)
params:params];
}
- (void)writeAttributeNullableEnum8WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableEnum8WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableEnum8WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableEnum8ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableEnum16WithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableEnum16ID)
params:params];
}
- (void)writeAttributeNullableEnum16WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableEnum16WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableEnum16WithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableEnum16ID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableFloatSingleWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableFloatSingleID)
params:params];
}
- (void)writeAttributeNullableFloatSingleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableFloatSingleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableFloatSingleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableFloatSingleID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableFloatDoubleWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableFloatDoubleID)
params:params];
}
- (void)writeAttributeNullableFloatDoubleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableFloatDoubleWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableFloatDoubleWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableFloatDoubleID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableOctetStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableOctetStringID)
params:params];
}
- (void)writeAttributeNullableOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableOctetStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableOctetStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableOctetStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableCharStringWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableCharStringID)
params:params];
}
- (void)writeAttributeNullableCharStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableCharStringWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableCharStringWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableCharStringID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableEnumAttrWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableEnumAttrID)
params:params];
}
- (void)writeAttributeNullableEnumAttrWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableEnumAttrWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableEnumAttrWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableEnumAttrID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableStructWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableStructID)
params:params];
}
- (void)writeAttributeNullableStructWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableStructWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeNullableStructWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableStructID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableRangeRestrictedInt8uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableRangeRestrictedInt8uID)
params:params];
}
- (void)writeAttributeNullableRangeRestrictedInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableRangeRestrictedInt8uWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeNullableRangeRestrictedInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableRangeRestrictedInt8uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableRangeRestrictedInt8sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableRangeRestrictedInt8sID)
params:params];
}
- (void)writeAttributeNullableRangeRestrictedInt8sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableRangeRestrictedInt8sWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeNullableRangeRestrictedInt8sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableRangeRestrictedInt8sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableRangeRestrictedInt16uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableRangeRestrictedInt16uID)
params:params];
}
- (void)writeAttributeNullableRangeRestrictedInt16uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableRangeRestrictedInt16uWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeNullableRangeRestrictedInt16uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableRangeRestrictedInt16uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeNullableRangeRestrictedInt16sWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableRangeRestrictedInt16sID)
params:params];
}
- (void)writeAttributeNullableRangeRestrictedInt16sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeNullableRangeRestrictedInt16sWithValue:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
params:nil];
}
- (void)writeAttributeNullableRangeRestrictedInt16sWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeNullableRangeRestrictedInt16sID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeWriteOnlyInt8uWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeWriteOnlyInt8uID)
params:params];
}
- (void)writeAttributeWriteOnlyInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
{
[self writeAttributeWriteOnlyInt8uWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil];
}
- (void)writeAttributeWriteOnlyInt8uWithValue:(NSDictionary<NSString *, id> *)dataValueDictionary
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
params:(MTRWriteParams * _Nullable)params
{
NSNumber * timedWriteTimeout = params.timedWriteTimeout;
[self.device writeAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeWriteOnlyInt8uID)
value:dataValueDictionary
expectedValueInterval:expectedValueIntervalMs
timedWriteTimeout:timedWriteTimeout];
}
- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeGeneratedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeAcceptedCommandListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeAttributeListID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeFeatureMapID)
params:params];
}
- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
{
return [self.device readAttributeWithEndpointID:@(_endpoint)
clusterID:@(MTRClusterUnitTestingID)
attributeID:@(MTRClusterUnitTestingAttributeClusterRevisionID)
params:params];
}
@end
@implementation MTRClusterUnitTesting (Deprecated)
- (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue
{
return [self initWithDevice:device endpointID:@(endpoint) queue:queue];
}
- (void)testWithParams:(MTRUnitTestingClusterTestParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self testWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self testWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)testNotHandledWithParams:(MTRUnitTestingClusterTestNotHandledParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self testNotHandledWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testNotHandledWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self testNotHandledWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testSpecificWithParams:(MTRUnitTestingClusterTestSpecificParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterTestSpecificResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testSpecificWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testSpecificWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterTestSpecificResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testSpecificWithExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completionHandler];
}
- (void)testUnknownCommandWithParams:(MTRUnitTestingClusterTestUnknownCommandParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self testUnknownCommandWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testUnknownCommandWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self testUnknownCommandWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testAddArgumentsWithParams:(MTRUnitTestingClusterTestAddArgumentsParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testAddArgumentsWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testSimpleArgumentRequestWithParams:(MTRUnitTestingClusterTestSimpleArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterTestSimpleArgumentResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testSimpleArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testStructArrayArgumentRequestWithParams:(MTRUnitTestingClusterTestStructArrayArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRUnitTestingClusterTestStructArrayArgumentResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testStructArrayArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testStructArgumentRequestWithParams:(MTRUnitTestingClusterTestStructArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testStructArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testNestedStructArgumentRequestWithParams:(MTRUnitTestingClusterTestNestedStructArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testNestedStructArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testListStructArgumentRequestWithParams:(MTRUnitTestingClusterTestListStructArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testListStructArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testListInt8UArgumentRequestWithParams:(MTRUnitTestingClusterTestListInt8UArgumentRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testListInt8UArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testNestedStructListArgumentRequestWithParams:(MTRUnitTestingClusterTestNestedStructListArgumentRequestParams *)params
expectedValues:
(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testNestedStructListArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testListNestedStructListArgumentRequestWithParams:
(MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams *)params
expectedValues:
(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterBooleanResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testListNestedStructListArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testListInt8UReverseRequestWithParams:(MTRUnitTestingClusterTestListInt8UReverseRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testListInt8UReverseRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testEnumsRequestWithParams:(MTRUnitTestingClusterTestEnumsRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testEnumsRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testNullableOptionalRequestWithParams:(MTRUnitTestingClusterTestNullableOptionalRequestParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testNullableOptionalRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testComplexNullableOptionalRequestWithParams:(MTRUnitTestingClusterTestComplexNullableOptionalRequestParams *)params
expectedValues:
(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(MTRUnitTestingClusterTestComplexNullableOptionalResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testComplexNullableOptionalRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)simpleStructEchoRequestWithParams:(MTRUnitTestingClusterSimpleStructEchoRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterSimpleStructResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self simpleStructEchoRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)timedInvokeRequestWithParams:(MTRUnitTestingClusterTimedInvokeRequestParams * _Nullable)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self timedInvokeRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)timedInvokeRequestWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
expectedValueInterval:(NSNumber *)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self timedInvokeRequestWithExpectedValues:expectedValues
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testSimpleOptionalArgumentRequestWithParams:(MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams * _Nullable)params
expectedValues:
(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(MTRStatusCompletion)completionHandler
{
[self testSimpleOptionalArgumentRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testEmitTestEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestEventRequestParams *)params
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:(void (^)(MTRUnitTestingClusterTestEmitTestEventResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testEmitTestEventRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
- (void)testEmitTestFabricScopedEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestFabricScopedEventRequestParams *)params
expectedValues:
(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
completionHandler:
(void (^)(
MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams * _Nullable data,
NSError * _Nullable error))completionHandler
{
[self testEmitTestFabricScopedEventRequestWithParams:params
expectedValues:expectedDataValueDictionaries
expectedValueInterval:expectedValueIntervalMs
completion:completionHandler];
}
@end
// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)