Skip to content

Commit

Permalink
Merge b4aa1aa into cd44d83
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov authored Mar 2, 2022
2 parents cd44d83 + b4aa1aa commit 5649225
Show file tree
Hide file tree
Showing 23 changed files with 216 additions and 232 deletions.
35 changes: 2 additions & 33 deletions examples/tv-app/android/java/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters::Channel;
using namespace chip::Uint8;

/** @brief Channel Cluster Init
*
Expand Down Expand Up @@ -245,8 +246,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();

ChangeChannelResponseType response;
response.channelMatch.majorNumber = 0;
response.channelMatch.minorNumber = 0;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));

ChipLogProgress(Zcl, "Received ChannelManager::HandleChangeChannel name %s", name.c_str());
VerifyOrExit(mChannelManagerObject != nullptr, ChipLogError(Zcl, "mChannelManagerObject null"));
Expand All @@ -271,37 +271,6 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
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));
if (jcallSign != NULL)
{
JniUtfString callsign(env, jcallSign);
response.channelMatch.callSign = Optional<CharSpan>(callsign.charSpan());
}

jfieldID getNameField = env->GetFieldID(channelClass, "name", "Ljava/lang/String;");
jstring jname = static_cast<jstring>(env->GetObjectField(channelObject, getNameField));
if (jname != NULL)
{
JniUtfString junitname(env, jname);
response.channelMatch.name = Optional<CharSpan>(junitname.charSpan());
}
jfieldID getJaffiliateCallSignField = env->GetFieldID(channelClass, "affiliateCallSign", "Ljava/lang/String;");
jstring jaffiliateCallSign = static_cast<jstring>(env->GetObjectField(channelObject, getJaffiliateCallSignField));
if (jaffiliateCallSign != NULL)
{
JniUtfString affiliateCallSign(env, jaffiliateCallSign);
response.channelMatch.affiliateCallSign = Optional<CharSpan>(affiliateCallSign.charSpan());
}

jfieldID majorNumField = env->GetFieldID(channelClass, "majorNumber", "I");
jint jmajorNum = env->GetIntField(channelObject, majorNumField);
response.channelMatch.majorNumber = static_cast<uint16_t>(jmajorNum);

jfieldID minorNumField = env->GetFieldID(channelClass, "minorNumber", "I");
jint jminorNum = env->GetIntField(channelObject, minorNumField);
response.channelMatch.minorNumber = static_cast<uint16_t>(jminorNum);

helper.Success(response);
}

Expand Down
2 changes: 2 additions & 0 deletions examples/tv-app/android/java/MediaPlaybackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ using namespace chip;
using namespace chip::app;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::MediaPlayback;
using namespace chip::Uint8;
using chip::CharSpan;

/** @brief Media PlayBack Cluster Init
*
Expand Down
9 changes: 5 additions & 4 deletions examples/tv-app/linux/include/channel/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters::Channel;
using namespace chip::Uint8;

ChannelManager::ChannelManager()
{
Expand Down Expand Up @@ -132,10 +133,10 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
}
else
{
response.status = chip::app::Clusters::Channel::StatusEnum::kSuccess;
response.channelMatch = matchedChannels[0];
mCurrentChannel = matchedChannels[0];
mCurrentChannelIndex = index;
response.status = chip::app::Clusters::Channel::StatusEnum::kSuccess;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
mCurrentChannel = matchedChannels[0];
mCurrentChannelIndex = index;
helper.Success(response);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
using namespace std;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::MediaPlayback;
using namespace chip::Uint8;
using chip::CharSpan;

PlaybackStateEnum MediaPlaybackManager::HandleGetCurrentState()
{
Expand Down Expand Up @@ -61,6 +63,7 @@ void MediaPlaybackManager::HandlePlay(CommandResponseHelper<Commands::PlaybackRe
// TODO: Insert code here
mCurrentState = PlaybackStateEnum::kPlaying;
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -70,6 +73,7 @@ void MediaPlaybackManager::HandlePause(CommandResponseHelper<Commands::PlaybackR
// TODO: Insert code here
mCurrentState = PlaybackStateEnum::kPaused;
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -79,6 +83,7 @@ void MediaPlaybackManager::HandleStop(CommandResponseHelper<Commands::PlaybackRe
// TODO: Insert code here
mCurrentState = PlaybackStateEnum::kNotPlaying;
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -87,6 +92,7 @@ void MediaPlaybackManager::HandleFastForward(CommandResponseHelper<Commands::Pla
{
// TODO: Insert code here
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -96,6 +102,7 @@ void MediaPlaybackManager::HandlePrevious(CommandResponseHelper<Commands::Playba
// TODO: Insert code here
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -105,6 +112,7 @@ void MediaPlaybackManager::HandleRewind(CommandResponseHelper<Commands::Playback
// TODO: Insert code here
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -117,6 +125,7 @@ void MediaPlaybackManager::HandleSkipBackward(CommandResponseHelper<Commands::Pl
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(newPosition) };

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -130,6 +139,7 @@ void MediaPlaybackManager::HandleSkipForward(CommandResponseHelper<Commands::Pla
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(newPosition) };

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -141,6 +151,7 @@ void MediaPlaybackManager::HandleSeek(CommandResponseHelper<Commands::PlaybackRe
if (positionMilliseconds > mDuration)
{
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSeekOutOfRange;
helper.Success(response);
}
Expand All @@ -149,6 +160,7 @@ void MediaPlaybackManager::HandleSeek(CommandResponseHelper<Commands::PlaybackRe
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(positionMilliseconds) };

Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -158,6 +170,7 @@ void MediaPlaybackManager::HandleNext(CommandResponseHelper<Commands::PlaybackRe
{
// TODO: Insert code here
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
Expand All @@ -167,6 +180,7 @@ void MediaPlaybackManager::HandleStartOver(CommandResponseHelper<Commands::Playb
// TODO: Insert code here
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
Commands::PlaybackResponse::Type response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
response.status = StatusEnum::kSuccess;
helper.Success(response);
}
5 changes: 3 additions & 2 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ server cluster Channel = 1284 {
}

response struct ChangeChannelResponse {
ChannelInfo channelMatch = 0;
StatusEnum status = 1;
StatusEnum status = 0;
optional CHAR_STRING data = 1;
}

command ChangeChannel(ChangeChannelRequest): ChangeChannelResponse = 0;
Expand Down Expand Up @@ -1064,6 +1064,7 @@ server cluster MediaPlayback = 1286 {

response struct PlaybackResponse {
StatusEnum status = 0;
optional CHAR_STRING data = 1;
}

command FastForward(): PlaybackResponse = 7;
Expand Down
11 changes: 2 additions & 9 deletions src/app/tests/suites/TV_ChannelCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,10 @@ tests:
value: "PBS"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0
- name: "channelMatch"
value:
{
majorNumber: 9,
minorNumber: 1,
name: "PBS",
callSign: "KCTS-TV",
affiliateCallSign: "KCTS",
}

- label: "Change Channel By Number Command"
command: "changeChannelByNumber"
Expand Down
22 changes: 22 additions & 0 deletions src/app/tests/suites/TV_MediaPlaybackCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,55 +74,71 @@ tests:
command: "play"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

- label: "Media Playback Pause Command"
command: "pause"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

- label: "Media Playback Stop Command"
command: "stopPlayback"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

- label: "Media Playback Start Over Command"
command: "startOver"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

- label: "Media Playback Previous Command"
command: "previous"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

- label: "Media Playback Next Command"
command: "next"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

- label: "Media Playback Rewind Command"
command: "rewind"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

- label: "Media Playback Fast Forward Command"
command: "fastForward"
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

Expand All @@ -134,6 +150,8 @@ tests:
value: 500
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

Expand All @@ -151,6 +169,8 @@ tests:
value: 100
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

Expand All @@ -168,6 +188,8 @@ tests:
value: 1000
response:
values:
- name: "data"
value: "data response"
- name: "status"
value: 0

Expand Down
4 changes: 2 additions & 2 deletions src/app/zap-templates/zcl/data-model/chip/channel-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ limitations under the License.

<command source="server" code="0x01" name="ChangeChannelResponse" optional="false">
<description>Upon receipt, this SHALL display the active status of the input list on screen.</description>
<arg name="channelMatch" type="ChannelInfo"/>
<arg name="status" type="StatusEnum"/>
<arg name="status" type="StatusEnum"/>
<arg name="data" type="CHAR_STRING" optional="true"/>
</command>

</cluster>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,32 @@ limitations under the License.
<command source="server" code="0x0A" name="PlaybackResponse" optional="false">
<description>This command SHALL be generated in response to various Playback Request commands.</description>
<arg name="status" type="StatusEnum"/>
<arg name="data" type="CHAR_STRING" optional="true"/>
</command>

</cluster>

<struct name="PlaybackPosition">
<cluster code="0x0506"/>
<item name="updatedAt" type="INT64U"/>
<item name="position" type="INT64U" isNullable="true"/>
<item name="position" type="INT64U" isNullable="true"/>
</struct>

<enum name="PlaybackStateEnum" type="ENUM8">
<cluster code="0x0506"/>
<item name="Playing" value="0x00"/>
<item name="Paused" value="0x01"/>
<item name="Playing" value="0x00"/>
<item name="Paused" value="0x01"/>
<item name="NotPlaying" value="0x02"/>
<item name="Buffering" value="0x03"/>
<item name="Buffering" value="0x03"/>
</enum>

<enum name="StatusEnum" type="ENUM8">
<cluster code="0x0506"/>
<item name="Success" value="0x00"/>
<item name="Success" value="0x00"/>
<item name="InvalidStateForCommand" value="0x01"/>
<item name="NotAllowed" value="0x02"/>
<item name="NotActive" value="0x03"/>
<item name="SpeedOutOfRange" value="0x04"/>
<item name="SeekOutOfRange" value="0x05"/>
<item name="NotAllowed" value="0x02"/>
<item name="NotActive" value="0x03"/>
<item name="SpeedOutOfRange" value="0x04"/>
<item name="SeekOutOfRange" value="0x05"/>
</enum>
</configurator>
Loading

0 comments on commit 5649225

Please sign in to comment.