Skip to content

Commit fbd68cc

Browse files
committedJun 21, 2024
Addressed comments by sharadb-amazon
1 parent a04cbde commit fbd68cc

15 files changed

+128
-212
lines changed
 

‎examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ - (NSError *)verifyOrEstablishConnectionWithCallbacks:(MCConnectionCallbacks * _
133133
if (identificationDeclarationOptions != nil) {
134134
cppIdOptions = [identificationDeclarationOptions getCppIdentificationDeclarationOptions];
135135
} else {
136-
ChipLogProgress(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks()->setupCppIdOptions() helper. Client did not set the optional MCIdentificationDeclarationOptions using default options");
136+
ChipLogProgress(AppServer, "MCCastingPlayer.setupCppIdOptions() Client did not set the optional MCIdentificationDeclarationOptions using default options");
137137
}
138138
return cppIdOptions;
139139
}

‎examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.h

+29-7
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,42 @@ typedef NS_ENUM(NSInteger, CdError) {
4848
kUnexpectedCommissionerPasscodeReady = 18
4949
};
5050

51+
/** Feature: All - Indicates errors incurred during commissioning. */
52+
@property (nonatomic, readonly) CdError errorCode;
53+
/**
54+
* Feature: Coordinate PIN Dialogs - When NoPasscode field set to true, and the Commissioner
55+
* determines that a Passcode code will be needed for commissioning.
56+
*/
57+
@property (nonatomic, readonly) BOOL needsPasscode;
58+
/**
59+
* Feature: Target Content Application - No apps with AccountLogin cluster implementation were
60+
* found for the last IdentificationDeclaration request. Only apps which provide access to the
61+
* vendor id of the Commissionee will be considered.
62+
*/
63+
@property (nonatomic, readonly) BOOL noAppsFound;
64+
/**
65+
* Feature: Coordinate PIN Dialogs - A Passcode input dialog is now displayed for the user on the
66+
* Commissioner.
67+
*/
68+
@property (nonatomic, readonly) BOOL passcodeDialogDisplayed;
69+
/**
70+
* Feature: Commissioner-Generated Passcode - A Passcode is now displayed for the user by the
71+
* CastingPlayer/Commissioner.
72+
*/
73+
@property (nonatomic, readonly) BOOL commissionerPasscode;
74+
/**
75+
* Feature: Commissioner-Generated Passcode - The user experience conveying a Passcode to the user
76+
* also displays a QR code.
77+
*/
78+
@property (nonatomic, readonly) BOOL qRCodeDisplayed;
79+
5180
- (instancetype)initWithOptions:(NSInteger)errorCode
5281
needsPasscode:(BOOL)needsPasscode
5382
noAppsFound:(BOOL)noAppsFound
5483
passcodeDialogDisplayed:(BOOL)passcodeDialogDisplayed
5584
commissionerPasscode:(BOOL)commissionerPasscode
5685
qRCodeDisplayed:(BOOL)qRCodeDisplayed;
5786

58-
- (CdError)getErrorCode;
59-
- (BOOL)getNeedsPasscode;
60-
- (BOOL)getNoAppsFound;
61-
- (BOOL)getPasscodeDialogDisplayed;
62-
- (BOOL)getCommissionerPasscode;
63-
- (BOOL)getQRCodeDisplayed;
64-
6587
- (NSString *)description;
6688
- (void)logDetail;
6789

‎examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionerDeclaration.mm

-59
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,6 @@
2020

2121
@interface MCCommissionerDeclaration ()
2222

23-
/** Feature: All - Indicates errors incurred during commissioning. */
24-
@property (nonatomic) CdError errorCode;
25-
/**
26-
* Feature: Coordinate PIN Dialogs - When NoPasscode field set to true, and the Commissioner
27-
* determines that a Passcode code will be needed for commissioning.
28-
*/
29-
@property (nonatomic) BOOL needsPasscode;
30-
/**
31-
* Feature: Target Content Application - No apps with AccountLogin cluster implementation were
32-
* found for the last IdentificationDeclaration request. Only apps which provide access to the
33-
* vendor id of the Commissionee will be considered.
34-
*/
35-
@property (nonatomic) BOOL noAppsFound;
36-
/**
37-
* Feature: Coordinate PIN Dialogs - A Passcode input dialog is now displayed for the user on the
38-
* Commissioner.
39-
*/
40-
@property (nonatomic) BOOL passcodeDialogDisplayed;
41-
/**
42-
* Feature: Commissioner-Generated Passcode - A Passcode is now displayed for the user by the
43-
* CastingPlayer/Commissioner.
44-
*/
45-
@property (nonatomic) BOOL commissionerPasscode;
46-
/**
47-
* Feature: Commissioner-Generated Passcode - The user experience conveying a Passcode to the user
48-
* also displays a QR code.
49-
*/
50-
@property (nonatomic) BOOL qRCodeDisplayed;
51-
5223
@property (nonatomic, readwrite) matter::casting::memory::Strong<chip::Protocols::UserDirectedCommissioning::CommissionerDeclaration> cppCommissionerDeclaration;
5324

5425
@end
@@ -88,36 +59,6 @@ - (instancetype)initWithOptions:(NSInteger)errorCode
8859
return self;
8960
}
9061

91-
- (CdError)getErrorCode
92-
{
93-
return _errorCode;
94-
}
95-
96-
- (BOOL)getNeedsPasscode
97-
{
98-
return _needsPasscode;
99-
}
100-
101-
- (BOOL)getNoAppsFound
102-
{
103-
return _noAppsFound;
104-
}
105-
106-
- (BOOL)getPasscodeDialogDisplayed
107-
{
108-
return _passcodeDialogDisplayed;
109-
}
110-
111-
- (BOOL)getCommissionerPasscode
112-
{
113-
return _commissionerPasscode;
114-
}
115-
116-
- (BOOL)getQRCodeDisplayed
117-
{
118-
return _qRCodeDisplayed;
119-
}
120-
12162
- (NSString *)description
12263
{
12364
return [NSString stringWithFormat:@"MCCommissionerDeclaration::errorCode: %@\nMCCommissionerDeclaration::needsPasscode: %d\nMCCommissionerDeclaration::noAppsFound: %d\nMCCommissionerDeclaration::passcodeDialogDisplayed: %d\nMCCommissionerDeclaration::commissionerPasscode: %d\nMCCommissionerDeclaration::qRCodeDisplayed: %d",

‎examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDataSource.h

-10
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@
2929
*/
3030
- (dispatch_queue_t _Nonnull)clientQueue;
3131

32-
/**
33-
* @brief Updates the MCCommissionableData object stored inside MCAppParametersDataSource, which was used to
34-
* initialize the MCCastingApp. This function needs to be implemented by the client in use cases where the
35-
* MCCommissionableData needs to be updated post-initialization. For example, when the Commissioner-Generated
36-
* Passcode feature is used.
37-
*
38-
* @param newCommissionableData The new MCCommissionableData object to be used for the next commissioning session.
39-
*/
40-
- (void)update:(MCCommissionableData * _Nonnull)newCommissionableData;
41-
4232
/**
4333
* @brief Provide UniqueId used to generate the RotatingDeviceId advertised during commissioning by the MCCastingApp
4434
* Must be at least 16 bytes (i.e. ConfigurationManager::kMinRotatingDeviceIDUniqueIDLength)

‎examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.h

+34-7
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,49 @@
2727
*/
2828
@interface MCIdentificationDeclarationOptions : NSObject
2929

30+
/**
31+
* Feature: Target Content Application - Flag to instruct the Commissioner not to display a
32+
* Passcode input dialog, and instead send a CommissionerDeclaration message if a commissioning
33+
* Passcode is needed.
34+
*/
35+
@property (nonatomic, readonly) BOOL noPasscode;
36+
/**
37+
* Feature: Coordinate Passcode Dialogs - Flag to instruct the Commissioner to send a
38+
* CommissionerDeclaration message when the Passcode input dialog on the Commissioner has been
39+
* shown to the user.
40+
*/
41+
@property (nonatomic, readonly) BOOL cdUponPasscodeDialog;
42+
/**
43+
* Feature: Commissioner-Generated Passcode - Flag to instruct the Commissioner to use the
44+
* Commissioner-generated Passcode for commissioning.
45+
*/
46+
@property (nonatomic, readonly) BOOL commissionerPasscode;
47+
/**
48+
* Feature: Commissioner-Generated Passcode - Flag to indicate whether or not the Commissionee has
49+
* obtained the Commissioner Passcode from the user and is therefore ready for commissioning.
50+
*/
51+
@property (nonatomic, readonly) BOOL commissionerPasscodeReady;
52+
/**
53+
* Feature: Coordinate Passcode Dialogs Flag - to indicate when the Commissionee user has decided
54+
* to exit the commissioning process.
55+
*/
56+
@property (nonatomic, readonly) BOOL cancelPasscode;
57+
3058
- (instancetype)init;
3159

3260
- (instancetype)initWithCommissionerPasscodeOnly:(BOOL)commissionerPasscode;
3361

34-
// Getter methods
35-
- (BOOL)getNoPasscode;
36-
- (BOOL)getCdUponPasscodeDialog;
37-
- (BOOL)getCommissionerPasscode;
38-
- (BOOL)getCommissionerPasscodeReady;
39-
- (BOOL)getCancelPasscode;
40-
4162
/**
4263
* @brief Adds a TargetAppInfo to the IdentificationDeclarationOptions.java TargetAppInfos list,
4364
* up to a maximum of CHIP_DEVICE_CONFIG_UDC_MAX_TARGET_APPS.
4465
*/
4566
- (BOOL)addTargetAppInfo:(MCTargetAppInfo *)targetAppInfo NS_SWIFT_NAME(addTargetAppInfo(_:));
67+
/**
68+
* Feature: Target Content Application - The set of content app Vendor IDs (and optionally,
69+
* Product IDs) that can be used for authentication. Also, if TargetAppInfo is passed in,
70+
* VerifyOrEstablishConnection() will force User Directed Commissioning, in case the desired
71+
* TargetApp is not found in the on-device CastingStore.
72+
*/
4673
- (NSArray<MCTargetAppInfo *> *)getTargetAppInfoList;
4774

4875
- (NSString *)description;

‎examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCIdentificationDeclarationOptions.mm

+2-31
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,6 @@
2121

2222
@interface MCIdentificationDeclarationOptions ()
2323

24-
// Private properties:
25-
26-
/**
27-
* Feature: Target Content Application - Flag to instruct the Commissioner not to display a
28-
* Passcode input dialog, and instead send a CommissionerDeclaration message if a commissioning
29-
* Passcode is needed.
30-
*/
31-
@property (nonatomic) BOOL noPasscode;
32-
/**
33-
* Feature: Coordinate Passcode Dialogs - Flag to instruct the Commissioner to send a
34-
* CommissionerDeclaration message when the Passcode input dialog on the Commissioner has been
35-
* shown to the user.
36-
*/
37-
@property (nonatomic) BOOL cdUponPasscodeDialog;
38-
/**
39-
* Feature: Commissioner-Generated Passcode - Flag to instruct the Commissioner to use the
40-
* Commissioner-generated Passcode for commissioning.
41-
*/
42-
@property (nonatomic) BOOL commissionerPasscode;
43-
/**
44-
* Feature: Commissioner-Generated Passcode - Flag to indicate whether or not the Commissionee has
45-
* obtained the Commissioner Passcode from the user and is therefore ready for commissioning.
46-
*/
47-
@property (nonatomic) BOOL commissionerPasscodeReady;
48-
/**
49-
* Feature: Coordinate Passcode Dialogs Flag - to indicate when the Commissionee user has decided
50-
* to exit the commissioning process.
51-
*/
52-
@property (nonatomic) BOOL cancelPasscode;
5324
/**
5425
* Feature: Target Content Application - The set of content app Vendor IDs (and optionally,
5526
* Product IDs) that can be used for authentication. Also, if TargetAppInfo is passed in,
@@ -159,8 +130,8 @@ - (NSString *)description
159130
NSArray<MCTargetAppInfo *> * targetAppInfos = [self getTargetAppInfoList];
160131
for (MCTargetAppInfo * appInfo in targetAppInfos) {
161132
chip::Protocols::UserDirectedCommissioning::TargetAppInfo targetAppInfo;
162-
targetAppInfo.vendorId = appInfo.getVendorId;
163-
targetAppInfo.productId = appInfo.getProductId;
133+
targetAppInfo.vendorId = appInfo.vendorId;
134+
targetAppInfo.productId = appInfo.productId;
164135
CHIP_ERROR err = cppIdOptions.addTargetAppInfo(targetAppInfo);
165136
if (err != CHIP_NO_ERROR) {
166137
ChipLogError(AppServer, "MCIdentificationDeclarationOptions.getCppIdentificationDeclarationOptions() Failed to add TargetAppInfo: %@", appInfo.description);

‎examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.h

+6-13
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
*/
2727
@interface MCTargetAppInfo : NSObject
2828

29-
/** Initialize with vendorId and productId set to 0 */
29+
/** Target Target Content Application Vendor ID, 0 means unspecified */
30+
@property (nonatomic, readonly) uint16_t vendorId;
31+
32+
/** Target Target Content Application Product ID, 0 means unspecified */
33+
@property (nonatomic, readonly) uint16_t productId;
3034

35+
/** Initialize with vendorId and productId set to 0 */
3136
- (instancetype)init;
3237

3338
/** Initialize with vendorId, productId defaults to 0 */
@@ -36,18 +41,6 @@
3641
/** Initialize with vendorId and productId */
3742
- (instancetype _Nonnull)initWithVendorId:(uint16_t)vendorId productId:(uint16_t)productId NS_DESIGNATED_INITIALIZER;
3843

39-
/** Vendor ID getter */
40-
- (uint16_t)getVendorId;
41-
42-
/** Vendor ID setter */
43-
- (void)setVendorId:(uint16_t)vendorId;
44-
45-
/** Product ID getter */
46-
- (uint16_t)getProductId;
47-
48-
/** Product ID setter */
49-
- (void)setProductId:(uint16_t)productId;
50-
5144
/** Description method */
5245
- (NSString * _Nonnull)description;
5346

‎examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCTargetAppInfo.mm

-32
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@
1717

1818
#import "MCTargetAppInfo.h"
1919

20-
@interface MCTargetAppInfo ()
21-
22-
// Private properties:
23-
24-
/** Target Target Content Application Vendor ID, 0 means unspecified */
25-
@property (nonatomic) uint16_t vendorId;
26-
27-
/** Target Target Content Application Product ID, 0 means unspecified */
28-
@property (nonatomic) uint16_t productId;
29-
30-
@end
31-
3220
@implementation MCTargetAppInfo
3321

3422
- (instancetype)init
@@ -56,26 +44,6 @@ - (instancetype)initWithVendorId:(uint16_t)vendorId productId:(uint16_t)productI
5644
return self;
5745
}
5846

59-
- (uint16_t)getVendorId
60-
{
61-
return _vendorId;
62-
}
63-
64-
- (void)setVendorId:(uint16_t)vendorId
65-
{
66-
_vendorId = vendorId;
67-
}
68-
69-
- (uint16_t)getProductId
70-
{
71-
return _productId;
72-
}
73-
74-
- (void)setProductId:(uint16_t)productId
75-
{
76-
_productId = productId;
77-
}
78-
7947
- (NSString *)description
8048
{
8149
return [NSString stringWithFormat:@"MCTargetAppInfo: vendorId: %d, productId: %d", self.vendorId, self.productId];

‎examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
39231BEA2C24F90200ADFB3A /* MCEndpointSelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39231BE92C24F90200ADFB3A /* MCEndpointSelector.swift */; };
1011
3C40586E2B632DC500C7C6D6 /* MCMediaPlaybackSubscribeToCurrentStateExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40586D2B632DC500C7C6D6 /* MCMediaPlaybackSubscribeToCurrentStateExampleView.swift */; };
1112
3C4058702B632DDB00C7C6D6 /* MCMediaPlaybackSubscribeToCurrentStateExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40586F2B632DDB00C7C6D6 /* MCMediaPlaybackSubscribeToCurrentStateExampleViewModel.swift */; };
1213
3C4F52302B51F32000BB8A10 /* MCContentLauncherLaunchURLExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C4F522F2B51F32000BB8A10 /* MCContentLauncherLaunchURLExampleViewModel.swift */; };
@@ -54,6 +55,7 @@
5455
/* End PBXCopyFilesBuildPhase section */
5556

5657
/* Begin PBXFileReference section */
58+
39231BE92C24F90200ADFB3A /* MCEndpointSelector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCEndpointSelector.swift; sourceTree = "<group>"; };
5759
3C40586D2B632DC500C7C6D6 /* MCMediaPlaybackSubscribeToCurrentStateExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCMediaPlaybackSubscribeToCurrentStateExampleView.swift; sourceTree = "<group>"; };
5860
3C40586F2B632DDB00C7C6D6 /* MCMediaPlaybackSubscribeToCurrentStateExampleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCMediaPlaybackSubscribeToCurrentStateExampleViewModel.swift; sourceTree = "<group>"; };
5961
3C4F522F2B51F32000BB8A10 /* MCContentLauncherLaunchURLExampleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCContentLauncherLaunchURLExampleViewModel.swift; sourceTree = "<group>"; };
@@ -158,6 +160,7 @@
158160
3C94377C2B364D380096E5F4 /* MCDiscoveryExampleViewModel.swift */,
159161
3C94378F2B3B3FF90096E5F4 /* MCConnectionExampleView.swift */,
160162
3C94377E2B364D510096E5F4 /* MCConnectionExampleViewModel.swift */,
163+
39231BE92C24F90200ADFB3A /* MCEndpointSelector.swift */,
161164
3C621CB42B607FFD005CDBA3 /* MCActionSelectorView.swift */,
162165
3C4F52312B5721D000BB8A10 /* MCContentLauncherLaunchURLExampleView.swift */,
163166
3C4F522F2B51F32000BB8A10 /* MCContentLauncherLaunchURLExampleViewModel.swift */,
@@ -266,6 +269,7 @@
266269
3C94377F2B364D510096E5F4 /* MCConnectionExampleViewModel.swift in Sources */,
267270
3C4058702B632DDB00C7C6D6 /* MCMediaPlaybackSubscribeToCurrentStateExampleViewModel.swift in Sources */,
268271
3CCB8745286A5D0F00771BAD /* CommissionerDiscoveryView.swift in Sources */,
272+
39231BEA2C24F90200ADFB3A /* MCEndpointSelector.swift in Sources */,
269273
3C621CB12B6078A9005CDBA3 /* MCApplicationBasicReadVendorIDExampleView.swift in Sources */,
270274
3CCB8746286A5D0F00771BAD /* CommissionerDiscoveryViewModel.swift in Sources */,
271275
3C4F52302B51F32000BB8A10 /* MCContentLauncherLaunchURLExampleViewModel.swift in Sources */,

‎examples/tv-casting-app/darwin/TvCasting/TvCasting/MCApplicationBasicReadVendorIDExampleViewModel.swift

+3-15
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,10 @@ class MCApplicationBasicReadVendorIDExampleViewModel: ObservableObject {
3232
{
3333
self.Log.info("MCApplicationBasicReadVendorIDExampleViewModel.read()")
3434
castingPlayer.logAllEndpoints()
35-
var selectedEndpoint: MCEndpoint?
3635

37-
// select the MCEndpoint on the MCCastingPlayer to invoke the command on
38-
if let endpoint = castingPlayer.endpoints().filter({ $0.vendorId().intValue == sampleEndpointVid }).first {
39-
selectedEndpoint = endpoint
40-
// For the example Commissioner-Generated passcode commissioning flow, run demo interactions with the Endpoint with
41-
// ID 1. For this flow, we commissioned with the Target Content Application with Vendor ID 1111. Since this target
42-
// content application does not report its Endpoint's Vendor IDs, we find the desired endpoint based on the Endpoint
43-
// ID. See connectedhomeip/examples/tv-app/tv-common/include/AppTv.h.
44-
} else if let endpoint = castingPlayer.endpoints().filter({ $0.identifier().intValue == 1 }).first {
45-
self.Log.info("MCApplicationBasicReadVendorIDExampleViewModel.read() No endpoint matching the sampleEndpointVid: \(String(describing: self.sampleEndpointVid)), but found endpoint with identifier: 1")
46-
selectedEndpoint = endpoint
47-
}
48-
49-
guard let endpoint = selectedEndpoint else {
50-
self.Log.error("No endpoint matching the example VID or identifier 1 found")
36+
// Use MCEndpointSelector to select the endpoint
37+
guard let endpoint = MCEndpointSelector.selectEndpoint(from: castingPlayer, sampleEndpointVid: sampleEndpointVid) else {
38+
self.Log.error("MCApplicationBasicReadVendorIDExampleViewModel.read() No endpoint matching the example VID or identifier 1 found")
5139
DispatchQueue.main.async {
5240
self.status = "No endpoint matching the example VID or identifier 1 found"
5341
}

0 commit comments

Comments
 (0)