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 1 commit
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
16 changes: 16 additions & 0 deletions examples/tv-app/linux/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ 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.catalogVendorId 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;
}

ContentAppFactoryImpl::ContentAppFactoryImpl()
{
mContentApps[1].GetAccountLogin()->SetSetupPIN(34567890);
Expand Down
62 changes: 62 additions & 0 deletions examples/tv-app/linux/AppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,56 @@ 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() {}

protected:
};

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

protected:
};

class DLL_EXPORT TargetNavigatorImpl : public TargetNavigator
{
public:
virtual ~TargetNavigatorImpl() {}

protected:
};

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

protected:
};

class DLL_EXPORT ContentAppImpl : public ContentApp
{
public:
Expand All @@ -94,10 +144,22 @@ 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
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 @@ -36,15 +38,25 @@ CHIP_ERROR ApplicationLauncherManager::Init()

CHIP_ERROR ApplicationLauncherManager::proxyGetApplicationList(chip::app::AttributeValueEncoder & aEncoder)
{
ChipLogProgress(Zcl, "ApplicationLauncherManager::proxyGetApplicationList");
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & 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)
{
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ContentApp * app = chip::AppPlatform::AppPlatform::GetInstance().GetContentAppByEndpointId(endpoint);
if (app != NULL)
{
return app->GetApplicationLauncher()->LaunchApp(application, data);
}
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED

// TODO: Insert your code
ApplicationLauncherResponse response;
const char * testData = "data";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
using namespace chip;
using namespace chip::app::Clusters::ApplicationBasic;

bool applicationBasicClusterChangeApplicationStatus(ApplicationBasicStatus status, EndpointId endpoint);
bool applicationBasicClusterChangeApplicationStatus(EndpointId endpoint, ApplicationBasicStatus status);

bool emberAfApplicationBasicClusterChangeStatusCallback(app::CommandHandler * commandObj,
const app::ConcreteCommandPath & commandPath,
const Commands::ChangeStatus::DecodableType & commandData)
{
auto & newApplicationStatus = commandData.status;

bool success = applicationBasicClusterChangeApplicationStatus(newApplicationStatus, emberAfCurrentEndpoint());
bool success = applicationBasicClusterChangeApplicationStatus(emberAfCurrentEndpoint(), newApplicationStatus);
EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE;
emberAfSendImmediateDefaultResponse(status);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ApplicationLauncher;

ApplicationLauncherResponse applicationLauncherClusterLaunchApp(::ApplicationLauncherApp application, std::string data);
ApplicationLauncherResponse applicationLauncherClusterLaunchApp(EndpointId endpoint, ::ApplicationLauncherApp application,
std::string data);

bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * commandObj,
const app::ConcreteCommandPath & commandPath, EndpointId endpoint,
Expand Down Expand Up @@ -81,7 +82,8 @@ bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * co

::ApplicationLauncherApp application = getApplicationFromCommand(requestApplicationCatalogVendorId, requestApplicationId);
std::string reqestDataString(requestData.data(), requestData.size());
ApplicationLauncherResponse response = applicationLauncherClusterLaunchApp(application, reqestDataString);
ApplicationLauncherResponse response =
applicationLauncherClusterLaunchApp(emberAfCurrentEndpoint(), application, reqestDataString);
sendResponse(command, response);
return true;
}
Expand Down
78 changes: 78 additions & 0 deletions src/app/util/ContentApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,83 @@ EmberAfStatus AccountLogin::HandleWriteAttribute(chip::AttributeId attributeId,
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus KeypadInput::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "KeypadInput::HandleReadAttribute: attrId=%d, maxReadLength=%d",
static_cast<uint16_t>(attributeId), maxReadLength);
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus KeypadInput::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer)
{
ChipLogProgress(DeviceLayer, "KeypadInput::HandleWriteAttribute: attrId=%d", static_cast<uint16_t>(attributeId));
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus ApplicationLauncher::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "ApplicationLauncher::HandleReadAttribute: attrId=%d, maxReadLength=%d",
static_cast<uint16_t>(attributeId), maxReadLength);
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus ApplicationLauncher::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer)
{
ChipLogProgress(DeviceLayer, "ApplicationLauncher::HandleWriteAttribute: attrId=%d", static_cast<uint16_t>(attributeId));
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus ContentLauncher::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "ContentLauncher::HandleReadAttribute: attrId=%d, maxReadLength=%d",
static_cast<uint16_t>(attributeId), maxReadLength);
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus ContentLauncher::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer)
{
ChipLogProgress(DeviceLayer, "ContentLauncher::HandleWriteAttribute: attrId=%d", static_cast<uint16_t>(attributeId));
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus MediaPlayback::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "MediaPlayback::HandleReadAttribute: attrId=%d, maxReadLength=%d",
static_cast<uint16_t>(attributeId), maxReadLength);
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus MediaPlayback::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer)
{
ChipLogProgress(DeviceLayer, "MediaPlayback::HandleWriteAttribute: attrId=%d", static_cast<uint16_t>(attributeId));
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus TargetNavigator::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "TargetNavigator::HandleReadAttribute: attrId=%d, maxReadLength=%d",
static_cast<uint16_t>(attributeId), maxReadLength);
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus TargetNavigator::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer)
{
ChipLogProgress(DeviceLayer, "TargetNavigator::HandleWriteAttribute: attrId=%d", static_cast<uint16_t>(attributeId));
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus Channel::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "Channel::HandleReadAttribute: attrId=%d, maxReadLength=%d", static_cast<uint16_t>(attributeId),
maxReadLength);
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus Channel::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer)
{
ChipLogProgress(DeviceLayer, "Channel::HandleWriteAttribute: attrId=%d", static_cast<uint16_t>(attributeId));
return EMBER_ZCL_STATUS_FAILURE;
}

} // namespace AppPlatform
} // namespace chip
Loading