diff --git a/examples/chip-tool/gen/CHIPClustersObjc.mm b/examples/chip-tool/gen/CHIPClustersObjc.mm index c3f896b91ca2a4..5d074bcd7ee101 100644 --- a/examples/chip-tool/gen/CHIPClustersObjc.mm +++ b/examples/chip-tool/gen/CHIPClustersObjc.mm @@ -28,6 +28,7 @@ #include #include +#include using namespace ::chip; @@ -2180,6 +2181,7 @@ static void CallbackFn(void * context, uint16_t count, _FabricDescriptor * entri @interface CHIPCluster () @property (readonly, nonatomic) dispatch_queue_t callbackQueue; +@property (readonly, nonatomic) dispatch_queue_t chipWorkQueue; - (Controller::ClusterBase *)getCluster; @end @@ -2197,6 +2199,11 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin return nil; } + _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); + if (_chipWorkQueue == nil) { + return nil; + } + _callbackQueue = queue; } return self; @@ -2235,7 +2242,11 @@ - (void)readAttributeVendorName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2258,7 +2269,11 @@ - (void)readAttributeVendorId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2282,7 +2297,11 @@ - (void)readAttributeApplicationName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2305,7 +2324,11 @@ - (void)readAttributeProductId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2329,7 +2352,11 @@ - (void)readAttributeApplicationId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2352,7 +2379,11 @@ - (void)readAttributeCatalogVendorId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2375,7 +2406,11 @@ - (void)readAttributeApplicationSatus:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2398,7 +2433,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2434,7 +2473,11 @@ - (void)barrierControlGoToPercent:(uint8_t)percentOpen completionHandler:(Respon return; } - CHIP_ERROR err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2456,7 +2499,11 @@ - (void)barrierControlStop:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2479,7 +2526,11 @@ - (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2502,7 +2553,11 @@ - (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2525,7 +2580,11 @@ - (void)readAttributeBarrierCapabilities:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2548,7 +2607,11 @@ - (void)readAttributeBarrierPosition:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2571,7 +2634,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2607,7 +2674,11 @@ - (void)mfgSpecificPing:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2630,7 +2701,11 @@ - (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2654,7 +2729,11 @@ - (void)readAttributeVendorName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2677,7 +2756,11 @@ - (void)readAttributeVendorID:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2701,7 +2784,11 @@ - (void)readAttributeProductName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2724,7 +2811,11 @@ - (void)readAttributeProductID:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2748,7 +2839,11 @@ - (void)readAttributeUserLabel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2771,9 +2866,13 @@ - (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHan return; } - NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; - CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( - onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2797,7 +2896,11 @@ - (void)readAttributeLocation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2820,9 +2923,13 @@ - (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHand return; } - NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; - CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( - onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2845,7 +2952,11 @@ - (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2869,7 +2980,11 @@ - (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2892,7 +3007,11 @@ - (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2916,7 +3035,11 @@ - (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2940,7 +3063,11 @@ - (void)readAttributeManufacturingDate:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeManufacturingDate(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeManufacturingDate(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2964,7 +3091,11 @@ - (void)readAttributePartNumber:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePartNumber(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePartNumber(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2988,7 +3119,11 @@ - (void)readAttributeProductURL:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductURL(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductURL(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3012,7 +3147,11 @@ - (void)readAttributeProductLabel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductLabel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductLabel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3036,7 +3175,11 @@ - (void)readAttributeSerialNumber:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSerialNumber(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSerialNumber(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3060,7 +3203,11 @@ - (void)readAttributeLocalConfigDisabled:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3083,7 +3230,11 @@ - (void)writeAttributeLocalConfigDisabled:(uint8_t)value completionHandler:(Resp return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3106,7 +3257,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3146,7 +3301,11 @@ - (void)bind:(uint64_t)nodeId return; } - CHIP_ERROR err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3172,7 +3331,11 @@ - (void)unbind:(uint64_t)nodeId return; } - CHIP_ERROR err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3195,7 +3358,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3235,8 +3402,11 @@ - (void)moveColor:(int16_t)rateX return; } - CHIP_ERROR err - = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3264,8 +3434,12 @@ - (void)moveColorTemperature:(uint8_t)moveMode return; } - CHIP_ERROR err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, - colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, + colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3291,8 +3465,11 @@ - (void)moveHue:(uint8_t)moveMode return; } - CHIP_ERROR err - = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3318,8 +3495,12 @@ - (void)moveSaturation:(uint8_t)moveMode return; } - CHIP_ERROR err - = self.cppCluster.MoveSaturation(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveSaturation( + onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3346,8 +3527,12 @@ - (void)moveToColor:(uint16_t)colorX return; } - CHIP_ERROR err = self.cppCluster.MoveToColor( - onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToColor( + onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3373,8 +3558,12 @@ - (void)moveToColorTemperature:(uint16_t)colorTemperature return; } - CHIP_ERROR err = self.cppCluster.MoveToColorTemperature( - onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToColorTemperature( + onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3401,8 +3590,12 @@ - (void)moveToHue:(uint8_t)hue return; } - CHIP_ERROR err = self.cppCluster.MoveToHue( - onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToHue( + onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3429,8 +3622,12 @@ - (void)moveToHueAndSaturation:(uint8_t)hue return; } - CHIP_ERROR err = self.cppCluster.MoveToHueAndSaturation( - onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToHueAndSaturation( + onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3456,8 +3653,12 @@ - (void)moveToSaturation:(uint8_t)saturation return; } - CHIP_ERROR err = self.cppCluster.MoveToSaturation( - onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToSaturation( + onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3484,8 +3685,12 @@ - (void)stepColor:(int16_t)stepX return; } - CHIP_ERROR err = self.cppCluster.StepColor( - onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepColor( + onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3514,8 +3719,12 @@ - (void)stepColorTemperature:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, - transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, + colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3542,8 +3751,12 @@ - (void)stepHue:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepHue( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepHue( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3570,8 +3783,12 @@ - (void)stepSaturation:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepSaturation( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepSaturation( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3595,7 +3812,11 @@ - (void)stopMoveStep:(uint8_t)optionsMask return; } - CHIP_ERROR err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3618,7 +3839,11 @@ - (void)readAttributeCurrentHue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3644,8 +3869,12 @@ - (void)configureAttributeCurrentHue:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentHue( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3661,7 +3890,11 @@ - (void)reportAttributeCurrentHue:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3683,7 +3916,11 @@ - (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3709,8 +3946,12 @@ - (void)configureAttributeCurrentSaturation:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentSaturation( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentSaturation( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3726,7 +3967,11 @@ - (void)reportAttributeCurrentSaturation:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3748,7 +3993,11 @@ - (void)readAttributeRemainingTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3771,7 +4020,11 @@ - (void)readAttributeCurrentX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3797,8 +4050,12 @@ - (void)configureAttributeCurrentX:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentX( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3814,7 +4071,11 @@ - (void)reportAttributeCurrentX:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3836,7 +4097,11 @@ - (void)readAttributeCurrentY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3862,8 +4127,12 @@ - (void)configureAttributeCurrentY:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentY( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3879,7 +4148,11 @@ - (void)reportAttributeCurrentY:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3901,7 +4174,11 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3925,7 +4202,11 @@ - (void)readAttributeCompensationText:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3948,7 +4229,11 @@ - (void)readAttributeColorTemperature:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3974,8 +4259,12 @@ - (void)configureAttributeColorTemperature:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeColorTemperature( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeColorTemperature( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3991,7 +4280,11 @@ - (void)reportAttributeColorTemperature:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -4013,7 +4306,11 @@ - (void)readAttributeColorMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4036,7 +4333,11 @@ - (void)readAttributeColorControlOptions:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4059,7 +4360,11 @@ - (void)writeAttributeColorControlOptions:(uint8_t)value completionHandler:(Resp return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4082,7 +4387,11 @@ - (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4105,7 +4414,11 @@ - (void)readAttributePrimary1X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4128,7 +4441,11 @@ - (void)readAttributePrimary1Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4151,7 +4468,11 @@ - (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4174,7 +4495,11 @@ - (void)readAttributePrimary2X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4197,7 +4522,11 @@ - (void)readAttributePrimary2Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4220,7 +4549,11 @@ - (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4243,7 +4576,11 @@ - (void)readAttributePrimary3X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4266,7 +4603,11 @@ - (void)readAttributePrimary3Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4289,7 +4630,11 @@ - (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4312,7 +4657,11 @@ - (void)readAttributePrimary4X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4335,7 +4684,11 @@ - (void)readAttributePrimary4Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4358,7 +4711,11 @@ - (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4381,7 +4738,11 @@ - (void)readAttributePrimary5X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4404,7 +4765,11 @@ - (void)readAttributePrimary5Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4427,7 +4792,11 @@ - (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4450,7 +4819,11 @@ - (void)readAttributePrimary6X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4473,7 +4846,11 @@ - (void)readAttributePrimary6Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4496,7 +4873,11 @@ - (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4519,7 +4900,11 @@ - (void)readAttributeWhitePointX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4542,7 +4927,11 @@ - (void)writeAttributeWhitePointX:(uint16_t)value completionHandler:(ResponseHan return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4565,7 +4954,11 @@ - (void)readAttributeWhitePointY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4588,7 +4981,11 @@ - (void)writeAttributeWhitePointY:(uint16_t)value completionHandler:(ResponseHan return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4611,7 +5008,11 @@ - (void)readAttributeColorPointRX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4634,7 +5035,11 @@ - (void)writeAttributeColorPointRX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4657,7 +5062,11 @@ - (void)readAttributeColorPointRY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4680,7 +5089,11 @@ - (void)writeAttributeColorPointRY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4703,7 +5116,11 @@ - (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4726,7 +5143,11 @@ - (void)writeAttributeColorPointRIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4749,7 +5170,11 @@ - (void)readAttributeColorPointGX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4772,7 +5197,11 @@ - (void)writeAttributeColorPointGX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4795,7 +5224,11 @@ - (void)readAttributeColorPointGY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4818,7 +5251,11 @@ - (void)writeAttributeColorPointGY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4841,7 +5278,11 @@ - (void)readAttributeColorPointGIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4864,7 +5305,11 @@ - (void)writeAttributeColorPointGIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4887,7 +5332,11 @@ - (void)readAttributeColorPointBX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4910,7 +5359,11 @@ - (void)writeAttributeColorPointBX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4933,7 +5386,11 @@ - (void)readAttributeColorPointBY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4956,7 +5413,11 @@ - (void)writeAttributeColorPointBY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4979,7 +5440,11 @@ - (void)readAttributeColorPointBIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5002,7 +5467,11 @@ - (void)writeAttributeColorPointBIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5025,7 +5494,11 @@ - (void)readAttributeEnhancedCurrentHue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5048,7 +5521,11 @@ - (void)readAttributeEnhancedColorMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5071,7 +5548,11 @@ - (void)readAttributeColorLoopActive:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5094,7 +5575,11 @@ - (void)readAttributeColorLoopDirection:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5117,7 +5602,11 @@ - (void)readAttributeColorLoopTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5140,7 +5629,11 @@ - (void)readAttributeColorCapabilities:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5163,7 +5656,11 @@ - (void)readAttributeColorTempPhysicalMin:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5186,7 +5683,11 @@ - (void)readAttributeColorTempPhysicalMax:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5209,7 +5710,11 @@ - (void)readAttributeCoupleColorTempToLevelMinMireds:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5232,7 +5737,11 @@ - (void)readAttributeStartUpColorTemperatureMireds:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5255,7 +5764,11 @@ - (void)writeAttributeStartUpColorTemperatureMireds:(uint16_t)value completionHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5278,7 +5791,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5315,7 +5832,11 @@ - (void)readAttributeDeviceList:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeDeviceList(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeDeviceList(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5339,7 +5860,11 @@ - (void)readAttributeServerList:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeServerList(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeServerList(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5363,7 +5888,11 @@ - (void)readAttributeClientList:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClientList(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClientList(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5387,7 +5916,11 @@ - (void)readAttributePartsList:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePartsList(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePartsList(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5410,7 +5943,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5447,7 +5984,11 @@ - (void)clearAllPins:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5470,7 +6011,11 @@ - (void)clearAllRfids:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5493,7 +6038,11 @@ - (void)clearHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHand return; } - CHIP_ERROR err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5516,7 +6065,11 @@ - (void)clearPin:(uint16_t)userId completionHandler:(ResponseHandler)completionH return; } - CHIP_ERROR err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5539,7 +6092,11 @@ - (void)clearRfid:(uint16_t)userId completionHandler:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5562,7 +6119,11 @@ - (void)clearWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId complet return; } - CHIP_ERROR err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5585,7 +6146,11 @@ - (void)clearYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId complet return; } - CHIP_ERROR err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5608,7 +6173,11 @@ - (void)getHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandle return; } - CHIP_ERROR err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5631,7 +6200,11 @@ - (void)getLogRecord:(uint16_t)logIndex completionHandler:(ResponseHandler)compl return; } - CHIP_ERROR err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5654,7 +6227,11 @@ - (void)getPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHan return; } - CHIP_ERROR err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5677,7 +6254,11 @@ - (void)getRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5700,7 +6281,11 @@ - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completi return; } - CHIP_ERROR err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5723,7 +6308,11 @@ - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio return; } - CHIP_ERROR err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5746,7 +6335,11 @@ - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio return; } - CHIP_ERROR err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5769,9 +6362,13 @@ - (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5798,8 +6395,12 @@ - (void)setHolidaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetHolidaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetHolidaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5826,9 +6427,13 @@ - (void)setPin:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5855,9 +6460,13 @@ - (void)setRfid:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, - chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, - [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, + [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5880,7 +6489,11 @@ - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandle return; } - CHIP_ERROR err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5910,8 +6523,12 @@ - (void)setWeekdaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetWeekdaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetWeekdaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5938,8 +6555,12 @@ - (void)setYeardaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetYeardaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetYeardaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5962,9 +6583,13 @@ - (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5987,9 +6612,13 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin complet return; } - CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6012,7 +6641,11 @@ - (void)readAttributeLockState:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6037,8 +6670,11 @@ - (void)configureAttributeLockState:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6054,7 +6690,11 @@ - (void)reportAttributeLockState:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeLockState(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeLockState(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -6076,7 +6716,11 @@ - (void)readAttributeLockType:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6100,7 +6744,11 @@ - (void)readAttributeActuatorEnabled:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6123,7 +6771,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6163,8 +6815,11 @@ - (void)armFailSafe:(uint16_t)expiryLengthSeconds return; } - CHIP_ERROR err - = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6187,7 +6842,11 @@ - (void)commissioningComplete:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6214,9 +6873,13 @@ - (void)setFabric:(NSData *)fabricId return; } - CHIP_ERROR err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) fabricId.bytes, fabricId.length), - chip::ByteSpan((const uint8_t *) fabricSecret.bytes, fabricSecret.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) fabricId.bytes, fabricId.length), + chip::ByteSpan((const uint8_t *) fabricSecret.bytes, fabricSecret.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6240,7 +6903,11 @@ - (void)readAttributeFabricId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6263,7 +6930,11 @@ - (void)readAttributeBreadcrumb:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6286,7 +6957,11 @@ - (void)writeAttributeBreadcrumb:(uint64_t)value completionHandler:(ResponseHand return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6309,7 +6984,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6346,7 +7025,11 @@ - (void)readAttributeGroups:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeGroups(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeGroups(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6370,7 +7053,11 @@ - (void)readAttributeGroupKeys:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeGroupKeys(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeGroupKeys(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6393,7 +7080,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6430,9 +7121,13 @@ - (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHan return; } - CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, - chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6454,9 +7149,13 @@ - (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName return; } - CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, - chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6479,7 +7178,11 @@ - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList com return; } - CHIP_ERROR err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6501,7 +7204,11 @@ - (void)removeAllGroups:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6524,7 +7231,11 @@ - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)complet return; } - CHIP_ERROR err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6547,7 +7258,11 @@ - (void)viewGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completio return; } - CHIP_ERROR err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6570,7 +7285,11 @@ - (void)readAttributeNameSupport:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6593,7 +7312,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6629,7 +7352,11 @@ - (void)identify:(uint16_t)identifyTime completionHandler:(ResponseHandler)compl return; } - CHIP_ERROR err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6652,7 +7379,11 @@ - (void)identifyQuery:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6675,7 +7406,11 @@ - (void)readAttributeIdentifyTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6698,7 +7433,11 @@ - (void)writeAttributeIdentifyTime:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6721,7 +7460,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6761,7 +7504,11 @@ - (void)move:(uint8_t)moveMode return; } - CHIP_ERROR err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6787,8 +7534,12 @@ - (void)moveToLevel:(uint8_t)level return; } - CHIP_ERROR err - = self.cppCluster.MoveToLevel(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToLevel( + onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6812,7 +7563,11 @@ - (void)moveToLevelWithOnOff:(uint8_t)level return; } - CHIP_ERROR err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6834,7 +7589,11 @@ - (void)moveWithOnOff:(uint8_t)moveMode rate:(uint8_t)rate completionHandler:(Re return; } - CHIP_ERROR err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6861,8 +7620,12 @@ - (void)step:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.Step( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Step( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6887,7 +7650,11 @@ - (void)stepWithOnOff:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6909,7 +7676,11 @@ - (void)stop:(uint8_t)optionMask optionOverride:(uint8_t)optionOverride completi return; } - CHIP_ERROR err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6931,7 +7702,11 @@ - (void)stopWithOnOff:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6954,7 +7729,11 @@ - (void)readAttributeCurrentLevel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6980,8 +7759,12 @@ - (void)configureAttributeCurrentLevel:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentLevel( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentLevel( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6997,7 +7780,11 @@ - (void)reportAttributeCurrentLevel:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -7019,7 +7806,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7055,7 +7846,11 @@ - (void)sleep:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7078,7 +7873,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7118,8 +7917,12 @@ - (void)addThreadNetwork:(NSData *)operationalDataset return; } - CHIP_ERROR err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7146,9 +7949,13 @@ - (void)addWiFiNetwork:(NSData *)ssid return; } - CHIP_ERROR err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), - chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7174,8 +7981,12 @@ - (void)disableNetwork:(NSData *)networkID return; } - CHIP_ERROR err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7201,8 +8012,12 @@ - (void)enableNetwork:(NSData *)networkID return; } - CHIP_ERROR err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7224,7 +8039,11 @@ - (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler: return; } - CHIP_ERROR err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7250,8 +8069,12 @@ - (void)removeNetwork:(NSData *)networkID return; } - CHIP_ERROR err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7277,8 +8100,12 @@ - (void)scanNetworks:(NSData *)ssid return; } - CHIP_ERROR err = self.cppCluster.ScanNetworks( - onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ScanNetworks(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7304,8 +8131,12 @@ - (void)updateThreadNetwork:(NSData *)operationalDataset return; } - CHIP_ERROR err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7332,9 +8163,13 @@ - (void)updateWiFiNetwork:(NSData *)ssid return; } - CHIP_ERROR err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), - chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7357,7 +8192,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7393,7 +8232,11 @@ - (void)off:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Off(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Off(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7415,7 +8258,11 @@ - (void)on:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.On(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.On(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7437,7 +8284,11 @@ - (void)toggle:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Toggle(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Toggle(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7461,7 +8312,11 @@ - (void)readAttributeOnOff:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7486,7 +8341,11 @@ - (void)configureAttributeOnOff:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7503,7 +8362,11 @@ - (void)reportAttributeOnOff:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeOnOff(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeOnOff(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -7525,7 +8388,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7702,10 +8569,14 @@ - (void)addScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, - chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), - clusterId, length, value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, + chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), + clusterId, length, value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7728,7 +8599,11 @@ - (void)getSceneMembership:(uint16_t)groupId completionHandler:(ResponseHandler) return; } - CHIP_ERROR err = self.cppCluster.GetSceneMembership(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetSceneMembership(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7753,7 +8628,11 @@ - (void)recallScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.RecallScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RecallScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7776,7 +8655,11 @@ - (void)removeAllScenes:(uint16_t)groupId completionHandler:(ResponseHandler)com return; } - CHIP_ERROR err = self.cppCluster.RemoveAllScenes(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllScenes(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7799,7 +8682,11 @@ - (void)removeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler return; } - CHIP_ERROR err = self.cppCluster.RemoveScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7822,7 +8709,11 @@ - (void)storeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler: return; } - CHIP_ERROR err = self.cppCluster.StoreScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StoreScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7845,7 +8736,11 @@ - (void)viewScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler:( return; } - CHIP_ERROR err = self.cppCluster.ViewScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ViewScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7868,7 +8763,11 @@ - (void)readAttributeSceneCount:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSceneCount(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSceneCount(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7891,7 +8790,11 @@ - (void)readAttributeCurrentScene:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentScene(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentScene(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7914,7 +8817,11 @@ - (void)readAttributeCurrentGroup:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentGroup(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentGroup(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7938,7 +8845,11 @@ - (void)readAttributeSceneValid:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSceneValid(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSceneValid(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7961,7 +8872,11 @@ - (void)readAttributeNameSupport:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7984,7 +8899,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8020,7 +8939,11 @@ - (void)readAttributeMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8046,8 +8969,12 @@ - (void)configureAttributeMeasuredValue:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeMeasuredValue( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeMeasuredValue( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8063,7 +8990,11 @@ - (void)reportAttributeMeasuredValue:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -8085,7 +9016,11 @@ - (void)readAttributeMinMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8108,7 +9043,11 @@ - (void)readAttributeMaxMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8131,7 +9070,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8167,7 +9110,11 @@ - (void)clearWeeklySchedule:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearWeeklySchedule(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearWeeklySchedule(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8189,7 +9136,11 @@ - (void)getRelayStatusLog:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.GetRelayStatusLog(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetRelayStatusLog(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8213,7 +9164,11 @@ - (void)getWeeklySchedule:(uint8_t)daysToReturn return; } - CHIP_ERROR err = self.cppCluster.GetWeeklySchedule(onSuccess->Cancel(), onFailure->Cancel(), daysToReturn, modeToReturn); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetWeeklySchedule(onSuccess->Cancel(), onFailure->Cancel(), daysToReturn, modeToReturn); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8239,8 +9194,12 @@ - (void)setWeeklySchedule:(uint8_t)numberOfTransitionsForSequence return; } - CHIP_ERROR err = self.cppCluster.SetWeeklySchedule( - onSuccess->Cancel(), onFailure->Cancel(), numberOfTransitionsForSequence, dayOfWeekForSequence, modeForSequence, payload); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetWeeklySchedule(onSuccess->Cancel(), onFailure->Cancel(), numberOfTransitionsForSequence, + dayOfWeekForSequence, modeForSequence, payload); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8262,7 +9221,11 @@ - (void)setpointRaiseLower:(uint8_t)mode amount:(int8_t)amount completionHandler return; } - CHIP_ERROR err = self.cppCluster.SetpointRaiseLower(onSuccess->Cancel(), onFailure->Cancel(), mode, amount); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetpointRaiseLower(onSuccess->Cancel(), onFailure->Cancel(), mode, amount); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8285,7 +9248,11 @@ - (void)readAttributeLocalTemperature:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLocalTemperature(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLocalTemperature(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8311,8 +9278,12 @@ - (void)configureAttributeLocalTemperature:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeLocalTemperature( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeLocalTemperature( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8328,7 +9299,11 @@ - (void)reportAttributeLocalTemperature:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeLocalTemperature(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeLocalTemperature(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -8350,7 +9325,11 @@ - (void)readAttributeOccupiedCoolingSetpoint:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeOccupiedCoolingSetpoint(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeOccupiedCoolingSetpoint(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8373,7 +9352,11 @@ - (void)writeAttributeOccupiedCoolingSetpoint:(int16_t)value completionHandler:( return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeOccupiedCoolingSetpoint(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeOccupiedCoolingSetpoint(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8396,7 +9379,11 @@ - (void)readAttributeOccupiedHeatingSetpoint:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeOccupiedHeatingSetpoint(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeOccupiedHeatingSetpoint(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8419,7 +9406,11 @@ - (void)writeAttributeOccupiedHeatingSetpoint:(int16_t)value completionHandler:( return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeOccupiedHeatingSetpoint(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeOccupiedHeatingSetpoint(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8442,7 +9433,11 @@ - (void)readAttributeControlSequenceOfOperation:(ResponseHandler)completionHandl return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeControlSequenceOfOperation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeControlSequenceOfOperation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8465,7 +9460,11 @@ - (void)writeAttributeControlSequenceOfOperation:(uint8_t)value completionHandle return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeControlSequenceOfOperation(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeControlSequenceOfOperation(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8488,7 +9487,11 @@ - (void)readAttributeSystemMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSystemMode(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSystemMode(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8511,7 +9514,11 @@ - (void)writeAttributeSystemMode:(uint8_t)value completionHandler:(ResponseHandl return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeSystemMode(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeSystemMode(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8534,7 +9541,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt b/src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt index b40dc2054e7b53..80035eb5f6fe01 100644 --- a/src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt +++ b/src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt @@ -11,6 +11,7 @@ #import "app/util/af.h" #include +#include #include using namespace ::chip; @@ -457,6 +458,7 @@ private: @interface CHIPCluster () @property (readonly, nonatomic) dispatch_queue_t callbackQueue; +@property (readonly, nonatomic) dispatch_queue_t chipWorkQueue; - (Controller::ClusterBase *)getCluster; @end @@ -475,6 +477,12 @@ private: return nil; } + _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); + if (_chipWorkQueue == nil) + { + return nil; + } + _callbackQueue = queue; } return self; @@ -524,7 +532,11 @@ private: return; } - CHIP_ERROR err = self.cppCluster.{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isOctetString type)}}chip::ByteSpan((const uint8_t*){{asCamelCased label}}.bytes, {{asCamelCased label}}.length){{else if (isCharString type)}}chip::ByteSpan((const uint8_t*)[{{asCamelCased label}} dataUsingEncoding:NSUTF8StringEncoding].bytes, [{{asCamelCased label}} lengthOfBytesUsingEncoding:NSUTF8StringEncoding]){{else}}{{asCamelCased label}}{{/if}}{{/chip_server_cluster_command_arguments}}); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isOctetString type)}}chip::ByteSpan((const uint8_t*){{asCamelCased label}}.bytes, {{asCamelCased label}}.length){{else if (isCharString type)}}chip::ByteSpan((const uint8_t*)[{{asCamelCased label}} dataUsingEncoding:NSUTF8StringEncoding].bytes, [{{asCamelCased label}} lengthOfBytesUsingEncoding:NSUTF8StringEncoding]){{else}}{{asCamelCased label}}{{/if}}{{/chip_server_cluster_command_arguments}}); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -553,7 +565,11 @@ private: return; } - CHIP_ERROR err = self.cppCluster.ReadAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -577,14 +593,18 @@ private: return; } - {{#if (isOctetString type)}} - CHIP_ERROR err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t*)value.bytes, value.length)); - {{else if (isCharString type)}} - NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; - CHIP_ERROR err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t*)data.bytes, data.length)); - {{else}} - CHIP_ERROR err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), value); - {{/if}} + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + {{#if (isOctetString type)}} + err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t*)value.bytes, value.length)); + {{else if (isCharString type)}} + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t*)data.bytes, data.length)); + {{else}} + err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), value); + {{/if}} + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -610,7 +630,11 @@ private: } - CHIP_ERROR err = self.cppCluster.ConfigureAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval{{#unless (isDiscreteType)}}, change{{/unless}}); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval{{#unless (isDiscreteType)}}, change{{/unless}}); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -626,7 +650,11 @@ private: return; } - CHIP_ERROR err = self.cppCluster.ReportAttribute{{asCamelCased name false}}(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttribute{{asCamelCased name false}}(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); diff --git a/src/controller/python/gen/CHIPClustersObjc.mm b/src/controller/python/gen/CHIPClustersObjc.mm index 5cecb015851b48..8ee694e0b0ba7e 100644 --- a/src/controller/python/gen/CHIPClustersObjc.mm +++ b/src/controller/python/gen/CHIPClustersObjc.mm @@ -28,6 +28,7 @@ #include #include +#include using namespace ::chip; @@ -1542,6 +1543,7 @@ static void CallbackFn(void * context, uint16_t groupId, uint8_t sceneId, uint16 @interface CHIPCluster () @property (readonly, nonatomic) dispatch_queue_t callbackQueue; +@property (readonly, nonatomic) dispatch_queue_t chipWorkQueue; - (Controller::ClusterBase *)getCluster; @end @@ -1559,6 +1561,11 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin return nil; } + _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); + if (_chipWorkQueue == nil) { + return nil; + } + _callbackQueue = queue; } return self; @@ -1597,7 +1604,11 @@ - (void)readAttributeVendorName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1620,7 +1631,11 @@ - (void)readAttributeVendorId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1644,7 +1659,11 @@ - (void)readAttributeApplicationName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1667,7 +1686,11 @@ - (void)readAttributeProductId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1691,7 +1714,11 @@ - (void)readAttributeApplicationId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1714,7 +1741,11 @@ - (void)readAttributeCatalogVendorId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1737,7 +1768,11 @@ - (void)readAttributeApplicationSatus:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1760,7 +1795,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1796,7 +1835,11 @@ - (void)barrierControlGoToPercent:(uint8_t)percentOpen completionHandler:(Respon return; } - CHIP_ERROR err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1818,7 +1861,11 @@ - (void)barrierControlStop:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1841,7 +1888,11 @@ - (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1864,7 +1915,11 @@ - (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1887,7 +1942,11 @@ - (void)readAttributeBarrierCapabilities:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1910,7 +1969,11 @@ - (void)readAttributeBarrierPosition:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1933,7 +1996,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1969,7 +2036,11 @@ - (void)mfgSpecificPing:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1992,7 +2063,11 @@ - (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2016,7 +2091,11 @@ - (void)readAttributeVendorName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2039,7 +2118,11 @@ - (void)readAttributeVendorID:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2063,7 +2146,11 @@ - (void)readAttributeProductName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2086,7 +2173,11 @@ - (void)readAttributeProductID:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2110,7 +2201,11 @@ - (void)readAttributeUserLabel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2133,9 +2228,13 @@ - (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHan return; } - NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; - CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( - onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2159,7 +2258,11 @@ - (void)readAttributeLocation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2182,9 +2285,13 @@ - (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHand return; } - NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; - CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( - onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2207,7 +2314,11 @@ - (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2231,7 +2342,11 @@ - (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2254,7 +2369,11 @@ - (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2278,7 +2397,11 @@ - (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2302,7 +2425,11 @@ - (void)readAttributeManufacturingDate:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeManufacturingDate(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeManufacturingDate(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2326,7 +2453,11 @@ - (void)readAttributePartNumber:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePartNumber(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePartNumber(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2350,7 +2481,11 @@ - (void)readAttributeProductURL:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductURL(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductURL(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2374,7 +2509,11 @@ - (void)readAttributeProductLabel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductLabel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductLabel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2398,7 +2537,11 @@ - (void)readAttributeSerialNumber:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSerialNumber(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSerialNumber(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2422,7 +2565,11 @@ - (void)readAttributeLocalConfigDisabled:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2445,7 +2592,11 @@ - (void)writeAttributeLocalConfigDisabled:(uint8_t)value completionHandler:(Resp return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2468,7 +2619,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2508,7 +2663,11 @@ - (void)bind:(uint64_t)nodeId return; } - CHIP_ERROR err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2534,7 +2693,11 @@ - (void)unbind:(uint64_t)nodeId return; } - CHIP_ERROR err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2557,7 +2720,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2597,8 +2764,11 @@ - (void)moveColor:(int16_t)rateX return; } - CHIP_ERROR err - = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2626,8 +2796,12 @@ - (void)moveColorTemperature:(uint8_t)moveMode return; } - CHIP_ERROR err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, - colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, + colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2653,8 +2827,11 @@ - (void)moveHue:(uint8_t)moveMode return; } - CHIP_ERROR err - = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2680,8 +2857,12 @@ - (void)moveSaturation:(uint8_t)moveMode return; } - CHIP_ERROR err - = self.cppCluster.MoveSaturation(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveSaturation( + onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2708,8 +2889,12 @@ - (void)moveToColor:(uint16_t)colorX return; } - CHIP_ERROR err = self.cppCluster.MoveToColor( - onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToColor( + onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2735,8 +2920,12 @@ - (void)moveToColorTemperature:(uint16_t)colorTemperature return; } - CHIP_ERROR err = self.cppCluster.MoveToColorTemperature( - onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToColorTemperature( + onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2763,8 +2952,12 @@ - (void)moveToHue:(uint8_t)hue return; } - CHIP_ERROR err = self.cppCluster.MoveToHue( - onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToHue( + onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2791,8 +2984,12 @@ - (void)moveToHueAndSaturation:(uint8_t)hue return; } - CHIP_ERROR err = self.cppCluster.MoveToHueAndSaturation( - onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToHueAndSaturation( + onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2818,8 +3015,12 @@ - (void)moveToSaturation:(uint8_t)saturation return; } - CHIP_ERROR err = self.cppCluster.MoveToSaturation( - onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToSaturation( + onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2846,8 +3047,12 @@ - (void)stepColor:(int16_t)stepX return; } - CHIP_ERROR err = self.cppCluster.StepColor( - onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepColor( + onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2876,8 +3081,12 @@ - (void)stepColorTemperature:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, - transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, + colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2904,8 +3113,12 @@ - (void)stepHue:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepHue( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepHue( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2932,8 +3145,12 @@ - (void)stepSaturation:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepSaturation( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepSaturation( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2957,7 +3174,11 @@ - (void)stopMoveStep:(uint8_t)optionsMask return; } - CHIP_ERROR err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2980,7 +3201,11 @@ - (void)readAttributeCurrentHue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3006,8 +3231,12 @@ - (void)configureAttributeCurrentHue:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentHue( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3023,7 +3252,11 @@ - (void)reportAttributeCurrentHue:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3045,7 +3278,11 @@ - (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3071,8 +3308,12 @@ - (void)configureAttributeCurrentSaturation:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentSaturation( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentSaturation( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3088,7 +3329,11 @@ - (void)reportAttributeCurrentSaturation:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3110,7 +3355,11 @@ - (void)readAttributeRemainingTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3133,7 +3382,11 @@ - (void)readAttributeCurrentX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3159,8 +3412,12 @@ - (void)configureAttributeCurrentX:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentX( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3176,7 +3433,11 @@ - (void)reportAttributeCurrentX:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3198,7 +3459,11 @@ - (void)readAttributeCurrentY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3224,8 +3489,12 @@ - (void)configureAttributeCurrentY:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentY( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3241,7 +3510,11 @@ - (void)reportAttributeCurrentY:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3263,7 +3536,11 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3287,7 +3564,11 @@ - (void)readAttributeCompensationText:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3310,7 +3591,11 @@ - (void)readAttributeColorTemperature:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3336,8 +3621,12 @@ - (void)configureAttributeColorTemperature:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeColorTemperature( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeColorTemperature( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3353,7 +3642,11 @@ - (void)reportAttributeColorTemperature:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3375,7 +3668,11 @@ - (void)readAttributeColorMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3398,7 +3695,11 @@ - (void)readAttributeColorControlOptions:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3421,7 +3722,11 @@ - (void)writeAttributeColorControlOptions:(uint8_t)value completionHandler:(Resp return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3444,7 +3749,11 @@ - (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3467,7 +3776,11 @@ - (void)readAttributePrimary1X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3490,7 +3803,11 @@ - (void)readAttributePrimary1Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3513,7 +3830,11 @@ - (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3536,7 +3857,11 @@ - (void)readAttributePrimary2X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3559,7 +3884,11 @@ - (void)readAttributePrimary2Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3582,7 +3911,11 @@ - (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3605,7 +3938,11 @@ - (void)readAttributePrimary3X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3628,7 +3965,11 @@ - (void)readAttributePrimary3Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3651,7 +3992,11 @@ - (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3674,7 +4019,11 @@ - (void)readAttributePrimary4X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3697,7 +4046,11 @@ - (void)readAttributePrimary4Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3720,7 +4073,11 @@ - (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3743,7 +4100,11 @@ - (void)readAttributePrimary5X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3766,7 +4127,11 @@ - (void)readAttributePrimary5Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3789,7 +4154,11 @@ - (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3812,7 +4181,11 @@ - (void)readAttributePrimary6X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3835,7 +4208,11 @@ - (void)readAttributePrimary6Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3858,7 +4235,11 @@ - (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3881,7 +4262,11 @@ - (void)readAttributeWhitePointX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3904,7 +4289,11 @@ - (void)writeAttributeWhitePointX:(uint16_t)value completionHandler:(ResponseHan return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3927,7 +4316,11 @@ - (void)readAttributeWhitePointY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3950,7 +4343,11 @@ - (void)writeAttributeWhitePointY:(uint16_t)value completionHandler:(ResponseHan return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3973,7 +4370,11 @@ - (void)readAttributeColorPointRX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3996,7 +4397,11 @@ - (void)writeAttributeColorPointRX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4019,7 +4424,11 @@ - (void)readAttributeColorPointRY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4042,7 +4451,11 @@ - (void)writeAttributeColorPointRY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4065,7 +4478,11 @@ - (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4088,7 +4505,11 @@ - (void)writeAttributeColorPointRIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4111,7 +4532,11 @@ - (void)readAttributeColorPointGX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4134,7 +4559,11 @@ - (void)writeAttributeColorPointGX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4157,7 +4586,11 @@ - (void)readAttributeColorPointGY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4180,7 +4613,11 @@ - (void)writeAttributeColorPointGY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4203,7 +4640,11 @@ - (void)readAttributeColorPointGIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4226,7 +4667,11 @@ - (void)writeAttributeColorPointGIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4249,7 +4694,11 @@ - (void)readAttributeColorPointBX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4272,7 +4721,11 @@ - (void)writeAttributeColorPointBX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4295,7 +4748,11 @@ - (void)readAttributeColorPointBY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4318,7 +4775,11 @@ - (void)writeAttributeColorPointBY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4341,7 +4802,11 @@ - (void)readAttributeColorPointBIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4364,7 +4829,11 @@ - (void)writeAttributeColorPointBIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4387,7 +4856,11 @@ - (void)readAttributeEnhancedCurrentHue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4410,7 +4883,11 @@ - (void)readAttributeEnhancedColorMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4433,7 +4910,11 @@ - (void)readAttributeColorLoopActive:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4456,7 +4937,11 @@ - (void)readAttributeColorLoopDirection:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4479,7 +4964,11 @@ - (void)readAttributeColorLoopTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4502,7 +4991,11 @@ - (void)readAttributeColorCapabilities:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4525,7 +5018,11 @@ - (void)readAttributeColorTempPhysicalMin:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4548,7 +5045,11 @@ - (void)readAttributeColorTempPhysicalMax:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4571,7 +5072,11 @@ - (void)readAttributeCoupleColorTempToLevelMinMireds:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4594,7 +5099,11 @@ - (void)readAttributeStartUpColorTemperatureMireds:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4617,7 +5126,11 @@ - (void)writeAttributeStartUpColorTemperatureMireds:(uint16_t)value completionHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4640,7 +5153,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4677,7 +5194,11 @@ - (void)clearAllPins:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4700,7 +5221,11 @@ - (void)clearAllRfids:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4723,7 +5248,11 @@ - (void)clearHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHand return; } - CHIP_ERROR err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4746,7 +5275,11 @@ - (void)clearPin:(uint16_t)userId completionHandler:(ResponseHandler)completionH return; } - CHIP_ERROR err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4769,7 +5302,11 @@ - (void)clearRfid:(uint16_t)userId completionHandler:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4792,7 +5329,11 @@ - (void)clearWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId complet return; } - CHIP_ERROR err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4815,7 +5356,11 @@ - (void)clearYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId complet return; } - CHIP_ERROR err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4838,7 +5383,11 @@ - (void)getHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandle return; } - CHIP_ERROR err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4861,7 +5410,11 @@ - (void)getLogRecord:(uint16_t)logIndex completionHandler:(ResponseHandler)compl return; } - CHIP_ERROR err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4884,7 +5437,11 @@ - (void)getPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHan return; } - CHIP_ERROR err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4907,7 +5464,11 @@ - (void)getRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4930,7 +5491,11 @@ - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completi return; } - CHIP_ERROR err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4953,7 +5518,11 @@ - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio return; } - CHIP_ERROR err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4976,7 +5545,11 @@ - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio return; } - CHIP_ERROR err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4999,9 +5572,13 @@ - (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5028,8 +5605,12 @@ - (void)setHolidaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetHolidaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetHolidaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5056,9 +5637,13 @@ - (void)setPin:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5085,9 +5670,13 @@ - (void)setRfid:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, - chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, - [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, + [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5110,7 +5699,11 @@ - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandle return; } - CHIP_ERROR err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5140,8 +5733,12 @@ - (void)setWeekdaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetWeekdaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetWeekdaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5168,8 +5765,12 @@ - (void)setYeardaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetYeardaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetYeardaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5192,9 +5793,13 @@ - (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5217,9 +5822,13 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin complet return; } - CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5242,7 +5851,11 @@ - (void)readAttributeLockState:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5267,8 +5880,11 @@ - (void)configureAttributeLockState:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5284,7 +5900,11 @@ - (void)reportAttributeLockState:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeLockState(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeLockState(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -5306,7 +5926,11 @@ - (void)readAttributeLockType:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5330,7 +5954,11 @@ - (void)readAttributeActuatorEnabled:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5353,7 +5981,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5393,8 +6025,11 @@ - (void)armFailSafe:(uint16_t)expiryLengthSeconds return; } - CHIP_ERROR err - = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5417,7 +6052,11 @@ - (void)commissioningComplete:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5444,9 +6083,13 @@ - (void)setFabric:(NSData *)fabricId return; } - CHIP_ERROR err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) fabricId.bytes, fabricId.length), - chip::ByteSpan((const uint8_t *) fabricSecret.bytes, fabricSecret.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) fabricId.bytes, fabricId.length), + chip::ByteSpan((const uint8_t *) fabricSecret.bytes, fabricSecret.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5470,7 +6113,11 @@ - (void)readAttributeFabricId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5493,7 +6140,11 @@ - (void)readAttributeBreadcrumb:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5516,7 +6167,11 @@ - (void)writeAttributeBreadcrumb:(uint64_t)value completionHandler:(ResponseHand return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5539,7 +6194,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5576,9 +6235,13 @@ - (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHan return; } - CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, - chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5600,9 +6263,13 @@ - (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName return; } - CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, - chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5625,7 +6292,11 @@ - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList com return; } - CHIP_ERROR err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5647,7 +6318,11 @@ - (void)removeAllGroups:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5670,7 +6345,11 @@ - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)complet return; } - CHIP_ERROR err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5693,7 +6372,11 @@ - (void)viewGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completio return; } - CHIP_ERROR err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5716,7 +6399,11 @@ - (void)readAttributeNameSupport:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5739,7 +6426,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5775,7 +6466,11 @@ - (void)identify:(uint16_t)identifyTime completionHandler:(ResponseHandler)compl return; } - CHIP_ERROR err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5798,7 +6493,11 @@ - (void)identifyQuery:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5821,7 +6520,11 @@ - (void)readAttributeIdentifyTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5844,7 +6547,11 @@ - (void)writeAttributeIdentifyTime:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5867,7 +6574,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5907,7 +6618,11 @@ - (void)move:(uint8_t)moveMode return; } - CHIP_ERROR err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5933,8 +6648,12 @@ - (void)moveToLevel:(uint8_t)level return; } - CHIP_ERROR err - = self.cppCluster.MoveToLevel(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToLevel( + onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5958,7 +6677,11 @@ - (void)moveToLevelWithOnOff:(uint8_t)level return; } - CHIP_ERROR err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5980,7 +6703,11 @@ - (void)moveWithOnOff:(uint8_t)moveMode rate:(uint8_t)rate completionHandler:(Re return; } - CHIP_ERROR err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6007,8 +6734,12 @@ - (void)step:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.Step( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Step( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6033,7 +6764,11 @@ - (void)stepWithOnOff:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6055,7 +6790,11 @@ - (void)stop:(uint8_t)optionMask optionOverride:(uint8_t)optionOverride completi return; } - CHIP_ERROR err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6077,7 +6816,11 @@ - (void)stopWithOnOff:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6100,7 +6843,11 @@ - (void)readAttributeCurrentLevel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6126,8 +6873,12 @@ - (void)configureAttributeCurrentLevel:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentLevel( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentLevel( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6143,7 +6894,11 @@ - (void)reportAttributeCurrentLevel:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -6165,7 +6920,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6201,7 +6960,11 @@ - (void)sleep:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6224,7 +6987,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6260,7 +7027,11 @@ - (void)off:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Off(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Off(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6282,7 +7053,11 @@ - (void)on:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.On(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.On(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6304,7 +7079,11 @@ - (void)toggle:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Toggle(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Toggle(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6328,7 +7107,11 @@ - (void)readAttributeOnOff:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6353,7 +7136,11 @@ - (void)configureAttributeOnOff:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6370,7 +7157,11 @@ - (void)reportAttributeOnOff:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeOnOff(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeOnOff(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -6392,7 +7183,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6436,10 +7231,14 @@ - (void)addScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, - chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), - clusterId, length, value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, + chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), + clusterId, length, value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6462,7 +7261,11 @@ - (void)getSceneMembership:(uint16_t)groupId completionHandler:(ResponseHandler) return; } - CHIP_ERROR err = self.cppCluster.GetSceneMembership(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetSceneMembership(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6487,7 +7290,11 @@ - (void)recallScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.RecallScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RecallScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6510,7 +7317,11 @@ - (void)removeAllScenes:(uint16_t)groupId completionHandler:(ResponseHandler)com return; } - CHIP_ERROR err = self.cppCluster.RemoveAllScenes(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllScenes(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6533,7 +7344,11 @@ - (void)removeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler return; } - CHIP_ERROR err = self.cppCluster.RemoveScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6556,7 +7371,11 @@ - (void)storeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler: return; } - CHIP_ERROR err = self.cppCluster.StoreScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StoreScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6579,7 +7398,11 @@ - (void)viewScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler:( return; } - CHIP_ERROR err = self.cppCluster.ViewScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ViewScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6602,7 +7425,11 @@ - (void)readAttributeSceneCount:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSceneCount(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSceneCount(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6625,7 +7452,11 @@ - (void)readAttributeCurrentScene:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentScene(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentScene(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6648,7 +7479,11 @@ - (void)readAttributeCurrentGroup:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentGroup(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentGroup(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6672,7 +7507,11 @@ - (void)readAttributeSceneValid:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSceneValid(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSceneValid(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6695,7 +7534,11 @@ - (void)readAttributeNameSupport:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6718,7 +7561,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6754,7 +7601,11 @@ - (void)readAttributeMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6780,8 +7631,12 @@ - (void)configureAttributeMeasuredValue:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeMeasuredValue( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeMeasuredValue( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6797,7 +7652,11 @@ - (void)reportAttributeMeasuredValue:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -6819,7 +7678,11 @@ - (void)readAttributeMinMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6842,7 +7705,11 @@ - (void)readAttributeMaxMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6865,7 +7732,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.mm b/src/darwin/Framework/CHIP/CHIPDeviceController.mm index 4b5b1ba7bd9c3f..c918887c4666de 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.mm +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.mm @@ -26,16 +26,15 @@ #include #include +#include #include -static const char * const CHIP_CONTROLLER_QUEUE = "com.zigbee.chip.framework.controller.workqueue"; static const char * const CHIP_COMMISSIONER_DEVICE_ID_KEY = "com.zigbee.chip.commissioner.device.id"; static NSString * const kErrorMemoryInit = @"Init Memory failure"; static NSString * const kErrorCommissionerInit = @"Init failure while initializing a commissioner"; static NSString * const kErrorPairingInit = @"Init failure while creating a pairing delegate"; static NSString * const kErrorPersistentStorageInit = @"Init failure while creating a persistent storage delegate"; -static NSString * const kErrorNetworkDispatchQueueInit = @"Init failure while initializing a dispatch queue for the network events"; static NSString * const kErrorPairDevice = @"Failure while pairing the device"; static NSString * const kErrorUnpairDevice = @"Failure while unpairing the device"; static NSString * const kErrorStopPairing = @"Failure while trying to stop the pairing process"; @@ -74,10 +73,7 @@ - (instancetype)init if (self = [super init]) { CHIP_ERROR errorCode = CHIP_NO_ERROR; - _chipWorkQueue = dispatch_queue_create(CHIP_CONTROLLER_QUEUE, DISPATCH_QUEUE_SERIAL); - if ([self checkForStartError:(_chipWorkQueue != nil) logMsg:kErrorNetworkDispatchQueueInit]) { - return nil; - } + _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); errorCode = chip::Platform::MemoryInit(); if ([self checkForInitError:(CHIP_NO_ERROR == errorCode) logMsg:kErrorMemoryInit]) { diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index 7e3ee401887ed4..c85bd50add66c3 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -28,6 +28,7 @@ #include #include +#include using namespace ::chip; @@ -2106,6 +2107,7 @@ static void CallbackFn(void * context, uint16_t count, _FabricDescriptor * entri @interface CHIPCluster () @property (readonly, nonatomic) dispatch_queue_t callbackQueue; +@property (readonly, nonatomic) dispatch_queue_t chipWorkQueue; - (Controller::ClusterBase *)getCluster; @end @@ -2123,6 +2125,11 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin return nil; } + _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); + if (_chipWorkQueue == nil) { + return nil; + } + _callbackQueue = queue; } return self; @@ -2161,7 +2168,11 @@ - (void)readAttributeVendorName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2184,7 +2195,11 @@ - (void)readAttributeVendorId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2208,7 +2223,11 @@ - (void)readAttributeApplicationName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2231,7 +2250,11 @@ - (void)readAttributeProductId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2255,7 +2278,11 @@ - (void)readAttributeApplicationId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2278,7 +2305,11 @@ - (void)readAttributeCatalogVendorId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2301,7 +2332,11 @@ - (void)readAttributeApplicationSatus:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2324,7 +2359,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2360,7 +2399,11 @@ - (void)barrierControlGoToPercent:(uint8_t)percentOpen completionHandler:(Respon return; } - CHIP_ERROR err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2382,7 +2425,11 @@ - (void)barrierControlStop:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2405,7 +2452,11 @@ - (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2428,7 +2479,11 @@ - (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2451,7 +2506,11 @@ - (void)readAttributeBarrierCapabilities:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2474,7 +2533,11 @@ - (void)readAttributeBarrierPosition:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2497,7 +2560,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2533,7 +2600,11 @@ - (void)mfgSpecificPing:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2556,7 +2627,11 @@ - (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2580,7 +2655,11 @@ - (void)readAttributeVendorName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2603,7 +2682,11 @@ - (void)readAttributeVendorID:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2627,7 +2710,11 @@ - (void)readAttributeProductName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2650,7 +2737,11 @@ - (void)readAttributeProductID:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2674,7 +2765,11 @@ - (void)readAttributeUserLabel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2697,9 +2792,13 @@ - (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHan return; } - NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; - CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( - onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2723,7 +2822,11 @@ - (void)readAttributeLocation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2746,9 +2849,13 @@ - (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHand return; } - NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; - CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( - onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2771,7 +2878,11 @@ - (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2795,7 +2906,11 @@ - (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2818,7 +2933,11 @@ - (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2842,7 +2961,11 @@ - (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2866,7 +2989,11 @@ - (void)readAttributeManufacturingDate:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeManufacturingDate(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeManufacturingDate(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2890,7 +3017,11 @@ - (void)readAttributePartNumber:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePartNumber(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePartNumber(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2914,7 +3045,11 @@ - (void)readAttributeProductURL:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductURL(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductURL(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2938,7 +3073,11 @@ - (void)readAttributeProductLabel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductLabel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeProductLabel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2962,7 +3101,11 @@ - (void)readAttributeSerialNumber:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSerialNumber(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSerialNumber(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2986,7 +3129,11 @@ - (void)readAttributeLocalConfigDisabled:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3009,7 +3156,11 @@ - (void)writeAttributeLocalConfigDisabled:(uint8_t)value completionHandler:(Resp return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3032,7 +3183,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3072,7 +3227,11 @@ - (void)bind:(uint64_t)nodeId return; } - CHIP_ERROR err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3098,7 +3257,11 @@ - (void)unbind:(uint64_t)nodeId return; } - CHIP_ERROR err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3121,7 +3284,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3161,8 +3328,11 @@ - (void)moveColor:(int16_t)rateX return; } - CHIP_ERROR err - = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3190,8 +3360,12 @@ - (void)moveColorTemperature:(uint8_t)moveMode return; } - CHIP_ERROR err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, - colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, + colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3217,8 +3391,11 @@ - (void)moveHue:(uint8_t)moveMode return; } - CHIP_ERROR err - = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3244,8 +3421,12 @@ - (void)moveSaturation:(uint8_t)moveMode return; } - CHIP_ERROR err - = self.cppCluster.MoveSaturation(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveSaturation( + onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3272,8 +3453,12 @@ - (void)moveToColor:(uint16_t)colorX return; } - CHIP_ERROR err = self.cppCluster.MoveToColor( - onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToColor( + onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3299,8 +3484,12 @@ - (void)moveToColorTemperature:(uint16_t)colorTemperature return; } - CHIP_ERROR err = self.cppCluster.MoveToColorTemperature( - onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToColorTemperature( + onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3327,8 +3516,12 @@ - (void)moveToHue:(uint8_t)hue return; } - CHIP_ERROR err = self.cppCluster.MoveToHue( - onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToHue( + onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3355,8 +3548,12 @@ - (void)moveToHueAndSaturation:(uint8_t)hue return; } - CHIP_ERROR err = self.cppCluster.MoveToHueAndSaturation( - onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToHueAndSaturation( + onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3382,8 +3579,12 @@ - (void)moveToSaturation:(uint8_t)saturation return; } - CHIP_ERROR err = self.cppCluster.MoveToSaturation( - onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToSaturation( + onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3410,8 +3611,12 @@ - (void)stepColor:(int16_t)stepX return; } - CHIP_ERROR err = self.cppCluster.StepColor( - onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepColor( + onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3440,8 +3645,12 @@ - (void)stepColorTemperature:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, - transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, + colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3468,8 +3677,12 @@ - (void)stepHue:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepHue( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepHue( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3496,8 +3709,12 @@ - (void)stepSaturation:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepSaturation( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepSaturation( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3521,7 +3738,11 @@ - (void)stopMoveStep:(uint8_t)optionsMask return; } - CHIP_ERROR err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3544,7 +3765,11 @@ - (void)readAttributeCurrentHue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3570,8 +3795,12 @@ - (void)configureAttributeCurrentHue:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentHue( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3587,7 +3816,11 @@ - (void)reportAttributeCurrentHue:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3609,7 +3842,11 @@ - (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3635,8 +3872,12 @@ - (void)configureAttributeCurrentSaturation:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentSaturation( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentSaturation( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3652,7 +3893,11 @@ - (void)reportAttributeCurrentSaturation:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3674,7 +3919,11 @@ - (void)readAttributeRemainingTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3697,7 +3946,11 @@ - (void)readAttributeCurrentX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3723,8 +3976,12 @@ - (void)configureAttributeCurrentX:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentX( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3740,7 +3997,11 @@ - (void)reportAttributeCurrentX:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3762,7 +4023,11 @@ - (void)readAttributeCurrentY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3788,8 +4053,12 @@ - (void)configureAttributeCurrentY:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentY( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3805,7 +4074,11 @@ - (void)reportAttributeCurrentY:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3827,7 +4100,11 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3851,7 +4128,11 @@ - (void)readAttributeCompensationText:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3874,7 +4155,11 @@ - (void)readAttributeColorTemperature:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3900,8 +4185,12 @@ - (void)configureAttributeColorTemperature:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeColorTemperature( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeColorTemperature( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3917,7 +4206,11 @@ - (void)reportAttributeColorTemperature:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -3939,7 +4232,11 @@ - (void)readAttributeColorMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3962,7 +4259,11 @@ - (void)readAttributeColorControlOptions:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3985,7 +4286,11 @@ - (void)writeAttributeColorControlOptions:(uint8_t)value completionHandler:(Resp return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4008,7 +4313,11 @@ - (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4031,7 +4340,11 @@ - (void)readAttributePrimary1X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4054,7 +4367,11 @@ - (void)readAttributePrimary1Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4077,7 +4394,11 @@ - (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4100,7 +4421,11 @@ - (void)readAttributePrimary2X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4123,7 +4448,11 @@ - (void)readAttributePrimary2Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4146,7 +4475,11 @@ - (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4169,7 +4502,11 @@ - (void)readAttributePrimary3X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4192,7 +4529,11 @@ - (void)readAttributePrimary3Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4215,7 +4556,11 @@ - (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4238,7 +4583,11 @@ - (void)readAttributePrimary4X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4261,7 +4610,11 @@ - (void)readAttributePrimary4Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4284,7 +4637,11 @@ - (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4307,7 +4664,11 @@ - (void)readAttributePrimary5X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4330,7 +4691,11 @@ - (void)readAttributePrimary5Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4353,7 +4718,11 @@ - (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4376,7 +4745,11 @@ - (void)readAttributePrimary6X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4399,7 +4772,11 @@ - (void)readAttributePrimary6Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4422,7 +4799,11 @@ - (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4445,7 +4826,11 @@ - (void)readAttributeWhitePointX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4468,7 +4853,11 @@ - (void)writeAttributeWhitePointX:(uint16_t)value completionHandler:(ResponseHan return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4491,7 +4880,11 @@ - (void)readAttributeWhitePointY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4514,7 +4907,11 @@ - (void)writeAttributeWhitePointY:(uint16_t)value completionHandler:(ResponseHan return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4537,7 +4934,11 @@ - (void)readAttributeColorPointRX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4560,7 +4961,11 @@ - (void)writeAttributeColorPointRX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4583,7 +4988,11 @@ - (void)readAttributeColorPointRY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4606,7 +5015,11 @@ - (void)writeAttributeColorPointRY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4629,7 +5042,11 @@ - (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4652,7 +5069,11 @@ - (void)writeAttributeColorPointRIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4675,7 +5096,11 @@ - (void)readAttributeColorPointGX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4698,7 +5123,11 @@ - (void)writeAttributeColorPointGX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4721,7 +5150,11 @@ - (void)readAttributeColorPointGY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4744,7 +5177,11 @@ - (void)writeAttributeColorPointGY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4767,7 +5204,11 @@ - (void)readAttributeColorPointGIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4790,7 +5231,11 @@ - (void)writeAttributeColorPointGIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4813,7 +5258,11 @@ - (void)readAttributeColorPointBX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4836,7 +5285,11 @@ - (void)writeAttributeColorPointBX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4859,7 +5312,11 @@ - (void)readAttributeColorPointBY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4882,7 +5339,11 @@ - (void)writeAttributeColorPointBY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4905,7 +5366,11 @@ - (void)readAttributeColorPointBIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4928,7 +5393,11 @@ - (void)writeAttributeColorPointBIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4951,7 +5420,11 @@ - (void)readAttributeEnhancedCurrentHue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4974,7 +5447,11 @@ - (void)readAttributeEnhancedColorMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4997,7 +5474,11 @@ - (void)readAttributeColorLoopActive:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5020,7 +5501,11 @@ - (void)readAttributeColorLoopDirection:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5043,7 +5528,11 @@ - (void)readAttributeColorLoopTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5066,7 +5555,11 @@ - (void)readAttributeColorCapabilities:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5089,7 +5582,11 @@ - (void)readAttributeColorTempPhysicalMin:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5112,7 +5609,11 @@ - (void)readAttributeColorTempPhysicalMax:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5135,7 +5636,11 @@ - (void)readAttributeCoupleColorTempToLevelMinMireds:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5158,7 +5663,11 @@ - (void)readAttributeStartUpColorTemperatureMireds:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5181,7 +5690,11 @@ - (void)writeAttributeStartUpColorTemperatureMireds:(uint16_t)value completionHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5204,7 +5717,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5241,7 +5758,11 @@ - (void)readAttributeDeviceList:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeDeviceList(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeDeviceList(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5265,7 +5786,11 @@ - (void)readAttributeServerList:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeServerList(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeServerList(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5289,7 +5814,11 @@ - (void)readAttributeClientList:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClientList(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClientList(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5313,7 +5842,11 @@ - (void)readAttributePartsList:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePartsList(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributePartsList(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5336,7 +5869,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5373,7 +5910,11 @@ - (void)clearAllPins:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5396,7 +5937,11 @@ - (void)clearAllRfids:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5419,7 +5964,11 @@ - (void)clearHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHand return; } - CHIP_ERROR err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5442,7 +5991,11 @@ - (void)clearPin:(uint16_t)userId completionHandler:(ResponseHandler)completionH return; } - CHIP_ERROR err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5465,7 +6018,11 @@ - (void)clearRfid:(uint16_t)userId completionHandler:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5488,7 +6045,11 @@ - (void)clearWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId complet return; } - CHIP_ERROR err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5511,7 +6072,11 @@ - (void)clearYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId complet return; } - CHIP_ERROR err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5534,7 +6099,11 @@ - (void)getHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandle return; } - CHIP_ERROR err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5557,7 +6126,11 @@ - (void)getLogRecord:(uint16_t)logIndex completionHandler:(ResponseHandler)compl return; } - CHIP_ERROR err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5580,7 +6153,11 @@ - (void)getPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHan return; } - CHIP_ERROR err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5603,7 +6180,11 @@ - (void)getRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5626,7 +6207,11 @@ - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completi return; } - CHIP_ERROR err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5649,7 +6234,11 @@ - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio return; } - CHIP_ERROR err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5672,7 +6261,11 @@ - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio return; } - CHIP_ERROR err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5695,9 +6288,13 @@ - (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5724,8 +6321,12 @@ - (void)setHolidaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetHolidaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetHolidaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5752,9 +6353,13 @@ - (void)setPin:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5781,9 +6386,13 @@ - (void)setRfid:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, - chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, - [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, + [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5806,7 +6415,11 @@ - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandle return; } - CHIP_ERROR err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5836,8 +6449,12 @@ - (void)setWeekdaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetWeekdaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetWeekdaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5864,8 +6481,12 @@ - (void)setYeardaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetYeardaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetYeardaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5888,9 +6509,13 @@ - (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5913,9 +6538,13 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin complet return; } - CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, - chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, - [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5938,7 +6567,11 @@ - (void)readAttributeLockState:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5963,8 +6596,11 @@ - (void)configureAttributeLockState:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5980,7 +6616,11 @@ - (void)reportAttributeLockState:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeLockState(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeLockState(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -6002,7 +6642,11 @@ - (void)readAttributeLockType:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6026,7 +6670,11 @@ - (void)readAttributeActuatorEnabled:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6049,7 +6697,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6089,8 +6741,11 @@ - (void)armFailSafe:(uint16_t)expiryLengthSeconds return; } - CHIP_ERROR err - = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6113,7 +6768,11 @@ - (void)commissioningComplete:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6140,9 +6799,13 @@ - (void)setFabric:(NSData *)fabricId return; } - CHIP_ERROR err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) fabricId.bytes, fabricId.length), - chip::ByteSpan((const uint8_t *) fabricSecret.bytes, fabricSecret.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) fabricId.bytes, fabricId.length), + chip::ByteSpan((const uint8_t *) fabricSecret.bytes, fabricSecret.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6166,7 +6829,11 @@ - (void)readAttributeFabricId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6189,7 +6856,11 @@ - (void)readAttributeBreadcrumb:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6212,7 +6883,11 @@ - (void)writeAttributeBreadcrumb:(uint64_t)value completionHandler:(ResponseHand return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6235,7 +6910,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6272,7 +6951,11 @@ - (void)readAttributeGroups:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeGroups(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeGroups(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6296,7 +6979,11 @@ - (void)readAttributeGroupKeys:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeGroupKeys(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeGroupKeys(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6319,7 +7006,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6356,9 +7047,13 @@ - (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHan return; } - CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, - chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6380,9 +7075,13 @@ - (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName return; } - CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, - chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6405,7 +7104,11 @@ - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList com return; } - CHIP_ERROR err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6427,7 +7130,11 @@ - (void)removeAllGroups:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6450,7 +7157,11 @@ - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)complet return; } - CHIP_ERROR err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6473,7 +7184,11 @@ - (void)viewGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completio return; } - CHIP_ERROR err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6496,7 +7211,11 @@ - (void)readAttributeNameSupport:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6519,7 +7238,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6555,7 +7278,11 @@ - (void)identify:(uint16_t)identifyTime completionHandler:(ResponseHandler)compl return; } - CHIP_ERROR err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6578,7 +7305,11 @@ - (void)identifyQuery:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6601,7 +7332,11 @@ - (void)readAttributeIdentifyTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6624,7 +7359,11 @@ - (void)writeAttributeIdentifyTime:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6647,7 +7386,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6687,7 +7430,11 @@ - (void)move:(uint8_t)moveMode return; } - CHIP_ERROR err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6713,8 +7460,12 @@ - (void)moveToLevel:(uint8_t)level return; } - CHIP_ERROR err - = self.cppCluster.MoveToLevel(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToLevel( + onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6738,7 +7489,11 @@ - (void)moveToLevelWithOnOff:(uint8_t)level return; } - CHIP_ERROR err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6760,7 +7515,11 @@ - (void)moveWithOnOff:(uint8_t)moveMode rate:(uint8_t)rate completionHandler:(Re return; } - CHIP_ERROR err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6787,8 +7546,12 @@ - (void)step:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.Step( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Step( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6813,7 +7576,11 @@ - (void)stepWithOnOff:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6835,7 +7602,11 @@ - (void)stop:(uint8_t)optionMask optionOverride:(uint8_t)optionOverride completi return; } - CHIP_ERROR err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6857,7 +7628,11 @@ - (void)stopWithOnOff:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6880,7 +7655,11 @@ - (void)readAttributeCurrentLevel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6906,8 +7685,12 @@ - (void)configureAttributeCurrentLevel:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentLevel( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeCurrentLevel( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6923,7 +7706,11 @@ - (void)reportAttributeCurrentLevel:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -6945,7 +7732,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6981,7 +7772,11 @@ - (void)sleep:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7004,7 +7799,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7044,8 +7843,12 @@ - (void)addThreadNetwork:(NSData *)operationalDataset return; } - CHIP_ERROR err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7072,9 +7875,13 @@ - (void)addWiFiNetwork:(NSData *)ssid return; } - CHIP_ERROR err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), - chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7100,8 +7907,12 @@ - (void)disableNetwork:(NSData *)networkID return; } - CHIP_ERROR err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7127,8 +7938,12 @@ - (void)enableNetwork:(NSData *)networkID return; } - CHIP_ERROR err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7150,7 +7965,11 @@ - (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler: return; } - CHIP_ERROR err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7176,8 +7995,12 @@ - (void)removeNetwork:(NSData *)networkID return; } - CHIP_ERROR err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7203,8 +8026,12 @@ - (void)scanNetworks:(NSData *)ssid return; } - CHIP_ERROR err = self.cppCluster.ScanNetworks( - onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ScanNetworks(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7230,8 +8057,12 @@ - (void)updateThreadNetwork:(NSData *)operationalDataset return; } - CHIP_ERROR err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7258,9 +8089,13 @@ - (void)updateWiFiNetwork:(NSData *)ssid return; } - CHIP_ERROR err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), - chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), - chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7283,7 +8118,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7319,7 +8158,11 @@ - (void)off:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Off(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Off(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7341,7 +8184,11 @@ - (void)on:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.On(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.On(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7363,7 +8210,11 @@ - (void)toggle:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.Toggle(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.Toggle(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7387,7 +8238,11 @@ - (void)readAttributeOnOff:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7412,7 +8267,11 @@ - (void)configureAttributeOnOff:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7429,7 +8288,11 @@ - (void)reportAttributeOnOff:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeOnOff(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeOnOff(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -7451,7 +8314,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7628,10 +8495,14 @@ - (void)addScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, - chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, - [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), - clusterId, length, value); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, + chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), + clusterId, length, value); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7654,7 +8525,11 @@ - (void)getSceneMembership:(uint16_t)groupId completionHandler:(ResponseHandler) return; } - CHIP_ERROR err = self.cppCluster.GetSceneMembership(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.GetSceneMembership(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7679,7 +8554,11 @@ - (void)recallScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.RecallScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RecallScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7702,7 +8581,11 @@ - (void)removeAllScenes:(uint16_t)groupId completionHandler:(ResponseHandler)com return; } - CHIP_ERROR err = self.cppCluster.RemoveAllScenes(onSuccess->Cancel(), onFailure->Cancel(), groupId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllScenes(onSuccess->Cancel(), onFailure->Cancel(), groupId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7725,7 +8608,11 @@ - (void)removeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler return; } - CHIP_ERROR err = self.cppCluster.RemoveScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7748,7 +8635,11 @@ - (void)storeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler: return; } - CHIP_ERROR err = self.cppCluster.StoreScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.StoreScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7771,7 +8662,11 @@ - (void)viewScene:(uint16_t)groupId sceneId:(uint8_t)sceneId completionHandler:( return; } - CHIP_ERROR err = self.cppCluster.ViewScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ViewScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7794,7 +8689,11 @@ - (void)readAttributeSceneCount:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSceneCount(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSceneCount(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7817,7 +8716,11 @@ - (void)readAttributeCurrentScene:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentScene(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentScene(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7840,7 +8743,11 @@ - (void)readAttributeCurrentGroup:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentGroup(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeCurrentGroup(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7864,7 +8771,11 @@ - (void)readAttributeSceneValid:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSceneValid(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeSceneValid(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7887,7 +8798,11 @@ - (void)readAttributeNameSupport:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7910,7 +8825,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7946,7 +8865,11 @@ - (void)readAttributeMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7972,8 +8895,12 @@ - (void)configureAttributeMeasuredValue:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeMeasuredValue( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ConfigureAttributeMeasuredValue( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7989,7 +8916,11 @@ - (void)reportAttributeMeasuredValue:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onReport; reportHandler([CHIPError errorForCHIPErrorCode:err], nil); @@ -8011,7 +8942,11 @@ - (void)readAttributeMinMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8034,7 +8969,11 @@ - (void)readAttributeMaxMeasuredValue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -8057,7 +8996,11 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/src/platform/Darwin/BleConnectionDelegateImpl.mm b/src/platform/Darwin/BleConnectionDelegateImpl.mm index d41f21d0f6d267..ecb3506d67044f 100644 --- a/src/platform/Darwin/BleConnectionDelegateImpl.mm +++ b/src/platform/Darwin/BleConnectionDelegateImpl.mm @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,7 @@ @interface BleConnection : NSObject @property (strong, nonatomic) dispatch_queue_t workQueue; +@property (strong, nonatomic) dispatch_queue_t chipWorkQueue; @property (strong, nonatomic) CBCentralManager * centralManager; @property (strong, nonatomic) CBPeripheral * peripheral; @property (strong, nonatomic) CBUUID * shortServiceUUID; @@ -94,6 +96,7 @@ - (id)initWithDiscriminator:(uint16_t)deviceDiscriminator self.shortServiceUUID = [UUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID]; _deviceDiscriminator = deviceDiscriminator; _workQueue = dispatch_queue_create("com.chip.ble.work_queue", DISPATCH_QUEUE_SERIAL); + _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _workQueue); _centralManager = [CBCentralManager alloc]; @@ -233,10 +236,14 @@ - (void)peripheral:(CBPeripheral *)peripheral chip::Ble::ChipBleUUID svcId; chip::Ble::ChipBleUUID charId; [BleConnection fillServiceWithCharacteristicUuids:characteristic svcId:&svcId charId:&charId]; - _mBleLayer->HandleWriteConfirmation((__bridge void *) peripheral, &svcId, &charId); + dispatch_async(_chipWorkQueue, ^{ + _mBleLayer->HandleWriteConfirmation((__bridge void *) peripheral, &svcId, &charId); + }); } else { ChipLogError(Ble, "BLE:Error writing Characteristics in Chip service on the device: [%@]", error.localizedDescription); - _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_GATT_WRITE_FAILED); + dispatch_async(_chipWorkQueue, ^{ + _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_GATT_WRITE_FAILED); + }); } } @@ -251,20 +258,24 @@ - (void)peripheral:(CBPeripheral *)peripheral chip::Ble::ChipBleUUID charId; [BleConnection fillServiceWithCharacteristicUuids:characteristic svcId:&svcId charId:&charId]; - if (isNotifying) { - _mBleLayer->HandleSubscribeComplete((__bridge void *) peripheral, &svcId, &charId); - } else { - _mBleLayer->HandleUnsubscribeComplete((__bridge void *) peripheral, &svcId, &charId); - } + dispatch_async(_chipWorkQueue, ^{ + if (isNotifying) { + _mBleLayer->HandleSubscribeComplete((__bridge void *) peripheral, &svcId, &charId); + } else { + _mBleLayer->HandleUnsubscribeComplete((__bridge void *) peripheral, &svcId, &charId); + } + }); } else { ChipLogError(Ble, "BLE:Error subscribing/unsubcribing some characteristic on the device: [%@]", error.localizedDescription); - if (isNotifying) { - // we're still notifying, so we must failed the unsubscription - _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_GATT_UNSUBSCRIBE_FAILED); - } else { - // we're not notifying, so we must failed the subscription - _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_GATT_SUBSCRIBE_FAILED); - } + dispatch_async(_chipWorkQueue, ^{ + if (isNotifying) { + // we're still notifying, so we must failed the unsubscription + _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_GATT_UNSUBSCRIBE_FAILED); + } else { + // we're not notifying, so we must failed the subscription + _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_GATT_SUBSCRIBE_FAILED); + } + }); } } @@ -278,22 +289,28 @@ - (void)peripheral:(CBPeripheral *)peripheral [BleConnection fillServiceWithCharacteristicUuids:characteristic svcId:&svcId charId:&charId]; // build a inet buffer from the rxEv and send to blelayer. - chip::System::PacketBufferHandle msgBuf + __block chip::System::PacketBufferHandle msgBuf = chip::System::PacketBufferHandle::NewWithData(characteristic.value.bytes, characteristic.value.length); if (!msgBuf.IsNull()) { - if (!_mBleLayer->HandleIndicationReceived((__bridge void *) peripheral, &svcId, &charId, std::move(msgBuf))) { - // since this error comes from device manager core - // we assume it would do the right thing, like closing the connection - ChipLogError(Ble, "Failed at handling incoming BLE data"); - } + dispatch_async(_chipWorkQueue, ^{ + if (!_mBleLayer->HandleIndicationReceived((__bridge void *) peripheral, &svcId, &charId, std::move(msgBuf))) { + // since this error comes from device manager core + // we assume it would do the right thing, like closing the connection + ChipLogError(Ble, "Failed at handling incoming BLE data"); + } + }); } else { ChipLogError(Ble, "Failed at allocating buffer for incoming BLE data"); - _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_NO_MEMORY); + dispatch_async(_chipWorkQueue, ^{ + _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_NO_MEMORY); + }); } } else { ChipLogError(Ble, "BLE:Error receiving indication of Characteristics on the device: [%@]", error.localizedDescription); - _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_GATT_INDICATE_FAILED); + dispatch_async(_chipWorkQueue, ^{ + _mBleLayer->HandleConnectionError((__bridge void *) peripheral, BLE_ERROR_GATT_INDICATE_FAILED); + }); } } diff --git a/src/platform/Darwin/PlatformManagerImpl.h b/src/platform/Darwin/PlatformManagerImpl.h index 8e6d0a57fdce1e..327fd4c817ba5a 100644 --- a/src/platform/Darwin/PlatformManagerImpl.h +++ b/src/platform/Darwin/PlatformManagerImpl.h @@ -23,8 +23,11 @@ #pragma once +#include #include +static constexpr const char * const CHIP_CONTROLLER_QUEUE = "com.zigbee.chip.framework.controller.workqueue"; + namespace chip { namespace DeviceLayer { @@ -46,7 +49,14 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener public: // ===== Platform-specific members that may be accessed directly by the application. - /* none so far */ + dispatch_queue_t GetWorkQueue() + { + if (mWorkQueue == nullptr) + { + mWorkQueue = dispatch_queue_create(CHIP_CONTROLLER_QUEUE, DISPATCH_QUEUE_SERIAL); + } + return mWorkQueue; + } private: // ===== Methods that implement the PlatformManager abstract interface. @@ -60,6 +70,8 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener friend class Internal::BLEManagerImpl; static PlatformManagerImpl sInstance; + + dispatch_queue_t mWorkQueue = nullptr; }; /**