Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more ContentApp cluster handlers #12634

Merged
merged 18 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ Application ApplicationBasicManager::getApplicationForEndpoint(chip::EndpointId
return app;
}

bool applicationBasicClusterChangeApplicationStatus(app::Clusters::ApplicationBasic::ApplicationBasicStatus status,
chip::EndpointId endpoint)
bool applicationBasicClusterChangeApplicationStatus(chip::EndpointId endpoint,
app::Clusters::ApplicationBasic::ApplicationBasicStatus status)
{
// TODO: Insert code here
ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", to_underlying(status), endpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ CHIP_ERROR ApplicationLauncherManager::proxyGetApplicationList(chip::app::Attrib
});
}

ApplicationLauncherResponse applicationLauncherClusterLaunchApp(ApplicationLauncherApp application, std::string data)
ApplicationLauncherResponse applicationLauncherClusterLaunchApp(chip::EndpointId endpoint, ApplicationLauncherApp application,
std::string data)
{
// TODO: Insert your code
ApplicationLauncherResponse response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CHIP_ERROR TargetNavigatorManager::proxyGetTargetInfoList(chip::app::AttributeVa
});
}

TargetNavigatorResponse targetNavigatorClusterNavigateTarget(uint8_t target, std::string data)
TargetNavigatorResponse targetNavigatorClusterNavigateTarget(chip::EndpointId endpointId, uint8_t target, std::string data)
{
// TODO: Insert code here
TargetNavigatorResponse response;
Expand Down
3 changes: 2 additions & 1 deletion examples/tv-app/android/java/ContentLauncherManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ void emberAfContentLauncherClusterInitCallback(EndpointId endpoint)
}
}

ContentLaunchResponse contentLauncherClusterLaunchContent(std::list<ContentLaunchParamater> parameterList, bool autoplay,
ContentLaunchResponse contentLauncherClusterLaunchContent(chip::EndpointId endpointId,
std::list<ContentLaunchParamater> parameterList, bool autoplay,
const chip::CharSpan & data)
{
return ContentLauncherMgr().LaunchContent(parameterList, autoplay, data);
Expand Down
69 changes: 60 additions & 9 deletions examples/tv-app/linux/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_TV_CHANNEL_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAt
DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(contentAppClusters)
DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, applicationBasicAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, keypadInputAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, applicationLauncherAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, accountLoginAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, contentLauncherAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, mediaPlaybackAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, targetNavigatorAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, channelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END;
DECLARE_DYNAMIC_CLUSTER(ZCL_KEYPAD_INPUT_CLUSTER_ID, keypadInputAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_LAUNCHER_CLUSTER_ID, applicationLauncherAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_ACCOUNT_LOGIN_CLUSTER_ID, accountLoginAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_CONTENT_LAUNCH_CLUSTER_ID, contentLauncherAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_MEDIA_PLAYBACK_CLUSTER_ID, mediaPlaybackAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_TARGET_NAVIGATOR_CLUSTER_ID, targetNavigatorAttrs),
DECLARE_DYNAMIC_CLUSTER(ZCL_TV_CHANNEL_CLUSTER_ID, channelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END;

// Declare Content App endpoint
DECLARE_DYNAMIC_ENDPOINT(contentAppEndpoint, contentAppClusters);
Expand Down Expand Up @@ -191,6 +191,34 @@ uint32_t AccountLoginImpl::GetSetupPIN(const char * tempAccountId)
return mSetupPIN;
}

ApplicationLauncherResponse ApplicationLauncherImpl::LaunchApp(ApplicationLauncherApp application, std::string data)
{
std::string appId(application.applicationId.data(), application.applicationId.size());
ChipLogProgress(DeviceLayer,
"ApplicationLauncherResponse: LaunchApp application.catalogVendorId=%d "
"application.applicationId=%s data=%s",
application.catalogVendorId, appId.c_str(), data.c_str());

ApplicationLauncherResponse response;
const char * testData = "data";
response.data = (uint8_t *) testData;
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS;

return response;
}

ContentLaunchResponse ContentLauncherImpl::LaunchContent(std::list<ContentLaunchParamater> parameterList, bool autoplay,
std::string data)
{
ChipLogProgress(DeviceLayer, "ContentLauncherImpl: LaunchContent autoplay=%d data=\"%s\"", autoplay ? 1 : 0, data.c_str());

ContentLaunchResponse response;
response.err = CHIP_NO_ERROR;
response.data = "Example app data";
response.status = EMBER_ZCL_CONTENT_LAUNCH_STATUS_SUCCESS;
return response;
}

ContentAppFactoryImpl::ContentAppFactoryImpl()
{
mContentApps[1].GetAccountLogin()->SetSetupPIN(34567890);
Expand All @@ -199,12 +227,12 @@ ContentAppFactoryImpl::ContentAppFactoryImpl()

ContentApp * ContentAppFactoryImpl::LoadContentAppByVendorId(uint16_t vendorId)
{
for (unsigned int i = 0; i < sizeof(mContentApps); i++)
for (unsigned int i = 0; i < APP_LIBRARY_SIZE; i++)
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
{
ContentAppImpl app = mContentApps[i];
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
if (app.GetApplicationBasic()->GetVendorId() == vendorId)
{
AppPlatform::GetInstance().AddContentApp(&app, &contentAppEndpoint, DEVICE_TYPE_CONTENT_APP);
AppPlatform::GetInstance().AddContentApp(&mContentApps[i], &contentAppEndpoint, DEVICE_TYPE_CONTENT_APP);
return &mContentApps[i];
}
}
Expand All @@ -213,6 +241,29 @@ ContentApp * ContentAppFactoryImpl::LoadContentAppByVendorId(uint16_t vendorId)
return nullptr;
}

ContentApp * ContentAppFactoryImpl::LoadContentAppByAppId(ApplicationLauncherApp application)
{
std::string appId(application.applicationId.data(), application.applicationId.size());
ChipLogProgress(DeviceLayer,
"ContentAppFactoryImpl: LoadContentAppByAppId application.catalogVendorId=%d "
"application.applicationIdSize=%ld application.applicationId=%s ",
application.catalogVendorId, application.applicationId.size(), appId.c_str());

for (unsigned int i = 0; i < APP_LIBRARY_SIZE; i++)
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
{
ContentAppImpl app = mContentApps[i];
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
ChipLogProgress(DeviceLayer, " Looking next=%s ", app.GetApplicationBasic()->GetApplicationName());
if (strcmp(app.GetApplicationBasic()->GetApplicationName(), appId.c_str()) == 0)
{
AppPlatform::GetInstance().AddContentApp(&mContentApps[i], &contentAppEndpoint, DEVICE_TYPE_CONTENT_APP);
return &mContentApps[i];
}
}
ChipLogProgress(DeviceLayer, "LoadContentAppByAppId() - app id %s not found ", appId.c_str());

return nullptr;
}

} // namespace AppPlatform
} // namespace chip

Expand Down
73 changes: 70 additions & 3 deletions examples/tv-app/linux/AppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,59 @@ class DLL_EXPORT AccountLoginImpl : public AccountLogin
uint32_t mSetupPIN = 0;
};

class DLL_EXPORT KeypadInputImpl : public KeypadInput
{
public:
virtual ~KeypadInputImpl() {}

protected:
};

class DLL_EXPORT ApplicationLauncherImpl : public ApplicationLauncher
{
public:
virtual ~ApplicationLauncherImpl() {}

ApplicationLauncherResponse LaunchApp(ApplicationLauncherApp application, std::string data) override;

protected:
};

class DLL_EXPORT ContentLauncherImpl : public ContentLauncher
{
public:
virtual ~ContentLauncherImpl() {}

ContentLaunchResponse LaunchContent(std::list<ContentLaunchParamater> parameterList, bool autoplay, std::string data) override;

protected:
};

class DLL_EXPORT MediaPlaybackImpl : public MediaPlayback
{
public:
virtual ~MediaPlaybackImpl() {}

protected:
};

class DLL_EXPORT TargetNavigatorImpl : public TargetNavigator
{
public:
TargetNavigatorImpl() : TargetNavigator{ { "home", "search", "info", "guide", "menu" }, 0 } {};
virtual ~TargetNavigatorImpl() {}

protected:
};

class DLL_EXPORT ChannelImpl : public Channel
{
public:
virtual ~ChannelImpl() {}

protected:
};

class DLL_EXPORT ContentAppImpl : public ContentApp
{
public:
Expand All @@ -94,24 +147,38 @@ class DLL_EXPORT ContentAppImpl : public ContentApp

inline ApplicationBasic * GetApplicationBasic() override { return &mApplicationBasic; };
inline AccountLogin * GetAccountLogin() override { return &mAccountLogin; };
inline KeypadInput * GetKeypadInput() override { return &mKeypadInput; };
inline ApplicationLauncher * GetApplicationLauncher() override { return &mApplicationLauncher; };
inline ContentLauncher * GetContentLauncher() override { return &mContentLauncher; };
inline MediaPlayback * GetMediaPlayback() override { return &mMediaPlayback; };
inline TargetNavigator * GetTargetNavigator() override { return &mTargetNavigator; };
inline Channel * GetChannel() override { return &mChannel; };

protected:
ApplicationBasicImpl mApplicationBasic;
AccountLoginImpl mAccountLogin;
KeypadInputImpl mKeypadInput;
ApplicationLauncherImpl mApplicationLauncher;
ContentLauncherImpl mContentLauncher;
MediaPlaybackImpl mMediaPlayback;
TargetNavigatorImpl mTargetNavigator;
ChannelImpl mChannel;
};

class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
{
#define APP_LIBRARY_SIZE 3
public:
ContentAppFactoryImpl();
virtual ~ContentAppFactoryImpl() {}

ContentApp * LoadContentAppByVendorId(uint16_t vendorId);
ContentApp * LoadContentAppByAppId(ApplicationLauncherApp application);

protected:
ContentAppImpl mContentApps[3] = { ContentAppImpl("Vendor1", 1, "App1", 11, "Version1"),
ContentAppImpl("Vendor2", 2, "App2", 22, "Version2"),
ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3") };
ContentAppImpl mContentApps[APP_LIBRARY_SIZE] = { ContentAppImpl("Vendor1", 1, "App1", 11, "Version1"),
ContentAppImpl("Vendor2", 2, "App2", 22, "Version2"),
ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3") };
};

} // namespace AppPlatform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ Application ApplicationBasicManager::getApplicationForEndpoint(chip::EndpointId
return app;
}

bool applicationBasicClusterChangeApplicationStatus(app::Clusters::ApplicationBasic::ApplicationBasicStatus status,
chip::EndpointId endpoint)
bool applicationBasicClusterChangeApplicationStatus(chip::EndpointId endpoint,
app::Clusters::ApplicationBasic::ApplicationBasicStatus status)
{
ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", to_underlying(status), endpoint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
#include <app-common/zap-generated/af-structs.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/clusters/application-launcher-server/application-launcher-server.h>
#include <app/util/ContentAppPlatform.h>
#include <app/util/af.h>
#include <app/util/basic-types.h>

using namespace std;
using namespace chip::AppPlatform;

CHIP_ERROR ApplicationLauncherManager::Init()
{
Expand All @@ -34,22 +36,43 @@ CHIP_ERROR ApplicationLauncherManager::Init()
return err;
}

CHIP_ERROR ApplicationLauncherManager::proxyGetApplicationList(chip::app::AttributeValueEncoder & aEncoder)
CHIP_ERROR ApplicationLauncherManager::proxyGetApplicationList(chip::EndpointId mEndpointId,
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
chip::app::AttributeValueEncoder & aEncoder)
{
ChipLogProgress(Zcl, "ApplicationLauncherManager::proxyGetApplicationList endpoint=%d", mEndpointId);
return aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR {
ReturnErrorOnFailure(encoder.Encode(123u));
ReturnErrorOnFailure(encoder.Encode(456u));
return CHIP_NO_ERROR;
});
}

ApplicationLauncherResponse applicationLauncherClusterLaunchApp(ApplicationLauncherApp application, std::string data)
ApplicationLauncherResponse applicationLauncherClusterLaunchApp(chip::EndpointId endpoint, ApplicationLauncherApp application,
std::string data)
{
ChipLogProgress(Zcl, "ApplicationLauncherManager::applicationLauncherClusterLaunchApp endpoint=%d", emberAfCurrentEndpoint());
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ContentApp * app = chip::AppPlatform::AppPlatform::GetInstance().GetContentAppByEndpointId(endpoint);
if (app != NULL)
{
return app->GetApplicationLauncher()->LaunchApp(application, data);
}

app = chip::AppPlatform::AppPlatform::GetInstance().GetLoadContentAppByAppId(application);
if (app != NULL)
{
return app->GetApplicationLauncher()->LaunchApp(application, data);
}
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED

ChipLogProgress(Zcl, "ApplicationLauncherManager::applicationLauncherClusterLaunchApp app not found");

// TODO: Insert your code
ApplicationLauncherResponse response;
const char * testData = "data";
response.data = (uint8_t *) testData;
response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS;
response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_APP_NOT_AVAILABLE;
// TODO: Update once storing a structure attribute is supported
// emberAfWriteServerAttribute(endpoint, ZCL_APPLICATION_LAUNCH_CLUSTER_ID, ZCL_APPLICATION_LAUNCHER_CURRENT_APP_APPLICATION_ID,
// (uint8_t *) &application, ZCL_STRUCT_ATTRIBUTE_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class ApplicationLauncherManager
{
public:
CHIP_ERROR Init();
CHIP_ERROR proxyGetApplicationList(chip::app::AttributeValueEncoder & aEncoder);
CHIP_ERROR proxyGetApplicationList(chip::EndpointId mEndpointId, chip::app::AttributeValueEncoder & aEncoder);
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ CHIP_ERROR AudioOutputManager::Init()
return err;
}

CHIP_ERROR AudioOutputManager::proxyGetListOfAudioOutputInfo(chip::app::AttributeValueEncoder & aEncoder)
CHIP_ERROR AudioOutputManager::proxyGetListOfAudioOutputInfo(chip::EndpointId mEndpointId,
chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR {
// TODO: Insert code here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class AudioOutputManager
{
public:
CHIP_ERROR Init();
CHIP_ERROR proxyGetListOfAudioOutputInfo(chip::app::AttributeValueEncoder & aEncoder);
CHIP_ERROR proxyGetListOfAudioOutputInfo(chip::EndpointId mEndpointId, chip::app::AttributeValueEncoder & aEncoder);
};
4 changes: 2 additions & 2 deletions examples/tv-app/linux/include/cluster-init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
using namespace chip;

namespace {
template <typename Manager, typename AttrTypeInfo, CHIP_ERROR (Manager::*Getter)(app::AttributeValueEncoder &)>
template <typename Manager, typename AttrTypeInfo, CHIP_ERROR (Manager::*Getter)(uint16_t, app::AttributeValueEncoder &)>
class TvAttrAccess : public app::AttributeAccessInterface
{
public:
Expand All @@ -46,7 +46,7 @@ class TvAttrAccess : public app::AttributeAccessInterface
{
if (aPath.mAttributeId == AttrTypeInfo::GetAttributeId())
{
return (Manager().*Getter)(aEncoder);
return (Manager().*Getter)(aPath.mEndpointId, aEncoder);
}

return CHIP_NO_ERROR;
Expand Down
Loading