Skip to content

Commit e1f2e44

Browse files
committed
Update basic logic
1 parent 3e9f59b commit e1f2e44

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

examples/tv-app/tv-common/include/AppTv.h

+1-11
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,7 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
142142
void AddContentApp(uint16_t vendorId, uint16_t productId);
143143

144144
protected:
145-
// ContentAppImpl mContentApps[APP_LIBRARY_SIZE] = {
146-
// ContentAppImpl("Vendor1", 1, "exampleid", 11, "Version1", "34567890"),
147-
// // ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "20202021"),
148-
// ContentAppImpl("Vendor2", 2, "exampleString", 10, "Version2", "20202021"),
149-
// ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3", "20202021"),
150-
// ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2", "20202021")
151-
// };
152-
153-
ContentAppImpl mContentApps[APP_LIBRARY_SIZE];
154-
// = [];
155-
145+
std::vector<std::unique_ptr<ContentAppImpl>> mContentApps;
156146
std::vector<uint16_t> mAdminVendorIds{};
157147
};
158148

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

+29-13
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,10 @@ class MyUserPrompter : public UserPrompter
104104
// tv should override this with a dialog prompt
105105
inline void PromptForAppInstallOKPermission(uint16_t vendorId, uint16_t productId, const char * commissioneeName) override
106106
{
107-
// mContentApps[5] = ContentAppImpl("Vendor1", vendorId, "exampleid", productId, "Version3", "20202021");
107+
ChipLogError(Controller, "Adding Content App");
108+
gFactory.AddContentApp((uint16_t)65521, (uint16_t)32768);
108109

109-
gFactory.AddContentApp(vendorId, productId);
110-
// ContentAppFactoryImpl::GetContentAppFactoryImpl().AddContentApp(vendorId, productId);
111-
112-
ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId);
110+
// ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId);
113111

114112
return;
115113
}
@@ -552,19 +550,23 @@ ContentApp * ContentAppFactoryImpl::LoadContentApp(const CatalogVendorApp & vend
552550
{
553551
ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl: LoadContentAppByAppId catalogVendorId=%d applicationId=%s ",
554552
vendorApp.catalogVendorId, vendorApp.applicationId);
553+
int index = 0;
554+
555+
for (auto & contentApp : mContentApps) {
555556

556-
for (size_t i = 0; i < ArraySize(mContentApps); ++i)
557-
{
558-
auto & app = mContentApps[i];
559557

560-
ChipLogProgress(DeviceLayer, " Looking next=%s ", app.GetApplicationBasicDelegate()->GetCatalogVendorApp()->applicationId);
561-
if (app.GetApplicationBasicDelegate()->GetCatalogVendorApp()->Matches(vendorApp))
558+
auto app = contentApp.get();
559+
560+
ChipLogProgress(DeviceLayer, " Looking next=%s ", app->GetApplicationBasicDelegate()->GetCatalogVendorApp()->applicationId);
561+
if (app->GetApplicationBasicDelegate()->GetCatalogVendorApp()->Matches(vendorApp))
562562
{
563-
ContentAppPlatform::GetInstance().AddContentApp(&app, &contentAppEndpoint, Span<DataVersion>(gDataVersions[i]),
563+
ContentAppPlatform::GetInstance().AddContentApp(app, &contentAppEndpoint, Span<DataVersion>(gDataVersions[index]),
564564
Span<const EmberAfDeviceType>(gContentAppDeviceType));
565-
return &app;
565+
return app;
566566
}
567+
index++;
567568
}
569+
568570
ChipLogProgress(DeviceLayer, "LoadContentAppByAppId NOT FOUND catalogVendorId=%d applicationId=%s ", vendorApp.catalogVendorId,
569571
vendorApp.applicationId);
570572

@@ -578,7 +580,17 @@ void ContentAppFactoryImpl::AddAdminVendorId(uint16_t vendorId)
578580

579581
void ContentAppFactoryImpl::AddContentApp(uint16_t vendorId, uint16_t productId)
580582
{
581-
// mContentApps[5] = ContentAppImpl("Vendor1", vendorId, "exampleid", productId, "Version3", "20202021");
583+
if (vendorId == 1 && productId == 11) {
584+
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1", "34567890"));
585+
} else if (vendorId == 65521 && productId == 32768) {
586+
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2", "20202021"));
587+
} else if (vendorId == 9050 && productId == 22) {
588+
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor3", vendorId, "App3", productId, "Version3", "20202021"));
589+
} else if (vendorId == 1111 && productId == 22) {
590+
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("TestSuiteVendor", vendorId, "applicationId", productId, "v2", "20202021"));
591+
} else {
592+
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("NewAppVendor", vendorId, "newAppApplicationId", productId, "v2", "20202021"));
593+
}
582594
}
583595

584596
Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege(uint16_t vendorId)
@@ -637,6 +649,10 @@ CHIP_ERROR AppTvInit()
637649
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
638650
ContentAppPlatform::GetInstance().SetupAppPlatform();
639651
ContentAppPlatform::GetInstance().SetContentAppFactory(&gFactory);
652+
gFactory.AddContentApp((uint16_t)1, (uint16_t)11);
653+
// gFactory.AddContentApp((uint16_t)65521, (uint16_t)32768);
654+
// gFactory.AddContentApp((uint16_t)9050, (uint16_t)22);
655+
// gFactory.AddContentApp((uint16_t)1111, (uint16_t)22);
640656
uint16_t value;
641657
if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR)
642658
{

src/controller/CommissionerDiscoveryController.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ void CommissionerDiscoveryController::InternalOk()
260260
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
261261
}
262262
ChipLogDetail(Controller, "------Via Shell Enter: controller ux accept|cancel");
263+
client->SetUDCClientProcessingState(UDCClientProcessingState::kPromptingUser);
263264
return;
264265
}
265266

0 commit comments

Comments
 (0)