From 594250105988644deb234bdb11a528aa4a5e3bae Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Mon, 7 Feb 2022 19:34:45 -0800 Subject: [PATCH] Updating zap --- .../CHIP/zap-generated/CHIPCallbackBridge.mm | 126 +++++++++++ .../CHIPCallbackBridge_internal.h | 122 ++++++++++ .../CHIP/zap-generated/CHIPClustersObjc.h | 41 ++++ .../CHIP/zap-generated/CHIPClustersObjc.mm | 212 ++++++++++++++++++ .../Framework/CHIPTests/CHIPClustersTests.m | 202 +++++++++++++++++ 5 files changed, 703 insertions(+) diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm index d162110349ae6f..4118b10e1cee20 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm @@ -1453,6 +1453,39 @@ } } +void CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::DecodableType & value) +{ + CHIPApplicationLauncherClusterApplicationEP * _Nonnull objCValue; + objCValue = [CHIPApplicationLauncherClusterApplicationEP new]; + objCValue.application = [CHIPApplicationLauncherClusterApplication new]; + objCValue.application.catalogVendorId = [NSNumber numberWithUnsignedShort:value.application.catalogVendorId]; + objCValue.application.applicationId = [[NSString alloc] initWithBytes:value.application.applicationId.data() + length:value.application.applicationId.size() + encoding:NSUTF8StringEncoding]; + objCValue.endpoint = [[NSString alloc] initWithBytes:value.endpoint.data() + length:value.endpoint.size() + encoding:NSUTF8StringEncoding]; + DispatchSuccess(context, objCValue); +}; + +void CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished( + void * context) +{ + auto * self = static_cast(context); + if (!self->mQueue) { + return; + } + + if (self->mEstablishedHandler != nil) { + dispatch_async(self->mQueue, self->mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + self->mEstablishedHandler = nil; + } +} + void CHIPApplicationLauncherServerGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn( void * context, const chip::app::DataModel::DecodableList & value) { @@ -2714,6 +2747,73 @@ } } +void CHIPChannelChannelLineupStructAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::Clusters::Channel::Structs::LineupInfo::DecodableType & value) +{ + CHIPChannelClusterLineupInfo * _Nonnull objCValue; + objCValue = [CHIPChannelClusterLineupInfo new]; + objCValue.operatorName = [[NSString alloc] initWithBytes:value.operatorName.data() + length:value.operatorName.size() + encoding:NSUTF8StringEncoding]; + objCValue.lineupName = [[NSString alloc] initWithBytes:value.lineupName.data() + length:value.lineupName.size() + encoding:NSUTF8StringEncoding]; + objCValue.postalCode = [[NSString alloc] initWithBytes:value.postalCode.data() + length:value.postalCode.size() + encoding:NSUTF8StringEncoding]; + objCValue.lineupInfoType = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.lineupInfoType)]; + DispatchSuccess(context, objCValue); +}; + +void CHIPChannelChannelLineupStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished(void * context) +{ + auto * self = static_cast(context); + if (!self->mQueue) { + return; + } + + if (self->mEstablishedHandler != nil) { + dispatch_async(self->mQueue, self->mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + self->mEstablishedHandler = nil; + } +} + +void CHIPChannelCurrentChannelStructAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::Clusters::Channel::Structs::ChannelInfo::DecodableType & value) +{ + CHIPChannelClusterChannelInfo * _Nonnull objCValue; + objCValue = [CHIPChannelClusterChannelInfo new]; + objCValue.majorNumber = [NSNumber numberWithUnsignedShort:value.majorNumber]; + objCValue.minorNumber = [NSNumber numberWithUnsignedShort:value.minorNumber]; + objCValue.name = [[NSString alloc] initWithBytes:value.name.data() length:value.name.size() encoding:NSUTF8StringEncoding]; + objCValue.callSign = [[NSString alloc] initWithBytes:value.callSign.data() + length:value.callSign.size() + encoding:NSUTF8StringEncoding]; + objCValue.affiliateCallSign = [[NSString alloc] initWithBytes:value.affiliateCallSign.data() + length:value.affiliateCallSign.size() + encoding:NSUTF8StringEncoding]; + DispatchSuccess(context, objCValue); +}; + +void CHIPChannelCurrentChannelStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished(void * context) +{ + auto * self = static_cast(context); + if (!self->mQueue) { + return; + } + + if (self->mEstablishedHandler != nil) { + dispatch_async(self->mQueue, self->mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + self->mEstablishedHandler = nil; + } +} + void CHIPChannelServerGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn( void * context, const chip::app::DataModel::DecodableList & value) { @@ -5781,6 +5881,32 @@ } } +void CHIPMediaPlaybackPositionStructAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::Clusters::MediaPlayback::Structs::PlaybackPosition::DecodableType & value) +{ + CHIPMediaPlaybackClusterPlaybackPosition * _Nonnull objCValue; + objCValue = [CHIPMediaPlaybackClusterPlaybackPosition new]; + objCValue.updatedAt = [NSNumber numberWithUnsignedLongLong:value.updatedAt]; + objCValue.position = [NSNumber numberWithUnsignedLongLong:value.position]; + DispatchSuccess(context, objCValue); +}; + +void CHIPMediaPlaybackPositionStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished(void * context) +{ + auto * self = static_cast(context); + if (!self->mQueue) { + return; + } + + if (self->mEstablishedHandler != nil) { + dispatch_async(self->mQueue, self->mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + self->mEstablishedHandler = nil; + } +} + void CHIPMediaPlaybackServerGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn( void * context, const chip::app::DataModel::DecodableList & value) { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h index e8805677828cbc..d3e4eb4758bb43 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h @@ -545,8 +545,16 @@ typedef void (*NullableApplianceEventsAndAlertClusterEventIdentificationAttribut typedef void (*ApplicationBasicApplicationAppStructAttributeCallback)( void *, const chip::app::Clusters::ApplicationBasic::Structs::ApplicationBasicApplication::DecodableType &); +typedef void (*ApplicationLauncherApplicationLauncherAppStructAttributeCallback)( + void *, const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::DecodableType &); +typedef void (*ChannelChannelLineupStructAttributeCallback)( + void *, const chip::app::Clusters::Channel::Structs::LineupInfo::DecodableType &); +typedef void (*ChannelCurrentChannelStructAttributeCallback)( + void *, const chip::app::Clusters::Channel::Structs::ChannelInfo::DecodableType &); typedef void (*GeneralCommissioningBasicCommissioningInfoStructAttributeCallback)( void *, const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType &); +typedef void (*MediaPlaybackPositionStructAttributeCallback)( + void *, const chip::app::Clusters::MediaPlayback::Structs::PlaybackPosition::DecodableType &); typedef void (*TestClusterStructAttrStructAttributeCallback)( void *, const chip::app::Clusters::TestCluster::Structs::SimpleStruct::DecodableType &); typedef void (*TestClusterNullableStructStructAttributeCallback)( @@ -1770,6 +1778,36 @@ class CHIPApplicationLauncherApplicationLauncherListListAttributeCallbackSubscri SubscriptionEstablishedHandler mEstablishedHandler; }; +class CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackBridge + : public CHIPCallbackBridge +{ +public: + CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + CHIPActionBlock action, bool keepAlive = false) : + CHIPCallbackBridge(queue, handler, action, OnSuccessFn, + keepAlive){}; + + static void OnSuccessFn(void * context, + const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::DecodableType & value); +}; + +class CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackSubscriptionBridge + : public CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackBridge +{ +public: + CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, CHIPActionBlock action, + SubscriptionEstablishedHandler establishedHandler) : + CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackBridge(queue, handler, action, true), + mEstablishedHandler(establishedHandler) + {} + + static void OnSubscriptionEstablished(void * context); + +private: + SubscriptionEstablishedHandler mEstablishedHandler; +}; + class CHIPApplicationLauncherServerGeneratedCommandListListAttributeCallbackBridge : public CHIPCallbackBridge { @@ -2658,6 +2696,61 @@ class CHIPChannelChannelListListAttributeCallbackSubscriptionBridge : public CHI SubscriptionEstablishedHandler mEstablishedHandler; }; +class CHIPChannelChannelLineupStructAttributeCallbackBridge : public CHIPCallbackBridge +{ +public: + CHIPChannelChannelLineupStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, CHIPActionBlock action, + bool keepAlive = false) : + CHIPCallbackBridge(queue, handler, action, OnSuccessFn, keepAlive){}; + + static void OnSuccessFn(void * context, const chip::app::Clusters::Channel::Structs::LineupInfo::DecodableType & value); +}; + +class CHIPChannelChannelLineupStructAttributeCallbackSubscriptionBridge + : public CHIPChannelChannelLineupStructAttributeCallbackBridge +{ +public: + CHIPChannelChannelLineupStructAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler, + CHIPActionBlock action, + SubscriptionEstablishedHandler establishedHandler) : + CHIPChannelChannelLineupStructAttributeCallbackBridge(queue, handler, action, true), + mEstablishedHandler(establishedHandler) + {} + + static void OnSubscriptionEstablished(void * context); + +private: + SubscriptionEstablishedHandler mEstablishedHandler; +}; + +class CHIPChannelCurrentChannelStructAttributeCallbackBridge + : public CHIPCallbackBridge +{ +public: + CHIPChannelCurrentChannelStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, CHIPActionBlock action, + bool keepAlive = false) : + CHIPCallbackBridge(queue, handler, action, OnSuccessFn, keepAlive){}; + + static void OnSuccessFn(void * context, const chip::app::Clusters::Channel::Structs::ChannelInfo::DecodableType & value); +}; + +class CHIPChannelCurrentChannelStructAttributeCallbackSubscriptionBridge + : public CHIPChannelCurrentChannelStructAttributeCallbackBridge +{ +public: + CHIPChannelCurrentChannelStructAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler, + CHIPActionBlock action, + SubscriptionEstablishedHandler establishedHandler) : + CHIPChannelCurrentChannelStructAttributeCallbackBridge(queue, handler, action, true), + mEstablishedHandler(establishedHandler) + {} + + static void OnSubscriptionEstablished(void * context); + +private: + SubscriptionEstablishedHandler mEstablishedHandler; +}; + class CHIPChannelServerGeneratedCommandListListAttributeCallbackBridge : public CHIPCallbackBridge { @@ -4868,6 +4961,35 @@ class CHIPMediaInputAttributeListListAttributeCallbackSubscriptionBridge SubscriptionEstablishedHandler mEstablishedHandler; }; +class CHIPMediaPlaybackPositionStructAttributeCallbackBridge + : public CHIPCallbackBridge +{ +public: + CHIPMediaPlaybackPositionStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, CHIPActionBlock action, + bool keepAlive = false) : + CHIPCallbackBridge(queue, handler, action, OnSuccessFn, keepAlive){}; + + static void OnSuccessFn(void * context, + const chip::app::Clusters::MediaPlayback::Structs::PlaybackPosition::DecodableType & value); +}; + +class CHIPMediaPlaybackPositionStructAttributeCallbackSubscriptionBridge + : public CHIPMediaPlaybackPositionStructAttributeCallbackBridge +{ +public: + CHIPMediaPlaybackPositionStructAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler, + CHIPActionBlock action, + SubscriptionEstablishedHandler establishedHandler) : + CHIPMediaPlaybackPositionStructAttributeCallbackBridge(queue, handler, action, true), + mEstablishedHandler(establishedHandler) + {} + + static void OnSubscriptionEstablished(void * context); + +private: + SubscriptionEstablishedHandler mEstablishedHandler; +}; + class CHIPMediaPlaybackServerGeneratedCommandListListAttributeCallbackBridge : public CHIPCallbackBridge { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h index ec04507377ef8f..008ab30d57bf17 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h @@ -339,6 +339,17 @@ NS_ASSUME_NONNULL_BEGIN reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; +- (void)readAttributeApplicationLauncherAppWithCompletionHandler: + (void (^)(CHIPApplicationLauncherClusterApplicationEP * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)writeAttributeApplicationLauncherAppWithValue:(CHIPApplicationLauncherClusterApplicationEP * _Nonnull)value + completionHandler:(StatusCompletion)completionHandler; +- (void) + subscribeAttributeApplicationLauncherAppWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(CHIPApplicationLauncherClusterApplicationEP * _Nullable value, + NSError * _Nullable error))reportHandler; + - (void)readAttributeServerGeneratedCommandListWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)subscribeAttributeServerGeneratedCommandListWithMinInterval:(uint16_t)minInterval @@ -1128,6 +1139,26 @@ NS_ASSUME_NONNULL_BEGIN subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; +- (void)readAttributeChannelLineupWithCompletionHandler:(void (^)(CHIPChannelClusterLineupInfo * _Nullable value, + NSError * _Nullable error))completionHandler; +- (void)writeAttributeChannelLineupWithValue:(CHIPChannelClusterLineupInfo * _Nonnull)value + completionHandler:(StatusCompletion)completionHandler; +- (void)subscribeAttributeChannelLineupWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(CHIPChannelClusterLineupInfo * _Nullable value, + NSError * _Nullable error))reportHandler; + +- (void)readAttributeCurrentChannelWithCompletionHandler:(void (^)(CHIPChannelClusterChannelInfo * _Nullable value, + NSError * _Nullable error))completionHandler; +- (void)writeAttributeCurrentChannelWithValue:(CHIPChannelClusterChannelInfo * _Nonnull)value + completionHandler:(StatusCompletion)completionHandler; +- (void)subscribeAttributeCurrentChannelWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(CHIPChannelClusterChannelInfo * _Nullable value, + NSError * _Nullable error))reportHandler; + - (void)readAttributeServerGeneratedCommandListWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)subscribeAttributeServerGeneratedCommandListWithMinInterval:(uint16_t)minInterval @@ -3394,6 +3425,16 @@ NS_ASSUME_NONNULL_BEGIN subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler; +- (void)readAttributePositionWithCompletionHandler:(void (^)(CHIPMediaPlaybackClusterPlaybackPosition * _Nullable value, + NSError * _Nullable error))completionHandler; +- (void)writeAttributePositionWithValue:(CHIPMediaPlaybackClusterPlaybackPosition * _Nonnull)value + completionHandler:(StatusCompletion)completionHandler; +- (void)subscribeAttributePositionWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(CHIPMediaPlaybackClusterPlaybackPosition * _Nullable value, + NSError * _Nullable error))reportHandler; + - (void)readAttributePlaybackSpeedWithCompletionHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completionHandler; - (void)subscribeAttributePlaybackSpeedWithMinInterval:(uint16_t)minInterval diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm index 679e9462293c07..5a94e913a00948 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm @@ -1308,6 +1308,59 @@ new CHIPApplicationLauncherApplicationLauncherListListAttributeCallbackSubscript subscriptionEstablishedHandler); } +- (void)readAttributeApplicationLauncherAppWithCompletionHandler: + (void (^)(CHIPApplicationLauncherClusterApplicationEP * _Nullable value, NSError * _Nullable error))completionHandler +{ + new CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = ApplicationLauncher::Attributes::ApplicationLauncherApp::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)writeAttributeApplicationLauncherAppWithValue:(CHIPApplicationLauncherClusterApplicationEP * _Nonnull)value + completionHandler:(StatusCompletion)completionHandler +{ + new CHIPDefaultSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable ignored, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + ListFreer listFreer; + using TypeInfo = ApplicationLauncher::Attributes::ApplicationLauncherApp::TypeInfo; + TypeInfo::Type cppValue; + cppValue.application.catalogVendorId = value.application.catalogVendorId.unsignedShortValue; + cppValue.application.applicationId = [self asCharSpan:value.application.applicationId]; + cppValue.endpoint = [self asCharSpan:value.endpoint]; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void) + subscribeAttributeApplicationLauncherAppWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(CHIPApplicationLauncherClusterApplicationEP * _Nullable value, + NSError * _Nullable error))reportHandler +{ + new CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackSubscriptionBridge( + self.callbackQueue, reportHandler, + ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = ApplicationLauncher::Attributes::ApplicationLauncherApp::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + minInterval, maxInterval, + CHIPApplicationLauncherApplicationLauncherAppStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + }, + subscriptionEstablishedHandler); +} + - (void)readAttributeServerGeneratedCommandListWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { @@ -4406,6 +4459,114 @@ new CHIPChannelChannelListListAttributeCallbackSubscriptionBridge( subscriptionEstablishedHandler); } +- (void)readAttributeChannelLineupWithCompletionHandler:(void (^)(CHIPChannelClusterLineupInfo * _Nullable value, + NSError * _Nullable error))completionHandler +{ + new CHIPChannelChannelLineupStructAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = Channel::Attributes::ChannelLineup::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)writeAttributeChannelLineupWithValue:(CHIPChannelClusterLineupInfo * _Nonnull)value + completionHandler:(StatusCompletion)completionHandler +{ + new CHIPDefaultSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable ignored, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + ListFreer listFreer; + using TypeInfo = Channel::Attributes::ChannelLineup::TypeInfo; + TypeInfo::Type cppValue; + cppValue.operatorName = [self asCharSpan:value.operatorName]; + cppValue.lineupName = [self asCharSpan:value.lineupName]; + cppValue.postalCode = [self asCharSpan:value.postalCode]; + cppValue.lineupInfoType + = static_cast>(value.lineupInfoType.unsignedCharValue); + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)subscribeAttributeChannelLineupWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(CHIPChannelClusterLineupInfo * _Nullable value, + NSError * _Nullable error))reportHandler +{ + new CHIPChannelChannelLineupStructAttributeCallbackSubscriptionBridge( + self.callbackQueue, reportHandler, + ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = Channel::Attributes::ChannelLineup::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + minInterval, maxInterval, + CHIPChannelChannelLineupStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + }, + subscriptionEstablishedHandler); +} + +- (void)readAttributeCurrentChannelWithCompletionHandler:(void (^)(CHIPChannelClusterChannelInfo * _Nullable value, + NSError * _Nullable error))completionHandler +{ + new CHIPChannelCurrentChannelStructAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = Channel::Attributes::CurrentChannel::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)writeAttributeCurrentChannelWithValue:(CHIPChannelClusterChannelInfo * _Nonnull)value + completionHandler:(StatusCompletion)completionHandler +{ + new CHIPDefaultSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable ignored, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + ListFreer listFreer; + using TypeInfo = Channel::Attributes::CurrentChannel::TypeInfo; + TypeInfo::Type cppValue; + cppValue.majorNumber = value.majorNumber.unsignedShortValue; + cppValue.minorNumber = value.minorNumber.unsignedShortValue; + cppValue.name = [self asCharSpan:value.name]; + cppValue.callSign = [self asCharSpan:value.callSign]; + cppValue.affiliateCallSign = [self asCharSpan:value.affiliateCallSign]; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)subscribeAttributeCurrentChannelWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(CHIPChannelClusterChannelInfo * _Nullable value, + NSError * _Nullable error))reportHandler +{ + new CHIPChannelCurrentChannelStructAttributeCallbackSubscriptionBridge( + self.callbackQueue, reportHandler, + ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = Channel::Attributes::CurrentChannel::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + minInterval, maxInterval, + CHIPChannelCurrentChannelStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + }, + subscriptionEstablishedHandler); +} + - (void)readAttributeServerGeneratedCommandListWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { @@ -13922,6 +14083,57 @@ new CHIPInt64uAttributeCallbackSubscriptionBridge( subscriptionEstablishedHandler); } +- (void)readAttributePositionWithCompletionHandler:(void (^)(CHIPMediaPlaybackClusterPlaybackPosition * _Nullable value, + NSError * _Nullable error))completionHandler +{ + new CHIPMediaPlaybackPositionStructAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = MediaPlayback::Attributes::Position::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)writeAttributePositionWithValue:(CHIPMediaPlaybackClusterPlaybackPosition * _Nonnull)value + completionHandler:(StatusCompletion)completionHandler +{ + new CHIPDefaultSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable ignored, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + ListFreer listFreer; + using TypeInfo = MediaPlayback::Attributes::Position::TypeInfo; + TypeInfo::Type cppValue; + cppValue.updatedAt = value.updatedAt.unsignedLongLongValue; + cppValue.position = value.position.unsignedLongLongValue; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)subscribeAttributePositionWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(CHIPMediaPlaybackClusterPlaybackPosition * _Nullable value, + NSError * _Nullable error))reportHandler +{ + new CHIPMediaPlaybackPositionStructAttributeCallbackSubscriptionBridge( + self.callbackQueue, reportHandler, + ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = MediaPlayback::Attributes::Position::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + minInterval, maxInterval, + CHIPMediaPlaybackPositionStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + }, + subscriptionEstablishedHandler); +} + - (void)readAttributePlaybackSpeedWithCompletionHandler:(void (^)( NSNumber * _Nullable value, NSError * _Nullable error))completionHandler { diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 55c239066c218f..71116af4a37eb9 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -44170,6 +44170,58 @@ - (void)testSendClusterApplicationLauncherReadAttributeApplicationLauncherListWi [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterApplicationLauncherReadAttributeApplicationLauncherAppWithCompletionHandler +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPApplicationLauncher * cluster = [[CHIPApplicationLauncher alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = + [self expectationWithDescription:@"ApplicationLauncherReadAttributeApplicationLauncherAppWithCompletionHandler"]; + + [cluster readAttributeApplicationLauncherAppWithCompletionHandler:^( + CHIPApplicationLauncherClusterApplicationEP * _Nullable value, NSError * _Nullable err) { + NSLog(@"ApplicationLauncher ApplicationLauncherApp Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterApplicationLauncherWriteAttributeApplicationLauncherAppWithValue +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPApplicationLauncher * cluster = [[CHIPApplicationLauncher alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = + [self expectationWithDescription:@"ApplicationLauncherWriteAttributeApplicationLauncherAppWithValue"]; + + CHIPApplicationLauncherClusterApplicationEP * _Nonnull value = [[CHIPApplicationLauncherClusterApplicationEP alloc] init]; + [cluster writeAttributeApplicationLauncherAppWithValue:value + completionHandler:^(NSError * _Nullable err) { + NSLog(@"ApplicationLauncher ApplicationLauncherApp Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} - (void)testSendClusterApplicationLauncherReadAttributeServerGeneratedCommandListWithCompletionHandler { dispatch_queue_t queue = dispatch_get_main_queue(); @@ -45740,6 +45792,106 @@ - (void)testSendClusterChannelReadAttributeChannelListWithCompletionHandler [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterChannelReadAttributeChannelLineupWithCompletionHandler +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPChannel * cluster = [[CHIPChannel alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = [self expectationWithDescription:@"ChannelReadAttributeChannelLineupWithCompletionHandler"]; + + [cluster + readAttributeChannelLineupWithCompletionHandler:^(CHIPChannelClusterLineupInfo * _Nullable value, NSError * _Nullable err) { + NSLog(@"Channel ChannelLineup Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterChannelWriteAttributeChannelLineupWithValue +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPChannel * cluster = [[CHIPChannel alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = [self expectationWithDescription:@"ChannelWriteAttributeChannelLineupWithValue"]; + + CHIPChannelClusterLineupInfo * _Nonnull value = [[CHIPChannelClusterLineupInfo alloc] init]; + [cluster writeAttributeChannelLineupWithValue:value + completionHandler:^(NSError * _Nullable err) { + NSLog(@"Channel ChannelLineup Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterChannelReadAttributeCurrentChannelWithCompletionHandler +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPChannel * cluster = [[CHIPChannel alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = [self expectationWithDescription:@"ChannelReadAttributeCurrentChannelWithCompletionHandler"]; + + [cluster readAttributeCurrentChannelWithCompletionHandler:^( + CHIPChannelClusterChannelInfo * _Nullable value, NSError * _Nullable err) { + NSLog(@"Channel CurrentChannel Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterChannelWriteAttributeCurrentChannelWithValue +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPChannel * cluster = [[CHIPChannel alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = [self expectationWithDescription:@"ChannelWriteAttributeCurrentChannelWithValue"]; + + CHIPChannelClusterChannelInfo * _Nonnull value = [[CHIPChannelClusterChannelInfo alloc] init]; + [cluster writeAttributeCurrentChannelWithValue:value + completionHandler:^(NSError * _Nullable err) { + NSLog(@"Channel CurrentChannel Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} - (void)testSendClusterChannelReadAttributeServerGeneratedCommandListWithCompletionHandler { dispatch_queue_t queue = dispatch_get_main_queue(); @@ -52356,6 +52508,56 @@ - (void)testSendClusterMediaPlaybackReadAttributeDurationWithCompletionHandler [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterMediaPlaybackReadAttributePositionWithCompletionHandler +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPMediaPlayback * cluster = [[CHIPMediaPlayback alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = [self expectationWithDescription:@"MediaPlaybackReadAttributePositionWithCompletionHandler"]; + + [cluster readAttributePositionWithCompletionHandler:^( + CHIPMediaPlaybackClusterPlaybackPosition * _Nullable value, NSError * _Nullable err) { + NSLog(@"MediaPlayback Position Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterMediaPlaybackWriteAttributePositionWithValue +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPMediaPlayback * cluster = [[CHIPMediaPlayback alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = [self expectationWithDescription:@"MediaPlaybackWriteAttributePositionWithValue"]; + + CHIPMediaPlaybackClusterPlaybackPosition * _Nonnull value = [[CHIPMediaPlaybackClusterPlaybackPosition alloc] init]; + [cluster writeAttributePositionWithValue:value + completionHandler:^(NSError * _Nullable err) { + NSLog(@"MediaPlayback Position Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} - (void)testSendClusterMediaPlaybackReadAttributePlaybackSpeedWithCompletionHandler { dispatch_queue_t queue = dispatch_get_main_queue();