Skip to content

Commit

Permalink
Rename channel cluster ErrorTypeEnum to StatusEnum (#15382)
Browse files Browse the repository at this point in the history
* Update xml & code

* Run zap regen script

* Submit the fix

* Run zap regen script

* Restyle fix

* Fix linux build fail
  • Loading branch information
lazarkov authored Feb 21, 2022
1 parent 4b7972a commit 292e148
Show file tree
Hide file tree
Showing 26 changed files with 680 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ server cluster ApplicationLauncher = 1292 {
kApplicationPlatform = 0x1;
}

bitmap ChannelFeature : BITMAP32 {
kChannelList = 0x1;
kLineupInfo = 0x2;
}

struct Application {
INT16U catalogVendorId = 0;
CHAR_STRING applicationId = 1;
Expand Down Expand Up @@ -344,15 +339,21 @@ server cluster BridgedActions = 37 {
}

server cluster Channel = 1284 {
enum ErrorTypeEnum : ENUM8 {
kMultipleMatches = 0;
kNoMatches = 1;
}

enum LineupInfoTypeEnum : ENUM8 {
kMso = 0;
}

enum StatusEnum : ENUM8 {
kSuccess = 0;
kMultipleMatches = 1;
kNoMatches = 2;
}

bitmap ChannelFeature : BITMAP32 {
kChannelList = 0x1;
kLineupInfo = 0x2;
}

struct ChannelInfo {
INT16U majorNumber = 0;
INT16U minorNumber = 1;
Expand Down
6 changes: 3 additions & 3 deletions examples/tv-app/android/java/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp

jclass channelClass = env->GetObjectClass(channelObject);

jfieldID getErrorTypeField = env->GetFieldID(channelClass, "errorType", "I");
jint jerrorType = env->GetIntField(channelObject, getErrorTypeField);
response.errorType = static_cast<app::Clusters::Channel::ErrorTypeEnum>(jerrorType);
jfieldID getStatusField = env->GetFieldID(channelClass, "status", "I");
jint jstatus = env->GetIntField(channelObject, getStatusField);
response.status = static_cast<app::Clusters::Channel::StatusEnum>(jstatus);

jfieldID getCallSignField = env->GetFieldID(channelClass, "callSign", "Ljava/lang/String;");
jstring jcallSign = static_cast<jstring>(env->GetObjectField(channelObject, getCallSignField));
Expand Down
5 changes: 3 additions & 2 deletions examples/tv-app/linux/include/channel/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,18 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
// Error: Found multiple matches
if (matchedChannels.size() > 1)
{
response.errorType = chip::app::Clusters::Channel::ErrorTypeEnum::kMultipleMatches;
response.status = chip::app::Clusters::Channel::StatusEnum::kMultipleMatches;
helper.Success(response);
}
else if (matchedChannels.size() == 0)
{
// Error: Found no match
response.errorType = chip::app::Clusters::Channel::ErrorTypeEnum::kNoMatches;
response.status = chip::app::Clusters::Channel::StatusEnum::kNoMatches;
helper.Success(response);
}
else
{
response.status = chip::app::Clusters::Channel::StatusEnum::kSuccess;
response.channelMatch = matchedChannels[0];
mCurrentChannel = matchedChannels[0];
mCurrentChannelIndex = index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,32 @@ PlaybackStateEnum MediaPlaybackManager::HandleGetCurrentState()

uint64_t MediaPlaybackManager::HandleGetStartTime()
{
return 0;
return mStartTime;
}

uint64_t MediaPlaybackManager::HandleGetDuration()
{
return 0;
return mDuration;
}

CHIP_ERROR MediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncoder & aEncoder)
{
Structs::PlaybackPosition::Type sampledPosition;
sampledPosition.updatedAt = 0;
sampledPosition.position = Nullable<uint64_t>(0);

return aEncoder.Encode(sampledPosition);
return aEncoder.Encode(mPlaybackPosition);
}

float MediaPlaybackManager::HandleGetPlaybackSpeed()
{
return 0;
return mPlaybackSpeed;
}

uint64_t MediaPlaybackManager::HandleGetSeekRangeStart()
{
return 0;
return mPlaybackPosition.position.Value();
}

uint64_t MediaPlaybackManager::HandleGetSeekRangeEnd()
{
return 0;
return mDuration - mPlaybackPosition.position.Value();
}

void MediaPlaybackManager::HandlePlay(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
Expand Down Expand Up @@ -98,6 +94,7 @@ void MediaPlaybackManager::HandleFastForward(CommandResponseHelper<Commands::Pla
void MediaPlaybackManager::HandlePrevious(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
{
// TODO: Insert code here
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
Commands::PlaybackResponse::Type response;
response.status = StatusEnum::kSuccess;
helper.Success(response);
Expand All @@ -106,6 +103,7 @@ void MediaPlaybackManager::HandlePrevious(CommandResponseHelper<Commands::Playba
void MediaPlaybackManager::HandleRewind(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
{
// TODO: Insert code here
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
Commands::PlaybackResponse::Type response;
response.status = StatusEnum::kSuccess;
helper.Success(response);
Expand All @@ -115,6 +113,9 @@ void MediaPlaybackManager::HandleSkipBackward(CommandResponseHelper<Commands::Pl
const uint64_t & deltaPositionMilliseconds)
{
// TODO: Insert code here
uint64_t newPosition = mPlaybackPosition.position.Value() - deltaPositionMilliseconds;
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(newPosition) };

Commands::PlaybackResponse::Type response;
response.status = StatusEnum::kSuccess;
helper.Success(response);
Expand All @@ -124,6 +125,10 @@ void MediaPlaybackManager::HandleSkipForward(CommandResponseHelper<Commands::Pla
const uint64_t & deltaPositionMilliseconds)
{
// TODO: Insert code here
uint64_t newPosition = mPlaybackPosition.position.Value() + deltaPositionMilliseconds;
newPosition = newPosition > mDuration ? mDuration : newPosition;
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(newPosition) };

Commands::PlaybackResponse::Type response;
response.status = StatusEnum::kSuccess;
helper.Success(response);
Expand All @@ -133,9 +138,20 @@ void MediaPlaybackManager::HandleSeek(CommandResponseHelper<Commands::PlaybackRe
const uint64_t & positionMilliseconds)
{
// TODO: Insert code here
Commands::PlaybackResponse::Type response;
response.status = StatusEnum::kSuccess;
helper.Success(response);
if (positionMilliseconds > mDuration)
{
Commands::PlaybackResponse::Type response;
response.status = StatusEnum::kSeekOutOfRange;
helper.Success(response);
}
else
{
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(positionMilliseconds) };

Commands::PlaybackResponse::Type response;
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
}

void MediaPlaybackManager::HandleNext(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
Expand All @@ -149,6 +165,7 @@ void MediaPlaybackManager::HandleNext(CommandResponseHelper<Commands::PlaybackRe
void MediaPlaybackManager::HandleStartOver(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
{
// TODO: Insert code here
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
Commands::PlaybackResponse::Type response;
response.status = StatusEnum::kSuccess;
helper.Success(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ using chip::app::AttributeValueEncoder;
using chip::app::CommandResponseHelper;
using MediaPlaybackDelegate = chip::app::Clusters::MediaPlayback::Delegate;
using PlaybackResponseType = chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::Type;
using PlaybackPositionType = chip::app::Clusters::MediaPlayback::Structs::PlaybackPosition::Type;

class MediaPlaybackManager : public MediaPlaybackDelegate
{
Expand Down Expand Up @@ -52,4 +53,9 @@ class MediaPlaybackManager : public MediaPlaybackDelegate

protected:
chip::app::Clusters::MediaPlayback::PlaybackStateEnum mCurrentState;
PlaybackPositionType mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
float mPlaybackSpeed = 0;
uint64_t mStartTime = 0;
// Magic number for testing.
uint64_t mDuration = 80000;
};
23 changes: 12 additions & 11 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ server cluster ApplicationLauncher = 1292 {
kApplicationPlatform = 0x1;
}

bitmap ChannelFeature : BITMAP32 {
kChannelList = 0x1;
kLineupInfo = 0x2;
}

struct ApplicationEP {
Application application = 0;
optional ENDPOINT_NO endpoint = 1;
Expand Down Expand Up @@ -319,15 +314,21 @@ server cluster Binding = 30 {
}

server cluster Channel = 1284 {
enum ErrorTypeEnum : ENUM8 {
kMultipleMatches = 0;
kNoMatches = 1;
}

enum LineupInfoTypeEnum : ENUM8 {
kMso = 0;
}

enum StatusEnum : ENUM8 {
kSuccess = 0;
kMultipleMatches = 1;
kNoMatches = 2;
}

bitmap ChannelFeature : BITMAP32 {
kChannelList = 0x1;
kLineupInfo = 0x2;
}

struct ChannelInfo {
INT16U majorNumber = 0;
INT16U minorNumber = 1;
Expand Down Expand Up @@ -363,7 +364,7 @@ server cluster Channel = 1284 {

response struct ChangeChannelResponse {
ChannelInfo channelMatch = 0;
ErrorTypeEnum errorType = 1;
StatusEnum status = 1;
}

command ChangeChannel(ChangeChannelRequest): ChangeChannelResponse = 0;
Expand Down
21 changes: 11 additions & 10 deletions examples/tv-casting-app/tv-casting-common/tv-casting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ client cluster ApplicationLauncher = 1292 {
kApplicationPlatform = 0x1;
}

bitmap ChannelFeature : BITMAP32 {
kChannelList = 0x1;
kLineupInfo = 0x2;
}

struct Application {
INT16U catalogVendorId = 0;
CHAR_STRING applicationId = 1;
Expand Down Expand Up @@ -297,15 +292,21 @@ server cluster Binding = 30 {
}

client cluster Channel = 1284 {
enum ErrorTypeEnum : ENUM8 {
kMultipleMatches = 0;
kNoMatches = 1;
}

enum LineupInfoTypeEnum : ENUM8 {
kMso = 0;
}

enum StatusEnum : ENUM8 {
kSuccess = 0;
kMultipleMatches = 1;
kNoMatches = 2;
}

bitmap ChannelFeature : BITMAP32 {
kChannelList = 0x1;
kLineupInfo = 0x2;
}

struct ChannelInfo {
INT16U majorNumber = 0;
INT16U minorNumber = 1;
Expand Down
6 changes: 2 additions & 4 deletions src/app/tests/suites/TV_ApplicationBasicCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ tests:
attribute: "Status"
response:
value: 0
# TODO: Enable once attribute struct is supported

- label: "Read attribute application status"
disabled: true
command: "readAttribute"
attribute: "Application"
response:
Expand All @@ -75,8 +74,7 @@ tests:
value: "exampleVersion"

- label: "Read attribute application allowed vendor list"
disabled: true
command: "readAttribute"
attribute: "AllowedVendorList"
response:
value: [123, 456]
value: [1, 456]
4 changes: 1 addition & 3 deletions src/app/tests/suites/TV_ApplicationLauncherCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ tests:
response:
value: [123, 456]

# TODO: Enable once attribute struct is supported
- label: "Read attribute application launcher app"
disabled: true
command: "readAttribute"
attribute: "CurrentApp"
response:
value: { catalogVendorId: 123, applicationId: "applicationId" }
value: null

- label: "Launch App Command"
command: "launchApp"
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/suites/TV_ChannelCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ tests:
value: "PBS"
response:
values:
- name: "errorType"
- name: "status"
value: 0
- name: "channelMatch"
value:
Expand Down
Loading

0 comments on commit 292e148

Please sign in to comment.