Apply Upstream code (2021-03-15)
[platform/upstream/connectedhomeip.git] / examples / all-clusters-app / all-clusters-common / gen / CHIPClustersObjc.mm
1 /*
2  *
3  *    Copyright (c) 2021 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 // THIS FILE IS GENERATED BY ZAP
19
20 #import <Foundation/Foundation.h>
21
22 #import "CHIPDevice.h"
23 #import "CHIPDevice_Internal.h"
24 #import "ChipError.h"
25 #import "gen/CHIPClientCallbacks.h"
26 #import "gen/CHIPClustersObjc.h"
27
28 #include <controller/CHIPClusters.h>
29 #include <lib/support/Span.h>
30
31 using namespace ::chip;
32
33 class CHIPDefaultSuccessCallbackBridge : public Callback::Callback<DefaultSuccessCallback> {
34 public:
35     CHIPDefaultSuccessCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
36         : Callback::Callback<DefaultSuccessCallback>(CallbackFn, this)
37         , mHandler(handler)
38         , mQueue(queue)
39     {
40     }
41
42     ~CHIPDefaultSuccessCallbackBridge() {};
43
44     static void CallbackFn(void * context)
45     {
46         CHIPDefaultSuccessCallbackBridge * callback = reinterpret_cast<CHIPDefaultSuccessCallbackBridge *>(context);
47         if (callback && callback->mQueue) {
48             dispatch_async(callback->mQueue, ^{
49                 callback->mHandler(nil, nil);
50                 callback->Cancel();
51                 delete callback;
52             });
53         }
54     };
55
56 private:
57     ResponseHandler mHandler;
58     dispatch_queue_t mQueue;
59 };
60
61 class CHIPDefaultFailureCallbackBridge : public Callback::Callback<DefaultFailureCallback> {
62 public:
63     CHIPDefaultFailureCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
64         : Callback::Callback<DefaultFailureCallback>(CallbackFn, this)
65         , mHandler(handler)
66         , mQueue(queue)
67     {
68     }
69
70     ~CHIPDefaultFailureCallbackBridge() {};
71
72     static void CallbackFn(void * context, uint8_t status)
73     {
74         CHIPDefaultFailureCallbackBridge * callback = reinterpret_cast<CHIPDefaultFailureCallbackBridge *>(context);
75         if (callback && callback->mQueue) {
76             dispatch_async(callback->mQueue, ^{
77                 NSError * error = [NSError errorWithDomain:CHIPErrorDomain
78                                                       code:status
79                                                   userInfo:@ { NSLocalizedDescriptionKey : @"" }];
80                 callback->mHandler(error, nil);
81                 callback->Cancel();
82                 delete callback;
83             });
84         }
85     };
86
87 private:
88     ResponseHandler mHandler;
89     dispatch_queue_t mQueue;
90 };
91
92 class CHIPStringAttributeCallbackBridge : public Callback::Callback<StringAttributeCallback> {
93 public:
94     CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false)
95         : Callback::Callback<StringAttributeCallback>(CallbackFn, this)
96         , mHandler(handler)
97         , mQueue(queue)
98         , mOctetString(octetString)
99         , mKeepAlive(keepAlive)
100     {
101     }
102
103     ~CHIPStringAttributeCallbackBridge() {};
104
105     static void CallbackFn(void * context, chip::ByteSpan value)
106     {
107         CHIPStringAttributeCallbackBridge * callback = reinterpret_cast<CHIPStringAttributeCallbackBridge *>(context);
108         if (callback && callback->mQueue) {
109             dispatch_async(callback->mQueue, ^{
110                 if (callback->mOctetString) {
111                     NSData * data = [NSData dataWithBytes:value.data() length:value.size()];
112                     callback->mHandler(nil, @ { @"value" : data });
113                 } else {
114                     NSString * str = [[NSString alloc] initWithBytes:value.data()
115                                                               length:value.size()
116                                                             encoding:NSUTF8StringEncoding];
117                     callback->mHandler(nil, @ { @"value" : str });
118                 }
119
120                 if (!callback->mKeepAlive) {
121                     callback->Cancel();
122                     delete callback;
123                 }
124             });
125         }
126     };
127
128 private:
129     ResponseHandler mHandler;
130     dispatch_queue_t mQueue;
131     bool mOctetString;
132     bool mKeepAlive;
133 };
134
135 class CHIPBooleanAttributeCallbackBridge : public Callback::Callback<BooleanAttributeCallback> {
136 public:
137     CHIPBooleanAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
138         : Callback::Callback<BooleanAttributeCallback>(CallbackFn, this)
139         , mHandler(handler)
140         , mQueue(queue)
141         , mKeepAlive(keepAlive)
142     {
143     }
144
145     ~CHIPBooleanAttributeCallbackBridge() {};
146
147     static void CallbackFn(void * context, bool value)
148     {
149         CHIPBooleanAttributeCallbackBridge * callback = reinterpret_cast<CHIPBooleanAttributeCallbackBridge *>(context);
150         if (callback && callback->mQueue) {
151             dispatch_async(callback->mQueue, ^{
152                 callback->mHandler(nil, @ { @"value" : [NSNumber numberWithBool:value] });
153                 if (!callback->mKeepAlive) {
154                     callback->Cancel();
155                     delete callback;
156                 }
157             });
158         }
159     };
160
161 private:
162     ResponseHandler mHandler;
163     dispatch_queue_t mQueue;
164     bool mKeepAlive;
165 };
166
167 class CHIPInt8uAttributeCallbackBridge : public Callback::Callback<Int8uAttributeCallback> {
168 public:
169     CHIPInt8uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
170         : Callback::Callback<Int8uAttributeCallback>(CallbackFn, this)
171         , mHandler(handler)
172         , mQueue(queue)
173         , mKeepAlive(keepAlive)
174     {
175     }
176
177     ~CHIPInt8uAttributeCallbackBridge() {};
178
179     static void CallbackFn(void * context, uint8_t value)
180     {
181         CHIPInt8uAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt8uAttributeCallbackBridge *>(context);
182         if (callback && callback->mQueue) {
183             dispatch_async(callback->mQueue, ^{
184                 callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedChar:value] });
185                 if (!callback->mKeepAlive) {
186                     callback->Cancel();
187                     delete callback;
188                 }
189             });
190         }
191     };
192
193 private:
194     ResponseHandler mHandler;
195     dispatch_queue_t mQueue;
196     bool mKeepAlive;
197 };
198
199 class CHIPInt8sAttributeCallbackBridge : public Callback::Callback<Int8sAttributeCallback> {
200 public:
201     CHIPInt8sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
202         : Callback::Callback<Int8sAttributeCallback>(CallbackFn, this)
203         , mHandler(handler)
204         , mQueue(queue)
205         , mKeepAlive(keepAlive)
206     {
207     }
208
209     ~CHIPInt8sAttributeCallbackBridge() {};
210
211     static void CallbackFn(void * context, int8_t value)
212     {
213         CHIPInt8sAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt8sAttributeCallbackBridge *>(context);
214         if (callback && callback->mQueue) {
215             dispatch_async(callback->mQueue, ^{
216                 callback->mHandler(nil, @ { @"value" : [NSNumber numberWithChar:value] });
217                 if (!callback->mKeepAlive) {
218                     callback->Cancel();
219                     delete callback;
220                 }
221             });
222         }
223     };
224
225 private:
226     ResponseHandler mHandler;
227     dispatch_queue_t mQueue;
228     bool mKeepAlive;
229 };
230
231 class CHIPInt16uAttributeCallbackBridge : public Callback::Callback<Int16uAttributeCallback> {
232 public:
233     CHIPInt16uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
234         : Callback::Callback<Int16uAttributeCallback>(CallbackFn, this)
235         , mHandler(handler)
236         , mQueue(queue)
237         , mKeepAlive(keepAlive)
238     {
239     }
240
241     ~CHIPInt16uAttributeCallbackBridge() {};
242
243     static void CallbackFn(void * context, uint16_t value)
244     {
245         CHIPInt16uAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt16uAttributeCallbackBridge *>(context);
246         if (callback && callback->mQueue) {
247             dispatch_async(callback->mQueue, ^{
248                 callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedShort:value] });
249                 if (!callback->mKeepAlive) {
250                     callback->Cancel();
251                     delete callback;
252                 }
253             });
254         }
255     };
256
257 private:
258     ResponseHandler mHandler;
259     dispatch_queue_t mQueue;
260     bool mKeepAlive;
261 };
262
263 class CHIPInt32uAttributeCallbackBridge : public Callback::Callback<Int32uAttributeCallback> {
264 public:
265     CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
266         : Callback::Callback<Int32uAttributeCallback>(CallbackFn, this)
267         , mHandler(handler)
268         , mQueue(queue)
269         , mKeepAlive(keepAlive)
270     {
271     }
272
273     ~CHIPInt32uAttributeCallbackBridge() {};
274
275     static void CallbackFn(void * context, uint32_t value)
276     {
277         CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt32uAttributeCallbackBridge *>(context);
278         if (callback && callback->mQueue) {
279             dispatch_async(callback->mQueue, ^{
280                 callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] });
281                 if (!callback->mKeepAlive) {
282                     callback->Cancel();
283                     delete callback;
284                 }
285             });
286         }
287     };
288
289 private:
290     ResponseHandler mHandler;
291     dispatch_queue_t mQueue;
292     bool mKeepAlive;
293 };
294
295 class CHIPInt16sAttributeCallbackBridge : public Callback::Callback<Int16sAttributeCallback> {
296 public:
297     CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
298         : Callback::Callback<Int16sAttributeCallback>(CallbackFn, this)
299         , mHandler(handler)
300         , mQueue(queue)
301         , mKeepAlive(keepAlive)
302     {
303     }
304
305     ~CHIPInt16sAttributeCallbackBridge() {};
306
307     static void CallbackFn(void * context, int16_t value)
308     {
309         CHIPInt16sAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt16sAttributeCallbackBridge *>(context);
310         if (callback && callback->mQueue) {
311             dispatch_async(callback->mQueue, ^{
312                 callback->mHandler(nil, @ { @"value" : [NSNumber numberWithShort:value] });
313                 if (!callback->mKeepAlive) {
314                     callback->Cancel();
315                     delete callback;
316                 }
317             });
318         }
319     };
320
321 private:
322     ResponseHandler mHandler;
323     dispatch_queue_t mQueue;
324     bool mKeepAlive;
325 };
326
327 @interface CHIPCluster ()
328 @property (readonly, nonatomic) dispatch_queue_t callbackQueue;
329 - (Controller::ClusterBase *)getCluster;
330 @end
331
332 @implementation CHIPCluster
333 - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoint queue:(dispatch_queue_t)queue
334 {
335     if (self = [super init]) {
336         Controller::ClusterBase * cppCluster = [self getCluster];
337         if (cppCluster == nullptr) {
338             return nil;
339         }
340
341         CHIP_ERROR err = cppCluster->Associate([device internalDevice], endpoint);
342         if (err != CHIP_NO_ERROR) {
343             return nil;
344         }
345
346         _callbackQueue = queue;
347     }
348     return self;
349 }
350
351 - (Controller::ClusterBase *)getCluster
352 {
353     return nullptr;
354 }
355 @end
356
357 @interface CHIPApplicationBasic ()
358 @property (readonly) Controller::ApplicationBasicCluster cppCluster;
359 @end
360
361 @implementation CHIPApplicationBasic
362
363 - (Controller::ClusterBase *)getCluster
364 {
365     return &_cppCluster;
366 }
367
368 - (void)readAttributeVendorName:(ResponseHandler)completionHandler
369 {
370     CHIPStringAttributeCallbackBridge * onSuccess
371         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true);
372     if (!onSuccess) {
373         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
374         return;
375     }
376
377     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
378     if (!onFailure) {
379         delete onSuccess;
380         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
381         return;
382     }
383
384     CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel());
385     if (err != CHIP_NO_ERROR) {
386         delete onSuccess;
387         delete onFailure;
388         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
389     }
390 }
391
392 - (void)readAttributeVendorId:(ResponseHandler)completionHandler
393 {
394     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
395     if (!onSuccess) {
396         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
397         return;
398     }
399
400     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
401     if (!onFailure) {
402         delete onSuccess;
403         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
404         return;
405     }
406
407     CHIP_ERROR err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel());
408     if (err != CHIP_NO_ERROR) {
409         delete onSuccess;
410         delete onFailure;
411         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
412     }
413 }
414
415 - (void)readAttributeApplicationName:(ResponseHandler)completionHandler
416 {
417     CHIPStringAttributeCallbackBridge * onSuccess
418         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true);
419     if (!onSuccess) {
420         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
421         return;
422     }
423
424     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
425     if (!onFailure) {
426         delete onSuccess;
427         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
428         return;
429     }
430
431     CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel());
432     if (err != CHIP_NO_ERROR) {
433         delete onSuccess;
434         delete onFailure;
435         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
436     }
437 }
438
439 - (void)readAttributeProductId:(ResponseHandler)completionHandler
440 {
441     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
442     if (!onSuccess) {
443         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
444         return;
445     }
446
447     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
448     if (!onFailure) {
449         delete onSuccess;
450         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
451         return;
452     }
453
454     CHIP_ERROR err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel());
455     if (err != CHIP_NO_ERROR) {
456         delete onSuccess;
457         delete onFailure;
458         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
459     }
460 }
461
462 - (void)readAttributeApplicationId:(ResponseHandler)completionHandler
463 {
464     CHIPStringAttributeCallbackBridge * onSuccess
465         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true);
466     if (!onSuccess) {
467         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
468         return;
469     }
470
471     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
472     if (!onFailure) {
473         delete onSuccess;
474         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
475         return;
476     }
477
478     CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel());
479     if (err != CHIP_NO_ERROR) {
480         delete onSuccess;
481         delete onFailure;
482         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
483     }
484 }
485
486 - (void)readAttributeCatalogVendorId:(ResponseHandler)completionHandler
487 {
488     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
489     if (!onSuccess) {
490         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
491         return;
492     }
493
494     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
495     if (!onFailure) {
496         delete onSuccess;
497         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
498         return;
499     }
500
501     CHIP_ERROR err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel());
502     if (err != CHIP_NO_ERROR) {
503         delete onSuccess;
504         delete onFailure;
505         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
506     }
507 }
508
509 - (void)readAttributeApplicationSatus:(ResponseHandler)completionHandler
510 {
511     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
512     if (!onSuccess) {
513         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
514         return;
515     }
516
517     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
518     if (!onFailure) {
519         delete onSuccess;
520         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
521         return;
522     }
523
524     CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel());
525     if (err != CHIP_NO_ERROR) {
526         delete onSuccess;
527         delete onFailure;
528         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
529     }
530 }
531
532 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
533 {
534     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
535     if (!onSuccess) {
536         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
537         return;
538     }
539
540     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
541     if (!onFailure) {
542         delete onSuccess;
543         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
544         return;
545     }
546
547     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
548     if (err != CHIP_NO_ERROR) {
549         delete onSuccess;
550         delete onFailure;
551         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
552     }
553 }
554
555 @end
556
557 @interface CHIPBarrierControl ()
558 @property (readonly) Controller::BarrierControlCluster cppCluster;
559 @end
560
561 @implementation CHIPBarrierControl
562
563 - (Controller::ClusterBase *)getCluster
564 {
565     return &_cppCluster;
566 }
567
568 - (void)barrierControlGoToPercent:(uint8_t)percentOpen completionHandler:(ResponseHandler)completionHandler
569 {
570     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
571     if (!onSuccess) {
572         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
573         return;
574     }
575
576     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
577     if (!onFailure) {
578         delete onSuccess;
579         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
580         return;
581     }
582
583     CHIP_ERROR err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen);
584     if (err != CHIP_NO_ERROR) {
585         delete onSuccess;
586         delete onFailure;
587         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
588     }
589 }
590 - (void)barrierControlStop:(ResponseHandler)completionHandler
591 {
592     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
593     if (!onSuccess) {
594         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
595         return;
596     }
597
598     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
599     if (!onFailure) {
600         delete onSuccess;
601         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
602         return;
603     }
604
605     CHIP_ERROR err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel());
606     if (err != CHIP_NO_ERROR) {
607         delete onSuccess;
608         delete onFailure;
609         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
610     }
611 }
612
613 - (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler
614 {
615     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
616     if (!onSuccess) {
617         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
618         return;
619     }
620
621     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
622     if (!onFailure) {
623         delete onSuccess;
624         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
625         return;
626     }
627
628     CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel());
629     if (err != CHIP_NO_ERROR) {
630         delete onSuccess;
631         delete onFailure;
632         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
633     }
634 }
635
636 - (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler
637 {
638     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
639     if (!onSuccess) {
640         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
641         return;
642     }
643
644     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
645     if (!onFailure) {
646         delete onSuccess;
647         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
648         return;
649     }
650
651     CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel());
652     if (err != CHIP_NO_ERROR) {
653         delete onSuccess;
654         delete onFailure;
655         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
656     }
657 }
658
659 - (void)readAttributeBarrierCapabilities:(ResponseHandler)completionHandler
660 {
661     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
662     if (!onSuccess) {
663         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
664         return;
665     }
666
667     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
668     if (!onFailure) {
669         delete onSuccess;
670         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
671         return;
672     }
673
674     CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel());
675     if (err != CHIP_NO_ERROR) {
676         delete onSuccess;
677         delete onFailure;
678         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
679     }
680 }
681
682 - (void)readAttributeBarrierPosition:(ResponseHandler)completionHandler
683 {
684     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
685     if (!onSuccess) {
686         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
687         return;
688     }
689
690     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
691     if (!onFailure) {
692         delete onSuccess;
693         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
694         return;
695     }
696
697     CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel());
698     if (err != CHIP_NO_ERROR) {
699         delete onSuccess;
700         delete onFailure;
701         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
702     }
703 }
704
705 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
706 {
707     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
708     if (!onSuccess) {
709         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
710         return;
711     }
712
713     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
714     if (!onFailure) {
715         delete onSuccess;
716         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
717         return;
718     }
719
720     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
721     if (err != CHIP_NO_ERROR) {
722         delete onSuccess;
723         delete onFailure;
724         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
725     }
726 }
727
728 @end
729
730 @interface CHIPBasic ()
731 @property (readonly) Controller::BasicCluster cppCluster;
732 @end
733
734 @implementation CHIPBasic
735
736 - (Controller::ClusterBase *)getCluster
737 {
738     return &_cppCluster;
739 }
740
741 - (void)mfgSpecificPing:(ResponseHandler)completionHandler
742 {
743     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
744     if (!onSuccess) {
745         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
746         return;
747     }
748
749     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
750     if (!onFailure) {
751         delete onSuccess;
752         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
753         return;
754     }
755
756     CHIP_ERROR err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel());
757     if (err != CHIP_NO_ERROR) {
758         delete onSuccess;
759         delete onFailure;
760         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
761     }
762 }
763
764 - (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler
765 {
766     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
767     if (!onSuccess) {
768         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
769         return;
770     }
771
772     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
773     if (!onFailure) {
774         delete onSuccess;
775         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
776         return;
777     }
778
779     CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel());
780     if (err != CHIP_NO_ERROR) {
781         delete onSuccess;
782         delete onFailure;
783         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
784     }
785 }
786
787 - (void)readAttributeVendorName:(ResponseHandler)completionHandler
788 {
789     CHIPStringAttributeCallbackBridge * onSuccess
790         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false);
791     if (!onSuccess) {
792         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
793         return;
794     }
795
796     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
797     if (!onFailure) {
798         delete onSuccess;
799         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
800         return;
801     }
802
803     CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel());
804     if (err != CHIP_NO_ERROR) {
805         delete onSuccess;
806         delete onFailure;
807         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
808     }
809 }
810
811 - (void)readAttributeVendorID:(ResponseHandler)completionHandler
812 {
813     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
814     if (!onSuccess) {
815         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
816         return;
817     }
818
819     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
820     if (!onFailure) {
821         delete onSuccess;
822         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
823         return;
824     }
825
826     CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel());
827     if (err != CHIP_NO_ERROR) {
828         delete onSuccess;
829         delete onFailure;
830         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
831     }
832 }
833
834 - (void)readAttributeProductName:(ResponseHandler)completionHandler
835 {
836     CHIPStringAttributeCallbackBridge * onSuccess
837         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false);
838     if (!onSuccess) {
839         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
840         return;
841     }
842
843     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
844     if (!onFailure) {
845         delete onSuccess;
846         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
847         return;
848     }
849
850     CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel());
851     if (err != CHIP_NO_ERROR) {
852         delete onSuccess;
853         delete onFailure;
854         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
855     }
856 }
857
858 - (void)readAttributeProductID:(ResponseHandler)completionHandler
859 {
860     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
861     if (!onSuccess) {
862         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
863         return;
864     }
865
866     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
867     if (!onFailure) {
868         delete onSuccess;
869         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
870         return;
871     }
872
873     CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel());
874     if (err != CHIP_NO_ERROR) {
875         delete onSuccess;
876         delete onFailure;
877         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
878     }
879 }
880
881 - (void)readAttributeUserLabel:(ResponseHandler)completionHandler
882 {
883     CHIPStringAttributeCallbackBridge * onSuccess
884         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false);
885     if (!onSuccess) {
886         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
887         return;
888     }
889
890     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
891     if (!onFailure) {
892         delete onSuccess;
893         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
894         return;
895     }
896
897     CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel());
898     if (err != CHIP_NO_ERROR) {
899         delete onSuccess;
900         delete onFailure;
901         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
902     }
903 }
904
905 - (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler
906 {
907     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
908     if (!onSuccess) {
909         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
910         return;
911     }
912
913     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
914     if (!onFailure) {
915         delete onSuccess;
916         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
917         return;
918     }
919
920     NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding];
921     CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel(
922         onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length));
923     if (err != CHIP_NO_ERROR) {
924         delete onSuccess;
925         delete onFailure;
926         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
927     }
928 }
929
930 - (void)readAttributeLocation:(ResponseHandler)completionHandler
931 {
932     CHIPStringAttributeCallbackBridge * onSuccess
933         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false);
934     if (!onSuccess) {
935         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
936         return;
937     }
938
939     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
940     if (!onFailure) {
941         delete onSuccess;
942         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
943         return;
944     }
945
946     CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel());
947     if (err != CHIP_NO_ERROR) {
948         delete onSuccess;
949         delete onFailure;
950         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
951     }
952 }
953
954 - (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler
955 {
956     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
957     if (!onSuccess) {
958         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
959         return;
960     }
961
962     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
963     if (!onFailure) {
964         delete onSuccess;
965         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
966         return;
967     }
968
969     NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding];
970     CHIP_ERROR err = self.cppCluster.WriteAttributeLocation(
971         onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length));
972     if (err != CHIP_NO_ERROR) {
973         delete onSuccess;
974         delete onFailure;
975         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
976     }
977 }
978
979 - (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler
980 {
981     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
982     if (!onSuccess) {
983         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
984         return;
985     }
986
987     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
988     if (!onFailure) {
989         delete onSuccess;
990         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
991         return;
992     }
993
994     CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel());
995     if (err != CHIP_NO_ERROR) {
996         delete onSuccess;
997         delete onFailure;
998         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
999     }
1000 }
1001
1002 - (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler
1003 {
1004     CHIPStringAttributeCallbackBridge * onSuccess
1005         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false);
1006     if (!onSuccess) {
1007         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1008         return;
1009     }
1010
1011     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1012     if (!onFailure) {
1013         delete onSuccess;
1014         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1015         return;
1016     }
1017
1018     CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel());
1019     if (err != CHIP_NO_ERROR) {
1020         delete onSuccess;
1021         delete onFailure;
1022         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1023     }
1024 }
1025
1026 - (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler
1027 {
1028     CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1029     if (!onSuccess) {
1030         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1031         return;
1032     }
1033
1034     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1035     if (!onFailure) {
1036         delete onSuccess;
1037         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1038         return;
1039     }
1040
1041     CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel());
1042     if (err != CHIP_NO_ERROR) {
1043         delete onSuccess;
1044         delete onFailure;
1045         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1046     }
1047 }
1048
1049 - (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler
1050 {
1051     CHIPStringAttributeCallbackBridge * onSuccess
1052         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false);
1053     if (!onSuccess) {
1054         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1055         return;
1056     }
1057
1058     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1059     if (!onFailure) {
1060         delete onSuccess;
1061         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1062         return;
1063     }
1064
1065     CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel());
1066     if (err != CHIP_NO_ERROR) {
1067         delete onSuccess;
1068         delete onFailure;
1069         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1070     }
1071 }
1072
1073 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
1074 {
1075     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1076     if (!onSuccess) {
1077         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1078         return;
1079     }
1080
1081     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1082     if (!onFailure) {
1083         delete onSuccess;
1084         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1085         return;
1086     }
1087
1088     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
1089     if (err != CHIP_NO_ERROR) {
1090         delete onSuccess;
1091         delete onFailure;
1092         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1093     }
1094 }
1095
1096 @end
1097
1098 @interface CHIPBinding ()
1099 @property (readonly) Controller::BindingCluster cppCluster;
1100 @end
1101
1102 @implementation CHIPBinding
1103
1104 - (Controller::ClusterBase *)getCluster
1105 {
1106     return &_cppCluster;
1107 }
1108
1109 - (void)bind:(uint64_t)nodeId
1110               groupId:(uint16_t)groupId
1111            endpointId:(uint8_t)endpointId
1112             clusterId:(uint16_t)clusterId
1113     completionHandler:(ResponseHandler)completionHandler
1114 {
1115     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1116     if (!onSuccess) {
1117         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1118         return;
1119     }
1120
1121     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1122     if (!onFailure) {
1123         delete onSuccess;
1124         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1125         return;
1126     }
1127
1128     CHIP_ERROR err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId);
1129     if (err != CHIP_NO_ERROR) {
1130         delete onSuccess;
1131         delete onFailure;
1132         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1133     }
1134 }
1135 - (void)unbind:(uint64_t)nodeId
1136               groupId:(uint16_t)groupId
1137            endpointId:(uint8_t)endpointId
1138             clusterId:(uint16_t)clusterId
1139     completionHandler:(ResponseHandler)completionHandler
1140 {
1141     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1142     if (!onSuccess) {
1143         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1144         return;
1145     }
1146
1147     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1148     if (!onFailure) {
1149         delete onSuccess;
1150         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1151         return;
1152     }
1153
1154     CHIP_ERROR err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId);
1155     if (err != CHIP_NO_ERROR) {
1156         delete onSuccess;
1157         delete onFailure;
1158         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1159     }
1160 }
1161
1162 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
1163 {
1164     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1165     if (!onSuccess) {
1166         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1167         return;
1168     }
1169
1170     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1171     if (!onFailure) {
1172         delete onSuccess;
1173         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1174         return;
1175     }
1176
1177     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
1178     if (err != CHIP_NO_ERROR) {
1179         delete onSuccess;
1180         delete onFailure;
1181         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1182     }
1183 }
1184
1185 @end
1186
1187 @interface CHIPColorControl ()
1188 @property (readonly) Controller::ColorControlCluster cppCluster;
1189 @end
1190
1191 @implementation CHIPColorControl
1192
1193 - (Controller::ClusterBase *)getCluster
1194 {
1195     return &_cppCluster;
1196 }
1197
1198 - (void)moveColor:(int16_t)rateX
1199                 rateY:(int16_t)rateY
1200           optionsMask:(uint8_t)optionsMask
1201       optionsOverride:(uint8_t)optionsOverride
1202     completionHandler:(ResponseHandler)completionHandler
1203 {
1204     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1205     if (!onSuccess) {
1206         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1207         return;
1208     }
1209
1210     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1211     if (!onFailure) {
1212         delete onSuccess;
1213         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1214         return;
1215     }
1216
1217     CHIP_ERROR err
1218         = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride);
1219     if (err != CHIP_NO_ERROR) {
1220         delete onSuccess;
1221         delete onFailure;
1222         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1223     }
1224 }
1225 - (void)moveColorTemperature:(uint8_t)moveMode
1226                         rate:(uint16_t)rate
1227      colorTemperatureMinimum:(uint16_t)colorTemperatureMinimum
1228      colorTemperatureMaximum:(uint16_t)colorTemperatureMaximum
1229                  optionsMask:(uint8_t)optionsMask
1230              optionsOverride:(uint8_t)optionsOverride
1231            completionHandler:(ResponseHandler)completionHandler
1232 {
1233     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1234     if (!onSuccess) {
1235         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1236         return;
1237     }
1238
1239     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1240     if (!onFailure) {
1241         delete onSuccess;
1242         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1243         return;
1244     }
1245
1246     CHIP_ERROR err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate,
1247         colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride);
1248     if (err != CHIP_NO_ERROR) {
1249         delete onSuccess;
1250         delete onFailure;
1251         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1252     }
1253 }
1254 - (void)moveHue:(uint8_t)moveMode
1255                  rate:(uint8_t)rate
1256           optionsMask:(uint8_t)optionsMask
1257       optionsOverride:(uint8_t)optionsOverride
1258     completionHandler:(ResponseHandler)completionHandler
1259 {
1260     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1261     if (!onSuccess) {
1262         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1263         return;
1264     }
1265
1266     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1267     if (!onFailure) {
1268         delete onSuccess;
1269         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1270         return;
1271     }
1272
1273     CHIP_ERROR err
1274         = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride);
1275     if (err != CHIP_NO_ERROR) {
1276         delete onSuccess;
1277         delete onFailure;
1278         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1279     }
1280 }
1281 - (void)moveSaturation:(uint8_t)moveMode
1282                   rate:(uint8_t)rate
1283            optionsMask:(uint8_t)optionsMask
1284        optionsOverride:(uint8_t)optionsOverride
1285      completionHandler:(ResponseHandler)completionHandler
1286 {
1287     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1288     if (!onSuccess) {
1289         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1290         return;
1291     }
1292
1293     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1294     if (!onFailure) {
1295         delete onSuccess;
1296         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1297         return;
1298     }
1299
1300     CHIP_ERROR err
1301         = self.cppCluster.MoveSaturation(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride);
1302     if (err != CHIP_NO_ERROR) {
1303         delete onSuccess;
1304         delete onFailure;
1305         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1306     }
1307 }
1308 - (void)moveToColor:(uint16_t)colorX
1309                colorY:(uint16_t)colorY
1310        transitionTime:(uint16_t)transitionTime
1311           optionsMask:(uint8_t)optionsMask
1312       optionsOverride:(uint8_t)optionsOverride
1313     completionHandler:(ResponseHandler)completionHandler
1314 {
1315     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1316     if (!onSuccess) {
1317         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1318         return;
1319     }
1320
1321     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1322     if (!onFailure) {
1323         delete onSuccess;
1324         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1325         return;
1326     }
1327
1328     CHIP_ERROR err = self.cppCluster.MoveToColor(
1329         onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride);
1330     if (err != CHIP_NO_ERROR) {
1331         delete onSuccess;
1332         delete onFailure;
1333         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1334     }
1335 }
1336 - (void)moveToColorTemperature:(uint16_t)colorTemperature
1337                 transitionTime:(uint16_t)transitionTime
1338                    optionsMask:(uint8_t)optionsMask
1339                optionsOverride:(uint8_t)optionsOverride
1340              completionHandler:(ResponseHandler)completionHandler
1341 {
1342     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1343     if (!onSuccess) {
1344         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1345         return;
1346     }
1347
1348     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1349     if (!onFailure) {
1350         delete onSuccess;
1351         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1352         return;
1353     }
1354
1355     CHIP_ERROR err = self.cppCluster.MoveToColorTemperature(
1356         onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride);
1357     if (err != CHIP_NO_ERROR) {
1358         delete onSuccess;
1359         delete onFailure;
1360         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1361     }
1362 }
1363 - (void)moveToHue:(uint8_t)hue
1364             direction:(uint8_t)direction
1365        transitionTime:(uint16_t)transitionTime
1366           optionsMask:(uint8_t)optionsMask
1367       optionsOverride:(uint8_t)optionsOverride
1368     completionHandler:(ResponseHandler)completionHandler
1369 {
1370     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1371     if (!onSuccess) {
1372         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1373         return;
1374     }
1375
1376     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1377     if (!onFailure) {
1378         delete onSuccess;
1379         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1380         return;
1381     }
1382
1383     CHIP_ERROR err = self.cppCluster.MoveToHue(
1384         onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride);
1385     if (err != CHIP_NO_ERROR) {
1386         delete onSuccess;
1387         delete onFailure;
1388         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1389     }
1390 }
1391 - (void)moveToHueAndSaturation:(uint8_t)hue
1392                     saturation:(uint8_t)saturation
1393                 transitionTime:(uint16_t)transitionTime
1394                    optionsMask:(uint8_t)optionsMask
1395                optionsOverride:(uint8_t)optionsOverride
1396              completionHandler:(ResponseHandler)completionHandler
1397 {
1398     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1399     if (!onSuccess) {
1400         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1401         return;
1402     }
1403
1404     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1405     if (!onFailure) {
1406         delete onSuccess;
1407         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1408         return;
1409     }
1410
1411     CHIP_ERROR err = self.cppCluster.MoveToHueAndSaturation(
1412         onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride);
1413     if (err != CHIP_NO_ERROR) {
1414         delete onSuccess;
1415         delete onFailure;
1416         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1417     }
1418 }
1419 - (void)moveToSaturation:(uint8_t)saturation
1420           transitionTime:(uint16_t)transitionTime
1421              optionsMask:(uint8_t)optionsMask
1422          optionsOverride:(uint8_t)optionsOverride
1423        completionHandler:(ResponseHandler)completionHandler
1424 {
1425     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1426     if (!onSuccess) {
1427         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1428         return;
1429     }
1430
1431     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1432     if (!onFailure) {
1433         delete onSuccess;
1434         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1435         return;
1436     }
1437
1438     CHIP_ERROR err = self.cppCluster.MoveToSaturation(
1439         onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride);
1440     if (err != CHIP_NO_ERROR) {
1441         delete onSuccess;
1442         delete onFailure;
1443         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1444     }
1445 }
1446 - (void)stepColor:(int16_t)stepX
1447                 stepY:(int16_t)stepY
1448        transitionTime:(uint16_t)transitionTime
1449           optionsMask:(uint8_t)optionsMask
1450       optionsOverride:(uint8_t)optionsOverride
1451     completionHandler:(ResponseHandler)completionHandler
1452 {
1453     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1454     if (!onSuccess) {
1455         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1456         return;
1457     }
1458
1459     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1460     if (!onFailure) {
1461         delete onSuccess;
1462         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1463         return;
1464     }
1465
1466     CHIP_ERROR err = self.cppCluster.StepColor(
1467         onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride);
1468     if (err != CHIP_NO_ERROR) {
1469         delete onSuccess;
1470         delete onFailure;
1471         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1472     }
1473 }
1474 - (void)stepColorTemperature:(uint8_t)stepMode
1475                     stepSize:(uint16_t)stepSize
1476               transitionTime:(uint16_t)transitionTime
1477      colorTemperatureMinimum:(uint16_t)colorTemperatureMinimum
1478      colorTemperatureMaximum:(uint16_t)colorTemperatureMaximum
1479                  optionsMask:(uint8_t)optionsMask
1480              optionsOverride:(uint8_t)optionsOverride
1481            completionHandler:(ResponseHandler)completionHandler
1482 {
1483     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1484     if (!onSuccess) {
1485         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1486         return;
1487     }
1488
1489     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1490     if (!onFailure) {
1491         delete onSuccess;
1492         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1493         return;
1494     }
1495
1496     CHIP_ERROR err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize,
1497         transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride);
1498     if (err != CHIP_NO_ERROR) {
1499         delete onSuccess;
1500         delete onFailure;
1501         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1502     }
1503 }
1504 - (void)stepHue:(uint8_t)stepMode
1505              stepSize:(uint8_t)stepSize
1506        transitionTime:(uint8_t)transitionTime
1507           optionsMask:(uint8_t)optionsMask
1508       optionsOverride:(uint8_t)optionsOverride
1509     completionHandler:(ResponseHandler)completionHandler
1510 {
1511     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1512     if (!onSuccess) {
1513         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1514         return;
1515     }
1516
1517     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1518     if (!onFailure) {
1519         delete onSuccess;
1520         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1521         return;
1522     }
1523
1524     CHIP_ERROR err = self.cppCluster.StepHue(
1525         onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
1526     if (err != CHIP_NO_ERROR) {
1527         delete onSuccess;
1528         delete onFailure;
1529         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1530     }
1531 }
1532 - (void)stepSaturation:(uint8_t)stepMode
1533               stepSize:(uint8_t)stepSize
1534         transitionTime:(uint8_t)transitionTime
1535            optionsMask:(uint8_t)optionsMask
1536        optionsOverride:(uint8_t)optionsOverride
1537      completionHandler:(ResponseHandler)completionHandler
1538 {
1539     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1540     if (!onSuccess) {
1541         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1542         return;
1543     }
1544
1545     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1546     if (!onFailure) {
1547         delete onSuccess;
1548         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1549         return;
1550     }
1551
1552     CHIP_ERROR err = self.cppCluster.StepSaturation(
1553         onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
1554     if (err != CHIP_NO_ERROR) {
1555         delete onSuccess;
1556         delete onFailure;
1557         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1558     }
1559 }
1560 - (void)stopMoveStep:(uint8_t)optionsMask
1561       optionsOverride:(uint8_t)optionsOverride
1562     completionHandler:(ResponseHandler)completionHandler
1563 {
1564     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1565     if (!onSuccess) {
1566         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1567         return;
1568     }
1569
1570     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1571     if (!onFailure) {
1572         delete onSuccess;
1573         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1574         return;
1575     }
1576
1577     CHIP_ERROR err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride);
1578     if (err != CHIP_NO_ERROR) {
1579         delete onSuccess;
1580         delete onFailure;
1581         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1582     }
1583 }
1584
1585 - (void)readAttributeCurrentHue:(ResponseHandler)completionHandler
1586 {
1587     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1588     if (!onSuccess) {
1589         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1590         return;
1591     }
1592
1593     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1594     if (!onFailure) {
1595         delete onSuccess;
1596         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1597         return;
1598     }
1599
1600     CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel());
1601     if (err != CHIP_NO_ERROR) {
1602         delete onSuccess;
1603         delete onFailure;
1604         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1605     }
1606 }
1607
1608 - (void)configureAttributeCurrentHue:(uint16_t)minInterval
1609                          maxInterval:(uint16_t)maxInterval
1610                               change:(uint8_t)change
1611                    completionHandler:(ResponseHandler)completionHandler
1612 {
1613     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1614     if (!onSuccess) {
1615         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1616         return;
1617     }
1618
1619     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1620     if (!onFailure) {
1621         delete onSuccess;
1622         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1623         return;
1624     }
1625
1626     CHIP_ERROR err
1627         = self.cppCluster.ConfigureAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
1628     if (err != CHIP_NO_ERROR) {
1629         delete onSuccess;
1630         delete onFailure;
1631         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1632     }
1633 }
1634
1635 - (void)reportAttributeCurrentHue:(ResponseHandler)reportHandler
1636 {
1637     CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
1638     if (!onReport) {
1639         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1640         return;
1641     }
1642
1643     CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel());
1644     if (err != CHIP_NO_ERROR) {
1645         delete onReport;
1646         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
1647     }
1648 }
1649
1650 - (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler
1651 {
1652     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1653     if (!onSuccess) {
1654         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1655         return;
1656     }
1657
1658     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1659     if (!onFailure) {
1660         delete onSuccess;
1661         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1662         return;
1663     }
1664
1665     CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel());
1666     if (err != CHIP_NO_ERROR) {
1667         delete onSuccess;
1668         delete onFailure;
1669         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1670     }
1671 }
1672
1673 - (void)configureAttributeCurrentSaturation:(uint16_t)minInterval
1674                                 maxInterval:(uint16_t)maxInterval
1675                                      change:(uint8_t)change
1676                           completionHandler:(ResponseHandler)completionHandler
1677 {
1678     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1679     if (!onSuccess) {
1680         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1681         return;
1682     }
1683
1684     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1685     if (!onFailure) {
1686         delete onSuccess;
1687         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1688         return;
1689     }
1690
1691     CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentSaturation(
1692         onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
1693     if (err != CHIP_NO_ERROR) {
1694         delete onSuccess;
1695         delete onFailure;
1696         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1697     }
1698 }
1699
1700 - (void)reportAttributeCurrentSaturation:(ResponseHandler)reportHandler
1701 {
1702     CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
1703     if (!onReport) {
1704         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1705         return;
1706     }
1707
1708     CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel());
1709     if (err != CHIP_NO_ERROR) {
1710         delete onReport;
1711         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
1712     }
1713 }
1714
1715 - (void)readAttributeRemainingTime:(ResponseHandler)completionHandler
1716 {
1717     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1718     if (!onSuccess) {
1719         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1720         return;
1721     }
1722
1723     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1724     if (!onFailure) {
1725         delete onSuccess;
1726         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1727         return;
1728     }
1729
1730     CHIP_ERROR err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel());
1731     if (err != CHIP_NO_ERROR) {
1732         delete onSuccess;
1733         delete onFailure;
1734         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1735     }
1736 }
1737
1738 - (void)readAttributeCurrentX:(ResponseHandler)completionHandler
1739 {
1740     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1741     if (!onSuccess) {
1742         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1743         return;
1744     }
1745
1746     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1747     if (!onFailure) {
1748         delete onSuccess;
1749         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1750         return;
1751     }
1752
1753     CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel());
1754     if (err != CHIP_NO_ERROR) {
1755         delete onSuccess;
1756         delete onFailure;
1757         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1758     }
1759 }
1760
1761 - (void)configureAttributeCurrentX:(uint16_t)minInterval
1762                        maxInterval:(uint16_t)maxInterval
1763                             change:(uint16_t)change
1764                  completionHandler:(ResponseHandler)completionHandler
1765 {
1766     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1767     if (!onSuccess) {
1768         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1769         return;
1770     }
1771
1772     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1773     if (!onFailure) {
1774         delete onSuccess;
1775         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1776         return;
1777     }
1778
1779     CHIP_ERROR err
1780         = self.cppCluster.ConfigureAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
1781     if (err != CHIP_NO_ERROR) {
1782         delete onSuccess;
1783         delete onFailure;
1784         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1785     }
1786 }
1787
1788 - (void)reportAttributeCurrentX:(ResponseHandler)reportHandler
1789 {
1790     CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
1791     if (!onReport) {
1792         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1793         return;
1794     }
1795
1796     CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel());
1797     if (err != CHIP_NO_ERROR) {
1798         delete onReport;
1799         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
1800     }
1801 }
1802
1803 - (void)readAttributeCurrentY:(ResponseHandler)completionHandler
1804 {
1805     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1806     if (!onSuccess) {
1807         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1808         return;
1809     }
1810
1811     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1812     if (!onFailure) {
1813         delete onSuccess;
1814         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1815         return;
1816     }
1817
1818     CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel());
1819     if (err != CHIP_NO_ERROR) {
1820         delete onSuccess;
1821         delete onFailure;
1822         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1823     }
1824 }
1825
1826 - (void)configureAttributeCurrentY:(uint16_t)minInterval
1827                        maxInterval:(uint16_t)maxInterval
1828                             change:(uint16_t)change
1829                  completionHandler:(ResponseHandler)completionHandler
1830 {
1831     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1832     if (!onSuccess) {
1833         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1834         return;
1835     }
1836
1837     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1838     if (!onFailure) {
1839         delete onSuccess;
1840         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1841         return;
1842     }
1843
1844     CHIP_ERROR err
1845         = self.cppCluster.ConfigureAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
1846     if (err != CHIP_NO_ERROR) {
1847         delete onSuccess;
1848         delete onFailure;
1849         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1850     }
1851 }
1852
1853 - (void)reportAttributeCurrentY:(ResponseHandler)reportHandler
1854 {
1855     CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
1856     if (!onReport) {
1857         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1858         return;
1859     }
1860
1861     CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel());
1862     if (err != CHIP_NO_ERROR) {
1863         delete onReport;
1864         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
1865     }
1866 }
1867
1868 - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler
1869 {
1870     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1871     if (!onSuccess) {
1872         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1873         return;
1874     }
1875
1876     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1877     if (!onFailure) {
1878         delete onSuccess;
1879         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1880         return;
1881     }
1882
1883     CHIP_ERROR err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel());
1884     if (err != CHIP_NO_ERROR) {
1885         delete onSuccess;
1886         delete onFailure;
1887         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1888     }
1889 }
1890
1891 - (void)readAttributeCompensationText:(ResponseHandler)completionHandler
1892 {
1893     CHIPStringAttributeCallbackBridge * onSuccess
1894         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false);
1895     if (!onSuccess) {
1896         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1897         return;
1898     }
1899
1900     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1901     if (!onFailure) {
1902         delete onSuccess;
1903         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1904         return;
1905     }
1906
1907     CHIP_ERROR err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel());
1908     if (err != CHIP_NO_ERROR) {
1909         delete onSuccess;
1910         delete onFailure;
1911         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1912     }
1913 }
1914
1915 - (void)readAttributeColorTemperature:(ResponseHandler)completionHandler
1916 {
1917     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1918     if (!onSuccess) {
1919         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1920         return;
1921     }
1922
1923     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1924     if (!onFailure) {
1925         delete onSuccess;
1926         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1927         return;
1928     }
1929
1930     CHIP_ERROR err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel());
1931     if (err != CHIP_NO_ERROR) {
1932         delete onSuccess;
1933         delete onFailure;
1934         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1935     }
1936 }
1937
1938 - (void)configureAttributeColorTemperature:(uint16_t)minInterval
1939                                maxInterval:(uint16_t)maxInterval
1940                                     change:(uint16_t)change
1941                          completionHandler:(ResponseHandler)completionHandler
1942 {
1943     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
1944     if (!onSuccess) {
1945         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1946         return;
1947     }
1948
1949     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1950     if (!onFailure) {
1951         delete onSuccess;
1952         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1953         return;
1954     }
1955
1956     CHIP_ERROR err = self.cppCluster.ConfigureAttributeColorTemperature(
1957         onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
1958     if (err != CHIP_NO_ERROR) {
1959         delete onSuccess;
1960         delete onFailure;
1961         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
1962     }
1963 }
1964
1965 - (void)reportAttributeColorTemperature:(ResponseHandler)reportHandler
1966 {
1967     CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
1968     if (!onReport) {
1969         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1970         return;
1971     }
1972
1973     CHIP_ERROR err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel());
1974     if (err != CHIP_NO_ERROR) {
1975         delete onReport;
1976         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
1977     }
1978 }
1979
1980 - (void)readAttributeColorMode:(ResponseHandler)completionHandler
1981 {
1982     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
1983     if (!onSuccess) {
1984         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1985         return;
1986     }
1987
1988     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
1989     if (!onFailure) {
1990         delete onSuccess;
1991         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
1992         return;
1993     }
1994
1995     CHIP_ERROR err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel());
1996     if (err != CHIP_NO_ERROR) {
1997         delete onSuccess;
1998         delete onFailure;
1999         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2000     }
2001 }
2002
2003 - (void)readAttributeColorControlOptions:(ResponseHandler)completionHandler
2004 {
2005     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2006     if (!onSuccess) {
2007         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2008         return;
2009     }
2010
2011     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2012     if (!onFailure) {
2013         delete onSuccess;
2014         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2015         return;
2016     }
2017
2018     CHIP_ERROR err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel());
2019     if (err != CHIP_NO_ERROR) {
2020         delete onSuccess;
2021         delete onFailure;
2022         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2023     }
2024 }
2025
2026 - (void)writeAttributeColorControlOptions:(uint8_t)value completionHandler:(ResponseHandler)completionHandler
2027 {
2028     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2029     if (!onSuccess) {
2030         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2031         return;
2032     }
2033
2034     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2035     if (!onFailure) {
2036         delete onSuccess;
2037         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2038         return;
2039     }
2040
2041     CHIP_ERROR err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value);
2042     if (err != CHIP_NO_ERROR) {
2043         delete onSuccess;
2044         delete onFailure;
2045         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2046     }
2047 }
2048
2049 - (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler
2050 {
2051     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2052     if (!onSuccess) {
2053         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2054         return;
2055     }
2056
2057     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2058     if (!onFailure) {
2059         delete onSuccess;
2060         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2061         return;
2062     }
2063
2064     CHIP_ERROR err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel());
2065     if (err != CHIP_NO_ERROR) {
2066         delete onSuccess;
2067         delete onFailure;
2068         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2069     }
2070 }
2071
2072 - (void)readAttributePrimary1X:(ResponseHandler)completionHandler
2073 {
2074     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2075     if (!onSuccess) {
2076         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2077         return;
2078     }
2079
2080     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2081     if (!onFailure) {
2082         delete onSuccess;
2083         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2084         return;
2085     }
2086
2087     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel());
2088     if (err != CHIP_NO_ERROR) {
2089         delete onSuccess;
2090         delete onFailure;
2091         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2092     }
2093 }
2094
2095 - (void)readAttributePrimary1Y:(ResponseHandler)completionHandler
2096 {
2097     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2098     if (!onSuccess) {
2099         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2100         return;
2101     }
2102
2103     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2104     if (!onFailure) {
2105         delete onSuccess;
2106         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2107         return;
2108     }
2109
2110     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel());
2111     if (err != CHIP_NO_ERROR) {
2112         delete onSuccess;
2113         delete onFailure;
2114         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2115     }
2116 }
2117
2118 - (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler
2119 {
2120     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2121     if (!onSuccess) {
2122         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2123         return;
2124     }
2125
2126     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2127     if (!onFailure) {
2128         delete onSuccess;
2129         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2130         return;
2131     }
2132
2133     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel());
2134     if (err != CHIP_NO_ERROR) {
2135         delete onSuccess;
2136         delete onFailure;
2137         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2138     }
2139 }
2140
2141 - (void)readAttributePrimary2X:(ResponseHandler)completionHandler
2142 {
2143     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2144     if (!onSuccess) {
2145         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2146         return;
2147     }
2148
2149     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2150     if (!onFailure) {
2151         delete onSuccess;
2152         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2153         return;
2154     }
2155
2156     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel());
2157     if (err != CHIP_NO_ERROR) {
2158         delete onSuccess;
2159         delete onFailure;
2160         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2161     }
2162 }
2163
2164 - (void)readAttributePrimary2Y:(ResponseHandler)completionHandler
2165 {
2166     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2167     if (!onSuccess) {
2168         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2169         return;
2170     }
2171
2172     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2173     if (!onFailure) {
2174         delete onSuccess;
2175         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2176         return;
2177     }
2178
2179     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel());
2180     if (err != CHIP_NO_ERROR) {
2181         delete onSuccess;
2182         delete onFailure;
2183         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2184     }
2185 }
2186
2187 - (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler
2188 {
2189     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2190     if (!onSuccess) {
2191         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2192         return;
2193     }
2194
2195     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2196     if (!onFailure) {
2197         delete onSuccess;
2198         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2199         return;
2200     }
2201
2202     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel());
2203     if (err != CHIP_NO_ERROR) {
2204         delete onSuccess;
2205         delete onFailure;
2206         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2207     }
2208 }
2209
2210 - (void)readAttributePrimary3X:(ResponseHandler)completionHandler
2211 {
2212     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2213     if (!onSuccess) {
2214         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2215         return;
2216     }
2217
2218     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2219     if (!onFailure) {
2220         delete onSuccess;
2221         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2222         return;
2223     }
2224
2225     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel());
2226     if (err != CHIP_NO_ERROR) {
2227         delete onSuccess;
2228         delete onFailure;
2229         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2230     }
2231 }
2232
2233 - (void)readAttributePrimary3Y:(ResponseHandler)completionHandler
2234 {
2235     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2236     if (!onSuccess) {
2237         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2238         return;
2239     }
2240
2241     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2242     if (!onFailure) {
2243         delete onSuccess;
2244         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2245         return;
2246     }
2247
2248     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel());
2249     if (err != CHIP_NO_ERROR) {
2250         delete onSuccess;
2251         delete onFailure;
2252         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2253     }
2254 }
2255
2256 - (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler
2257 {
2258     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2259     if (!onSuccess) {
2260         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2261         return;
2262     }
2263
2264     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2265     if (!onFailure) {
2266         delete onSuccess;
2267         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2268         return;
2269     }
2270
2271     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel());
2272     if (err != CHIP_NO_ERROR) {
2273         delete onSuccess;
2274         delete onFailure;
2275         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2276     }
2277 }
2278
2279 - (void)readAttributePrimary4X:(ResponseHandler)completionHandler
2280 {
2281     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2282     if (!onSuccess) {
2283         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2284         return;
2285     }
2286
2287     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2288     if (!onFailure) {
2289         delete onSuccess;
2290         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2291         return;
2292     }
2293
2294     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel());
2295     if (err != CHIP_NO_ERROR) {
2296         delete onSuccess;
2297         delete onFailure;
2298         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2299     }
2300 }
2301
2302 - (void)readAttributePrimary4Y:(ResponseHandler)completionHandler
2303 {
2304     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2305     if (!onSuccess) {
2306         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2307         return;
2308     }
2309
2310     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2311     if (!onFailure) {
2312         delete onSuccess;
2313         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2314         return;
2315     }
2316
2317     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel());
2318     if (err != CHIP_NO_ERROR) {
2319         delete onSuccess;
2320         delete onFailure;
2321         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2322     }
2323 }
2324
2325 - (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler
2326 {
2327     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2328     if (!onSuccess) {
2329         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2330         return;
2331     }
2332
2333     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2334     if (!onFailure) {
2335         delete onSuccess;
2336         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2337         return;
2338     }
2339
2340     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel());
2341     if (err != CHIP_NO_ERROR) {
2342         delete onSuccess;
2343         delete onFailure;
2344         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2345     }
2346 }
2347
2348 - (void)readAttributePrimary5X:(ResponseHandler)completionHandler
2349 {
2350     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2351     if (!onSuccess) {
2352         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2353         return;
2354     }
2355
2356     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2357     if (!onFailure) {
2358         delete onSuccess;
2359         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2360         return;
2361     }
2362
2363     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel());
2364     if (err != CHIP_NO_ERROR) {
2365         delete onSuccess;
2366         delete onFailure;
2367         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2368     }
2369 }
2370
2371 - (void)readAttributePrimary5Y:(ResponseHandler)completionHandler
2372 {
2373     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2374     if (!onSuccess) {
2375         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2376         return;
2377     }
2378
2379     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2380     if (!onFailure) {
2381         delete onSuccess;
2382         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2383         return;
2384     }
2385
2386     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel());
2387     if (err != CHIP_NO_ERROR) {
2388         delete onSuccess;
2389         delete onFailure;
2390         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2391     }
2392 }
2393
2394 - (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler
2395 {
2396     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2397     if (!onSuccess) {
2398         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2399         return;
2400     }
2401
2402     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2403     if (!onFailure) {
2404         delete onSuccess;
2405         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2406         return;
2407     }
2408
2409     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel());
2410     if (err != CHIP_NO_ERROR) {
2411         delete onSuccess;
2412         delete onFailure;
2413         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2414     }
2415 }
2416
2417 - (void)readAttributePrimary6X:(ResponseHandler)completionHandler
2418 {
2419     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2420     if (!onSuccess) {
2421         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2422         return;
2423     }
2424
2425     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2426     if (!onFailure) {
2427         delete onSuccess;
2428         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2429         return;
2430     }
2431
2432     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel());
2433     if (err != CHIP_NO_ERROR) {
2434         delete onSuccess;
2435         delete onFailure;
2436         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2437     }
2438 }
2439
2440 - (void)readAttributePrimary6Y:(ResponseHandler)completionHandler
2441 {
2442     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2443     if (!onSuccess) {
2444         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2445         return;
2446     }
2447
2448     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2449     if (!onFailure) {
2450         delete onSuccess;
2451         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2452         return;
2453     }
2454
2455     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel());
2456     if (err != CHIP_NO_ERROR) {
2457         delete onSuccess;
2458         delete onFailure;
2459         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2460     }
2461 }
2462
2463 - (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler
2464 {
2465     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2466     if (!onSuccess) {
2467         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2468         return;
2469     }
2470
2471     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2472     if (!onFailure) {
2473         delete onSuccess;
2474         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2475         return;
2476     }
2477
2478     CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel());
2479     if (err != CHIP_NO_ERROR) {
2480         delete onSuccess;
2481         delete onFailure;
2482         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2483     }
2484 }
2485
2486 - (void)readAttributeWhitePointX:(ResponseHandler)completionHandler
2487 {
2488     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2489     if (!onSuccess) {
2490         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2491         return;
2492     }
2493
2494     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2495     if (!onFailure) {
2496         delete onSuccess;
2497         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2498         return;
2499     }
2500
2501     CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel());
2502     if (err != CHIP_NO_ERROR) {
2503         delete onSuccess;
2504         delete onFailure;
2505         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2506     }
2507 }
2508
2509 - (void)writeAttributeWhitePointX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
2510 {
2511     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2512     if (!onSuccess) {
2513         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2514         return;
2515     }
2516
2517     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2518     if (!onFailure) {
2519         delete onSuccess;
2520         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2521         return;
2522     }
2523
2524     CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value);
2525     if (err != CHIP_NO_ERROR) {
2526         delete onSuccess;
2527         delete onFailure;
2528         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2529     }
2530 }
2531
2532 - (void)readAttributeWhitePointY:(ResponseHandler)completionHandler
2533 {
2534     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2535     if (!onSuccess) {
2536         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2537         return;
2538     }
2539
2540     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2541     if (!onFailure) {
2542         delete onSuccess;
2543         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2544         return;
2545     }
2546
2547     CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel());
2548     if (err != CHIP_NO_ERROR) {
2549         delete onSuccess;
2550         delete onFailure;
2551         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2552     }
2553 }
2554
2555 - (void)writeAttributeWhitePointY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
2556 {
2557     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2558     if (!onSuccess) {
2559         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2560         return;
2561     }
2562
2563     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2564     if (!onFailure) {
2565         delete onSuccess;
2566         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2567         return;
2568     }
2569
2570     CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value);
2571     if (err != CHIP_NO_ERROR) {
2572         delete onSuccess;
2573         delete onFailure;
2574         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2575     }
2576 }
2577
2578 - (void)readAttributeColorPointRX:(ResponseHandler)completionHandler
2579 {
2580     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2581     if (!onSuccess) {
2582         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2583         return;
2584     }
2585
2586     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2587     if (!onFailure) {
2588         delete onSuccess;
2589         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2590         return;
2591     }
2592
2593     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel());
2594     if (err != CHIP_NO_ERROR) {
2595         delete onSuccess;
2596         delete onFailure;
2597         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2598     }
2599 }
2600
2601 - (void)writeAttributeColorPointRX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
2602 {
2603     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2604     if (!onSuccess) {
2605         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2606         return;
2607     }
2608
2609     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2610     if (!onFailure) {
2611         delete onSuccess;
2612         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2613         return;
2614     }
2615
2616     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value);
2617     if (err != CHIP_NO_ERROR) {
2618         delete onSuccess;
2619         delete onFailure;
2620         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2621     }
2622 }
2623
2624 - (void)readAttributeColorPointRY:(ResponseHandler)completionHandler
2625 {
2626     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2627     if (!onSuccess) {
2628         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2629         return;
2630     }
2631
2632     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2633     if (!onFailure) {
2634         delete onSuccess;
2635         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2636         return;
2637     }
2638
2639     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel());
2640     if (err != CHIP_NO_ERROR) {
2641         delete onSuccess;
2642         delete onFailure;
2643         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2644     }
2645 }
2646
2647 - (void)writeAttributeColorPointRY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
2648 {
2649     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2650     if (!onSuccess) {
2651         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2652         return;
2653     }
2654
2655     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2656     if (!onFailure) {
2657         delete onSuccess;
2658         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2659         return;
2660     }
2661
2662     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value);
2663     if (err != CHIP_NO_ERROR) {
2664         delete onSuccess;
2665         delete onFailure;
2666         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2667     }
2668 }
2669
2670 - (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler
2671 {
2672     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2673     if (!onSuccess) {
2674         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2675         return;
2676     }
2677
2678     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2679     if (!onFailure) {
2680         delete onSuccess;
2681         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2682         return;
2683     }
2684
2685     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel());
2686     if (err != CHIP_NO_ERROR) {
2687         delete onSuccess;
2688         delete onFailure;
2689         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2690     }
2691 }
2692
2693 - (void)writeAttributeColorPointRIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler
2694 {
2695     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2696     if (!onSuccess) {
2697         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2698         return;
2699     }
2700
2701     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2702     if (!onFailure) {
2703         delete onSuccess;
2704         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2705         return;
2706     }
2707
2708     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value);
2709     if (err != CHIP_NO_ERROR) {
2710         delete onSuccess;
2711         delete onFailure;
2712         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2713     }
2714 }
2715
2716 - (void)readAttributeColorPointGX:(ResponseHandler)completionHandler
2717 {
2718     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2719     if (!onSuccess) {
2720         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2721         return;
2722     }
2723
2724     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2725     if (!onFailure) {
2726         delete onSuccess;
2727         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2728         return;
2729     }
2730
2731     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel());
2732     if (err != CHIP_NO_ERROR) {
2733         delete onSuccess;
2734         delete onFailure;
2735         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2736     }
2737 }
2738
2739 - (void)writeAttributeColorPointGX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
2740 {
2741     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2742     if (!onSuccess) {
2743         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2744         return;
2745     }
2746
2747     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2748     if (!onFailure) {
2749         delete onSuccess;
2750         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2751         return;
2752     }
2753
2754     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value);
2755     if (err != CHIP_NO_ERROR) {
2756         delete onSuccess;
2757         delete onFailure;
2758         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2759     }
2760 }
2761
2762 - (void)readAttributeColorPointGY:(ResponseHandler)completionHandler
2763 {
2764     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2765     if (!onSuccess) {
2766         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2767         return;
2768     }
2769
2770     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2771     if (!onFailure) {
2772         delete onSuccess;
2773         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2774         return;
2775     }
2776
2777     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel());
2778     if (err != CHIP_NO_ERROR) {
2779         delete onSuccess;
2780         delete onFailure;
2781         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2782     }
2783 }
2784
2785 - (void)writeAttributeColorPointGY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
2786 {
2787     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2788     if (!onSuccess) {
2789         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2790         return;
2791     }
2792
2793     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2794     if (!onFailure) {
2795         delete onSuccess;
2796         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2797         return;
2798     }
2799
2800     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value);
2801     if (err != CHIP_NO_ERROR) {
2802         delete onSuccess;
2803         delete onFailure;
2804         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2805     }
2806 }
2807
2808 - (void)readAttributeColorPointGIntensity:(ResponseHandler)completionHandler
2809 {
2810     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2811     if (!onSuccess) {
2812         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2813         return;
2814     }
2815
2816     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2817     if (!onFailure) {
2818         delete onSuccess;
2819         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2820         return;
2821     }
2822
2823     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel());
2824     if (err != CHIP_NO_ERROR) {
2825         delete onSuccess;
2826         delete onFailure;
2827         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2828     }
2829 }
2830
2831 - (void)writeAttributeColorPointGIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler
2832 {
2833     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2834     if (!onSuccess) {
2835         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2836         return;
2837     }
2838
2839     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2840     if (!onFailure) {
2841         delete onSuccess;
2842         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2843         return;
2844     }
2845
2846     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value);
2847     if (err != CHIP_NO_ERROR) {
2848         delete onSuccess;
2849         delete onFailure;
2850         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2851     }
2852 }
2853
2854 - (void)readAttributeColorPointBX:(ResponseHandler)completionHandler
2855 {
2856     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2857     if (!onSuccess) {
2858         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2859         return;
2860     }
2861
2862     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2863     if (!onFailure) {
2864         delete onSuccess;
2865         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2866         return;
2867     }
2868
2869     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel());
2870     if (err != CHIP_NO_ERROR) {
2871         delete onSuccess;
2872         delete onFailure;
2873         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2874     }
2875 }
2876
2877 - (void)writeAttributeColorPointBX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
2878 {
2879     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2880     if (!onSuccess) {
2881         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2882         return;
2883     }
2884
2885     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2886     if (!onFailure) {
2887         delete onSuccess;
2888         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2889         return;
2890     }
2891
2892     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value);
2893     if (err != CHIP_NO_ERROR) {
2894         delete onSuccess;
2895         delete onFailure;
2896         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2897     }
2898 }
2899
2900 - (void)readAttributeColorPointBY:(ResponseHandler)completionHandler
2901 {
2902     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2903     if (!onSuccess) {
2904         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2905         return;
2906     }
2907
2908     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2909     if (!onFailure) {
2910         delete onSuccess;
2911         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2912         return;
2913     }
2914
2915     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel());
2916     if (err != CHIP_NO_ERROR) {
2917         delete onSuccess;
2918         delete onFailure;
2919         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2920     }
2921 }
2922
2923 - (void)writeAttributeColorPointBY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
2924 {
2925     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2926     if (!onSuccess) {
2927         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2928         return;
2929     }
2930
2931     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2932     if (!onFailure) {
2933         delete onSuccess;
2934         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2935         return;
2936     }
2937
2938     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value);
2939     if (err != CHIP_NO_ERROR) {
2940         delete onSuccess;
2941         delete onFailure;
2942         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2943     }
2944 }
2945
2946 - (void)readAttributeColorPointBIntensity:(ResponseHandler)completionHandler
2947 {
2948     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2949     if (!onSuccess) {
2950         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2951         return;
2952     }
2953
2954     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2955     if (!onFailure) {
2956         delete onSuccess;
2957         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2958         return;
2959     }
2960
2961     CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel());
2962     if (err != CHIP_NO_ERROR) {
2963         delete onSuccess;
2964         delete onFailure;
2965         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2966     }
2967 }
2968
2969 - (void)writeAttributeColorPointBIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler
2970 {
2971     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
2972     if (!onSuccess) {
2973         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2974         return;
2975     }
2976
2977     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
2978     if (!onFailure) {
2979         delete onSuccess;
2980         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2981         return;
2982     }
2983
2984     CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value);
2985     if (err != CHIP_NO_ERROR) {
2986         delete onSuccess;
2987         delete onFailure;
2988         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
2989     }
2990 }
2991
2992 - (void)readAttributeEnhancedCurrentHue:(ResponseHandler)completionHandler
2993 {
2994     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
2995     if (!onSuccess) {
2996         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
2997         return;
2998     }
2999
3000     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3001     if (!onFailure) {
3002         delete onSuccess;
3003         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3004         return;
3005     }
3006
3007     CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel());
3008     if (err != CHIP_NO_ERROR) {
3009         delete onSuccess;
3010         delete onFailure;
3011         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3012     }
3013 }
3014
3015 - (void)readAttributeEnhancedColorMode:(ResponseHandler)completionHandler
3016 {
3017     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3018     if (!onSuccess) {
3019         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3020         return;
3021     }
3022
3023     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3024     if (!onFailure) {
3025         delete onSuccess;
3026         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3027         return;
3028     }
3029
3030     CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel());
3031     if (err != CHIP_NO_ERROR) {
3032         delete onSuccess;
3033         delete onFailure;
3034         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3035     }
3036 }
3037
3038 - (void)readAttributeColorLoopActive:(ResponseHandler)completionHandler
3039 {
3040     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3041     if (!onSuccess) {
3042         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3043         return;
3044     }
3045
3046     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3047     if (!onFailure) {
3048         delete onSuccess;
3049         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3050         return;
3051     }
3052
3053     CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel());
3054     if (err != CHIP_NO_ERROR) {
3055         delete onSuccess;
3056         delete onFailure;
3057         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3058     }
3059 }
3060
3061 - (void)readAttributeColorLoopDirection:(ResponseHandler)completionHandler
3062 {
3063     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3064     if (!onSuccess) {
3065         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3066         return;
3067     }
3068
3069     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3070     if (!onFailure) {
3071         delete onSuccess;
3072         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3073         return;
3074     }
3075
3076     CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel());
3077     if (err != CHIP_NO_ERROR) {
3078         delete onSuccess;
3079         delete onFailure;
3080         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3081     }
3082 }
3083
3084 - (void)readAttributeColorLoopTime:(ResponseHandler)completionHandler
3085 {
3086     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3087     if (!onSuccess) {
3088         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3089         return;
3090     }
3091
3092     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3093     if (!onFailure) {
3094         delete onSuccess;
3095         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3096         return;
3097     }
3098
3099     CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel());
3100     if (err != CHIP_NO_ERROR) {
3101         delete onSuccess;
3102         delete onFailure;
3103         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3104     }
3105 }
3106
3107 - (void)readAttributeColorCapabilities:(ResponseHandler)completionHandler
3108 {
3109     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3110     if (!onSuccess) {
3111         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3112         return;
3113     }
3114
3115     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3116     if (!onFailure) {
3117         delete onSuccess;
3118         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3119         return;
3120     }
3121
3122     CHIP_ERROR err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel());
3123     if (err != CHIP_NO_ERROR) {
3124         delete onSuccess;
3125         delete onFailure;
3126         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3127     }
3128 }
3129
3130 - (void)readAttributeColorTempPhysicalMin:(ResponseHandler)completionHandler
3131 {
3132     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3133     if (!onSuccess) {
3134         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3135         return;
3136     }
3137
3138     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3139     if (!onFailure) {
3140         delete onSuccess;
3141         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3142         return;
3143     }
3144
3145     CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel());
3146     if (err != CHIP_NO_ERROR) {
3147         delete onSuccess;
3148         delete onFailure;
3149         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3150     }
3151 }
3152
3153 - (void)readAttributeColorTempPhysicalMax:(ResponseHandler)completionHandler
3154 {
3155     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3156     if (!onSuccess) {
3157         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3158         return;
3159     }
3160
3161     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3162     if (!onFailure) {
3163         delete onSuccess;
3164         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3165         return;
3166     }
3167
3168     CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel());
3169     if (err != CHIP_NO_ERROR) {
3170         delete onSuccess;
3171         delete onFailure;
3172         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3173     }
3174 }
3175
3176 - (void)readAttributeCoupleColorTempToLevelMinMireds:(ResponseHandler)completionHandler
3177 {
3178     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3179     if (!onSuccess) {
3180         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3181         return;
3182     }
3183
3184     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3185     if (!onFailure) {
3186         delete onSuccess;
3187         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3188         return;
3189     }
3190
3191     CHIP_ERROR err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel());
3192     if (err != CHIP_NO_ERROR) {
3193         delete onSuccess;
3194         delete onFailure;
3195         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3196     }
3197 }
3198
3199 - (void)readAttributeStartUpColorTemperatureMireds:(ResponseHandler)completionHandler
3200 {
3201     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3202     if (!onSuccess) {
3203         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3204         return;
3205     }
3206
3207     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3208     if (!onFailure) {
3209         delete onSuccess;
3210         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3211         return;
3212     }
3213
3214     CHIP_ERROR err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel());
3215     if (err != CHIP_NO_ERROR) {
3216         delete onSuccess;
3217         delete onFailure;
3218         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3219     }
3220 }
3221
3222 - (void)writeAttributeStartUpColorTemperatureMireds:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
3223 {
3224     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3225     if (!onSuccess) {
3226         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3227         return;
3228     }
3229
3230     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3231     if (!onFailure) {
3232         delete onSuccess;
3233         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3234         return;
3235     }
3236
3237     CHIP_ERROR err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value);
3238     if (err != CHIP_NO_ERROR) {
3239         delete onSuccess;
3240         delete onFailure;
3241         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3242     }
3243 }
3244
3245 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
3246 {
3247     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3248     if (!onSuccess) {
3249         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3250         return;
3251     }
3252
3253     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3254     if (!onFailure) {
3255         delete onSuccess;
3256         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3257         return;
3258     }
3259
3260     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
3261     if (err != CHIP_NO_ERROR) {
3262         delete onSuccess;
3263         delete onFailure;
3264         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3265     }
3266 }
3267
3268 @end
3269
3270 @interface CHIPContentLaunch ()
3271 @property (readonly) Controller::ContentLaunchCluster cppCluster;
3272 @end
3273
3274 @implementation CHIPContentLaunch
3275
3276 - (Controller::ClusterBase *)getCluster
3277 {
3278     return &_cppCluster;
3279 }
3280
3281 - (void)launchContent:(ResponseHandler)completionHandler
3282 {
3283     CHIPContentLaunchClusterLaunchContentResponseCallbackBridge * onSuccess
3284         = new CHIPContentLaunchClusterLaunchContentResponseCallbackBridge(completionHandler, [self callbackQueue]);
3285     if (!onSuccess) {
3286         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3287         return;
3288     }
3289
3290     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3291     if (!onFailure) {
3292         delete onSuccess;
3293         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3294         return;
3295     }
3296
3297     CHIP_ERROR err = self.cppCluster.LaunchContent(onSuccess->Cancel(), onFailure->Cancel());
3298     if (err != CHIP_NO_ERROR) {
3299         delete onSuccess;
3300         delete onFailure;
3301         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3302     }
3303 }
3304 - (void)launchURL:(ResponseHandler)completionHandler
3305 {
3306     CHIPContentLaunchClusterLaunchURLResponseCallbackBridge * onSuccess
3307         = new CHIPContentLaunchClusterLaunchURLResponseCallbackBridge(completionHandler, [self callbackQueue]);
3308     if (!onSuccess) {
3309         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3310         return;
3311     }
3312
3313     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3314     if (!onFailure) {
3315         delete onSuccess;
3316         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3317         return;
3318     }
3319
3320     CHIP_ERROR err = self.cppCluster.LaunchURL(onSuccess->Cancel(), onFailure->Cancel());
3321     if (err != CHIP_NO_ERROR) {
3322         delete onSuccess;
3323         delete onFailure;
3324         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3325     }
3326 }
3327
3328 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
3329 {
3330     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3331     if (!onSuccess) {
3332         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3333         return;
3334     }
3335
3336     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3337     if (!onFailure) {
3338         delete onSuccess;
3339         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3340         return;
3341     }
3342
3343     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
3344     if (err != CHIP_NO_ERROR) {
3345         delete onSuccess;
3346         delete onFailure;
3347         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3348     }
3349 }
3350
3351 @end
3352
3353 @interface CHIPDoorLock ()
3354 @property (readonly) Controller::DoorLockCluster cppCluster;
3355 @end
3356
3357 @implementation CHIPDoorLock
3358
3359 - (Controller::ClusterBase *)getCluster
3360 {
3361     return &_cppCluster;
3362 }
3363
3364 - (void)clearAllPins:(ResponseHandler)completionHandler
3365 {
3366     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3367     if (!onSuccess) {
3368         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3369         return;
3370     }
3371
3372     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3373     if (!onFailure) {
3374         delete onSuccess;
3375         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3376         return;
3377     }
3378
3379     CHIP_ERROR err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel());
3380     if (err != CHIP_NO_ERROR) {
3381         delete onSuccess;
3382         delete onFailure;
3383         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3384     }
3385 }
3386 - (void)clearAllRfids:(ResponseHandler)completionHandler
3387 {
3388     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3389     if (!onSuccess) {
3390         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3391         return;
3392     }
3393
3394     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3395     if (!onFailure) {
3396         delete onSuccess;
3397         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3398         return;
3399     }
3400
3401     CHIP_ERROR err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel());
3402     if (err != CHIP_NO_ERROR) {
3403         delete onSuccess;
3404         delete onFailure;
3405         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3406     }
3407 }
3408 - (void)clearHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandler)completionHandler
3409 {
3410     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3411     if (!onSuccess) {
3412         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3413         return;
3414     }
3415
3416     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3417     if (!onFailure) {
3418         delete onSuccess;
3419         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3420         return;
3421     }
3422
3423     CHIP_ERROR err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId);
3424     if (err != CHIP_NO_ERROR) {
3425         delete onSuccess;
3426         delete onFailure;
3427         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3428     }
3429 }
3430 - (void)clearPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3431 {
3432     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3433     if (!onSuccess) {
3434         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3435         return;
3436     }
3437
3438     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3439     if (!onFailure) {
3440         delete onSuccess;
3441         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3442         return;
3443     }
3444
3445     CHIP_ERROR err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId);
3446     if (err != CHIP_NO_ERROR) {
3447         delete onSuccess;
3448         delete onFailure;
3449         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3450     }
3451 }
3452 - (void)clearRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3453 {
3454     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3455     if (!onSuccess) {
3456         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3457         return;
3458     }
3459
3460     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3461     if (!onFailure) {
3462         delete onSuccess;
3463         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3464         return;
3465     }
3466
3467     CHIP_ERROR err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId);
3468     if (err != CHIP_NO_ERROR) {
3469         delete onSuccess;
3470         delete onFailure;
3471         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3472     }
3473 }
3474 - (void)clearWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3475 {
3476     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3477     if (!onSuccess) {
3478         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3479         return;
3480     }
3481
3482     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3483     if (!onFailure) {
3484         delete onSuccess;
3485         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3486         return;
3487     }
3488
3489     CHIP_ERROR err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId);
3490     if (err != CHIP_NO_ERROR) {
3491         delete onSuccess;
3492         delete onFailure;
3493         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3494     }
3495 }
3496 - (void)clearYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3497 {
3498     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3499     if (!onSuccess) {
3500         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3501         return;
3502     }
3503
3504     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3505     if (!onFailure) {
3506         delete onSuccess;
3507         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3508         return;
3509     }
3510
3511     CHIP_ERROR err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId);
3512     if (err != CHIP_NO_ERROR) {
3513         delete onSuccess;
3514         delete onFailure;
3515         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3516     }
3517 }
3518 - (void)getHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandler)completionHandler
3519 {
3520     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3521     if (!onSuccess) {
3522         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3523         return;
3524     }
3525
3526     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3527     if (!onFailure) {
3528         delete onSuccess;
3529         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3530         return;
3531     }
3532
3533     CHIP_ERROR err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId);
3534     if (err != CHIP_NO_ERROR) {
3535         delete onSuccess;
3536         delete onFailure;
3537         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3538     }
3539 }
3540 - (void)getLogRecord:(uint16_t)logIndex completionHandler:(ResponseHandler)completionHandler
3541 {
3542     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3543     if (!onSuccess) {
3544         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3545         return;
3546     }
3547
3548     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3549     if (!onFailure) {
3550         delete onSuccess;
3551         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3552         return;
3553     }
3554
3555     CHIP_ERROR err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex);
3556     if (err != CHIP_NO_ERROR) {
3557         delete onSuccess;
3558         delete onFailure;
3559         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3560     }
3561 }
3562 - (void)getPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3563 {
3564     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3565     if (!onSuccess) {
3566         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3567         return;
3568     }
3569
3570     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3571     if (!onFailure) {
3572         delete onSuccess;
3573         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3574         return;
3575     }
3576
3577     CHIP_ERROR err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId);
3578     if (err != CHIP_NO_ERROR) {
3579         delete onSuccess;
3580         delete onFailure;
3581         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3582     }
3583 }
3584 - (void)getRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3585 {
3586     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3587     if (!onSuccess) {
3588         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3589         return;
3590     }
3591
3592     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3593     if (!onFailure) {
3594         delete onSuccess;
3595         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3596         return;
3597     }
3598
3599     CHIP_ERROR err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId);
3600     if (err != CHIP_NO_ERROR) {
3601         delete onSuccess;
3602         delete onFailure;
3603         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3604     }
3605 }
3606 - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3607 {
3608     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3609     if (!onSuccess) {
3610         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3611         return;
3612     }
3613
3614     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3615     if (!onFailure) {
3616         delete onSuccess;
3617         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3618         return;
3619     }
3620
3621     CHIP_ERROR err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId);
3622     if (err != CHIP_NO_ERROR) {
3623         delete onSuccess;
3624         delete onFailure;
3625         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3626     }
3627 }
3628 - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3629 {
3630     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3631     if (!onSuccess) {
3632         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3633         return;
3634     }
3635
3636     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3637     if (!onFailure) {
3638         delete onSuccess;
3639         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3640         return;
3641     }
3642
3643     CHIP_ERROR err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId);
3644     if (err != CHIP_NO_ERROR) {
3645         delete onSuccess;
3646         delete onFailure;
3647         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3648     }
3649 }
3650 - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler
3651 {
3652     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3653     if (!onSuccess) {
3654         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3655         return;
3656     }
3657
3658     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3659     if (!onFailure) {
3660         delete onSuccess;
3661         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3662         return;
3663     }
3664
3665     CHIP_ERROR err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId);
3666     if (err != CHIP_NO_ERROR) {
3667         delete onSuccess;
3668         delete onFailure;
3669         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3670     }
3671 }
3672 - (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler
3673 {
3674     CHIPDoorLockClusterLockDoorResponseCallbackBridge * onSuccess
3675         = new CHIPDoorLockClusterLockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]);
3676     if (!onSuccess) {
3677         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3678         return;
3679     }
3680
3681     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3682     if (!onFailure) {
3683         delete onSuccess;
3684         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3685         return;
3686     }
3687
3688     CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(),
3689         chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes,
3690             [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
3691     if (err != CHIP_NO_ERROR) {
3692         delete onSuccess;
3693         delete onFailure;
3694         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3695     }
3696 }
3697 - (void)setHolidaySchedule:(uint8_t)scheduleId
3698                 localStartTime:(uint32_t)localStartTime
3699                   localEndTime:(uint32_t)localEndTime
3700     operatingModeDuringHoliday:(uint8_t)operatingModeDuringHoliday
3701              completionHandler:(ResponseHandler)completionHandler
3702 {
3703     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3704     if (!onSuccess) {
3705         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3706         return;
3707     }
3708
3709     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3710     if (!onFailure) {
3711         delete onSuccess;
3712         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3713         return;
3714     }
3715
3716     CHIP_ERROR err = self.cppCluster.SetHolidaySchedule(
3717         onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday);
3718     if (err != CHIP_NO_ERROR) {
3719         delete onSuccess;
3720         delete onFailure;
3721         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3722     }
3723 }
3724 - (void)setPin:(uint16_t)userId
3725            userStatus:(uint8_t)userStatus
3726              userType:(uint8_t)userType
3727                   pin:(NSString *)pin
3728     completionHandler:(ResponseHandler)completionHandler
3729 {
3730     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3731     if (!onSuccess) {
3732         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3733         return;
3734     }
3735
3736     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3737     if (!onFailure) {
3738         delete onSuccess;
3739         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3740         return;
3741     }
3742
3743     CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType,
3744         chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes,
3745             [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
3746     if (err != CHIP_NO_ERROR) {
3747         delete onSuccess;
3748         delete onFailure;
3749         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3750     }
3751 }
3752 - (void)setRfid:(uint16_t)userId
3753            userStatus:(uint8_t)userStatus
3754              userType:(uint8_t)userType
3755                    id:(NSString *)id
3756     completionHandler:(ResponseHandler)completionHandler
3757 {
3758     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3759     if (!onSuccess) {
3760         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3761         return;
3762     }
3763
3764     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3765     if (!onFailure) {
3766         delete onSuccess;
3767         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3768         return;
3769     }
3770
3771     CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType,
3772         chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes,
3773             [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
3774     if (err != CHIP_NO_ERROR) {
3775         delete onSuccess;
3776         delete onFailure;
3777         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3778     }
3779 }
3780 - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandler:(ResponseHandler)completionHandler
3781 {
3782     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3783     if (!onSuccess) {
3784         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3785         return;
3786     }
3787
3788     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3789     if (!onFailure) {
3790         delete onSuccess;
3791         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3792         return;
3793     }
3794
3795     CHIP_ERROR err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType);
3796     if (err != CHIP_NO_ERROR) {
3797         delete onSuccess;
3798         delete onFailure;
3799         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3800     }
3801 }
3802 - (void)setWeekdaySchedule:(uint8_t)scheduleId
3803                     userId:(uint16_t)userId
3804                   daysMask:(uint8_t)daysMask
3805                  startHour:(uint8_t)startHour
3806                startMinute:(uint8_t)startMinute
3807                    endHour:(uint8_t)endHour
3808                  endMinute:(uint8_t)endMinute
3809          completionHandler:(ResponseHandler)completionHandler
3810 {
3811     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3812     if (!onSuccess) {
3813         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3814         return;
3815     }
3816
3817     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3818     if (!onFailure) {
3819         delete onSuccess;
3820         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3821         return;
3822     }
3823
3824     CHIP_ERROR err = self.cppCluster.SetWeekdaySchedule(
3825         onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute);
3826     if (err != CHIP_NO_ERROR) {
3827         delete onSuccess;
3828         delete onFailure;
3829         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3830     }
3831 }
3832 - (void)setYeardaySchedule:(uint8_t)scheduleId
3833                     userId:(uint16_t)userId
3834             localStartTime:(uint32_t)localStartTime
3835               localEndTime:(uint32_t)localEndTime
3836          completionHandler:(ResponseHandler)completionHandler
3837 {
3838     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3839     if (!onSuccess) {
3840         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3841         return;
3842     }
3843
3844     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3845     if (!onFailure) {
3846         delete onSuccess;
3847         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3848         return;
3849     }
3850
3851     CHIP_ERROR err = self.cppCluster.SetYeardaySchedule(
3852         onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime);
3853     if (err != CHIP_NO_ERROR) {
3854         delete onSuccess;
3855         delete onFailure;
3856         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3857     }
3858 }
3859 - (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler
3860 {
3861     CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * onSuccess
3862         = new CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]);
3863     if (!onSuccess) {
3864         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3865         return;
3866     }
3867
3868     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3869     if (!onFailure) {
3870         delete onSuccess;
3871         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3872         return;
3873     }
3874
3875     CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(),
3876         chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes,
3877             [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
3878     if (err != CHIP_NO_ERROR) {
3879         delete onSuccess;
3880         delete onFailure;
3881         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3882     }
3883 }
3884 - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler
3885 {
3886     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3887     if (!onSuccess) {
3888         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3889         return;
3890     }
3891
3892     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3893     if (!onFailure) {
3894         delete onSuccess;
3895         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3896         return;
3897     }
3898
3899     CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds,
3900         chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes,
3901             [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
3902     if (err != CHIP_NO_ERROR) {
3903         delete onSuccess;
3904         delete onFailure;
3905         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3906     }
3907 }
3908
3909 - (void)readAttributeLockState:(ResponseHandler)completionHandler
3910 {
3911     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3912     if (!onSuccess) {
3913         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3914         return;
3915     }
3916
3917     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3918     if (!onFailure) {
3919         delete onSuccess;
3920         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3921         return;
3922     }
3923
3924     CHIP_ERROR err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel());
3925     if (err != CHIP_NO_ERROR) {
3926         delete onSuccess;
3927         delete onFailure;
3928         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3929     }
3930 }
3931
3932 - (void)configureAttributeLockState:(uint16_t)minInterval
3933                         maxInterval:(uint16_t)maxInterval
3934                   completionHandler:(ResponseHandler)completionHandler
3935 {
3936     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
3937     if (!onSuccess) {
3938         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3939         return;
3940     }
3941
3942     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3943     if (!onFailure) {
3944         delete onSuccess;
3945         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3946         return;
3947     }
3948
3949     CHIP_ERROR err
3950         = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
3951     if (err != CHIP_NO_ERROR) {
3952         delete onSuccess;
3953         delete onFailure;
3954         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3955     }
3956 }
3957
3958 - (void)reportAttributeLockState:(ResponseHandler)reportHandler
3959 {
3960     CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
3961     if (!onReport) {
3962         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3963         return;
3964     }
3965
3966     CHIP_ERROR err = self.cppCluster.ReportAttributeLockState(onReport->Cancel());
3967     if (err != CHIP_NO_ERROR) {
3968         delete onReport;
3969         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
3970     }
3971 }
3972
3973 - (void)readAttributeLockType:(ResponseHandler)completionHandler
3974 {
3975     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
3976     if (!onSuccess) {
3977         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3978         return;
3979     }
3980
3981     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
3982     if (!onFailure) {
3983         delete onSuccess;
3984         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
3985         return;
3986     }
3987
3988     CHIP_ERROR err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel());
3989     if (err != CHIP_NO_ERROR) {
3990         delete onSuccess;
3991         delete onFailure;
3992         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
3993     }
3994 }
3995
3996 - (void)readAttributeActuatorEnabled:(ResponseHandler)completionHandler
3997 {
3998     CHIPBooleanAttributeCallbackBridge * onSuccess
3999         = new CHIPBooleanAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4000     if (!onSuccess) {
4001         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4002         return;
4003     }
4004
4005     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4006     if (!onFailure) {
4007         delete onSuccess;
4008         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4009         return;
4010     }
4011
4012     CHIP_ERROR err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel());
4013     if (err != CHIP_NO_ERROR) {
4014         delete onSuccess;
4015         delete onFailure;
4016         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4017     }
4018 }
4019
4020 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
4021 {
4022     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4023     if (!onSuccess) {
4024         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4025         return;
4026     }
4027
4028     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4029     if (!onFailure) {
4030         delete onSuccess;
4031         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4032         return;
4033     }
4034
4035     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
4036     if (err != CHIP_NO_ERROR) {
4037         delete onSuccess;
4038         delete onFailure;
4039         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4040     }
4041 }
4042
4043 @end
4044
4045 @interface CHIPGeneralCommissioning ()
4046 @property (readonly) Controller::GeneralCommissioningCluster cppCluster;
4047 @end
4048
4049 @implementation CHIPGeneralCommissioning
4050
4051 - (Controller::ClusterBase *)getCluster
4052 {
4053     return &_cppCluster;
4054 }
4055
4056 - (void)armFailSafe:(uint16_t)expiryLengthSeconds
4057            breadcrumb:(uint64_t)breadcrumb
4058             timeoutMs:(uint32_t)timeoutMs
4059     completionHandler:(ResponseHandler)completionHandler
4060 {
4061     CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge * onSuccess
4062         = new CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge(completionHandler, [self callbackQueue]);
4063     if (!onSuccess) {
4064         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4065         return;
4066     }
4067
4068     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4069     if (!onFailure) {
4070         delete onSuccess;
4071         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4072         return;
4073     }
4074
4075     CHIP_ERROR err
4076         = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs);
4077     if (err != CHIP_NO_ERROR) {
4078         delete onSuccess;
4079         delete onFailure;
4080         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4081     }
4082 }
4083 - (void)commissioningComplete:(ResponseHandler)completionHandler
4084 {
4085     CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge * onSuccess
4086         = new CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge(completionHandler, [self callbackQueue]);
4087     if (!onSuccess) {
4088         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4089         return;
4090     }
4091
4092     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4093     if (!onFailure) {
4094         delete onSuccess;
4095         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4096         return;
4097     }
4098
4099     CHIP_ERROR err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel());
4100     if (err != CHIP_NO_ERROR) {
4101         delete onSuccess;
4102         delete onFailure;
4103         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4104     }
4105 }
4106 - (void)setFabric:(NSData *)fabricId
4107          fabricSecret:(NSData *)fabricSecret
4108            breadcrumb:(uint64_t)breadcrumb
4109             timeoutMs:(uint32_t)timeoutMs
4110     completionHandler:(ResponseHandler)completionHandler
4111 {
4112     CHIPGeneralCommissioningClusterSetFabricResponseCallbackBridge * onSuccess
4113         = new CHIPGeneralCommissioningClusterSetFabricResponseCallbackBridge(completionHandler, [self callbackQueue]);
4114     if (!onSuccess) {
4115         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4116         return;
4117     }
4118
4119     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4120     if (!onFailure) {
4121         delete onSuccess;
4122         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4123         return;
4124     }
4125
4126     CHIP_ERROR err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(),
4127         chip::ByteSpan((const uint8_t *) fabricId.bytes, fabricId.length),
4128         chip::ByteSpan((const uint8_t *) fabricSecret.bytes, fabricSecret.length), breadcrumb, timeoutMs);
4129     if (err != CHIP_NO_ERROR) {
4130         delete onSuccess;
4131         delete onFailure;
4132         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4133     }
4134 }
4135
4136 - (void)readAttributeFabricId:(ResponseHandler)completionHandler
4137 {
4138     CHIPStringAttributeCallbackBridge * onSuccess
4139         = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true);
4140     if (!onSuccess) {
4141         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4142         return;
4143     }
4144
4145     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4146     if (!onFailure) {
4147         delete onSuccess;
4148         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4149         return;
4150     }
4151
4152     CHIP_ERROR err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel());
4153     if (err != CHIP_NO_ERROR) {
4154         delete onSuccess;
4155         delete onFailure;
4156         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4157     }
4158 }
4159
4160 - (void)readAttributeBreadcrumb:(ResponseHandler)completionHandler
4161 {
4162     CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4163     if (!onSuccess) {
4164         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4165         return;
4166     }
4167
4168     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4169     if (!onFailure) {
4170         delete onSuccess;
4171         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4172         return;
4173     }
4174
4175     CHIP_ERROR err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel());
4176     if (err != CHIP_NO_ERROR) {
4177         delete onSuccess;
4178         delete onFailure;
4179         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4180     }
4181 }
4182
4183 - (void)writeAttributeBreadcrumb:(uint64_t)value completionHandler:(ResponseHandler)completionHandler
4184 {
4185     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4186     if (!onSuccess) {
4187         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4188         return;
4189     }
4190
4191     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4192     if (!onFailure) {
4193         delete onSuccess;
4194         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4195         return;
4196     }
4197
4198     CHIP_ERROR err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value);
4199     if (err != CHIP_NO_ERROR) {
4200         delete onSuccess;
4201         delete onFailure;
4202         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4203     }
4204 }
4205
4206 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
4207 {
4208     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4209     if (!onSuccess) {
4210         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4211         return;
4212     }
4213
4214     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4215     if (!onFailure) {
4216         delete onSuccess;
4217         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4218         return;
4219     }
4220
4221     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
4222     if (err != CHIP_NO_ERROR) {
4223         delete onSuccess;
4224         delete onFailure;
4225         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4226     }
4227 }
4228
4229 @end
4230
4231 @interface CHIPGroups ()
4232 @property (readonly) Controller::GroupsCluster cppCluster;
4233 @end
4234
4235 @implementation CHIPGroups
4236
4237 - (Controller::ClusterBase *)getCluster
4238 {
4239     return &_cppCluster;
4240 }
4241
4242 - (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler
4243 {
4244     CHIPGroupsClusterAddGroupResponseCallbackBridge * onSuccess
4245         = new CHIPGroupsClusterAddGroupResponseCallbackBridge(completionHandler, [self callbackQueue]);
4246     if (!onSuccess) {
4247         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4248         return;
4249     }
4250
4251     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4252     if (!onFailure) {
4253         delete onSuccess;
4254         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4255         return;
4256     }
4257
4258     CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId,
4259         chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes,
4260             [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
4261     if (err != CHIP_NO_ERROR) {
4262         delete onSuccess;
4263         delete onFailure;
4264         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4265     }
4266 }
4267 - (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler
4268 {
4269     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4270     if (!onSuccess) {
4271         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4272         return;
4273     }
4274
4275     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4276     if (!onFailure) {
4277         delete onSuccess;
4278         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4279         return;
4280     }
4281
4282     CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId,
4283         chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes,
4284             [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
4285     if (err != CHIP_NO_ERROR) {
4286         delete onSuccess;
4287         delete onFailure;
4288         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4289     }
4290 }
4291 - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList completionHandler:(ResponseHandler)completionHandler
4292 {
4293     CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge * onSuccess
4294         = new CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge(completionHandler, [self callbackQueue]);
4295     if (!onSuccess) {
4296         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4297         return;
4298     }
4299
4300     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4301     if (!onFailure) {
4302         delete onSuccess;
4303         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4304         return;
4305     }
4306
4307     CHIP_ERROR err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList);
4308     if (err != CHIP_NO_ERROR) {
4309         delete onSuccess;
4310         delete onFailure;
4311         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4312     }
4313 }
4314 - (void)removeAllGroups:(ResponseHandler)completionHandler
4315 {
4316     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4317     if (!onSuccess) {
4318         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4319         return;
4320     }
4321
4322     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4323     if (!onFailure) {
4324         delete onSuccess;
4325         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4326         return;
4327     }
4328
4329     CHIP_ERROR err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel());
4330     if (err != CHIP_NO_ERROR) {
4331         delete onSuccess;
4332         delete onFailure;
4333         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4334     }
4335 }
4336 - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler
4337 {
4338     CHIPGroupsClusterRemoveGroupResponseCallbackBridge * onSuccess
4339         = new CHIPGroupsClusterRemoveGroupResponseCallbackBridge(completionHandler, [self callbackQueue]);
4340     if (!onSuccess) {
4341         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4342         return;
4343     }
4344
4345     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4346     if (!onFailure) {
4347         delete onSuccess;
4348         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4349         return;
4350     }
4351
4352     CHIP_ERROR err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId);
4353     if (err != CHIP_NO_ERROR) {
4354         delete onSuccess;
4355         delete onFailure;
4356         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4357     }
4358 }
4359 - (void)viewGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler
4360 {
4361     CHIPGroupsClusterViewGroupResponseCallbackBridge * onSuccess
4362         = new CHIPGroupsClusterViewGroupResponseCallbackBridge(completionHandler, [self callbackQueue]);
4363     if (!onSuccess) {
4364         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4365         return;
4366     }
4367
4368     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4369     if (!onFailure) {
4370         delete onSuccess;
4371         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4372         return;
4373     }
4374
4375     CHIP_ERROR err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId);
4376     if (err != CHIP_NO_ERROR) {
4377         delete onSuccess;
4378         delete onFailure;
4379         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4380     }
4381 }
4382
4383 - (void)readAttributeNameSupport:(ResponseHandler)completionHandler
4384 {
4385     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4386     if (!onSuccess) {
4387         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4388         return;
4389     }
4390
4391     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4392     if (!onFailure) {
4393         delete onSuccess;
4394         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4395         return;
4396     }
4397
4398     CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel());
4399     if (err != CHIP_NO_ERROR) {
4400         delete onSuccess;
4401         delete onFailure;
4402         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4403     }
4404 }
4405
4406 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
4407 {
4408     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4409     if (!onSuccess) {
4410         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4411         return;
4412     }
4413
4414     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4415     if (!onFailure) {
4416         delete onSuccess;
4417         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4418         return;
4419     }
4420
4421     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
4422     if (err != CHIP_NO_ERROR) {
4423         delete onSuccess;
4424         delete onFailure;
4425         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4426     }
4427 }
4428
4429 @end
4430
4431 @interface CHIPIasZone ()
4432 @property (readonly) Controller::IasZoneCluster cppCluster;
4433 @end
4434
4435 @implementation CHIPIasZone
4436
4437 - (Controller::ClusterBase *)getCluster
4438 {
4439     return &_cppCluster;
4440 }
4441
4442 - (void)readAttributeZoneState:(ResponseHandler)completionHandler
4443 {
4444     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4445     if (!onSuccess) {
4446         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4447         return;
4448     }
4449
4450     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4451     if (!onFailure) {
4452         delete onSuccess;
4453         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4454         return;
4455     }
4456
4457     CHIP_ERROR err = self.cppCluster.ReadAttributeZoneState(onSuccess->Cancel(), onFailure->Cancel());
4458     if (err != CHIP_NO_ERROR) {
4459         delete onSuccess;
4460         delete onFailure;
4461         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4462     }
4463 }
4464
4465 - (void)readAttributeZoneType:(ResponseHandler)completionHandler
4466 {
4467     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4468     if (!onSuccess) {
4469         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4470         return;
4471     }
4472
4473     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4474     if (!onFailure) {
4475         delete onSuccess;
4476         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4477         return;
4478     }
4479
4480     CHIP_ERROR err = self.cppCluster.ReadAttributeZoneType(onSuccess->Cancel(), onFailure->Cancel());
4481     if (err != CHIP_NO_ERROR) {
4482         delete onSuccess;
4483         delete onFailure;
4484         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4485     }
4486 }
4487
4488 - (void)readAttributeZoneStatus:(ResponseHandler)completionHandler
4489 {
4490     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4491     if (!onSuccess) {
4492         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4493         return;
4494     }
4495
4496     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4497     if (!onFailure) {
4498         delete onSuccess;
4499         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4500         return;
4501     }
4502
4503     CHIP_ERROR err = self.cppCluster.ReadAttributeZoneStatus(onSuccess->Cancel(), onFailure->Cancel());
4504     if (err != CHIP_NO_ERROR) {
4505         delete onSuccess;
4506         delete onFailure;
4507         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4508     }
4509 }
4510
4511 - (void)readAttributeIasCieAddress:(ResponseHandler)completionHandler
4512 {
4513     CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4514     if (!onSuccess) {
4515         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4516         return;
4517     }
4518
4519     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4520     if (!onFailure) {
4521         delete onSuccess;
4522         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4523         return;
4524     }
4525
4526     CHIP_ERROR err = self.cppCluster.ReadAttributeIasCieAddress(onSuccess->Cancel(), onFailure->Cancel());
4527     if (err != CHIP_NO_ERROR) {
4528         delete onSuccess;
4529         delete onFailure;
4530         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4531     }
4532 }
4533
4534 - (void)writeAttributeIasCieAddress:(uint64_t)value completionHandler:(ResponseHandler)completionHandler
4535 {
4536     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4537     if (!onSuccess) {
4538         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4539         return;
4540     }
4541
4542     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4543     if (!onFailure) {
4544         delete onSuccess;
4545         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4546         return;
4547     }
4548
4549     CHIP_ERROR err = self.cppCluster.WriteAttributeIasCieAddress(onSuccess->Cancel(), onFailure->Cancel(), value);
4550     if (err != CHIP_NO_ERROR) {
4551         delete onSuccess;
4552         delete onFailure;
4553         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4554     }
4555 }
4556
4557 - (void)readAttributeZoneId:(ResponseHandler)completionHandler
4558 {
4559     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4560     if (!onSuccess) {
4561         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4562         return;
4563     }
4564
4565     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4566     if (!onFailure) {
4567         delete onSuccess;
4568         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4569         return;
4570     }
4571
4572     CHIP_ERROR err = self.cppCluster.ReadAttributeZoneId(onSuccess->Cancel(), onFailure->Cancel());
4573     if (err != CHIP_NO_ERROR) {
4574         delete onSuccess;
4575         delete onFailure;
4576         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4577     }
4578 }
4579
4580 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
4581 {
4582     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4583     if (!onSuccess) {
4584         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4585         return;
4586     }
4587
4588     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4589     if (!onFailure) {
4590         delete onSuccess;
4591         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4592         return;
4593     }
4594
4595     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
4596     if (err != CHIP_NO_ERROR) {
4597         delete onSuccess;
4598         delete onFailure;
4599         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4600     }
4601 }
4602
4603 @end
4604
4605 @interface CHIPIdentify ()
4606 @property (readonly) Controller::IdentifyCluster cppCluster;
4607 @end
4608
4609 @implementation CHIPIdentify
4610
4611 - (Controller::ClusterBase *)getCluster
4612 {
4613     return &_cppCluster;
4614 }
4615
4616 - (void)identify:(uint16_t)identifyTime completionHandler:(ResponseHandler)completionHandler
4617 {
4618     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4619     if (!onSuccess) {
4620         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4621         return;
4622     }
4623
4624     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4625     if (!onFailure) {
4626         delete onSuccess;
4627         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4628         return;
4629     }
4630
4631     CHIP_ERROR err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime);
4632     if (err != CHIP_NO_ERROR) {
4633         delete onSuccess;
4634         delete onFailure;
4635         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4636     }
4637 }
4638 - (void)identifyQuery:(ResponseHandler)completionHandler
4639 {
4640     CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge * onSuccess
4641         = new CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge(completionHandler, [self callbackQueue]);
4642     if (!onSuccess) {
4643         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4644         return;
4645     }
4646
4647     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4648     if (!onFailure) {
4649         delete onSuccess;
4650         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4651         return;
4652     }
4653
4654     CHIP_ERROR err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel());
4655     if (err != CHIP_NO_ERROR) {
4656         delete onSuccess;
4657         delete onFailure;
4658         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4659     }
4660 }
4661
4662 - (void)readAttributeIdentifyTime:(ResponseHandler)completionHandler
4663 {
4664     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4665     if (!onSuccess) {
4666         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4667         return;
4668     }
4669
4670     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4671     if (!onFailure) {
4672         delete onSuccess;
4673         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4674         return;
4675     }
4676
4677     CHIP_ERROR err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel());
4678     if (err != CHIP_NO_ERROR) {
4679         delete onSuccess;
4680         delete onFailure;
4681         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4682     }
4683 }
4684
4685 - (void)writeAttributeIdentifyTime:(uint16_t)value completionHandler:(ResponseHandler)completionHandler
4686 {
4687     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4688     if (!onSuccess) {
4689         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4690         return;
4691     }
4692
4693     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4694     if (!onFailure) {
4695         delete onSuccess;
4696         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4697         return;
4698     }
4699
4700     CHIP_ERROR err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value);
4701     if (err != CHIP_NO_ERROR) {
4702         delete onSuccess;
4703         delete onFailure;
4704         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4705     }
4706 }
4707
4708 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
4709 {
4710     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4711     if (!onSuccess) {
4712         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4713         return;
4714     }
4715
4716     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4717     if (!onFailure) {
4718         delete onSuccess;
4719         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4720         return;
4721     }
4722
4723     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
4724     if (err != CHIP_NO_ERROR) {
4725         delete onSuccess;
4726         delete onFailure;
4727         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4728     }
4729 }
4730
4731 @end
4732
4733 @interface CHIPLevelControl ()
4734 @property (readonly) Controller::LevelControlCluster cppCluster;
4735 @end
4736
4737 @implementation CHIPLevelControl
4738
4739 - (Controller::ClusterBase *)getCluster
4740 {
4741     return &_cppCluster;
4742 }
4743
4744 - (void)move:(uint8_t)moveMode
4745                  rate:(uint8_t)rate
4746            optionMask:(uint8_t)optionMask
4747        optionOverride:(uint8_t)optionOverride
4748     completionHandler:(ResponseHandler)completionHandler
4749 {
4750     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4751     if (!onSuccess) {
4752         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4753         return;
4754     }
4755
4756     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4757     if (!onFailure) {
4758         delete onSuccess;
4759         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4760         return;
4761     }
4762
4763     CHIP_ERROR err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride);
4764     if (err != CHIP_NO_ERROR) {
4765         delete onSuccess;
4766         delete onFailure;
4767         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4768     }
4769 }
4770 - (void)moveToLevel:(uint8_t)level
4771        transitionTime:(uint16_t)transitionTime
4772            optionMask:(uint8_t)optionMask
4773        optionOverride:(uint8_t)optionOverride
4774     completionHandler:(ResponseHandler)completionHandler
4775 {
4776     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4777     if (!onSuccess) {
4778         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4779         return;
4780     }
4781
4782     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4783     if (!onFailure) {
4784         delete onSuccess;
4785         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4786         return;
4787     }
4788
4789     CHIP_ERROR err
4790         = self.cppCluster.MoveToLevel(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride);
4791     if (err != CHIP_NO_ERROR) {
4792         delete onSuccess;
4793         delete onFailure;
4794         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4795     }
4796 }
4797 - (void)moveToLevelWithOnOff:(uint8_t)level
4798               transitionTime:(uint16_t)transitionTime
4799            completionHandler:(ResponseHandler)completionHandler
4800 {
4801     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4802     if (!onSuccess) {
4803         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4804         return;
4805     }
4806
4807     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4808     if (!onFailure) {
4809         delete onSuccess;
4810         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4811         return;
4812     }
4813
4814     CHIP_ERROR err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime);
4815     if (err != CHIP_NO_ERROR) {
4816         delete onSuccess;
4817         delete onFailure;
4818         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4819     }
4820 }
4821 - (void)moveWithOnOff:(uint8_t)moveMode rate:(uint8_t)rate completionHandler:(ResponseHandler)completionHandler
4822 {
4823     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4824     if (!onSuccess) {
4825         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4826         return;
4827     }
4828
4829     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4830     if (!onFailure) {
4831         delete onSuccess;
4832         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4833         return;
4834     }
4835
4836     CHIP_ERROR err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate);
4837     if (err != CHIP_NO_ERROR) {
4838         delete onSuccess;
4839         delete onFailure;
4840         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4841     }
4842 }
4843 - (void)step:(uint8_t)stepMode
4844              stepSize:(uint8_t)stepSize
4845        transitionTime:(uint16_t)transitionTime
4846            optionMask:(uint8_t)optionMask
4847        optionOverride:(uint8_t)optionOverride
4848     completionHandler:(ResponseHandler)completionHandler
4849 {
4850     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4851     if (!onSuccess) {
4852         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4853         return;
4854     }
4855
4856     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4857     if (!onFailure) {
4858         delete onSuccess;
4859         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4860         return;
4861     }
4862
4863     CHIP_ERROR err = self.cppCluster.Step(
4864         onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride);
4865     if (err != CHIP_NO_ERROR) {
4866         delete onSuccess;
4867         delete onFailure;
4868         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4869     }
4870 }
4871 - (void)stepWithOnOff:(uint8_t)stepMode
4872              stepSize:(uint8_t)stepSize
4873        transitionTime:(uint16_t)transitionTime
4874     completionHandler:(ResponseHandler)completionHandler
4875 {
4876     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4877     if (!onSuccess) {
4878         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4879         return;
4880     }
4881
4882     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4883     if (!onFailure) {
4884         delete onSuccess;
4885         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4886         return;
4887     }
4888
4889     CHIP_ERROR err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime);
4890     if (err != CHIP_NO_ERROR) {
4891         delete onSuccess;
4892         delete onFailure;
4893         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4894     }
4895 }
4896 - (void)stop:(uint8_t)optionMask optionOverride:(uint8_t)optionOverride completionHandler:(ResponseHandler)completionHandler
4897 {
4898     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4899     if (!onSuccess) {
4900         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4901         return;
4902     }
4903
4904     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4905     if (!onFailure) {
4906         delete onSuccess;
4907         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4908         return;
4909     }
4910
4911     CHIP_ERROR err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride);
4912     if (err != CHIP_NO_ERROR) {
4913         delete onSuccess;
4914         delete onFailure;
4915         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4916     }
4917 }
4918 - (void)stopWithOnOff:(ResponseHandler)completionHandler
4919 {
4920     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4921     if (!onSuccess) {
4922         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4923         return;
4924     }
4925
4926     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4927     if (!onFailure) {
4928         delete onSuccess;
4929         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4930         return;
4931     }
4932
4933     CHIP_ERROR err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel());
4934     if (err != CHIP_NO_ERROR) {
4935         delete onSuccess;
4936         delete onFailure;
4937         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4938     }
4939 }
4940
4941 - (void)readAttributeCurrentLevel:(ResponseHandler)completionHandler
4942 {
4943     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
4944     if (!onSuccess) {
4945         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4946         return;
4947     }
4948
4949     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4950     if (!onFailure) {
4951         delete onSuccess;
4952         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4953         return;
4954     }
4955
4956     CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel());
4957     if (err != CHIP_NO_ERROR) {
4958         delete onSuccess;
4959         delete onFailure;
4960         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4961     }
4962 }
4963
4964 - (void)configureAttributeCurrentLevel:(uint16_t)minInterval
4965                            maxInterval:(uint16_t)maxInterval
4966                                 change:(uint8_t)change
4967                      completionHandler:(ResponseHandler)completionHandler
4968 {
4969     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
4970     if (!onSuccess) {
4971         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4972         return;
4973     }
4974
4975     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
4976     if (!onFailure) {
4977         delete onSuccess;
4978         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4979         return;
4980     }
4981
4982     CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentLevel(
4983         onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
4984     if (err != CHIP_NO_ERROR) {
4985         delete onSuccess;
4986         delete onFailure;
4987         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
4988     }
4989 }
4990
4991 - (void)reportAttributeCurrentLevel:(ResponseHandler)reportHandler
4992 {
4993     CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
4994     if (!onReport) {
4995         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
4996         return;
4997     }
4998
4999     CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel());
5000     if (err != CHIP_NO_ERROR) {
5001         delete onReport;
5002         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
5003     }
5004 }
5005
5006 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
5007 {
5008     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5009     if (!onSuccess) {
5010         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5011         return;
5012     }
5013
5014     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5015     if (!onFailure) {
5016         delete onSuccess;
5017         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5018         return;
5019     }
5020
5021     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
5022     if (err != CHIP_NO_ERROR) {
5023         delete onSuccess;
5024         delete onFailure;
5025         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5026     }
5027 }
5028
5029 @end
5030
5031 @interface CHIPLowPower ()
5032 @property (readonly) Controller::LowPowerCluster cppCluster;
5033 @end
5034
5035 @implementation CHIPLowPower
5036
5037 - (Controller::ClusterBase *)getCluster
5038 {
5039     return &_cppCluster;
5040 }
5041
5042 - (void)sleep:(ResponseHandler)completionHandler
5043 {
5044     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5045     if (!onSuccess) {
5046         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5047         return;
5048     }
5049
5050     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5051     if (!onFailure) {
5052         delete onSuccess;
5053         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5054         return;
5055     }
5056
5057     CHIP_ERROR err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel());
5058     if (err != CHIP_NO_ERROR) {
5059         delete onSuccess;
5060         delete onFailure;
5061         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5062     }
5063 }
5064
5065 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
5066 {
5067     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5068     if (!onSuccess) {
5069         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5070         return;
5071     }
5072
5073     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5074     if (!onFailure) {
5075         delete onSuccess;
5076         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5077         return;
5078     }
5079
5080     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
5081     if (err != CHIP_NO_ERROR) {
5082         delete onSuccess;
5083         delete onFailure;
5084         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5085     }
5086 }
5087
5088 @end
5089
5090 @interface CHIPMediaPlayback ()
5091 @property (readonly) Controller::MediaPlaybackCluster cppCluster;
5092 @end
5093
5094 @implementation CHIPMediaPlayback
5095
5096 - (Controller::ClusterBase *)getCluster
5097 {
5098     return &_cppCluster;
5099 }
5100
5101 - (void)fastForwardRequest:(ResponseHandler)completionHandler
5102 {
5103     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5104     if (!onSuccess) {
5105         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5106         return;
5107     }
5108
5109     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5110     if (!onFailure) {
5111         delete onSuccess;
5112         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5113         return;
5114     }
5115
5116     CHIP_ERROR err = self.cppCluster.FastForwardRequest(onSuccess->Cancel(), onFailure->Cancel());
5117     if (err != CHIP_NO_ERROR) {
5118         delete onSuccess;
5119         delete onFailure;
5120         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5121     }
5122 }
5123 - (void)nextRequest:(ResponseHandler)completionHandler
5124 {
5125     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5126     if (!onSuccess) {
5127         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5128         return;
5129     }
5130
5131     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5132     if (!onFailure) {
5133         delete onSuccess;
5134         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5135         return;
5136     }
5137
5138     CHIP_ERROR err = self.cppCluster.NextRequest(onSuccess->Cancel(), onFailure->Cancel());
5139     if (err != CHIP_NO_ERROR) {
5140         delete onSuccess;
5141         delete onFailure;
5142         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5143     }
5144 }
5145 - (void)pauseRequest:(ResponseHandler)completionHandler
5146 {
5147     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5148     if (!onSuccess) {
5149         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5150         return;
5151     }
5152
5153     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5154     if (!onFailure) {
5155         delete onSuccess;
5156         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5157         return;
5158     }
5159
5160     CHIP_ERROR err = self.cppCluster.PauseRequest(onSuccess->Cancel(), onFailure->Cancel());
5161     if (err != CHIP_NO_ERROR) {
5162         delete onSuccess;
5163         delete onFailure;
5164         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5165     }
5166 }
5167 - (void)playRequest:(ResponseHandler)completionHandler
5168 {
5169     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5170     if (!onSuccess) {
5171         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5172         return;
5173     }
5174
5175     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5176     if (!onFailure) {
5177         delete onSuccess;
5178         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5179         return;
5180     }
5181
5182     CHIP_ERROR err = self.cppCluster.PlayRequest(onSuccess->Cancel(), onFailure->Cancel());
5183     if (err != CHIP_NO_ERROR) {
5184         delete onSuccess;
5185         delete onFailure;
5186         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5187     }
5188 }
5189 - (void)previousRequest:(ResponseHandler)completionHandler
5190 {
5191     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5192     if (!onSuccess) {
5193         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5194         return;
5195     }
5196
5197     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5198     if (!onFailure) {
5199         delete onSuccess;
5200         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5201         return;
5202     }
5203
5204     CHIP_ERROR err = self.cppCluster.PreviousRequest(onSuccess->Cancel(), onFailure->Cancel());
5205     if (err != CHIP_NO_ERROR) {
5206         delete onSuccess;
5207         delete onFailure;
5208         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5209     }
5210 }
5211 - (void)rewindRequest:(ResponseHandler)completionHandler
5212 {
5213     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5214     if (!onSuccess) {
5215         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5216         return;
5217     }
5218
5219     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5220     if (!onFailure) {
5221         delete onSuccess;
5222         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5223         return;
5224     }
5225
5226     CHIP_ERROR err = self.cppCluster.RewindRequest(onSuccess->Cancel(), onFailure->Cancel());
5227     if (err != CHIP_NO_ERROR) {
5228         delete onSuccess;
5229         delete onFailure;
5230         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5231     }
5232 }
5233 - (void)skipBackwardRequest:(ResponseHandler)completionHandler
5234 {
5235     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5236     if (!onSuccess) {
5237         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5238         return;
5239     }
5240
5241     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5242     if (!onFailure) {
5243         delete onSuccess;
5244         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5245         return;
5246     }
5247
5248     CHIP_ERROR err = self.cppCluster.SkipBackwardRequest(onSuccess->Cancel(), onFailure->Cancel());
5249     if (err != CHIP_NO_ERROR) {
5250         delete onSuccess;
5251         delete onFailure;
5252         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5253     }
5254 }
5255 - (void)skipForwardRequest:(ResponseHandler)completionHandler
5256 {
5257     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5258     if (!onSuccess) {
5259         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5260         return;
5261     }
5262
5263     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5264     if (!onFailure) {
5265         delete onSuccess;
5266         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5267         return;
5268     }
5269
5270     CHIP_ERROR err = self.cppCluster.SkipForwardRequest(onSuccess->Cancel(), onFailure->Cancel());
5271     if (err != CHIP_NO_ERROR) {
5272         delete onSuccess;
5273         delete onFailure;
5274         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5275     }
5276 }
5277 - (void)startOverRequest:(ResponseHandler)completionHandler
5278 {
5279     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5280     if (!onSuccess) {
5281         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5282         return;
5283     }
5284
5285     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5286     if (!onFailure) {
5287         delete onSuccess;
5288         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5289         return;
5290     }
5291
5292     CHIP_ERROR err = self.cppCluster.StartOverRequest(onSuccess->Cancel(), onFailure->Cancel());
5293     if (err != CHIP_NO_ERROR) {
5294         delete onSuccess;
5295         delete onFailure;
5296         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5297     }
5298 }
5299 - (void)stopRequest:(ResponseHandler)completionHandler
5300 {
5301     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5302     if (!onSuccess) {
5303         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5304         return;
5305     }
5306
5307     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5308     if (!onFailure) {
5309         delete onSuccess;
5310         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5311         return;
5312     }
5313
5314     CHIP_ERROR err = self.cppCluster.StopRequest(onSuccess->Cancel(), onFailure->Cancel());
5315     if (err != CHIP_NO_ERROR) {
5316         delete onSuccess;
5317         delete onFailure;
5318         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5319     }
5320 }
5321
5322 - (void)readAttributeCurrentState:(ResponseHandler)completionHandler
5323 {
5324     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5325     if (!onSuccess) {
5326         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5327         return;
5328     }
5329
5330     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5331     if (!onFailure) {
5332         delete onSuccess;
5333         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5334         return;
5335     }
5336
5337     CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentState(onSuccess->Cancel(), onFailure->Cancel());
5338     if (err != CHIP_NO_ERROR) {
5339         delete onSuccess;
5340         delete onFailure;
5341         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5342     }
5343 }
5344
5345 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
5346 {
5347     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5348     if (!onSuccess) {
5349         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5350         return;
5351     }
5352
5353     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5354     if (!onFailure) {
5355         delete onSuccess;
5356         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5357         return;
5358     }
5359
5360     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
5361     if (err != CHIP_NO_ERROR) {
5362         delete onSuccess;
5363         delete onFailure;
5364         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5365     }
5366 }
5367
5368 @end
5369
5370 @interface CHIPOnOff ()
5371 @property (readonly) Controller::OnOffCluster cppCluster;
5372 @end
5373
5374 @implementation CHIPOnOff
5375
5376 - (Controller::ClusterBase *)getCluster
5377 {
5378     return &_cppCluster;
5379 }
5380
5381 - (void)off:(ResponseHandler)completionHandler
5382 {
5383     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5384     if (!onSuccess) {
5385         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5386         return;
5387     }
5388
5389     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5390     if (!onFailure) {
5391         delete onSuccess;
5392         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5393         return;
5394     }
5395
5396     CHIP_ERROR err = self.cppCluster.Off(onSuccess->Cancel(), onFailure->Cancel());
5397     if (err != CHIP_NO_ERROR) {
5398         delete onSuccess;
5399         delete onFailure;
5400         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5401     }
5402 }
5403 - (void)on:(ResponseHandler)completionHandler
5404 {
5405     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5406     if (!onSuccess) {
5407         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5408         return;
5409     }
5410
5411     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5412     if (!onFailure) {
5413         delete onSuccess;
5414         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5415         return;
5416     }
5417
5418     CHIP_ERROR err = self.cppCluster.On(onSuccess->Cancel(), onFailure->Cancel());
5419     if (err != CHIP_NO_ERROR) {
5420         delete onSuccess;
5421         delete onFailure;
5422         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5423     }
5424 }
5425 - (void)toggle:(ResponseHandler)completionHandler
5426 {
5427     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5428     if (!onSuccess) {
5429         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5430         return;
5431     }
5432
5433     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5434     if (!onFailure) {
5435         delete onSuccess;
5436         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5437         return;
5438     }
5439
5440     CHIP_ERROR err = self.cppCluster.Toggle(onSuccess->Cancel(), onFailure->Cancel());
5441     if (err != CHIP_NO_ERROR) {
5442         delete onSuccess;
5443         delete onFailure;
5444         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5445     }
5446 }
5447
5448 - (void)readAttributeOnOff:(ResponseHandler)completionHandler
5449 {
5450     CHIPBooleanAttributeCallbackBridge * onSuccess
5451         = new CHIPBooleanAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5452     if (!onSuccess) {
5453         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5454         return;
5455     }
5456
5457     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5458     if (!onFailure) {
5459         delete onSuccess;
5460         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5461         return;
5462     }
5463
5464     CHIP_ERROR err = self.cppCluster.ReadAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel());
5465     if (err != CHIP_NO_ERROR) {
5466         delete onSuccess;
5467         delete onFailure;
5468         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5469     }
5470 }
5471
5472 - (void)configureAttributeOnOff:(uint16_t)minInterval
5473                     maxInterval:(uint16_t)maxInterval
5474               completionHandler:(ResponseHandler)completionHandler
5475 {
5476     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5477     if (!onSuccess) {
5478         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5479         return;
5480     }
5481
5482     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5483     if (!onFailure) {
5484         delete onSuccess;
5485         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5486         return;
5487     }
5488
5489     CHIP_ERROR err = self.cppCluster.ConfigureAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
5490     if (err != CHIP_NO_ERROR) {
5491         delete onSuccess;
5492         delete onFailure;
5493         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5494     }
5495 }
5496
5497 - (void)reportAttributeOnOff:(ResponseHandler)reportHandler
5498 {
5499     CHIPBooleanAttributeCallbackBridge * onReport
5500         = new CHIPBooleanAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
5501     if (!onReport) {
5502         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5503         return;
5504     }
5505
5506     CHIP_ERROR err = self.cppCluster.ReportAttributeOnOff(onReport->Cancel());
5507     if (err != CHIP_NO_ERROR) {
5508         delete onReport;
5509         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
5510     }
5511 }
5512
5513 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
5514 {
5515     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5516     if (!onSuccess) {
5517         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5518         return;
5519     }
5520
5521     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5522     if (!onFailure) {
5523         delete onSuccess;
5524         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5525         return;
5526     }
5527
5528     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
5529     if (err != CHIP_NO_ERROR) {
5530         delete onSuccess;
5531         delete onFailure;
5532         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5533     }
5534 }
5535
5536 @end
5537
5538 @interface CHIPScenes ()
5539 @property (readonly) Controller::ScenesCluster cppCluster;
5540 @end
5541
5542 @implementation CHIPScenes
5543
5544 - (Controller::ClusterBase *)getCluster
5545 {
5546     return &_cppCluster;
5547 }
5548
5549 - (void)addScene:(uint16_t)groupId
5550               sceneId:(uint8_t)sceneId
5551        transitionTime:(uint16_t)transitionTime
5552             sceneName:(NSString *)sceneName
5553             clusterId:(uint16_t)clusterId
5554                length:(uint8_t)length
5555                 value:(uint8_t)value
5556     completionHandler:(ResponseHandler)completionHandler
5557 {
5558     CHIPScenesClusterAddSceneResponseCallbackBridge * onSuccess
5559         = new CHIPScenesClusterAddSceneResponseCallbackBridge(completionHandler, [self callbackQueue]);
5560     if (!onSuccess) {
5561         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5562         return;
5563     }
5564
5565     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5566     if (!onFailure) {
5567         delete onSuccess;
5568         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5569         return;
5570     }
5571
5572     CHIP_ERROR err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime,
5573         chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes,
5574             [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
5575         clusterId, length, value);
5576     if (err != CHIP_NO_ERROR) {
5577         delete onSuccess;
5578         delete onFailure;
5579         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5580     }
5581 }
5582 - (void)getSceneMembership:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler
5583 {
5584     CHIPScenesClusterGetSceneMembershipResponseCallbackBridge * onSuccess
5585         = new CHIPScenesClusterGetSceneMembershipResponseCallbackBridge(completionHandler, [self callbackQueue]);
5586     if (!onSuccess) {
5587         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5588         return;
5589     }
5590
5591     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5592     if (!onFailure) {
5593         delete onSuccess;
5594         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5595         return;
5596     }
5597
5598     CHIP_ERROR err = self.cppCluster.GetSceneMembership(onSuccess->Cancel(), onFailure->Cancel(), groupId);
5599     if (err != CHIP_NO_ERROR) {
5600         delete onSuccess;
5601         delete onFailure;
5602         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5603     }
5604 }
5605 - (void)recallScene:(uint16_t)groupId
5606               sceneId:(uint8_t)sceneId
5607        transitionTime:(uint16_t)transitionTime
5608     completionHandler:(ResponseHandler)completionHandler
5609 {
5610     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5611     if (!onSuccess) {
5612         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5613         return;
5614     }
5615
5616     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5617     if (!onFailure) {
5618         delete onSuccess;
5619         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5620         return;
5621     }
5622
5623     CHIP_ERROR err = self.cppCluster.RecallScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime);
5624     if (err != CHIP_NO_ERROR) {
5625         delete onSuccess;
5626         delete onFailure;
5627         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5628     }
5629 }
5630 - (void)removeAllScenes:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler
5631 {
5632     CHIPScenesClusterRemoveAllScenesResponseCallbackBridge * onSuccess
5633         = new CHIPScenesClusterRemoveAllScenesResponseCallbackBridge(completionHandler, [self callbackQueue]);
5634     if (!onSuccess) {
5635         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5636         return;
5637     }
5638
5639     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5640     if (!onFailure) {
5641         delete onSuccess;
5642         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5643         return;
5644     }
5645
5646     CHIP_ERROR err = self.cppCluster.RemoveAllScenes(onSuccess->Cancel(), onFailure->Cancel(), groupId);
5647     if (err != CHIP_NO_ERROR) {
5648         delete onSuccess;
5649         delete onFailure;
5650         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5651     }
5652 }
5653 - (void)removeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler:(ResponseHandler)completionHandler
5654 {
5655     CHIPScenesClusterRemoveSceneResponseCallbackBridge * onSuccess
5656         = new CHIPScenesClusterRemoveSceneResponseCallbackBridge(completionHandler, [self callbackQueue]);
5657     if (!onSuccess) {
5658         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5659         return;
5660     }
5661
5662     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5663     if (!onFailure) {
5664         delete onSuccess;
5665         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5666         return;
5667     }
5668
5669     CHIP_ERROR err = self.cppCluster.RemoveScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId);
5670     if (err != CHIP_NO_ERROR) {
5671         delete onSuccess;
5672         delete onFailure;
5673         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5674     }
5675 }
5676 - (void)storeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler:(ResponseHandler)completionHandler
5677 {
5678     CHIPScenesClusterStoreSceneResponseCallbackBridge * onSuccess
5679         = new CHIPScenesClusterStoreSceneResponseCallbackBridge(completionHandler, [self callbackQueue]);
5680     if (!onSuccess) {
5681         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5682         return;
5683     }
5684
5685     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5686     if (!onFailure) {
5687         delete onSuccess;
5688         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5689         return;
5690     }
5691
5692     CHIP_ERROR err = self.cppCluster.StoreScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId);
5693     if (err != CHIP_NO_ERROR) {
5694         delete onSuccess;
5695         delete onFailure;
5696         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5697     }
5698 }
5699 - (void)viewScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler:(ResponseHandler)completionHandler
5700 {
5701     CHIPScenesClusterViewSceneResponseCallbackBridge * onSuccess
5702         = new CHIPScenesClusterViewSceneResponseCallbackBridge(completionHandler, [self callbackQueue]);
5703     if (!onSuccess) {
5704         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5705         return;
5706     }
5707
5708     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5709     if (!onFailure) {
5710         delete onSuccess;
5711         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5712         return;
5713     }
5714
5715     CHIP_ERROR err = self.cppCluster.ViewScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId);
5716     if (err != CHIP_NO_ERROR) {
5717         delete onSuccess;
5718         delete onFailure;
5719         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5720     }
5721 }
5722
5723 - (void)readAttributeSceneCount:(ResponseHandler)completionHandler
5724 {
5725     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5726     if (!onSuccess) {
5727         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5728         return;
5729     }
5730
5731     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5732     if (!onFailure) {
5733         delete onSuccess;
5734         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5735         return;
5736     }
5737
5738     CHIP_ERROR err = self.cppCluster.ReadAttributeSceneCount(onSuccess->Cancel(), onFailure->Cancel());
5739     if (err != CHIP_NO_ERROR) {
5740         delete onSuccess;
5741         delete onFailure;
5742         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5743     }
5744 }
5745
5746 - (void)readAttributeCurrentScene:(ResponseHandler)completionHandler
5747 {
5748     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5749     if (!onSuccess) {
5750         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5751         return;
5752     }
5753
5754     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5755     if (!onFailure) {
5756         delete onSuccess;
5757         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5758         return;
5759     }
5760
5761     CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentScene(onSuccess->Cancel(), onFailure->Cancel());
5762     if (err != CHIP_NO_ERROR) {
5763         delete onSuccess;
5764         delete onFailure;
5765         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5766     }
5767 }
5768
5769 - (void)readAttributeCurrentGroup:(ResponseHandler)completionHandler
5770 {
5771     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5772     if (!onSuccess) {
5773         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5774         return;
5775     }
5776
5777     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5778     if (!onFailure) {
5779         delete onSuccess;
5780         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5781         return;
5782     }
5783
5784     CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentGroup(onSuccess->Cancel(), onFailure->Cancel());
5785     if (err != CHIP_NO_ERROR) {
5786         delete onSuccess;
5787         delete onFailure;
5788         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5789     }
5790 }
5791
5792 - (void)readAttributeSceneValid:(ResponseHandler)completionHandler
5793 {
5794     CHIPBooleanAttributeCallbackBridge * onSuccess
5795         = new CHIPBooleanAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5796     if (!onSuccess) {
5797         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5798         return;
5799     }
5800
5801     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5802     if (!onFailure) {
5803         delete onSuccess;
5804         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5805         return;
5806     }
5807
5808     CHIP_ERROR err = self.cppCluster.ReadAttributeSceneValid(onSuccess->Cancel(), onFailure->Cancel());
5809     if (err != CHIP_NO_ERROR) {
5810         delete onSuccess;
5811         delete onFailure;
5812         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5813     }
5814 }
5815
5816 - (void)readAttributeNameSupport:(ResponseHandler)completionHandler
5817 {
5818     CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5819     if (!onSuccess) {
5820         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5821         return;
5822     }
5823
5824     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5825     if (!onFailure) {
5826         delete onSuccess;
5827         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5828         return;
5829     }
5830
5831     CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel());
5832     if (err != CHIP_NO_ERROR) {
5833         delete onSuccess;
5834         delete onFailure;
5835         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5836     }
5837 }
5838
5839 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
5840 {
5841     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5842     if (!onSuccess) {
5843         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5844         return;
5845     }
5846
5847     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5848     if (!onFailure) {
5849         delete onSuccess;
5850         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5851         return;
5852     }
5853
5854     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
5855     if (err != CHIP_NO_ERROR) {
5856         delete onSuccess;
5857         delete onFailure;
5858         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5859     }
5860 }
5861
5862 @end
5863
5864 @interface CHIPTemperatureMeasurement ()
5865 @property (readonly) Controller::TemperatureMeasurementCluster cppCluster;
5866 @end
5867
5868 @implementation CHIPTemperatureMeasurement
5869
5870 - (Controller::ClusterBase *)getCluster
5871 {
5872     return &_cppCluster;
5873 }
5874
5875 - (void)readAttributeMeasuredValue:(ResponseHandler)completionHandler
5876 {
5877     CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5878     if (!onSuccess) {
5879         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5880         return;
5881     }
5882
5883     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5884     if (!onFailure) {
5885         delete onSuccess;
5886         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5887         return;
5888     }
5889
5890     CHIP_ERROR err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
5891     if (err != CHIP_NO_ERROR) {
5892         delete onSuccess;
5893         delete onFailure;
5894         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5895     }
5896 }
5897
5898 - (void)configureAttributeMeasuredValue:(uint16_t)minInterval
5899                             maxInterval:(uint16_t)maxInterval
5900                                  change:(int16_t)change
5901                       completionHandler:(ResponseHandler)completionHandler
5902 {
5903     CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
5904     if (!onSuccess) {
5905         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5906         return;
5907     }
5908
5909     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5910     if (!onFailure) {
5911         delete onSuccess;
5912         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5913         return;
5914     }
5915
5916     CHIP_ERROR err = self.cppCluster.ConfigureAttributeMeasuredValue(
5917         onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
5918     if (err != CHIP_NO_ERROR) {
5919         delete onSuccess;
5920         delete onFailure;
5921         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5922     }
5923 }
5924
5925 - (void)reportAttributeMeasuredValue:(ResponseHandler)reportHandler
5926 {
5927     CHIPInt16sAttributeCallbackBridge * onReport = new CHIPInt16sAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
5928     if (!onReport) {
5929         reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5930         return;
5931     }
5932
5933     CHIP_ERROR err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel());
5934     if (err != CHIP_NO_ERROR) {
5935         delete onReport;
5936         reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
5937     }
5938 }
5939
5940 - (void)readAttributeMinMeasuredValue:(ResponseHandler)completionHandler
5941 {
5942     CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5943     if (!onSuccess) {
5944         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5945         return;
5946     }
5947
5948     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5949     if (!onFailure) {
5950         delete onSuccess;
5951         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5952         return;
5953     }
5954
5955     CHIP_ERROR err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
5956     if (err != CHIP_NO_ERROR) {
5957         delete onSuccess;
5958         delete onFailure;
5959         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5960     }
5961 }
5962
5963 - (void)readAttributeMaxMeasuredValue:(ResponseHandler)completionHandler
5964 {
5965     CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5966     if (!onSuccess) {
5967         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5968         return;
5969     }
5970
5971     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5972     if (!onFailure) {
5973         delete onSuccess;
5974         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5975         return;
5976     }
5977
5978     CHIP_ERROR err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
5979     if (err != CHIP_NO_ERROR) {
5980         delete onSuccess;
5981         delete onFailure;
5982         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
5983     }
5984 }
5985
5986 - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler
5987 {
5988     CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]);
5989     if (!onSuccess) {
5990         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5991         return;
5992     }
5993
5994     CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
5995     if (!onFailure) {
5996         delete onSuccess;
5997         completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
5998         return;
5999     }
6000
6001     CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
6002     if (err != CHIP_NO_ERROR) {
6003         delete onSuccess;
6004         delete onFailure;
6005         completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
6006     }
6007 }
6008
6009 @end