Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8e42f42

Browse files
committedMay 29, 2024·
Update code per comments
1 parent 05c6db8 commit 8e42f42

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed
 

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
157157
protected:
158158
std::vector<std::unique_ptr<ContentAppImpl>> mContentApps;
159159
std::vector<uint16_t> mAdminVendorIds{};
160-
std::map<uint16_t, Protocols::UserDirectedCommissioning::CommissionerDeclaration::CdError> mAppInstallationStatus{};
160+
std::map<std::string, Protocols::UserDirectedCommissioning::CommissionerDeclaration::CdError> mAppInstallationStatus{};
161161
};
162162

163163
} // namespace AppPlatform

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

+16-8
Original file line numberDiff line numberDiff line change
@@ -633,26 +633,34 @@ bool ContentAppFactoryImpl::UninstallContentApp(uint16_t vendorId, uint16_t prod
633633
return false;
634634
}
635635

636+
std::string createSearchIndex(uint16_t vendorId, uint16_t productId) {
637+
// Format the IDs into a string
638+
std::string formattedString = std::to_string(vendorId) + ":" + std::to_string(productId);
639+
return formattedString;
640+
}
641+
636642
void ContentAppFactoryImpl::SetAppInstallationStatus(uint16_t vendorId, uint16_t productId, CommissionerDeclaration::CdError status)
637643
{
638-
std::map<uint16_t, Protocols::UserDirectedCommissioning::CommissionerDeclaration::CdError>::iterator it;
639-
it = mAppInstallationStatus.find(vendorId);
644+
std::string searchIndex = createSearchIndex(vendorId, productId);
645+
std::map<std::string, Protocols::UserDirectedCommissioning::CommissionerDeclaration::CdError>::iterator it;
646+
it = mAppInstallationStatus.find(searchIndex);
640647
if (it != mAppInstallationStatus.end())
641648
{
642-
mAppInstallationStatus[vendorId] = status;
649+
mAppInstallationStatus[searchIndex] = status;
643650
return;
644651
}
645652

646-
mAppInstallationStatus.insert({ vendorId, status });
653+
mAppInstallationStatus.insert({ searchIndex, status });
647654
}
648655

649656
CommissionerDeclaration::CdError ContentAppFactoryImpl::GetAppInstallationStatus(uint16_t vendorId, uint16_t productId)
650657
{
651-
std::map<uint16_t, Protocols::UserDirectedCommissioning::CommissionerDeclaration::CdError>::iterator it;
652-
it = mAppInstallationStatus.find(vendorId);
658+
std::string searchIndex = createSearchIndex(vendorId, productId);
659+
std::map<std::string, Protocols::UserDirectedCommissioning::CommissionerDeclaration::CdError>::iterator it;
660+
it = mAppInstallationStatus.find(searchIndex);
653661
if (it != mAppInstallationStatus.end())
654662
{
655-
return mAppInstallationStatus[vendorId];
663+
return mAppInstallationStatus[searchIndex];
656664
}
657665

658666
return CommissionerDeclaration::CdError::kAppInstallConsentPending;
@@ -715,7 +723,7 @@ CHIP_ERROR AppTvInit()
715723
ContentAppPlatform::GetInstance().SetupAppPlatform();
716724
ContentAppPlatform::GetInstance().SetContentAppFactory(&gFactory);
717725
gFactory.InstallContentApp((uint16_t) 1, (uint16_t) 11);
718-
gFactory.InstallContentApp((uint16_t) 65521, (uint16_t) 32768);
726+
gFactory.InstallContentApp((uint16_t) 65521, (uint16_t) 32769);
719727
gFactory.InstallContentApp((uint16_t) 9050, (uint16_t) 22);
720728
gFactory.InstallContentApp((uint16_t) 1111, (uint16_t) 22);
721729
uint16_t value;

‎src/controller/CommissionerDiscoveryController.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,11 @@ void CommissionerDiscoveryController::InternalOk()
243243
CommissionerDeclaration::CdError appInstallStatus =
244244
mAppInstallationService->GetInstallationStatusOfApp(client->GetVendorId(), client->GetProductId());
245245

246-
if (appInstallStatus != CommissionerDeclaration::CdError::kNoError)
247-
{
248-
// notify client the current app's installation status
249-
CommissionerDeclaration cd;
250-
cd.SetErrorCode(appInstallStatus);
251-
mUdcServer->SendCDCMessage(cd,
252-
Transport::PeerAddress::UDP(client->GetPeerAddress().GetIPAddress(), client->GetCdPort()));
253-
}
246+
// notify client the current app's installation status
247+
CommissionerDeclaration cd;
248+
cd.SetErrorCode(appInstallStatus);
249+
mUdcServer->SendCDCMessage(cd,
250+
Transport::PeerAddress::UDP(client->GetPeerAddress().GetIPAddress(), client->GetCdPort()));
254251
return;
255252
}
256253

‎src/controller/CommissionerDiscoveryController.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,10 @@ class DLL_EXPORT AppInstallationService
238238
/**
239239
* @brief
240240
* Called to check app's installation status.
241-
*
242-
* This will be called by the main chip thread so any blocking work should be moved to a separate thread.
241+
*
242+
* CdError status is designed for CommissionerDeclaration and should be set by using SetErrorCode() and
243+
* sent back to the client as a CDC Message. It is expected that app installation can have following statuses:
244+
* kNoError, kAppInstallConsentPending, kAppInstalling, kAppInstallFailed, kAppInstalledRetryNeeded
243245
*
244246
* @param[in] vendorId The vendorId in the DNS-SD advertisement of the requesting commissionee.
245247
* @param[in] productId The productId in the DNS-SD advertisement of the requesting commissionee.

0 commit comments

Comments
 (0)
Please sign in to comment.