From e1f2e44cc615c3d7a8d91f4537558cac7c711487 Mon Sep 17 00:00:00 2001 From: Lazar Kovacic Date: Tue, 14 May 2024 17:21:13 +0200 Subject: [PATCH] Update basic logic --- examples/tv-app/tv-common/include/AppTv.h | 12 +----- examples/tv-app/tv-common/src/AppTv.cpp | 42 +++++++++++++------ .../CommissionerDiscoveryController.cpp | 1 + 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/examples/tv-app/tv-common/include/AppTv.h b/examples/tv-app/tv-common/include/AppTv.h index efe3be96968804..d2870b73142f66 100644 --- a/examples/tv-app/tv-common/include/AppTv.h +++ b/examples/tv-app/tv-common/include/AppTv.h @@ -142,17 +142,7 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory void AddContentApp(uint16_t vendorId, uint16_t productId); protected: - // ContentAppImpl mContentApps[APP_LIBRARY_SIZE] = { - // ContentAppImpl("Vendor1", 1, "exampleid", 11, "Version1", "34567890"), - // // ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "20202021"), - // ContentAppImpl("Vendor2", 2, "exampleString", 10, "Version2", "20202021"), - // ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3", "20202021"), - // ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2", "20202021") - // }; - - ContentAppImpl mContentApps[APP_LIBRARY_SIZE]; - // = []; - + std::vector> mContentApps; std::vector mAdminVendorIds{}; }; diff --git a/examples/tv-app/tv-common/src/AppTv.cpp b/examples/tv-app/tv-common/src/AppTv.cpp index 68e651a9cfdead..0339ef182af340 100644 --- a/examples/tv-app/tv-common/src/AppTv.cpp +++ b/examples/tv-app/tv-common/src/AppTv.cpp @@ -104,12 +104,10 @@ class MyUserPrompter : public UserPrompter // tv should override this with a dialog prompt inline void PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) override { - // mContentApps[5] = ContentAppImpl("Vendor1", vendorId, "exampleid", productId, "Version3", "20202021"); + ChipLogError(Controller, "Adding Content App"); + gFactory.AddContentApp((uint16_t)65521, (uint16_t)32768); - gFactory.AddContentApp(vendorId, productId); - // ContentAppFactoryImpl::GetContentAppFactoryImpl().AddContentApp(vendorId, productId); - - ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId); + // ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId); return; } @@ -552,19 +550,23 @@ ContentApp * ContentAppFactoryImpl::LoadContentApp(const CatalogVendorApp & vend { ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl: LoadContentAppByAppId catalogVendorId=%d applicationId=%s ", vendorApp.catalogVendorId, vendorApp.applicationId); + int index = 0; + + for (auto & contentApp : mContentApps) { - for (size_t i = 0; i < ArraySize(mContentApps); ++i) - { - auto & app = mContentApps[i]; - ChipLogProgress(DeviceLayer, " Looking next=%s ", app.GetApplicationBasicDelegate()->GetCatalogVendorApp()->applicationId); - if (app.GetApplicationBasicDelegate()->GetCatalogVendorApp()->Matches(vendorApp)) + auto app = contentApp.get(); + + ChipLogProgress(DeviceLayer, " Looking next=%s ", app->GetApplicationBasicDelegate()->GetCatalogVendorApp()->applicationId); + if (app->GetApplicationBasicDelegate()->GetCatalogVendorApp()->Matches(vendorApp)) { - ContentAppPlatform::GetInstance().AddContentApp(&app, &contentAppEndpoint, Span(gDataVersions[i]), + ContentAppPlatform::GetInstance().AddContentApp(app, &contentAppEndpoint, Span(gDataVersions[index]), Span(gContentAppDeviceType)); - return &app; + return app; } + index++; } + ChipLogProgress(DeviceLayer, "LoadContentAppByAppId NOT FOUND catalogVendorId=%d applicationId=%s ", vendorApp.catalogVendorId, vendorApp.applicationId); @@ -578,7 +580,17 @@ void ContentAppFactoryImpl::AddAdminVendorId(uint16_t vendorId) void ContentAppFactoryImpl::AddContentApp(uint16_t vendorId, uint16_t productId) { - // mContentApps[5] = ContentAppImpl("Vendor1", vendorId, "exampleid", productId, "Version3", "20202021"); + if (vendorId == 1 && productId == 11) { + mContentApps.emplace_back(std::make_unique("Vendor1", vendorId, "exampleid", productId, "Version1", "34567890")); + } else if (vendorId == 65521 && productId == 32768) { + mContentApps.emplace_back(std::make_unique("Vendor2", vendorId, "exampleString", productId, "Version2", "20202021")); + } else if (vendorId == 9050 && productId == 22) { + mContentApps.emplace_back(std::make_unique("Vendor3", vendorId, "App3", productId, "Version3", "20202021")); + } else if (vendorId == 1111 && productId == 22) { + mContentApps.emplace_back(std::make_unique("TestSuiteVendor", vendorId, "applicationId", productId, "v2", "20202021")); + } else { + mContentApps.emplace_back(std::make_unique("NewAppVendor", vendorId, "newAppApplicationId", productId, "v2", "20202021")); + } } Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege(uint16_t vendorId) @@ -637,6 +649,10 @@ CHIP_ERROR AppTvInit() #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED ContentAppPlatform::GetInstance().SetupAppPlatform(); ContentAppPlatform::GetInstance().SetContentAppFactory(&gFactory); + gFactory.AddContentApp((uint16_t)1, (uint16_t)11); + // gFactory.AddContentApp((uint16_t)65521, (uint16_t)32768); + // gFactory.AddContentApp((uint16_t)9050, (uint16_t)22); + // gFactory.AddContentApp((uint16_t)1111, (uint16_t)22); uint16_t value; if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR) { diff --git a/src/controller/CommissionerDiscoveryController.cpp b/src/controller/CommissionerDiscoveryController.cpp index 30dc89ef3c6457..3303d1cd73d12b 100644 --- a/src/controller/CommissionerDiscoveryController.cpp +++ b/src/controller/CommissionerDiscoveryController.cpp @@ -260,6 +260,7 @@ void CommissionerDiscoveryController::InternalOk() mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName()); } ChipLogDetail(Controller, "------Via Shell Enter: controller ux accept|cancel"); + client->SetUDCClientProcessingState(UDCClientProcessingState::kPromptingUser); return; }