Skip to content

Commit

Permalink
Add more logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov committed May 14, 2024
1 parent 6fff237 commit 5839b4a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
19 changes: 12 additions & 7 deletions examples/tv-app/tv-common/include/AppTv.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,19 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory

void AddAdminVendorId(uint16_t vendorId);

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] = {
// 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<uint16_t> mAdminVendorIds{};
};
Expand Down
16 changes: 15 additions & 1 deletion examples/tv-app/tv-common/src/AppTv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ using namespace chip::AppPlatform;
using namespace chip::app::Clusters;
using namespace chip::Protocols::UserDirectedCommissioning;

ContentAppFactoryImpl gFactory;

#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
class MyUserPrompter : public UserPrompter
{
Expand Down Expand Up @@ -102,6 +104,13 @@ 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");

gFactory.AddContentApp(vendorId, productId);
// ContentAppFactoryImpl::GetContentAppFactoryImpl().AddContentApp(vendorId, productId);

ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId);

return;
}
};
Expand Down Expand Up @@ -154,6 +163,7 @@ MyPasscodeService gMyPasscodeService;

class MyAppInstallationService : public AppInstallationService
{
// intentionally ambigiously named, need to find a better method name
bool HasContentApp(uint16_t vendorId, uint16_t productId) override
{
return ContentAppPlatform::GetInstance().LoadContentAppByClient(vendorId, productId) != nullptr;
Expand Down Expand Up @@ -288,7 +298,6 @@ MyPostCommissioningListener gMyPostCommissioningListener;
#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ContentAppFactoryImpl gFactory;

ContentAppFactoryImpl * GetContentAppFactoryImpl()
{
Expand Down Expand Up @@ -567,6 +576,11 @@ void ContentAppFactoryImpl::AddAdminVendorId(uint16_t vendorId)
mAdminVendorIds.push_back(vendorId);
}

void ContentAppFactoryImpl::AddContentApp(uint16_t vendorId, uint16_t productId)
{
// mContentApps[5] = ContentAppImpl("Vendor1", vendorId, "exampleid", productId, "Version3", "20202021");
}

Access::Privilege ContentAppFactoryImpl::GetVendorPrivilege(uint16_t vendorId)
{
for (size_t i = 0; i < mAdminVendorIds.size(); ++i)
Expand Down
6 changes: 5 additions & 1 deletion src/controller/CommissionerDiscoveryController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ void CommissionerDiscoveryController::InternalOk()
"------PROMPT USER: %s is requesting to install app on this TV, accept? [" ChipLogFormatMEI "," ChipLogFormatMEI "]",
client->GetDeviceName(), ChipLogValueMEI(client->GetVendorId()), ChipLogValueMEI(client->GetProductId()));

mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
if (mUserPrompter != nullptr)
{
mUserPrompter->PromptForAppInstallOKPermission(client->GetVendorId(), client->GetProductId(), client->GetDeviceName());
}
ChipLogDetail(Controller, "------Via Shell Enter: controller ux accept|cancel");
return;
}

Expand Down

0 comments on commit 5839b4a

Please sign in to comment.