From 75c3ab9b910f6d7e4d534823f4397452518159df Mon Sep 17 00:00:00 2001 From: Philip Gregor Date: Fri, 9 May 2025 16:33:11 -0700 Subject: [PATCH] tv-casting-app/tv-app target app, commissioner passcode flow Fixing tv-casting-app CI test --- examples/tv-app/android/java/AppImpl.cpp | 4 +- examples/tv-app/linux/README.md | 13 +++ examples/tv-app/tv-common/src/AppTv.cpp | 5 +- ...ationBasicReadVendorIDExampleFragment.java | 17 +--- .../casting/ConnectionExampleFragment.java | 4 - ...ntentLauncherLaunchURLExampleFragment.java | 17 +--- ...ubscribeToCurrentStateExampleFragment.java | 15 +--- .../MCConnectionExampleViewModel.swift | 12 +-- .../linux/simple-app-helper.cpp | 86 +++++++++---------- .../tv-casting-common/core/CastingPlayer.cpp | 16 ++-- .../tv-casting-common/core/Endpoint.cpp | 3 +- .../include/CHIPProjectAppConfig.h | 17 ++++ .../support/CastingStore.cpp | 14 +-- .../support/ChipDeviceEventHandler.cpp | 2 +- .../support/EndpointListLoader.cpp | 9 +- .../tests/linux/tv_casting_test_sequences.py | 20 +++-- src/app/app-platform/ContentAppPlatform.cpp | 16 ++-- .../UserDirectedCommissioningServer.cpp | 5 +- 18 files changed, 135 insertions(+), 140 deletions(-) diff --git a/examples/tv-app/android/java/AppImpl.cpp b/examples/tv-app/android/java/AppImpl.cpp index 4420ce938f2447..d5ae6aac0acb9f 100644 --- a/examples/tv-app/android/java/AppImpl.cpp +++ b/examples/tv-app/android/java/AppImpl.cpp @@ -272,8 +272,8 @@ std::vector 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", diff --git a/examples/tv-app/linux/README.md b/examples/tv-app/linux/README.md index 27b18fc2a913e2..6db6c478ad3957 100644 --- a/examples/tv-app/linux/README.md +++ b/examples/tv-app/linux/README.md @@ -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 diff --git a/examples/tv-app/tv-common/src/AppTv.cpp b/examples/tv-app/tv-common/src/AppTv.cpp index be36e1f5ace794..14b0d922c45ce9 100644 --- a/examples/tv-app/tv-common/src/AppTv.cpp +++ b/examples/tv-app/tv-common/src/AppTv.cpp @@ -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) @@ -653,7 +656,7 @@ void ContentAppFactoryImpl::InstallContentApp(uint16_t vendorId, uint16_t produc } else if (vendorId == 65521 && productId == 32769) { - auto ptr = std::make_unique("Vendor2", vendorId, "exampleString", productId, "Version2", "20202021", + auto ptr = std::make_unique("Vendor2", vendorId, "exampleString", productId, "Version2", "0", make_default_supported_clusters()); mContentApps.emplace_back(std::move(ptr)); } diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ApplicationBasicReadVendorIDExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ApplicationBasicReadVendorIDExampleFragment.java index e0a188455877c3..503334e5121b87 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ApplicationBasicReadVendorIDExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ApplicationBasicReadVendorIDExampleFragment.java @@ -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; @@ -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; diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java index 6320c48d0dc3fb..7c99651c08a31c 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java @@ -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; @@ -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: " diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ContentLauncherLaunchURLExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ContentLauncherLaunchURLExampleFragment.java index 9d31619fe1fc86..1ff66063f5e58e 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ContentLauncherLaunchURLExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ContentLauncherLaunchURLExampleFragment.java @@ -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; @@ -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; diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/MediaPlaybackSubscribeToCurrentStateExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/MediaPlaybackSubscribeToCurrentStateExampleFragment.java index 882fc261f67e45..5420c9ec0f8dd5 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/MediaPlaybackSubscribeToCurrentStateExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/MediaPlaybackSubscribeToCurrentStateExampleFragment.java @@ -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; @@ -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( diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift index 8848cf456cd521..80cd67f1216fda 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift @@ -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?; @@ -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 diff --git a/examples/tv-casting-app/linux/simple-app-helper.cpp b/examples/tv-casting-app/linux/simple-app-helper.cpp index 0109fa819d1f1d..da695c6789ac30 100644 --- a/examples/tv-casting-app/linux/simple-app-helper.cpp +++ b/examples/tv-casting-app/linux/simple-app-helper.cpp @@ -32,10 +32,8 @@ #include // VendorId of the Endpoint on the CastingPlayer that the CastingApp desires to interact with after connection -const uint16_t kDesiredEndpointVendorId = 65521; -// EndpointId of the Endpoint on the CastingPlayer that the CastingApp desires to interact with after connection using the -// Commissioner-Generated passcode commissioning flow -const uint8_t kDesiredEndpointId = 1; +const uint16_t kDesiredEndpointVendorId = 65521; // 0xFFF1 +const uint16_t kDesiredEndpointVendorIdTwo = 65522; // 0xFFF2 // Indicates that the Commissioner-Generated passcode commissioning flow is in progress. bool gCommissionerGeneratedPasscodeFlowRunning = false; @@ -265,46 +263,25 @@ void ConnectionHandler(CHIP_ERROR err, matter::casting::core::CastingPlayer * ca ChipLogProgress(AppServer, "simple-app-helper.cpp::ConnectionHandler()"); // For a connection failure, called back with an error and nullptr. - VerifyOrReturn( - err == CHIP_NO_ERROR, - ChipLogError( - AppServer, - "simple-app-helper.cpp::ConnectionHandler(): Failed to connect to CastingPlayer (ID: %s) with err %" CHIP_ERROR_FORMAT, - targetCastingPlayer->GetId(), err.Format())); + VerifyOrReturn(err == CHIP_NO_ERROR, + ChipLogError(AppServer, + "simple-app-helper.cpp::ConnectionHandler(): Failed to connect to CastingPlayer (ID: %s, Vendor " + "ID: %d) with err %" CHIP_ERROR_FORMAT, + targetCastingPlayer->GetId(), targetCastingPlayer->GetVendorId(), err.Format())); - if (gCommissionerGeneratedPasscodeFlowRunning) - { - ChipLogProgress(AppServer, - "simple-app-helper.cpp::ConnectionHandler(): Successfully connected to CastingPlayer (ID: %s) using " - "Commissioner-Generated passcode", - castingPlayer->GetId()); - ChipLogProgress(AppServer, "simple-app-helper.cpp::ConnectionHandler(): Desired Endpoint ID for demo interactions: 1"); - } - else - { - ChipLogProgress(AppServer, "simple-app-helper.cpp::ConnectionHandler(): Successfully connected to CastingPlayer (ID: %s)", - castingPlayer->GetId()); - ChipLogProgress(AppServer, - "simple-app-helper.cpp::ConnectionHandler(): Desired Endpoint Vendor ID for demo interactions: %d", - kDesiredEndpointVendorId); - } - - ChipLogProgress(AppServer, "simple-app-helper.cpp::ConnectionHandler(): Getting endpoints available for demo interactions"); + ChipLogProgress(AppServer, + "simple-app-helper.cpp::ConnectionHandler(): Successfully connected to CastingPlayer (ID: %s, Vendor ID: %d)", + castingPlayer->GetId(), targetCastingPlayer->GetVendorId()); + ChipLogProgress( + AppServer, + "simple-app-helper.cpp::ConnectionHandler(): Demo interactions, getting endpoints matching Endpoint Vendor ID: %d", + kDesiredEndpointVendorId); std::vector> endpoints = castingPlayer->GetEndpoints(); LogEndpointsDetails(endpoints); // Find the desired Endpoint and auto-trigger some Matter Casting demo interactions auto it = std::find_if(endpoints.begin(), endpoints.end(), [](const matter::casting::memory::Strong & endpoint) { - if (gCommissionerGeneratedPasscodeFlowRunning) - { - // For the example Commissioner-Generated passcode commissioning flow, run demo interactions with - // the Endpoint with ID 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. - return endpoint->GetId() == kDesiredEndpointId; - } return endpoint->GetVendorId() == kDesiredEndpointVendorId; }); if (it != endpoints.end()) @@ -405,6 +382,11 @@ CHIP_ERROR CommandHandler(int argc, char ** argv) matter::casting::core::IdentificationDeclarationOptions idOptions; chip::Protocols::UserDirectedCommissioning::TargetAppInfo targetAppInfo; targetAppInfo.vendorId = kDesiredEndpointVendorId; + // For demonstration purposes add another TargetApp Vendor ID to interact with after commissioning. If the + // target content app's allowedVendorList contains the casting client's Vendor ID, then the client will receive + // the corresponding bindings and endpoints. + chip::Protocols::UserDirectedCommissioning::TargetAppInfo targetAppInfoTwo; + targetAppInfoTwo.vendorId = kDesiredEndpointVendorIdTwo; if (argc == 3) { @@ -419,14 +401,7 @@ CHIP_ERROR CommandHandler(int argc, char ** argv) "CommandHandler() request %lu commissioner-generated-passcode. Attempting the " "Commissioner-Generated Passcode commissioning flow", index); - idOptions.mCommissionerPasscode = true; - - // For the example Commissioner-Generated passcode commissioning flow, override the default 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. - targetAppInfo.vendorId = 1111; + idOptions.mCommissionerPasscode = true; gCommissionerGeneratedPasscodeFlowRunning = true; } else @@ -444,6 +419,22 @@ CHIP_ERROR CommandHandler(int argc, char ** argv) { ChipLogError(AppServer, "CommandHandler() request, failed to add targetAppInfo: %" CHIP_ERROR_FORMAT, result.Format()); } + result = CHIP_NO_ERROR; + result = idOptions.addTargetAppInfo(targetAppInfoTwo); + if (result != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "CommandHandler() request, failed to add targetAppInfoTwo: %" CHIP_ERROR_FORMAT, + result.Format()); + } + + if (!gCommissionerGeneratedPasscodeFlowRunning) + { + uint32_t defaultTestPasscode = 0; + chip::DeviceLayer::TestOnlyCommissionableDataProvider TestOnlyCommissionableDataProvider; + VerifyOrDie(TestOnlyCommissionableDataProvider.GetSetupPasscode(defaultTestPasscode) == CHIP_NO_ERROR); + ChipLogProgress(AppServer, "CommandHandler() request, tv-casting-app Commissionee Passcode: %u", + static_cast(defaultTestPasscode)); + } matter::casting::core::ConnectionCallbacks connectionCallbacks; connectionCallbacks.mOnConnectionComplete = ConnectionHandler; @@ -572,7 +563,8 @@ CHIP_ERROR PrintAllCommands() "[index] using the Commissionee-Generated passcode commissioning flow. Usage: cast request 0\r\n"); streamer_printf(sout, " request commissioner-generated-passcode Request connecting to discovered Casting Player with " - "[index] using the Commissioner-Generated passcode commissioning flow. Usage: cast request 0 cgp\r\n"); + "[index] using the Commissioner-Generated passcode commissioning flow. Usage: cast request 0 " + "commissioner-generated-passcode\r\n"); streamer_printf(sout, " setcommissionerpasscode Set the commissioning session's passcode to the " "Commissioner-Generated passcode. Used for the the Commissioner-Generated passcode commissioning flow. Usage: " @@ -590,7 +582,7 @@ void PrintBindings() for (const auto & binding : chip::BindingTable::GetInstance()) { ChipLogProgress(AppServer, - "Binding type=%d fab=%d nodeId=0x" ChipLogFormatX64 + "PrintBindings() Binding type=%d fab=%d nodeId=0x" ChipLogFormatX64 " groupId=%d local endpoint=%d remote endpoint=%d cluster=" ChipLogFormatMEI, binding.type, binding.fabricIndex, ChipLogValueX64(binding.nodeId), binding.groupId, binding.local, binding.remote, ChipLogValueMEI(binding.clusterId.value_or(0))); diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp index 113a559f4bced6..ebfd29b687ca21 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp @@ -102,20 +102,23 @@ void CastingPlayer::VerifyOrEstablishConnection(ConnectionCallbacks connectionCa // as per IdentificationDeclarationOptions.mTargetAppInfos, simply Find or Re-establish the CASE session and return early. if (cachedCastingPlayers.size() != 0) { - ChipLogProgress(AppServer, "CastingPlayer::VerifyOrEstablishConnection() Re-establishing CASE with cached CastingPlayer"); + ChipLogProgress(AppServer, + "CastingPlayer::VerifyOrEstablishConnection() Checking cached CastingPlayer(s) for *this* CastingPlayer"); it = std::find_if(cachedCastingPlayers.begin(), cachedCastingPlayers.end(), [this](const core::CastingPlayer & castingPlayerParam) { return castingPlayerParam == *this; }); // found the CastingPlayer in cache if (it != cachedCastingPlayers.end()) { - ChipLogProgress(AppServer, "CastingPlayer::VerifyOrEstablishConnection() found this CastingPlayer in app cache"); + ChipLogProgress( + AppServer, + "CastingPlayer::VerifyOrEstablishConnection() *this* CastingPlayer found in cache; checking for TargetApp(s)"); unsigned index = (unsigned int) std::distance(cachedCastingPlayers.begin(), it); if (ContainsDesiredTargetApp(&cachedCastingPlayers[index], idOptions.getTargetAppInfoList())) { ChipLogProgress( AppServer, - "CastingPlayer::VerifyOrEstablishConnection() calling FindOrEstablishSession on cached CastingPlayer"); + "CastingPlayer::VerifyOrEstablishConnection() Attempting to Re-establish CASE with cached CastingPlayer"); *this = cachedCastingPlayers[index]; mConnectionState = CASTING_PLAYER_CONNECTING; mOnCompleted = connectionCallbacks.mOnConnectionComplete; @@ -314,6 +317,8 @@ void CastingPlayer::Disconnect() void CastingPlayer::RegisterEndpoint(const memory::Strong endpoint) { + ChipLogProgress(AppServer, "CastingPlayer::RegisterEndpoint() EndpointID: %d, VendorID: %d, ProductID: %d", endpoint->GetId(), + endpoint->GetVendorId(), endpoint->GetProductId()); auto it = std::find_if(mEndpoints.begin(), mEndpoints.end(), [endpoint](const memory::Strong & _endpoint) { return _endpoint->GetId() == endpoint->GetId(); }); @@ -403,12 +408,13 @@ bool CastingPlayer::ContainsDesiredTargetApp( match && (desiredTargetApps[i].productId == 0 || cachedEndpoint->GetProductId() == desiredTargetApps[i].productId); if (match) { - ChipLogProgress(AppServer, "CastingPlayer::ContainsDesiredTargetApp() matching cached CastingPlayer found"); + ChipLogProgress(AppServer, + "CastingPlayer::ContainsDesiredTargetApp() CastingPlayer's Endpoint(s) match Target App(s)"); return true; } } } - ChipLogProgress(AppServer, "CastingPlayer::ContainsDesiredTargetApp() matching cached CastingPlayer not found"); + ChipLogError(AppServer, "CastingPlayer::ContainsDesiredTargetApp() CastingPlayer's Endpoints DO NOT match Target App(s)"); return false; } diff --git a/examples/tv-casting-app/tv-casting-common/core/Endpoint.cpp b/examples/tv-casting-app/tv-casting-common/core/Endpoint.cpp index 25b9e2850edb56..4357178075327e 100644 --- a/examples/tv-casting-app/tv-casting-common/core/Endpoint.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/Endpoint.cpp @@ -28,7 +28,8 @@ void Endpoint::RegisterClusters(std::vector clusters) { for (chip::ClusterId clusterId : clusters) { - ChipLogProgress(AppServer, "Endpoint::RegisterClusters() Registering clusterId %d for endpointId %d", clusterId, GetId()); + ChipLogProgress(AppServer, "Endpoint::RegisterClusters() Registering clusterId %d for endpointId %d, vendorId: %d", + clusterId, GetId(), GetVendorId()); switch (clusterId) { case chip::app::Clusters::ApplicationBasic::Id: diff --git a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h index 0e9ccf7d67df19..f0bf33cf94c229 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h +++ b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h @@ -47,6 +47,23 @@ #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +/** + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * + * 0xFFF1 (65521): Test Vendor #1 is reserved for test and development by device manufacturers or hobbyists. A Vendor Identifier + * (Vendor ID or VID) is a 16-bit number that uniquely identifies a particular product manufacturer, vendor, or group thereof. + * For production, replace with the Vendor ID allocated for you by the Connectivity Standards Alliance. + */ +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID + * + * 0x8001 (32769): A Product Identifier (Product ID or PID) is a 16-bit number that uniquely identifies a product of a vendor. + * The Product ID is assigned by the vendor and SHALL be unique for each product within a Vendor ID. + */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8001 + #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 #define CHIP_DEVICE_CONFIG_DEVICE_NAME "Test TV casting app" diff --git a/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp b/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp index 1ddf40a9b27abc..b1da7c528717e2 100644 --- a/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp +++ b/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp @@ -40,8 +40,8 @@ CastingStore * CastingStore::GetInstance() CHIP_ERROR CastingStore::AddOrUpdate(core::CastingPlayer castingPlayer) { - ChipLogProgress(AppServer, "CastingStore::AddOrUpdate() called with CastingPlayer deviceName: %s", - castingPlayer.GetDeviceName()); + ChipLogProgress(AppServer, "CastingStore::AddOrUpdate() called with CastingPlayer deviceName: %s, VendorID: %u, ProductID: %u", + castingPlayer.GetDeviceName(), castingPlayer.GetVendorId(), castingPlayer.GetProductId()); // Read cache of CastingPlayers std::vector castingPlayers = ReadAll(); @@ -479,7 +479,9 @@ CHIP_ERROR CastingStore::WriteAll(std::vector castingPlayer for (auto & castingPlayer : castingPlayers) { - ChipLogProgress(AppServer, "CastingStore::WriteAll() writing CastingPlayer:"); + // ChipLogProgress(AppServer, "CastingStore::WriteAll() writing CastingPlayer:"); + ChipLogProgress(AppServer, "CastingStore::WriteAll() writing CastingPlayer deviceName: %s, VendorID: %u, ProductID: %u", + castingPlayer.GetDeviceName(), castingPlayer.GetVendorId(), castingPlayer.GetProductId()); chip::TLV::TLVType castingPlayerContainerType; // CastingPlayer container starts ReturnErrorOnFailure( @@ -512,8 +514,10 @@ CHIP_ERROR CastingStore::WriteAll(std::vector castingPlayer std::vector> endpoints = core::CastingPlayer::GetTargetCastingPlayer()->GetEndpoints(); for (auto & endpoint : endpoints) { - ChipLogProgress(AppServer, "CastingStore::WriteAll() writing CastingPlayer Endpoint with endpointId: %d", - endpoint->GetId()); + ChipLogProgress( + AppServer, + "CastingStore::WriteAll() writing CastingPlayer Endpoint with EndpointID: %d, VendorID: %d, ProductID: %d", + endpoint->GetId(), endpoint->GetVendorId(), endpoint->GetProductId()); chip::TLV::TLVType endpointContainerType; // Endpoint container starts ReturnErrorOnFailure( diff --git a/examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp b/examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp index b83201fc5c22cf..6e656230c8f2ff 100644 --- a/examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp +++ b/examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp @@ -35,7 +35,7 @@ bool ChipDeviceEventHandler::sUdcInProgress = false; void ChipDeviceEventHandler::Handle(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg) { - ChipLogProgress(AppServer, "ChipDeviceEventHandler::Handle() called"); + ChipLogProgress(AppServer, "ChipDeviceEventHandler::Handle() called with event type: %u", event->Type); // Make sure we have not disconnected from the TargetCastingPlayer when handling incoming messages. // Sometimes the tv-app will still send messages after we clean up the TargetCastingPlayer. diff --git a/examples/tv-casting-app/tv-casting-common/support/EndpointListLoader.cpp b/examples/tv-casting-app/tv-casting-common/support/EndpointListLoader.cpp index 07135e7d601e19..00bbe71081af74 100644 --- a/examples/tv-casting-app/tv-casting-common/support/EndpointListLoader.cpp +++ b/examples/tv-casting-app/tv-casting-common/support/EndpointListLoader.cpp @@ -109,7 +109,7 @@ CHIP_ERROR EndpointListLoader::Load() { // if we discovered a new Endpoint from the bindings, read its EndpointAttributes chip::EndpointId endpointId = binding.remote; - ChipLogProgress(AppServer, "EndpointListLoader::Load() Found new endpointId: %d", endpointId); + ChipLogProgress(AppServer, "EndpointListLoader::Load() Checking if endpointId: %d is new", endpointId); std::vector> endpoints = CastingPlayer::GetTargetCastingPlayer()->GetEndpoints(); if (std::find_if(endpoints.begin(), endpoints.end(), [&endpointId](const memory::Strong & endpoint) { return endpoint->GetId() == endpointId; @@ -149,7 +149,8 @@ void EndpointListLoader::Complete() if (mPendingAttributeReads == 0) { - ChipLogProgress(AppServer, "EndpointListLoader::Complete() Loading %lu endpoint(s)", mNewEndpointsToLoad); + ChipLogProgress(AppServer, "EndpointListLoader::Complete() Done reading attributes. Loading %lu endpoint(s)", + mNewEndpointsToLoad); for (unsigned long i = 0; i < mNewEndpointsToLoad; i++) { EndpointAttributes endpointAttributes = mEndpointAttributesList[i]; @@ -212,6 +213,8 @@ CHIP_ERROR EndpointListLoader::ReadVendorId(EndpointAttributes * endpointAttribu chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType decodableVendorId) { EndpointAttributes * _endpointAttributes = static_cast(context); _endpointAttributes->mVendorId = decodableVendorId; + ChipLogProgress(AppServer, "EndpointListLoader::ReadVendorId() endpointId: %d, decodableVendorId: %d", + _endpointAttributes->mId, decodableVendorId); EndpointListLoader::GetInstance()->Complete(); }, [](void * context, CHIP_ERROR err) { @@ -233,6 +236,8 @@ CHIP_ERROR EndpointListLoader::ReadProductId(EndpointAttributes * endpointAttrib chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType decodableProductId) { EndpointAttributes * _endpointAttributes = static_cast(context); _endpointAttributes->mProductId = decodableProductId; + ChipLogProgress(AppServer, "EndpointListLoader::ReadProductId() endpointId: %d, decodableProductId: %d", + _endpointAttributes->mId, decodableProductId); EndpointListLoader::GetInstance()->Complete(); }, [](void * context, CHIP_ERROR err) { diff --git a/scripts/tests/linux/tv_casting_test_sequences.py b/scripts/tests/linux/tv_casting_test_sequences.py index c4ca182f5583d2..d0dd91f5915b57 100644 --- a/scripts/tests/linux/tv_casting_test_sequences.py +++ b/scripts/tests/linux/tv_casting_test_sequences.py @@ -71,8 +71,6 @@ PRODUCT_ID = 0x8001 # 0x8001 = 32769 = Test product id DEVICE_TYPE_CASTING_VIDEO_PLAYER = 0x23 # 0x23 = 35 = Device type library 10.3: Casting Video Player -# 0x457 = 1111 = Target Content Application Vendor ID for the commissioner generated passcode flow -COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID = 0x457 COMMISSIONER_GENERATED_PASSCODE = '0x00BC_614E' # 0x00BC_614E = 12345678 = Default commissioner generated passcode # Value to verify the subscription state against in the Linux tv-casting-app output. @@ -119,6 +117,12 @@ # Send `controller ux ok\n` command to the tv-app subprocess. Step(app=App.TV_APP, input_cmd='controller ux ok\n'), + # Validate that we received the instructions on the tv-app output for sending the `controller ux ok [passcode]` command. + Step(app=App.TV_APP, output_msg=['Via Shell Enter: controller ux ok [passcode]']), + + # Send `controller ux ok 20202021\n` command to the tv-app subprocess. + Step(app=App.TV_APP, input_cmd='controller ux ok 20202021\n'), + # Validate that pairing succeeded between the tv-casting-app and the tv-app. Step(app=App.TV_APP, output_msg=['Secure Pairing Success']), @@ -179,10 +183,10 @@ # mCommissionerPasscode: true -> This flag instructs the commissioner to use the commissioner-generated-passcode flow for commissioning. # mCommissionerPasscodeReady: false -> This flag indicates that the commissionee has not obtained the commissioner passcode from the user and # thus is not ready for commissioning. - # Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID} -> The initial VENDOR_ID of the casting player will be overridden to {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}. - # Otherwise we will enter the commissionee-generated-passcode flow. + # Vendor ID: {VENDOR_ID} -> The target VENDOR_ID of the casting player is the same for both commissionee-generated-passcode and + # commissioner-generated-passcode flows. Step(app=App.TV_CASTING_APP, output_msg=['IdentificationDeclarationOptions::LogDetail()', 'IdentificationDeclarationOptions::mCommissionerPasscode: true', - 'IdentificationDeclarationOptions::mCommissionerPasscodeReady: false', 'IdentificationDeclarationOptions::TargetAppInfos list:', f'TargetAppInfo 1, Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}']), + 'IdentificationDeclarationOptions::mCommissionerPasscodeReady: false', 'IdentificationDeclarationOptions::TargetAppInfos list:', f'TargetAppInfo 1, Vendor ID: {VENDOR_ID}']), # Validate that we received the cast request from the tv-casting-app on the tv-app output. Step(app=App.TV_APP, @@ -221,10 +225,10 @@ # mCommissionerPasscode: true -> This flag instructs the commissioner to use the commissioner-generated-passcode flow for commissioning. # mCommissionerPasscodeReady: true -> This flag indicates that the commissionee has obtained the commissioner passcode from the user and # thus is ready for commissioning. - # Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID} -> The initial VENDOR_ID of the casting player will be overridden to {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}. - # Otherwise we will enter the commissionee-generated-passcode flow. + # Vendor ID: {VENDOR_ID} -> The target VENDOR_ID of the casting player is the same for both commissionee-generated-passcode and + # commissioner-generated-passcode flows. Step(app=App.TV_CASTING_APP, output_msg=['IdentificationDeclarationOptions::LogDetail()', 'IdentificationDeclarationOptions::mCommissionerPasscode: true', - 'IdentificationDeclarationOptions::mCommissionerPasscodeReady: true', 'IdentificationDeclarationOptions::TargetAppInfos list:', f'TargetAppInfo 1, Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}']), + 'IdentificationDeclarationOptions::mCommissionerPasscodeReady: true', 'IdentificationDeclarationOptions::TargetAppInfos list:', f'TargetAppInfo 1, Vendor ID: {VENDOR_ID}']), # Validate that pairing succeeded between the tv-casting-app and the tv-app. Step(app=App.TV_APP, output_msg=['Secure Pairing Success']), diff --git a/src/app/app-platform/ContentAppPlatform.cpp b/src/app/app-platform/ContentAppPlatform.cpp index aa615aaae8be54..7f89c69d4cb63b 100644 --- a/src/app/app-platform/ContentAppPlatform.cpp +++ b/src/app/app-platform/ContentAppPlatform.cpp @@ -324,13 +324,13 @@ ContentApp * ContentAppPlatform::LoadContentAppInternal(const CatalogVendorApp & ContentApp * ContentAppPlatform::LoadContentAppByClient(uint16_t vendorId, uint16_t productId) { - ChipLogProgress(DeviceLayer, "GetLoadContentAppByVendorId() - vendorId %d, productId %d", vendorId, productId); + ChipLogProgress(DeviceLayer, "LoadContentAppByVendorId() - vendorId %d, productId %d", vendorId, productId); CatalogVendorApp vendorApp; CHIP_ERROR err = mContentAppFactory->LookupCatalogVendorApp(vendorId, productId, &vendorApp); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "GetLoadContentAppByVendorId() - failed to find an app for vendorId %d, productId %d", vendorId, + ChipLogError(DeviceLayer, "LoadContentAppByVendorId() - failed to find an app for vendorId %d, productId %d", vendorId, productId); return nullptr; } @@ -514,7 +514,7 @@ bool ContentAppPlatform::HasTargetContentApp(uint16_t vendorId, uint16_t product ContentApp * app = LoadContentAppByClient(info.vendorId, info.productId); if (app == nullptr) { - ChipLogProgress(DeviceLayer, "no app found for vendor id=%d \r\n", info.vendorId); + ChipLogProgress(DeviceLayer, "no content app found for vendor id=%d \r\n", info.vendorId); return false; } @@ -531,6 +531,8 @@ bool ContentAppPlatform::HasTargetContentApp(uint16_t vendorId, uint16_t product // if no match, then check allowed vendor list for (const auto & allowedVendor : app->GetApplicationBasicDelegate()->GetAllowedVendorList()) { + ChipLogProgress(DeviceLayer, "HasTargetContentApp() allowedVendor id: %d, Client vendor id: %d", allowedVendor, + vendorId); if (allowedVendor == vendorId) { allow = true; @@ -539,10 +541,10 @@ bool ContentAppPlatform::HasTargetContentApp(uint16_t vendorId, uint16_t product } if (!allow) { - ChipLogProgress( - DeviceLayer, - "no permission given by ApplicationBasic cluster on app with vendor id=%d to client with vendor id=%d\r\n", - info.vendorId, vendorId); + ChipLogProgress(DeviceLayer, + "no permission given by ApplicationBasic cluster on Content App with vendor id=%d to Client " + "(Commissionee) with vendor id=%d\r\n", + info.vendorId, vendorId); return false; } } diff --git a/src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp b/src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp index 118ba7c7c524e4..7e1f602e2ddbaf 100644 --- a/src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp +++ b/src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp @@ -566,8 +566,9 @@ void UserDirectedCommissioningServer::PrintUDCClients() Encoding::BytesToUppercaseHexString(state->GetRotatingId(), chip::Dnssd::kMaxRotatingIdLen, rotatingIdString, sizeof(rotatingIdString)); - ChipLogProgress(AppServer, "UDC Client[%d] instance=%s deviceName=%s address=%s, vid/pid=%d/%d disc=%d rid=%s", i, - state->GetInstanceName(), state->GetDeviceName(), addrBuffer, state->GetVendorId(), + ChipLogProgress(AppServer, + "PrintUDCClients() UDC Client[%d] instance=%s deviceName=%s address=%s, vid/pid=%d/%d disc=%d rid=%s", + i, state->GetInstanceName(), state->GetDeviceName(), addrBuffer, state->GetVendorId(), state->GetProductId(), state->GetLongDiscriminator(), rotatingIdString); } }