diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm index 868ef822bd799d..bb5a53eeb9346b 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm @@ -81,16 +81,16 @@ - (NSError *)verifyOrEstablishConnectionWithCallbacks:(MCConnectionCallbacks * _ } void (^connectCallback)(CHIP_ERROR, matter::casting::core::CastingPlayer *) = ^(CHIP_ERROR err, matter::casting::core::CastingPlayer * castingPlayer) { - ChipLogProgress(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() connectCallback() called"); - dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue]; - dispatch_async(clientQueue, ^{ - if (connectionCallbacks.connectionCompleteCallback) { - connectionCallbacks.connectionCompleteCallback(err == CHIP_NO_ERROR ? nil : [MCErrorUtils NSErrorFromChipError:err]); - } else { - ChipLogError(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() connectCallback(), client failed to set the connectionCompleteCallback() callback"); - } - }); - }; + ChipLogProgress(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() connectCallback() called"); + dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue]; + dispatch_async(clientQueue, ^{ + if (connectionCallbacks.connectionCompleteCallback) { + connectionCallbacks.connectionCompleteCallback(err == CHIP_NO_ERROR ? nil : [MCErrorUtils NSErrorFromChipError:err]); + } else { + ChipLogError(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() connectCallback(), client failed to set the connectionCompleteCallback() callback"); + } + }); + }; void (^commissionerDeclarationCallback)(const chip::Transport::PeerAddress & source, const chip::Protocols::UserDirectedCommissioning::CommissionerDeclaration cppCommissionerDeclaration) = ^(const chip::Transport::PeerAddress & source, const chip::Protocols::UserDirectedCommissioning::CommissionerDeclaration cppCommissionerDeclaration) { ChipLogProgress(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() commissionerDeclarationCallback() called with cpp CommissionerDeclaration"); dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue]; diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.h index de9cc147fd2cdd..f92cb79fe3d7e9 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.h @@ -49,11 +49,11 @@ typedef NS_ENUM(NSInteger, CdError) { }; - (instancetype)initWithOptions:(NSInteger)errorCode - needsPasscode:(BOOL)needsPasscode - noAppsFound:(BOOL)noAppsFound - passcodeDialogDisplayed:(BOOL)passcodeDialogDisplayed - commissionerPasscode:(BOOL)commissionerPasscode - qRCodeDisplayed:(BOOL)qRCodeDisplayed; + needsPasscode:(BOOL)needsPasscode + noAppsFound:(BOOL)noAppsFound + passcodeDialogDisplayed:(BOOL)passcodeDialogDisplayed + commissionerPasscode:(BOOL)commissionerPasscode + qRCodeDisplayed:(BOOL)qRCodeDisplayed; - (CdError)getErrorCode; - (BOOL)getNeedsPasscode; diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.mm index 89aaee905dfcb1..6c1e270f4ac9f2 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.mm @@ -22,31 +22,31 @@ @interface MCCommissionerDeclaration () /** Feature: All - Indicates errors incurred during commissioning. */ @property (nonatomic) CdError errorCode; - /** - * Feature: Coordinate PIN Dialogs - When NoPasscode field set to true, and the Commissioner - * determines that a Passcode code will be needed for commissioning. - */ +/** + * Feature: Coordinate PIN Dialogs - When NoPasscode field set to true, and the Commissioner + * determines that a Passcode code will be needed for commissioning. + */ @property (nonatomic) BOOL needsPasscode; - /** - * Feature: Target Content Application - No apps with AccountLogin cluster implementation were - * found for the last IdentificationDeclaration request. Only apps which provide access to the - * vendor id of the Commissionee will be considered. - */ +/** + * Feature: Target Content Application - No apps with AccountLogin cluster implementation were + * found for the last IdentificationDeclaration request. Only apps which provide access to the + * vendor id of the Commissionee will be considered. + */ @property (nonatomic) BOOL noAppsFound; - /** - * Feature: Coordinate PIN Dialogs - A Passcode input dialog is now displayed for the user on the - * Commissioner. - */ +/** + * Feature: Coordinate PIN Dialogs - A Passcode input dialog is now displayed for the user on the + * Commissioner. + */ @property (nonatomic) BOOL passcodeDialogDisplayed; - /** - * Feature: Commissioner-Generated Passcode - A Passcode is now displayed for the user by the - * CastingPlayer/Commissioner. - */ +/** + * Feature: Commissioner-Generated Passcode - A Passcode is now displayed for the user by the + * CastingPlayer/Commissioner. + */ @property (nonatomic) BOOL commissionerPasscode; - /** - * Feature: Commissioner-Generated Passcode - The user experience conveying a Passcode to the user - * also displays a QR code. - */ +/** + * Feature: Commissioner-Generated Passcode - The user experience conveying a Passcode to the user + * also displays a QR code. + */ @property (nonatomic) BOOL qRCodeDisplayed; @property (nonatomic, readwrite) matter::casting::memory::Strong cppCommissionerDeclaration; @@ -70,14 +70,15 @@ - (instancetype _Nonnull)initWithCppCommissionerDeclaration:(std::shared_ptr -#ifndef MCCommissionerDeclaration_Internal_h -#define MCCommissionerDeclaration_Internal_h +#ifndef MCCommissionerDeclaration_Internal_h +#define MCCommissionerDeclaration_Internal_h @interface MCCommissionerDeclaration () diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCConnectionCallbacks.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCConnectionCallbacks.h index 08e2d3b807470b..18d4da96b2b823 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCConnectionCallbacks.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCConnectionCallbacks.h @@ -25,31 +25,28 @@ /** @brief A container class for User Directed Commissioning (UDC) callbacks. */ @interface MCConnectionCallbacks : NSObject - /** -* @param connectionCompleteCallback is required. -* @param commissionerDeclarationCallback is optional. -* -* @return A new instance of MCConnectionCallbacks. + * @param connectionCompleteCallback is required. + * @param commissionerDeclarationCallback is optional. + * + * @return A new instance of MCConnectionCallbacks. */ - (instancetype _Nonnull)initWithCallbacks:(void (^_Nonnull)(NSError * _Nonnull))connectionCompleteCallback commissionerDeclarationCallback:(void (^_Nullable)(MCCommissionerDeclaration * _Nonnull))commissionerDeclarationCallback; /** - * (Required) The callback called when the connection process has ended, regardless of whether it was successful or not. - */ + * (Required) The callback called when the connection process has ended, regardless of whether it was successful or not. + */ @property void (^_Nullable connectionCompleteCallback)(NSError * _Nonnull); - - /** - * (Optional) The callback called when the Client/Commissionee receives a CommissionerDeclaration - * message from the CastingPlayer/Commissioner. This callback is needed to support UDC features - * where a reply from the Commissioner is expected. It provides information indicating the - * Commissioner’s pre-commissioning state. - */ +/** + * (Optional) The callback called when the Client/Commissionee receives a CommissionerDeclaration + * message from the CastingPlayer/Commissioner. This callback is needed to support UDC features + * where a reply from the Commissioner is expected. It provides information indicating the + * Commissioner’s pre-commissioning state. + */ @property void (^_Nullable commissionerDeclarationCallback)(MCCommissionerDeclaration * _Nonnull); - @end #endif /* MCConnectionCallbacks_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCConnectionCallbacks.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCConnectionCallbacks.mm index a6b17b24c3f775..5a5e1e541efbb1 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCConnectionCallbacks.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCConnectionCallbacks.mm @@ -20,7 +20,8 @@ @implementation MCConnectionCallbacks - (instancetype _Nonnull)initWithCallbacks:(void (^_Nonnull)(NSError * _Nonnull))connectionCompleteCallback - commissionerDeclarationCallback:(void (^_Nullable)(MCCommissionerDeclaration * _Nonnull))commissionerDeclarationCallback { + commissionerDeclarationCallback:(void (^_Nullable)(MCCommissionerDeclaration * _Nonnull))commissionerDeclarationCallback +{ self = [super init]; if (self) { self.connectionCompleteCallback = connectionCompleteCallback; diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.h index d870588fa19531..6cdd08c596fb8e 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.h @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#import #import "MCTargetAppInfo.h" +#import #ifndef MCIdentificationDeclarationOptions_h #define MCIdentificationDeclarationOptions_h @@ -38,10 +38,10 @@ - (BOOL)getCommissionerPasscodeReady; - (BOOL)getCancelPasscode; - /** - * @brief Adds a TargetAppInfo to the IdentificationDeclarationOptions.java TargetAppInfos list, - * up to a maximum of CHIP_DEVICE_CONFIG_UDC_MAX_TARGET_APPS. - */ +/** + * @brief Adds a TargetAppInfo to the IdentificationDeclarationOptions.java TargetAppInfos list, + * up to a maximum of CHIP_DEVICE_CONFIG_UDC_MAX_TARGET_APPS. + */ - (BOOL)addTargetAppInfo:(MCTargetAppInfo *)targetAppInfo NS_SWIFT_NAME(addTargetAppInfo(_:)); - (NSArray *)getTargetAppInfoList; diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.mm index 83ca1343c23aff..002269e1275c2a 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.mm @@ -16,54 +16,55 @@ */ #import "MCIdentificationDeclarationOptions.h" -#import "core/Types.h" // from tv-casting-common #import "core/IdentificationDeclarationOptions.h" // from tv-casting-common +#import "core/Types.h" // from tv-casting-common #import "include/CHIPProjectAppConfig.h" // from tv-casting-common @interface MCIdentificationDeclarationOptions () // Private properties: - /** - * Feature: Target Content Application - Flag to instruct the Commissioner not to display a - * Passcode input dialog, and instead send a CommissionerDeclaration message if a commissioning - * Passcode is needed. - */ +/** + * Feature: Target Content Application - Flag to instruct the Commissioner not to display a + * Passcode input dialog, and instead send a CommissionerDeclaration message if a commissioning + * Passcode is needed. + */ @property (nonatomic) BOOL noPasscode; - /** - * Feature: Coordinate Passcode Dialogs - Flag to instruct the Commissioner to send a - * CommissionerDeclaration message when the Passcode input dialog on the Commissioner has been - * shown to the user. - */ +/** + * Feature: Coordinate Passcode Dialogs - Flag to instruct the Commissioner to send a + * CommissionerDeclaration message when the Passcode input dialog on the Commissioner has been + * shown to the user. + */ @property (nonatomic) BOOL cdUponPasscodeDialog; - /** - * Feature: Commissioner-Generated Passcode - Flag to instruct the Commissioner to use the - * Commissioner-generated Passcode for commissioning. - */ +/** + * Feature: Commissioner-Generated Passcode - Flag to instruct the Commissioner to use the + * Commissioner-generated Passcode for commissioning. + */ @property (nonatomic) BOOL commissionerPasscode; - /** - * Feature: Commissioner-Generated Passcode - Flag to indicate whether or not the Commissionee has - * obtained the Commissioner Passcode from the user and is therefore ready for commissioning. - */ +/** + * Feature: Commissioner-Generated Passcode - Flag to indicate whether or not the Commissionee has + * obtained the Commissioner Passcode from the user and is therefore ready for commissioning. + */ @property (nonatomic) BOOL commissionerPasscodeReady; - /** - * Feature: Coordinate Passcode Dialogs Flag - to indicate when the Commissionee user has decided - * to exit the commissioning process. - */ +/** + * Feature: Coordinate Passcode Dialogs Flag - to indicate when the Commissionee user has decided + * to exit the commissioning process. + */ @property (nonatomic) BOOL cancelPasscode; - /** - * Feature: Target Content Application - The set of content app Vendor IDs (and optionally, - * Product IDs) that can be used for authentication. Also, if TargetAppInfo is passed in, - * VerifyOrEstablishConnection() will force User Directed Commissioning, in case the desired - * TargetApp is not found in the on-device CastingStore. - */ -@property (nonatomic, strong) NSMutableArray *targetAppInfos; +/** + * Feature: Target Content Application - The set of content app Vendor IDs (and optionally, + * Product IDs) that can be used for authentication. Also, if TargetAppInfo is passed in, + * VerifyOrEstablishConnection() will force User Directed Commissioning, in case the desired + * TargetApp is not found in the on-device CastingStore. + */ +@property (nonatomic, strong) NSMutableArray * targetAppInfos; @end @implementation MCIdentificationDeclarationOptions -- (instancetype)init { +- (instancetype)init +{ self = [super init]; if (self) { _noPasscode = NO; @@ -76,7 +77,8 @@ - (instancetype)init { return self; } -- (instancetype)initWithCommissionerPasscodeOnly:(BOOL)commissionerPasscode { +- (instancetype)initWithCommissionerPasscodeOnly:(BOOL)commissionerPasscode +{ self = [super init]; if (self) { _noPasscode = NO; @@ -90,27 +92,33 @@ - (instancetype)initWithCommissionerPasscodeOnly:(BOOL)commissionerPasscode { } // Getter methods -- (BOOL)getNoPasscode { +- (BOOL)getNoPasscode +{ return _noPasscode; } -- (BOOL)getCdUponPasscodeDialog { +- (BOOL)getCdUponPasscodeDialog +{ return _cdUponPasscodeDialog; } -- (BOOL)getCommissionerPasscode { +- (BOOL)getCommissionerPasscode +{ return _commissionerPasscode; } -- (BOOL)getCommissionerPasscodeReady { +- (BOOL)getCommissionerPasscodeReady +{ return _commissionerPasscodeReady; } -- (BOOL)getCancelPasscode { +- (BOOL)getCancelPasscode +{ return _cancelPasscode; } -- (BOOL)addTargetAppInfo:(MCTargetAppInfo *)targetAppInfo { +- (BOOL)addTargetAppInfo:(MCTargetAppInfo *)targetAppInfo +{ if (self.targetAppInfos.count >= CHIP_DEVICE_CONFIG_UDC_MAX_TARGET_APPS) { ChipLogError(AppServer, "MCIdentificationDeclarationOptions addTargetAppInfo() failed to add TargetAppInfo, max targetAppInfos list size is: %d", CHIP_DEVICE_CONFIG_UDC_MAX_TARGET_APPS); return NO; @@ -119,30 +127,34 @@ - (BOOL)addTargetAppInfo:(MCTargetAppInfo *)targetAppInfo { return YES; } -- (NSArray *)getTargetAppInfoList { +- (NSArray *)getTargetAppInfoList +{ return [self.targetAppInfos copy]; } -- (NSString *)description { - NSMutableString *sb = [NSMutableString stringWithFormat:@"MCIdentificationDeclarationOptions::noPasscode: %d\n", self.noPasscode]; +- (NSString *)description +{ + NSMutableString * sb = [NSMutableString stringWithFormat:@"MCIdentificationDeclarationOptions::noPasscode: %d\n", self.noPasscode]; [sb appendFormat:@"MCIdentificationDeclarationOptions::cdUponPasscodeDialog: %d\n", self.cdUponPasscodeDialog]; [sb appendFormat:@"MCIdentificationDeclarationOptions::commissionerPasscode: %d\n", self.commissionerPasscode]; [sb appendFormat:@"MCIdentificationDeclarationOptions::commissionerPasscodeReady: %d\n", self.commissionerPasscodeReady]; [sb appendFormat:@"MCIdentificationDeclarationOptions::cancelPasscode: %d\n", self.cancelPasscode]; [sb appendString:@"MCIdentificationDeclarationOptions::targetAppInfos list: \n"]; - - for (MCTargetAppInfo *targetAppInfo in self.targetAppInfos) { + + for (MCTargetAppInfo * targetAppInfo in self.targetAppInfos) { [sb appendFormat:@"\t\tTargetAppInfo - Vendor ID: %d, Product ID: %d\n", targetAppInfo.vendorId, targetAppInfo.productId]; } - + return [sb copy]; } -- (void)logDetail { +- (void)logDetail +{ ChipLogDetail(AppServer, "MCIdentificationDeclarationOptions::logDetail()\n%@", [self description]); } -- (matter::casting::core::IdentificationDeclarationOptions)getCppIdentificationDeclarationOptions { +- (matter::casting::core::IdentificationDeclarationOptions)getCppIdentificationDeclarationOptions +{ matter::casting::core::IdentificationDeclarationOptions cppIdOptions; cppIdOptions.mNoPasscode = [self getNoPasscode]; cppIdOptions.mCdUponPasscodeDialog = [self getCdUponPasscodeDialog]; @@ -150,8 +162,8 @@ - (void)logDetail { cppIdOptions.mCommissionerPasscodeReady = [self getCommissionerPasscodeReady]; cppIdOptions.mCancelPasscode = [self getCancelPasscode]; - NSArray *targetAppInfos = [self getTargetAppInfoList]; - for (MCTargetAppInfo *appInfo in targetAppInfos) { + NSArray * targetAppInfos = [self getTargetAppInfoList]; + for (MCTargetAppInfo * appInfo in targetAppInfos) { chip::Protocols::UserDirectedCommissioning::TargetAppInfo targetAppInfo; targetAppInfo.vendorId = appInfo.vendorId; targetAppInfo.productId = appInfo.productId; diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions_Internal.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions_Internal.h index 6f466cbbb59158..8de257b0cbdbf8 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions_Internal.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions_Internal.h @@ -20,8 +20,8 @@ #import -#ifndef MCIdentificationDeclarationOptions_Internal_h -#define MCIdentificationDeclarationOptions_Internal_h +#ifndef MCIdentificationDeclarationOptions_Internal_h +#define MCIdentificationDeclarationOptions_Internal_h @interface MCIdentificationDeclarationOptions () diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.h index 7714b580752f1f..fba0799d888d35 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.h @@ -36,4 +36,4 @@ @end -#endif /* MCTargetAppInfo_h */ \ No newline at end of file +#endif /* MCTargetAppInfo_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.mm index 235603e7dcdfee..32c6b964350fef 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.mm @@ -19,7 +19,8 @@ @implementation MCTargetAppInfo -- (instancetype)init { +- (instancetype)init +{ self = [super init]; if (self) { _vendorId = 0;