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