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

Restyle Update TV SDK, mac address bug addressed and synced content launch xml files per spec. #14962

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions examples/tv-app/android/java/ContentLauncherManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

using namespace std;
using namespace chip;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::ContentLauncher;

void emberAfContentLauncherClusterInitCallback(EndpointId endpoint)
Expand All @@ -44,7 +45,7 @@ void ContentLauncherManager::NewManager(jint endpoint, jobject manager)
}

void ContentLauncherManager::HandleLaunchContent(CommandResponseHelper<LaunchResponseType> & helper,
const std::list<Parameter> & parameterList, bool autoplay,
const DecodableList<ParameterType> & parameterList, bool autoplay,
const chip::CharSpan & data)
{
Commands::LaunchResponse::Type response;
Expand Down Expand Up @@ -99,7 +100,7 @@ void ContentLauncherManager::HandleLaunchContent(CommandResponseHelper<LaunchRes

void ContentLauncherManager::HandleLaunchUrl(CommandResponseHelper<LaunchResponseType> & helper, const chip::CharSpan & contentUrl,
const chip::CharSpan & displayString,
const std::list<BrandingInformation> & brandingInformation)
const BrandingInformationType & brandingInformation)
{
Commands::LaunchResponse::Type response;
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down
10 changes: 6 additions & 4 deletions examples/tv-app/android/java/ContentLauncherManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,26 @@
#include <app/clusters/content-launch-server/content-launch-server.h>
#include <jni.h>
#include <lib/core/CHIPError.h>
#include <list>

using chip::CharSpan;
using chip::app::AttributeValueEncoder;
using chip::app::CommandResponseHelper;
using ContentLauncherDelegate = chip::app::Clusters::ContentLauncher::Delegate;
using LaunchResponseType = chip::app::Clusters::ContentLauncher::Commands::LaunchResponse::Type;
using ParameterType = chip::app::Clusters::ContentLauncher::Structs::Parameter::DecodableType;
using BrandingInformationType = chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type;

class ContentLauncherManager : public ContentLauncherDelegate
{
public:
static void NewManager(jint endpoint, jobject manager);
void InitializeWithObjects(jobject managerObject);

void HandleLaunchContent(CommandResponseHelper<LaunchResponseType> & helper, const std::list<Parameter> & parameterList,
bool autoplay, const CharSpan & data) override;
void HandleLaunchContent(CommandResponseHelper<LaunchResponseType> & helper,
const chip::app::DataModel::DecodableList<ParameterType> & parameterList, bool autoplay,
const CharSpan & data) override;
void HandleLaunchUrl(CommandResponseHelper<LaunchResponseType> & helper, const CharSpan & contentUrl,
const CharSpan & displayString, const std::list<BrandingInformation> & brandingInformation) override;
const CharSpan & displayString, const BrandingInformationType & brandingInformation) override;
CHIP_ERROR HandleGetAcceptHeaderList(AttributeValueEncoder & aEncoder) override;
uint32_t HandleGetSupportedStreamingProtocols() override;

Expand Down
19 changes: 19 additions & 0 deletions examples/tv-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ import("${chip_root}/build/chip/tools.gni")

assert(chip_build_tools)

declare_args() {
# Enable Wake on LAN cluster
chip_enable_wake_on_lan = false
}

config("config") {
include_dirs = [
".",
"${chip_root}/zzz_generated/chip-tv-app",
"${chip_root}/src/lib",
]

defines = [ "CHIP_ENABLE_WAKE_ON_LAN=${chip_enable_wake_on_lan}" ]

cflags = [ "-Wconversion" ]
}

executable("chip-tv-app") {
sources = [
"${chip_root}/examples/tv-app/tv-common/include/CHIPProjectAppConfig.h",
Expand Down Expand Up @@ -66,6 +83,8 @@ executable("chip-tv-app") {

cflags = [ "-Wconversion" ]

public_configs = [ ":config" ]

if (chip_build_libshell) {
cflags += [ "-DENABLE_CHIP_SHELL" ]
}
Expand Down
22 changes: 11 additions & 11 deletions examples/tv-app/linux/include/channel/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder
for (int i = 0; i < maximumVectorSize; ++i)
{
chip::app::Clusters::Channel::Structs::ChannelInfo::Type channelInfo;
channelInfo.affiliateCallSign = Optional<CharSpan>(chip::CharSpan::fromCharString("exampleASign"));
channelInfo.callSign = Optional<CharSpan>(chip::CharSpan::fromCharString("exampleCSign"));
channelInfo.name = Optional<CharSpan>(chip::CharSpan::fromCharString("exampleName"));
channelInfo.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("exampleASign"));
channelInfo.callSign = MakeOptional(chip::CharSpan::fromCharString("exampleCSign"));
channelInfo.name = MakeOptional(chip::CharSpan::fromCharString("exampleName"));
channelInfo.majorNumber = static_cast<uint8_t>(1 + i);
channelInfo.minorNumber = static_cast<uint16_t>(2 + i);

Expand All @@ -47,8 +47,8 @@ CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder)
{
chip::app::Clusters::Channel::Structs::LineupInfo::Type lineup;
lineup.operatorName = chip::CharSpan::fromCharString("operatorName");
lineup.lineupName = Optional<CharSpan>(chip::CharSpan::fromCharString("lineupName"));
lineup.postalCode = Optional<CharSpan>(chip::CharSpan::fromCharString("postalCode"));
lineup.lineupName = MakeOptional(chip::CharSpan::fromCharString("lineupName"));
lineup.postalCode = MakeOptional(chip::CharSpan::fromCharString("postalCode"));
lineup.lineupInfoType = chip::app::Clusters::Channel::LineupInfoTypeEnum::kMso;

return aEncoder.Encode(lineup);
Expand All @@ -57,9 +57,9 @@ CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder)
CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEncoder)
{
chip::app::Clusters::Channel::Structs::ChannelInfo::Type currentChannel;
currentChannel.affiliateCallSign = Optional<CharSpan>(chip::CharSpan::fromCharString("exampleASign"));
currentChannel.callSign = Optional<CharSpan>(chip::CharSpan::fromCharString("exampleCSign"));
currentChannel.name = Optional<CharSpan>(chip::CharSpan::fromCharString("exampleName"));
currentChannel.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("exampleASign"));
currentChannel.callSign = MakeOptional(chip::CharSpan::fromCharString("exampleCSign"));
currentChannel.name = MakeOptional(chip::CharSpan::fromCharString("exampleName"));
currentChannel.majorNumber = 1;
currentChannel.minorNumber = 0;

Expand All @@ -71,9 +71,9 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
ChangeChannelResponseType response;
response.channelMatch.majorNumber = 1;
response.channelMatch.minorNumber = 0;
response.channelMatch.name = Optional<CharSpan>(chip::CharSpan::fromCharString("name"));
response.channelMatch.callSign = Optional<CharSpan>(chip::CharSpan::fromCharString("callSign"));
response.channelMatch.affiliateCallSign = Optional<CharSpan>(chip::CharSpan::fromCharString("affiliateCallSign"));
response.channelMatch.name = MakeOptional(chip::CharSpan::fromCharString("name"));
response.channelMatch.callSign = MakeOptional(chip::CharSpan::fromCharString("callSign"));
response.channelMatch.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("affiliateCallSign"));
response.errorType = chip::app::Clusters::Channel::ErrorTypeEnum::kMultipleMatches;

helper.Success(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::ContentLauncher;

ContentLauncherManager::ContentLauncherManager(list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols)
Expand All @@ -30,20 +31,21 @@ ContentLauncherManager::ContentLauncherManager(list<std::string> acceptHeaderLis
}

void ContentLauncherManager::HandleLaunchContent(CommandResponseHelper<LaunchResponseType> & helper,
const list<Parameter> & parameterList, bool autoplay, const CharSpan & data)
const DecodableList<ParameterType> & parameterList, bool autoplay,
const CharSpan & data)
{
ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchContent for endpoint %d", mEndpointId);
string dataString(data.data(), data.size());

LaunchResponseType response;
// TODO: Insert code here
response.data = chip::Optional<CharSpan>(CharSpan::fromCharString("exampleData"));
response.data = chip::MakeOptional(CharSpan::fromCharString("exampleData"));
response.status = ContentLauncher::StatusEnum::kSuccess;
helper.Success(response);
}

void ContentLauncherManager::HandleLaunchUrl(CommandResponseHelper<LaunchResponseType> & helper, const CharSpan & contentUrl,
const CharSpan & displayString, const list<BrandingInformation> & brandingInformation)
const CharSpan & displayString, const BrandingInformationType & brandingInformation)
{
ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchUrl");

Expand All @@ -52,7 +54,7 @@ void ContentLauncherManager::HandleLaunchUrl(CommandResponseHelper<LaunchRespons

// TODO: Insert code here
LaunchResponseType response;
response.data = chip::Optional<CharSpan>(CharSpan::fromCharString("exampleData"));
response.data = chip::MakeOptional(CharSpan::fromCharString("exampleData"));
response.status = ContentLauncher::StatusEnum::kSuccess;
helper.Success(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ using chip::app::AttributeValueEncoder;
using chip::app::CommandResponseHelper;
using ContentLauncherDelegate = chip::app::Clusters::ContentLauncher::Delegate;
using LaunchResponseType = chip::app::Clusters::ContentLauncher::Commands::LaunchResponse::Type;
using ParameterType = chip::app::Clusters::ContentLauncher::Structs::Parameter::DecodableType;
using BrandingInformationType = chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type;

class ContentLauncherManager : public ContentLauncherDelegate
{
public:
ContentLauncherManager() : ContentLauncherManager({ "example", "example" }, 0){};
ContentLauncherManager(std::list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols);

void HandleLaunchContent(CommandResponseHelper<LaunchResponseType> & helper, const std::list<Parameter> & parameterList,
bool autoplay, const CharSpan & data) override;
void HandleLaunchContent(CommandResponseHelper<LaunchResponseType> & helper,
const chip::app::DataModel::DecodableList<ParameterType> & parameterList, bool autoplay,
const CharSpan & data) override;
void HandleLaunchUrl(CommandResponseHelper<LaunchResponseType> & helper, const CharSpan & contentUrl,
const CharSpan & displayString, const std::list<BrandingInformation> & brandingInformation) override;
const CharSpan & displayString, const BrandingInformationType & brandingInformation) override;
CHIP_ERROR HandleGetAcceptHeaderList(AttributeValueEncoder & aEncoder) override;
uint32_t HandleGetSupportedStreamingProtocols() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ void TargetNavigatorManager::HandleNavigateTarget(CommandResponseHelper<Navigate
NavigateTargetResponseType response;
if (target == kNoCurrentTarget || target > mTargets.size())
{
response.data = chip::Optional<CharSpan>(CharSpan::fromCharString("error"));
response.data = chip::MakeOptional(CharSpan::fromCharString("error"));
response.status = StatusEnum::kTargetNotFound;
helper.Success(response);
return;
}
mCurrentTarget = static_cast<uint8_t>(target);

response.data = chip::Optional<CharSpan>(CharSpan::fromCharString("data response"));
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
15 changes: 15 additions & 0 deletions examples/tv-app/linux/include/wake-on-lan/WakeOnLanManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@
*/

#include "WakeOnLanManager.h"
#include <fstream>
#include <iostream>
#include <string>

using namespace chip;
using namespace chip::app::Clusters::WakeOnLan;

std::string getMacAddress()
{
std::ifstream input("/sys/class/net/eth0/address");
std::string line;
std::getline(input, line);
return line;
}

CHIP_ERROR WakeOnLanManager::HandleGetMacAddress(chip::app::AttributeValueEncoder & aEncoder)
{
#if CHIP_ENABLE_WAKE_ON_LAN
return aEncoder.Encode(CharSpan::fromCharString(getMacAddress().c_str()));
#else
return aEncoder.Encode(CharSpan::fromCharString("00:00:00:00:00"));
#endif // CHIP_ENABLE_WAKE_ON_LAN
}
2 changes: 1 addition & 1 deletion examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ server cluster ContentLauncher = 1290 {
readonly global attribute int16u clusterRevision = 65533;

request struct LaunchContentRequestRequest {
ContentSearch search[] = 0;
ContentSearch search = 0;
BOOLEAN autoPlay = 1;
optional CHAR_STRING data = 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ client cluster ContentLauncher = 1290 {
readonly global attribute int16u clusterRevision = 65533;

request struct LaunchContentRequestRequest {
ContentSearch search[] = 0;
ContentSearch search = 0;
BOOLEAN autoPlay = 1;
optional CHAR_STRING data = 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@ namespace app {
namespace Clusters {
namespace ContentLauncher {

using BrandingInformation = chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type;
using Parameter = chip::app::Clusters::ContentLauncher::Structs::Parameter::DecodableType;

/** @brief
* Defines methods for implementing application-specific logic for the Content Launcher Cluster.
*/
class Delegate
{
public:
virtual void HandleLaunchContent(CommandResponseHelper<Commands::LaunchResponse::Type> & helper,
const std::list<Parameter> & parameterList, bool autoplay, const CharSpan & data) = 0;
const DataModel::DecodableList<Parameter> & parameterList, bool autoplay,
const CharSpan & data) = 0;

virtual void HandleLaunchUrl(CommandResponseHelper<Commands::LaunchResponse::Type> & helper, const CharSpan & contentUrl,
const CharSpan & displayString, const std::list<BrandingInformation> & brandingInformation) = 0;
const CharSpan & displayString, const BrandingInformation & brandingInformation) = 0;

virtual CHIP_ERROR HandleGetAcceptHeaderList(app::AttributeValueEncoder & aEncoder) = 0;

Expand Down
21 changes: 9 additions & 12 deletions src/app/clusters/content-launch-server/content-launch-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,16 @@ bool emberAfContentLauncherClusterLaunchContentRequestCallback(
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;

auto & autoplay = commandData.autoPlay;
auto & data = commandData.data;
// TODO: Decode the parameter and pass it to delegate
// auto searchIterator = commandData.search.begin();
std::list<Parameter> parameterList;
auto & autoplay = commandData.autoPlay;
auto & data = commandData.data;
auto & decodableParameterList = commandData.search.parameterList;

app::CommandResponseHelper<Commands::LaunchResponse::Type> responder(commandObj, commandPath);

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);
{
delegate->HandleLaunchContent(responder, parameterList, autoplay, data.HasValue() ? data.Value() : CharSpan());
delegate->HandleLaunchContent(responder, decodableParameterList, autoplay, data.HasValue() ? data.Value() : CharSpan());
}

exit:
Expand All @@ -229,19 +227,18 @@ bool emberAfContentLauncherClusterLaunchURLRequestCallback(
CHIP_ERROR err = CHIP_NO_ERROR;
EndpointId endpoint = commandPath.mEndpointId;

auto & contentUrl = commandData.contentURL;
auto & displayString = commandData.displayString;
// TODO: Decode the parameter and pass it to delegate
// auto brandingInformationIterator = commandData.brandingInformation.begin();
std::list<BrandingInformation> brandingInformationList;
auto & contentUrl = commandData.contentURL;
auto & displayString = commandData.displayString;
auto & brandingInformation = commandData.brandingInformation;

app::CommandResponseHelper<Commands::LaunchResponse::Type> responder(commandObj, commandPath);

Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);
{
delegate->HandleLaunchUrl(responder, contentUrl, displayString.HasValue() ? displayString.Value() : CharSpan(),
brandingInformationList);
brandingInformation.HasValue() ? brandingInformation.Value()
: chip::app::Clusters::ContentLauncher::BrandingInformation());
}

exit:
Expand Down
12 changes: 9 additions & 3 deletions src/app/tests/suites/TV_ContentLauncherCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ tests:
- name: "search"
value:
{
type: 1,
value: "exampleValue",
externalIDList: [{ name: "name", value: "value" }],
parameterList:
[
{
type: 1,
value: "exampleValue",
externalIDList:
[{ name: "name", value: "value" }],
},
],
}
response:
values:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ limitations under the License.

<command source="client" code="0x00" name="LaunchContentRequest" response="LaunchResponse" optional="false">
<description>Upon receipt, this SHALL launch the specified content with optional search criteria.</description>
<arg name="search" type="ContentSearch" array="true"/>
<arg name="search" type="ContentSearch"/>
<arg name="autoPlay" type="BOOLEAN"/>
<arg name="data" type="CHAR_STRING" optional="true"/>
</command>
Expand Down
2 changes: 1 addition & 1 deletion src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ client cluster ContentLauncher = 1290 {
readonly global attribute int16u clusterRevision = 65533;

request struct LaunchContentRequestRequest {
ContentSearch search[] = 0;
ContentSearch search = 0;
BOOLEAN autoPlay = 1;
optional CHAR_STRING data = 2;
}
Expand Down
Loading