Skip to content

Commit ebe16b7

Browse files
tv-casting-app/tv-app target app, commissioner passcode flow (#38856)
1 parent f4d171a commit ebe16b7

18 files changed

+135
-140
lines changed

examples/tv-app/android/java/AppImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ std::vector<SupportedCluster> make_default_supported_clusters()
272272
ContentAppFactoryImpl::ContentAppFactoryImpl() :
273273
mContentApps{ new ContentAppImpl("Vendor1", 1, "exampleid", 11, "Version1", "20202021", make_default_supported_clusters(),
274274
nullptr, nullptr),
275-
new ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "20202021",
276-
make_default_supported_clusters(), nullptr, nullptr),
275+
new ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "0", make_default_supported_clusters(),
276+
nullptr, nullptr),
277277
new ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3", "20202021", make_default_supported_clusters(),
278278
nullptr, nullptr),
279279
new ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2", "20202021",

examples/tv-app/linux/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ Begin commissioning it by running
7070

7171
$ controller ux ok
7272

73+
The TV content app will check if has a hard coded passcode available, and if so,
74+
attempt commissioning with it. If no passcode is available, it will ask for the
75+
commissionable node's (commissionee) generated passcode.
76+
77+
```
78+
CHIP:CTL: ------PROMPT USER: please enter passcode displayed in casting app
79+
CHIP:CTL: ------Via Shell Enter: controller ux ok [passcode]
80+
```
81+
82+
Continue commissioning by providing the commissionee passcode
83+
84+
$ controller ux ok 20202021
85+
7386
- User Directed Commissioning (UDC)
7487

7588
Print out the cached list of UDC sessions

examples/tv-app/tv-common/src/AppTv.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class MyPasscodeService : public PasscodeService
107107
void LookupTargetContentApp(uint16_t vendorId, uint16_t productId, chip::CharSpan rotatingId,
108108
chip::Protocols::UserDirectedCommissioning::TargetAppInfo & info) override
109109
{
110+
ChipLogProgress(DeviceLayer,
111+
"LookupTargetContentApp() client vendorID=%d productID=%d; TargetAppInfo vendorID=%d productID=%d",
112+
vendorId, productId, info.vendorId, info.productId);
110113
uint32_t passcode = 0;
111114
bool foundApp = ContentAppPlatform::GetInstance().HasTargetContentApp(vendorId, productId, rotatingId, info, passcode);
112115
if (!foundApp)
@@ -653,7 +656,7 @@ void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t produc
653656
}
654657
else if (vendorId == 65521 && productId == 32769)
655658
{
656-
auto ptr = std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2", "20202021",
659+
auto ptr = std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2", "0",
657660
make_default_supported_clusters());
658661
mContentApps.emplace_back(std::move(ptr));
659662
}

examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ApplicationBasicReadVendorIDExampleFragment.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
public class ApplicationBasicReadVendorIDExampleFragment extends Fragment {
3838
private static final String TAG =
3939
ApplicationBasicReadVendorIDExampleFragment.class.getSimpleName();
40-
private static final int DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1;
4140

4241
private final CastingPlayer selectedCastingPlayer;
4342
private final boolean useCommissionerGeneratedPasscode;
@@ -75,20 +74,8 @@ public View onCreateView(
7574
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
7675
this.readButtonClickListener =
7776
v -> {
78-
Endpoint endpoint;
79-
if (useCommissionerGeneratedPasscode) {
80-
// For the example Commissioner-Generated passcode commissioning flow, run demo
81-
// interactions with the Endpoint with ID DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1. For this
82-
// flow, we commissioned with the Target Content Application with Vendor ID 1111. Since
83-
// this target content application does not report its Endpoint's Vendor IDs, we find
84-
// the desired endpoint based on the Endpoint ID. See
85-
// connectedhomeip/examples/tv-app/tv-common/include/AppTv.h.
86-
endpoint =
87-
EndpointSelectorExample.selectEndpointById(
88-
selectedCastingPlayer, DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW);
89-
} else {
90-
endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
91-
}
77+
Endpoint endpoint =
78+
EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
9279
if (endpoint == null) {
9380
Log.e(TAG, "No Endpoint with sample vendorID found on CastingPlayer");
9481
return;

examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ public class ConnectionExampleFragment extends Fragment {
4747
// Must be >= 3 minutes.
4848
private static final short MIN_CONNECTION_TIMEOUT_SEC = 3 * 60;
4949
private static final Integer DESIRED_TARGET_APP_VENDOR_ID = 65521;
50-
// Use this Target Content Application Vendor ID, configured on the tv-app, to demonstrate the
51-
// CastingPlayer/Commissioner-Generated passcode commissioning flow.
52-
private static final Integer DESIRED_TARGET_APP_VENDOR_ID_FOR_CGP_FLOW = 1111;
5350
private static final long DEFAULT_COMMISSIONER_GENERATED_PASSCODE = 12345678;
5451
private static final int DEFAULT_DISCRIMINATOR_FOR_CGP_FLOW = 0;
5552
private final CastingPlayer targetCastingPlayer;
@@ -140,7 +137,6 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
140137
// Set commissionerPasscode to true for CastingPlayer/Commissioner-Generated
141138
// passcode commissioning.
142139
idOptions = new IdentificationDeclarationOptions(false, false, true, false, false);
143-
targetAppInfo = new TargetAppInfo(DESIRED_TARGET_APP_VENDOR_ID_FOR_CGP_FLOW);
144140
Log.d(
145141
TAG,
146142
"onViewCreated() calling CastingPlayer.verifyOrEstablishConnection() Target Content Application Vendor ID: "

examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ContentLauncherLaunchURLExampleFragment.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
public class ContentLauncherLaunchURLExampleFragment extends Fragment {
3838
private static final String TAG = ContentLauncherLaunchURLExampleFragment.class.getSimpleName();
3939
private static final Integer SAMPLE_ENDPOINT_VID = 65521;
40-
private static final int DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1;
4140

4241
private final CastingPlayer selectedCastingPlayer;
4342
private final boolean useCommissionerGeneratedPasscode;
@@ -75,20 +74,8 @@ public View onCreateView(
7574
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
7675
this.launchUrlButtonClickListener =
7776
v -> {
78-
Endpoint endpoint;
79-
if (useCommissionerGeneratedPasscode) {
80-
// For the example Commissioner-Generated passcode commissioning flow, run demo
81-
// interactions with the Endpoint with ID DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1. For this
82-
// flow, we commissioned with the Target Content Application with Vendor ID 1111. Since
83-
// this target content application does not report its Endpoint's Vendor IDs, we find
84-
// the desired endpoint based on the Endpoint ID. See
85-
// connectedhomeip/examples/tv-app/tv-common/include/AppTv.h.
86-
endpoint =
87-
EndpointSelectorExample.selectEndpointById(
88-
selectedCastingPlayer, DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW);
89-
} else {
90-
endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
91-
}
77+
Endpoint endpoint =
78+
EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
9279
if (endpoint == null) {
9380
Log.e(TAG, "No Endpoint with sample vendorID found on CastingPlayer");
9481
return;

examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/MediaPlaybackSubscribeToCurrentStateExampleFragment.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
public class MediaPlaybackSubscribeToCurrentStateExampleFragment extends Fragment {
4141
private static final String TAG =
4242
MediaPlaybackSubscribeToCurrentStateExampleFragment.class.getSimpleName();
43-
private static final int DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1;
4443

4544
private final CastingPlayer selectedCastingPlayer;
4645
private final boolean useCommissionerGeneratedPasscode;
@@ -77,19 +76,7 @@ public void onCreate(Bundle savedInstanceState) {
7776
@Override
7877
public View onCreateView(
7978
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
80-
Endpoint endpoint;
81-
if (useCommissionerGeneratedPasscode) {
82-
// For the example Commissioner-Generated passcode commissioning flow, run demo interactions
83-
// with the Endpoint with ID DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1. For this flow, we
84-
// commissioned with the Target Content Application with Vendor ID 1111. Since this target
85-
// content application does not report its Endpoint's Vendor IDs, we find the desired endpoint
86-
// based on the Endpoint ID. See connectedhomeip/examples/tv-app/tv-common/include/AppTv.h.
87-
endpoint =
88-
EndpointSelectorExample.selectEndpointById(
89-
selectedCastingPlayer, DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW);
90-
} else {
91-
endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
92-
}
79+
Endpoint endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
9380
if (endpoint == null) {
9481
Log.e(TAG, "No Endpoint with sample vendorID found on CastingPlayer");
9582
return inflater.inflate(

examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ class MCConnectionExampleViewModel: ObservableObject {
2727

2828
// VendorId of the MCEndpoint on the MCCastingPlayer that the MCCastingApp desires to interact with after connection
2929
let kDesiredEndpointVendorId: UInt16 = 65521;
30-
31-
// VendorId of the MCEndpoint on the MCCastingPlayer that the MCCastingApp desires to interact with after connecting
32-
// using the MCCastingPlayer/Commissioner-Generated passcode (CGP) commissioning flow. Use this Target Content
33-
// Application Vendor ID, which is configured on the tv-app. This Target Content Application Vendor ID (1111), does
34-
// not implement the AccountLogin cluster, which would otherwise auto commission using the Commissionee-Generated
35-
// passcode upon recieving the IdentificationDeclaration Message. See
36-
// connectedhomeip/examples/tv-app/tv-common/include/AppTv.h.
37-
let kDesiredEndpointVendorIdCGP: UInt16 = 1111;
3830

3931
@Published var connectionSuccess: Bool?;
4032

@@ -156,19 +148,17 @@ class MCConnectionExampleViewModel: ObservableObject {
156148
}
157149

158150
let identificationDeclarationOptions: MCIdentificationDeclarationOptions
159-
let targetAppInfo: MCTargetAppInfo
151+
let targetAppInfo: MCTargetAppInfo = MCTargetAppInfo(vendorId: kDesiredEndpointVendorId)
160152
let connectionCallbacks: MCConnectionCallbacks
161153

162154
if useCommissionerGeneratedPasscode {
163155
identificationDeclarationOptions = MCIdentificationDeclarationOptions(commissionerPasscodeOnly: true)
164-
targetAppInfo = MCTargetAppInfo(vendorId: kDesiredEndpointVendorIdCGP)
165156
connectionCallbacks = MCConnectionCallbacks(
166157
callbacks: connectionCompleteCallback,
167158
commissionerDeclarationCallback: commissionerDeclarationCallback
168159
)
169160
} else {
170161
identificationDeclarationOptions = MCIdentificationDeclarationOptions()
171-
targetAppInfo = MCTargetAppInfo(vendorId: kDesiredEndpointVendorId)
172162
connectionCallbacks = MCConnectionCallbacks(
173163
callbacks: connectionCompleteCallback,
174164
commissionerDeclarationCallback: commissionerDeclarationCallback

0 commit comments

Comments
 (0)