Skip to content

Commit

Permalink
Update basic logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov committed May 14, 2024
1 parent 3e9f59b commit e1f2e44
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
12 changes: 1 addition & 11 deletions examples/tv-app/tv-common/include/AppTv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::unique_ptr<ContentAppImpl>> mContentApps;
std::vector<uint16_t> mAdminVendorIds{};
};

Expand Down
42 changes: 29 additions & 13 deletions examples/tv-app/tv-common/src/AppTv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<DataVersion>(gDataVersions[i]),
ContentAppPlatform::GetInstance().AddContentApp(app, &contentAppEndpoint, Span<DataVersion>(gDataVersions[index]),
Span<const EmberAfDeviceType>(gContentAppDeviceType));
return &app;
return app;
}
index++;
}

ChipLogProgress(DeviceLayer, "LoadContentAppByAppId NOT FOUND catalogVendorId=%d applicationId=%s ", vendorApp.catalogVendorId,
vendorApp.applicationId);

Expand All @@ -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<ContentAppImpl>("Vendor1", vendorId, "exampleid", productId, "Version1", "34567890"));
} else if (vendorId == 65521 && productId == 32768) {
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor2", vendorId, "exampleString", productId, "Version2", "20202021"));
} else if (vendorId == 9050 && productId == 22) {
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("Vendor3", vendorId, "App3", productId, "Version3", "20202021"));
} else if (vendorId == 1111 && productId == 22) {
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("TestSuiteVendor", vendorId, "applicationId", productId, "v2", "20202021"));
} else {
mContentApps.emplace_back(std::make_unique<ContentAppImpl>("NewAppVendor", vendorId, "newAppApplicationId", productId, "v2", "20202021"));
}
}

Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege(uint16_t vendorId)
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/controller/CommissionerDiscoveryController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit e1f2e44

Please sign in to comment.