Skip to content

tv-casting-app/tv-app target app, commissioner passcode flow #38856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/tv-app/android/java/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ std::vector<SupportedCluster> make_default_supported_clusters()
ContentAppFactoryImpl::ContentAppFactoryImpl() :
mContentApps{ new ContentAppImpl("Vendor1", 1, "exampleid", 11, "Version1", "20202021", make_default_supported_clusters(),
nullptr, nullptr),
new ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "20202021",
make_default_supported_clusters(), nullptr, nullptr),
new ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "0", make_default_supported_clusters(),
nullptr, nullptr),
new ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3", "20202021", make_default_supported_clusters(),
nullptr, nullptr),
new ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2", "20202021",
Expand Down
13 changes: 13 additions & 0 deletions examples/tv-app/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ Begin commissioning it by running

$ controller ux ok

The TV content app will check if has a hard coded passcode available, and if so,
attempt commissioning with it. If no passcode is available, it will ask for the
commissionable node's (commissionee) generated passcode.

```
CHIP:CTL: ------PROMPT USER: please enter passcode displayed in casting app
CHIP:CTL: ------Via Shell Enter: controller ux ok [passcode]
```

Continue commissioning by providing the commissionee passcode

$ controller ux ok 20202021

- User Directed Commissioning (UDC)

Print out the cached list of UDC sessions
Expand Down
5 changes: 4 additions & 1 deletion examples/tv-app/tv-common/src/AppTv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class MyPasscodeService : public PasscodeService
void LookupTargetContentApp(uint16_t vendorId, uint16_t productId, chip::CharSpan rotatingId,
chip::Protocols::UserDirectedCommissioning::TargetAppInfo & info) override
{
ChipLogProgress(DeviceLayer,
"LookupTargetContentApp() client vendorID=%d productID=%d; TargetAppInfo vendorID=%d productID=%d",
vendorId, productId, info.vendorId, info.productId);
uint32_t passcode = 0;
bool foundApp = ContentAppPlatform::GetInstance().HasTargetContentApp(vendorId, productId, rotatingId, info, passcode);
if (!foundApp)
Expand Down Expand Up @@ -653,7 +656,7 @@ void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t produc
}
else if (vendorId == 65521 && productId == 32769)
{
auto ptr = std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2", "20202021",
auto ptr = std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2", "0",
make_default_supported_clusters());
mContentApps.emplace_back(std::move(ptr));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
public class ApplicationBasicReadVendorIDExampleFragment extends Fragment {
private static final String TAG =
ApplicationBasicReadVendorIDExampleFragment.class.getSimpleName();
private static final int DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1;

private final CastingPlayer selectedCastingPlayer;
private final boolean useCommissionerGeneratedPasscode;
Expand Down Expand Up @@ -75,20 +74,8 @@ public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
this.readButtonClickListener =
v -> {
Endpoint endpoint;
if (useCommissionerGeneratedPasscode) {
// For the example Commissioner-Generated passcode commissioning flow, run demo
// interactions with the Endpoint with ID DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1. For this
// flow, we commissioned with the Target Content Application with Vendor ID 1111. Since
// this target content application does not report its Endpoint's Vendor IDs, we find
// the desired endpoint based on the Endpoint ID. See
// connectedhomeip/examples/tv-app/tv-common/include/AppTv.h.
endpoint =
EndpointSelectorExample.selectEndpointById(
selectedCastingPlayer, DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW);
} else {
endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
}
Endpoint endpoint =
EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
if (endpoint == null) {
Log.e(TAG, "No Endpoint with sample vendorID found on CastingPlayer");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ public class ConnectionExampleFragment extends Fragment {
// Must be >= 3 minutes.
private static final short MIN_CONNECTION_TIMEOUT_SEC = 3 * 60;
private static final Integer DESIRED_TARGET_APP_VENDOR_ID = 65521;
// Use this Target Content Application Vendor ID, configured on the tv-app, to demonstrate the
// CastingPlayer/Commissioner-Generated passcode commissioning flow.
private static final Integer DESIRED_TARGET_APP_VENDOR_ID_FOR_CGP_FLOW = 1111;
private static final long DEFAULT_COMMISSIONER_GENERATED_PASSCODE = 12345678;
private static final int DEFAULT_DISCRIMINATOR_FOR_CGP_FLOW = 0;
private final CastingPlayer targetCastingPlayer;
Expand Down Expand Up @@ -140,7 +137,6 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// Set commissionerPasscode to true for CastingPlayer/Commissioner-Generated
// passcode commissioning.
idOptions = new IdentificationDeclarationOptions(false, false, true, false, false);
targetAppInfo = new TargetAppInfo(DESIRED_TARGET_APP_VENDOR_ID_FOR_CGP_FLOW);
Log.d(
TAG,
"onViewCreated() calling CastingPlayer.verifyOrEstablishConnection() Target Content Application Vendor ID: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
public class ContentLauncherLaunchURLExampleFragment extends Fragment {
private static final String TAG = ContentLauncherLaunchURLExampleFragment.class.getSimpleName();
private static final Integer SAMPLE_ENDPOINT_VID = 65521;
private static final int DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1;

private final CastingPlayer selectedCastingPlayer;
private final boolean useCommissionerGeneratedPasscode;
Expand Down Expand Up @@ -75,20 +74,8 @@ public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
this.launchUrlButtonClickListener =
v -> {
Endpoint endpoint;
if (useCommissionerGeneratedPasscode) {
// For the example Commissioner-Generated passcode commissioning flow, run demo
// interactions with the Endpoint with ID DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1. For this
// flow, we commissioned with the Target Content Application with Vendor ID 1111. Since
// this target content application does not report its Endpoint's Vendor IDs, we find
// the desired endpoint based on the Endpoint ID. See
// connectedhomeip/examples/tv-app/tv-common/include/AppTv.h.
endpoint =
EndpointSelectorExample.selectEndpointById(
selectedCastingPlayer, DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW);
} else {
endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
}
Endpoint endpoint =
EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
if (endpoint == null) {
Log.e(TAG, "No Endpoint with sample vendorID found on CastingPlayer");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
public class MediaPlaybackSubscribeToCurrentStateExampleFragment extends Fragment {
private static final String TAG =
MediaPlaybackSubscribeToCurrentStateExampleFragment.class.getSimpleName();
private static final int DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1;

private final CastingPlayer selectedCastingPlayer;
private final boolean useCommissionerGeneratedPasscode;
Expand Down Expand Up @@ -77,19 +76,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Endpoint endpoint;
if (useCommissionerGeneratedPasscode) {
// For the example Commissioner-Generated passcode commissioning flow, run demo interactions
// with the Endpoint with ID DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1. For this flow, we
// commissioned with the Target Content Application with Vendor ID 1111. Since this target
// content application does not report its Endpoint's Vendor IDs, we find the desired endpoint
// based on the Endpoint ID. See connectedhomeip/examples/tv-app/tv-common/include/AppTv.h.
endpoint =
EndpointSelectorExample.selectEndpointById(
selectedCastingPlayer, DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW);
} else {
endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
}
Endpoint endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
if (endpoint == null) {
Log.e(TAG, "No Endpoint with sample vendorID found on CastingPlayer");
return inflater.inflate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ class MCConnectionExampleViewModel: ObservableObject {

// VendorId of the MCEndpoint on the MCCastingPlayer that the MCCastingApp desires to interact with after connection
let kDesiredEndpointVendorId: UInt16 = 65521;

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

@Published var connectionSuccess: Bool?;

Expand Down Expand Up @@ -156,19 +148,17 @@ class MCConnectionExampleViewModel: ObservableObject {
}

let identificationDeclarationOptions: MCIdentificationDeclarationOptions
let targetAppInfo: MCTargetAppInfo
let targetAppInfo: MCTargetAppInfo = MCTargetAppInfo(vendorId: kDesiredEndpointVendorId)
let connectionCallbacks: MCConnectionCallbacks

if useCommissionerGeneratedPasscode {
identificationDeclarationOptions = MCIdentificationDeclarationOptions(commissionerPasscodeOnly: true)
targetAppInfo = MCTargetAppInfo(vendorId: kDesiredEndpointVendorIdCGP)
connectionCallbacks = MCConnectionCallbacks(
callbacks: connectionCompleteCallback,
commissionerDeclarationCallback: commissionerDeclarationCallback
)
} else {
identificationDeclarationOptions = MCIdentificationDeclarationOptions()
targetAppInfo = MCTargetAppInfo(vendorId: kDesiredEndpointVendorId)
connectionCallbacks = MCConnectionCallbacks(
callbacks: connectionCompleteCallback,
commissionerDeclarationCallback: commissionerDeclarationCallback
Expand Down
Loading
Loading