From 6fda537580beaa4bf75268d2c2303c44283ef5cf Mon Sep 17 00:00:00 2001 From: Erwin Pan Date: Tue, 13 Feb 2024 09:19:40 +0000 Subject: [PATCH] [Chef] Fix basicvideoplayer device type This was actually a squashed and rebased commit for PR #31987 since it mixed with unwanted commit from other people due to conflicts during rebasing --- examples/chef/chef.py | 1 + examples/chef/common/chef-channel-manager.cpp | 226 ---- examples/chef/common/chef-channel-manager.h | 55 - .../audio-output/AudioOutputManager.cpp | 93 ++ .../audio-output/AudioOutputManager.h | 43 + .../clusters/channel/ChannelManager.cpp | 354 +++++ .../common/clusters/channel/ChannelManager.h | 78 ++ .../keypad-input/KeypadInputManager.cpp | 115 ++ .../keypad-input/KeypadInputManager.h | 37 + .../clusters/low-power/LowPowerManager.cpp | 28 + .../clusters/low-power/LowPowerManager.h | 27 + .../media-input/MediaInputManager.cpp | 111 ++ .../clusters/media-input/MediaInputManager.h | 49 + .../media-playback/MediaPlaybackManager.cpp | 338 +++++ .../media-playback/MediaPlaybackManager.h | 117 ++ .../TargetNavigatorManager.cpp | 93 ++ .../target-navigator/TargetNavigatorManager.h | 45 + .../clusters/wake-on-lan/WakeOnLanManager.cpp | 68 + .../clusters/wake-on-lan/WakeOnLanManager.h | 27 + examples/chef/common/stubs.cpp | 125 +- ...ootnode_basicvideoplayer_0ff86e943b.matter | 327 ++++- .../rootnode_basicvideoplayer_0ff86e943b.zap | 1202 ++++++++++++++--- examples/chef/esp32/main/CMakeLists.txt | 9 + examples/chef/linux/BUILD.gn | 10 +- examples/chef/nrfconnect/CMakeLists.txt | 10 +- 25 files changed, 3090 insertions(+), 498 deletions(-) delete mode 100644 examples/chef/common/chef-channel-manager.cpp delete mode 100644 examples/chef/common/chef-channel-manager.h create mode 100644 examples/chef/common/clusters/audio-output/AudioOutputManager.cpp create mode 100644 examples/chef/common/clusters/audio-output/AudioOutputManager.h create mode 100644 examples/chef/common/clusters/channel/ChannelManager.cpp create mode 100644 examples/chef/common/clusters/channel/ChannelManager.h create mode 100644 examples/chef/common/clusters/keypad-input/KeypadInputManager.cpp create mode 100644 examples/chef/common/clusters/keypad-input/KeypadInputManager.h create mode 100644 examples/chef/common/clusters/low-power/LowPowerManager.cpp create mode 100644 examples/chef/common/clusters/low-power/LowPowerManager.h create mode 100644 examples/chef/common/clusters/media-input/MediaInputManager.cpp create mode 100644 examples/chef/common/clusters/media-input/MediaInputManager.h create mode 100644 examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp create mode 100644 examples/chef/common/clusters/media-playback/MediaPlaybackManager.h create mode 100644 examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp create mode 100644 examples/chef/common/clusters/target-navigator/TargetNavigatorManager.h create mode 100644 examples/chef/common/clusters/wake-on-lan/WakeOnLanManager.cpp create mode 100644 examples/chef/common/clusters/wake-on-lan/WakeOnLanManager.h diff --git a/examples/chef/chef.py b/examples/chef/chef.py index 688bdfef490761..816840f8584a45 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -801,6 +801,7 @@ def main() -> int: 'import("${chip_root}/config/standalone/args.gni")', 'chip_shell_cmd_server = false', 'chip_build_libshell = true', + 'chip_enable_openthread = false', 'chip_config_network_layer_ble = false', 'chip_device_project_config_include = ""', 'chip_project_config_include = ""', diff --git a/examples/chef/common/chef-channel-manager.cpp b/examples/chef/common/chef-channel-manager.cpp deleted file mode 100644 index 4a8d6de466d746..00000000000000 --- a/examples/chef/common/chef-channel-manager.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/** - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include - -using ChangeChannelResponseType = chip::app::Clusters::Channel::Commands::ChangeChannelResponse::Type; -using ChannelInfoType = chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type; -using LineupInfoType = chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type; -// Include Channel Cluster Server callbacks only when the server is enabled -#ifdef MATTER_DM_PLUGIN_CHANNEL_SERVER -#include - -using namespace chip; -using namespace chip::app; -using namespace chip::app::Clusters::Channel; -using namespace chip::Uint8; - -ChefChannelManager::ChefChannelManager() -{ - ChannelInfoType abc; - abc.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("KAAL")); - abc.callSign = MakeOptional(chip::CharSpan::fromCharString("KAAL-TV")); - abc.name = MakeOptional(chip::CharSpan::fromCharString("ABC")); - abc.majorNumber = static_cast(6); - abc.minorNumber = static_cast(0); - mChannels[mTotalChannels++] = abc; - - ChannelInfoType pbs; - pbs.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("KCTS")); - pbs.callSign = MakeOptional(chip::CharSpan::fromCharString("KCTS-TV")); - pbs.name = MakeOptional(chip::CharSpan::fromCharString("PBS")); - pbs.majorNumber = static_cast(9); - pbs.minorNumber = static_cast(1); - mChannels[mTotalChannels++] = pbs; - - ChannelInfoType pbsKids; - pbsKids.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("KCTS")); - pbsKids.callSign = MakeOptional(chip::CharSpan::fromCharString("KCTS-TV")); - pbsKids.name = MakeOptional(chip::CharSpan::fromCharString("PBS Kids")); - pbsKids.majorNumber = static_cast(9); - pbsKids.minorNumber = static_cast(2); - mChannels[mTotalChannels++] = pbsKids; - - ChannelInfoType worldChannel; - worldChannel.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("KCTS")); - worldChannel.callSign = MakeOptional(chip::CharSpan::fromCharString("KCTS-TV")); - worldChannel.name = MakeOptional(chip::CharSpan::fromCharString("World Channel")); - worldChannel.majorNumber = static_cast(9); - worldChannel.minorNumber = static_cast(3); - mChannels[mTotalChannels++] = worldChannel; -} - -static bool isChannelMatched(const ChannelInfoType & channel, const CharSpan & match) -{ - if (channel.name.HasValue() && channel.name.Value().data_equal(match)) - { - return true; - } - - if (channel.affiliateCallSign.HasValue() && channel.affiliateCallSign.Value().data_equal(match)) - { - return true; - } - - if (channel.callSign.HasValue() && channel.callSign.Value().data_equal(match)) - { - return true; - } - - StringBuilder<32> nr; - nr.AddFormat("%d.%d", channel.majorNumber, channel.minorNumber); - return match.data_equal(CharSpan::fromCharString(nr.c_str())); -} - -CHIP_ERROR ChefChannelManager::HandleGetChannelList(app::AttributeValueEncoder & aEncoder) -{ - return aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR { - int index = 0; - for (auto const & channel : ChefChannelManager().mChannels) - { - ReturnErrorOnFailure(encoder.Encode(channel)); - index++; - if (index >= ChefChannelManager().mTotalChannels) - break; - } - return CHIP_NO_ERROR; - }); -} - -CHIP_ERROR ChefChannelManager::HandleGetLineup(app::AttributeValueEncoder & aEncoder) -{ - LineupInfoType lineup; - lineup.operatorName = chip::CharSpan::fromCharString("Comcast"); - lineup.lineupName = MakeOptional(chip::CharSpan::fromCharString("Comcast King County")); - lineup.postalCode = MakeOptional(chip::CharSpan::fromCharString("98052")); - lineup.lineupInfoType = chip::app::Clusters::Channel::LineupInfoTypeEnum::kMso; - - return aEncoder.Encode(lineup); -} - -CHIP_ERROR ChefChannelManager::HandleGetCurrentChannel(app::AttributeValueEncoder & aEncoder) -{ - return aEncoder.Encode(mChannels[mCurrentChannelIndex]); -} - -void ChefChannelManager::HandleChangeChannel(CommandResponseHelper & helper, - const chip::CharSpan & match) -{ - std::array matchedChannels; - - uint16_t index = 0; - uint16_t totalMatchedChannels = 0; - for (auto const & channel : mChannels) - { - // verify if CharSpan matches channel name - // or callSign or affiliateCallSign or majorNumber.minorNumber - if (isChannelMatched(channel, match)) - { - matchedChannels[totalMatchedChannels++] = (channel); - } - else if (totalMatchedChannels == 0) - { - // "index" is only used when we end up with totalMatchedChannels == 1. - // In that case, we want it to be the number of non-matching channels we saw before - // the matching one. - index++; - } - } - - ChangeChannelResponseType response; - - // Error: Found multiple matches - if (totalMatchedChannels > 1) - { - response.status = chip::app::Clusters::Channel::StatusEnum::kMultipleMatches; - helper.Success(response); - } - else if (totalMatchedChannels == 0) - { - // Error: Found no match - response.status = chip::app::Clusters::Channel::StatusEnum::kNoMatches; - helper.Success(response); - } - else - { - response.status = chip::app::Clusters::Channel::StatusEnum::kSuccess; - response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); - mCurrentChannelIndex = index; - helper.Success(response); - } -} - -bool ChefChannelManager::HandleChangeChannelByNumber(const uint16_t & majorNumber, const uint16_t & minorNumber) -{ - bool channelChanged = false; - uint16_t index = 0; - for (auto const & channel : mChannels) - { - - // verify if major & minor matches one of the channel from the list - if (channel.minorNumber == minorNumber && channel.majorNumber == majorNumber) - { - // verify if channel changed by comparing values of current channel with the requested channel - if (channel.minorNumber != mChannels[mCurrentChannelIndex].minorNumber || - channel.majorNumber != mChannels[mCurrentChannelIndex].majorNumber) - { - channelChanged = true; - mCurrentChannelIndex = index; - } - - // return since we've already found the unique matched channel - return channelChanged; - } - index++; - if (index >= mTotalChannels) - break; - } - return channelChanged; -} - -bool ChefChannelManager::HandleSkipChannel(const int16_t & count) -{ - int32_t newChannelIndex = static_cast(count) + static_cast(mCurrentChannelIndex); - uint16_t channelsSize = static_cast(mChannels.size()); - - // handle newChannelIndex out of range. - newChannelIndex = newChannelIndex % channelsSize; - - if (newChannelIndex < 0) - { - newChannelIndex = newChannelIndex + channelsSize; - } - - mCurrentChannelIndex = static_cast(newChannelIndex); - return true; -} - -uint32_t ChefChannelManager::GetFeatureMap(chip::EndpointId endpoint) -{ - if (endpoint > MATTER_DM_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT) - { - return 0; - } - - uint32_t featureMap = 0; - Attributes::FeatureMap::Get(endpoint, &featureMap); - return featureMap; -} - -#endif /* MATTER_DM_PLUGIN_CHANNEL_SERVER */ diff --git a/examples/chef/common/chef-channel-manager.h b/examples/chef/common/chef-channel-manager.h deleted file mode 100644 index 53a1db529a9a4a..00000000000000 --- a/examples/chef/common/chef-channel-manager.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -class ChefChannelManager : public chip::app::Clusters::Channel::Delegate -{ - -public: - ChefChannelManager(); - - CHIP_ERROR HandleGetChannelList(chip::app::AttributeValueEncoder & aEncoder); - CHIP_ERROR HandleGetLineup(chip::app::AttributeValueEncoder & aEncoder); - CHIP_ERROR HandleGetCurrentChannel(chip::app::AttributeValueEncoder & aEncoder); - - void HandleChangeChannel( - chip::app::CommandResponseHelper & helper, - const chip::CharSpan & match); - bool HandleChangeChannelByNumber(const uint16_t & majorNumber, const uint16_t & minorNumber); - bool HandleSkipChannel(const int16_t & count); - - static ChefChannelManager & Instance() - { - static ChefChannelManager instance; - return instance; - } - - // bool HasFeature(chip::EndpointId endpoint, Feature feature); - uint32_t GetFeatureMap(chip::EndpointId endpoint); - - ~ChefChannelManager() = default; - -protected: - static constexpr size_t kMaxChannels = 10; - uint16_t mCurrentChannelIndex{ 0 }; - uint16_t mTotalChannels{ 0 }; - std::array mChannels; -}; diff --git a/examples/chef/common/clusters/audio-output/AudioOutputManager.cpp b/examples/chef/common/clusters/audio-output/AudioOutputManager.cpp new file mode 100644 index 00000000000000..fac96a7290aff4 --- /dev/null +++ b/examples/chef/common/clusters/audio-output/AudioOutputManager.cpp @@ -0,0 +1,93 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifdef MATTER_DM_PLUGIN_AUDIO_OUTPUT_SERVER +#include "AudioOutputManager.h" + +using namespace std; +using namespace chip::app; +using namespace chip::app::Clusters::AudioOutput; +using chip::app::AttributeValueEncoder; + +AudioOutputManager::AudioOutputManager() +{ + const int totalOutput = 4; + + for (uint8_t i = 1; i < totalOutput; ++i) + { + OutputInfoType outputInfo; + outputInfo.outputType = chip::app::Clusters::AudioOutput::OutputTypeEnum::kHdmi; + // note: safe only because of use of string literal + outputInfo.name = chip::CharSpan::fromCharString("HDMI"); + outputInfo.index = static_cast(i); + mOutputs.push_back(outputInfo); + } +} + +uint8_t AudioOutputManager::HandleGetCurrentOutput() +{ + return mCurrentOutput; +} + +CHIP_ERROR AudioOutputManager::HandleGetOutputList(AttributeValueEncoder & aEncoder) +{ + return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR { + for (auto const & outputInfo : this->mOutputs) + { + ReturnErrorOnFailure(encoder.Encode(outputInfo)); + } + return CHIP_NO_ERROR; + }); +} + +bool AudioOutputManager::HandleRenameOutput(const uint8_t & index, const chip::CharSpan & name) +{ + bool audioOutputRenamed = false; + + for (OutputInfoType & output : mOutputs) + { + if (output.index == index) + { + audioOutputRenamed = true; + const size_t len = std::min(mBufMax, name.size()); + memcpy(this->Data(index), name.data(), len); + output.name = chip::CharSpan(this->Data(index), len); + return audioOutputRenamed; + } + } + + return audioOutputRenamed; +} + +bool AudioOutputManager::HandleSelectOutput(const uint8_t & index) +{ + bool audioOutputSelected = false; + for (OutputInfoType & output : mOutputs) + { + if (output.index == index) + { + audioOutputSelected = true; + mCurrentOutput = index; + return audioOutputSelected; + } + } + + return audioOutputSelected; +} +#endif // MATTER_DM_PLUGIN_AUDIO_OUTPUT_SERVER diff --git a/examples/chef/common/clusters/audio-output/AudioOutputManager.h b/examples/chef/common/clusters/audio-output/AudioOutputManager.h new file mode 100644 index 00000000000000..b19b2a4735a485 --- /dev/null +++ b/examples/chef/common/clusters/audio-output/AudioOutputManager.h @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +class AudioOutputManager : public chip::app::Clusters::AudioOutput::Delegate +{ + using OutputInfoType = chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type; + +public: + AudioOutputManager(); + + uint8_t HandleGetCurrentOutput() override; + CHIP_ERROR HandleGetOutputList(chip::app::AttributeValueEncoder & aEncoder) override; + bool HandleRenameOutput(const uint8_t & index, const chip::CharSpan & name) override; + bool HandleSelectOutput(const uint8_t & index) override; + char * Data(uint8_t index) { return mCharDataBuffer[index]; } + +protected: + uint8_t mCurrentOutput = 1; + std::vector mOutputs; + // Magic numbers are here on purpose, please allocate memory + static constexpr size_t mBufMax = 32; + char mCharDataBuffer[10][mBufMax]; +}; diff --git a/examples/chef/common/clusters/channel/ChannelManager.cpp b/examples/chef/common/clusters/channel/ChannelManager.cpp new file mode 100644 index 00000000000000..88aca0f131b348 --- /dev/null +++ b/examples/chef/common/clusters/channel/ChannelManager.cpp @@ -0,0 +1,354 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifdef MATTER_DM_PLUGIN_CHANNEL_SERVER +#include "ChannelManager.h" +#include +#include + +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters::Channel; +using namespace chip::Uint8; + +ChannelManager::ChannelManager() +{ + ChannelInfoType abc; + abc.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("KAAL")); + abc.callSign = MakeOptional(chip::CharSpan::fromCharString("KAAL-TV")); + abc.name = MakeOptional(chip::CharSpan::fromCharString("ABC")); + abc.majorNumber = static_cast(6); + abc.minorNumber = static_cast(0); + mChannels.push_back(abc); + + ChannelInfoType pbs; + pbs.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("KCTS")); + pbs.callSign = MakeOptional(chip::CharSpan::fromCharString("KCTS-TV")); + pbs.name = MakeOptional(chip::CharSpan::fromCharString("PBS")); + pbs.majorNumber = static_cast(9); + pbs.minorNumber = static_cast(1); + mChannels.push_back(pbs); + + ChannelInfoType pbsKids; + pbsKids.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("KCTS")); + pbsKids.callSign = MakeOptional(chip::CharSpan::fromCharString("KCTS-TV")); + pbsKids.name = MakeOptional(chip::CharSpan::fromCharString("PBS Kids")); + pbsKids.majorNumber = static_cast(9); + pbsKids.minorNumber = static_cast(2); + mChannels.push_back(pbsKids); + + ChannelInfoType worldChannel; + worldChannel.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("KCTS")); + worldChannel.callSign = MakeOptional(chip::CharSpan::fromCharString("KCTS-TV")); + worldChannel.name = MakeOptional(chip::CharSpan::fromCharString("World Channel")); + worldChannel.majorNumber = static_cast(9); + worldChannel.minorNumber = static_cast(3); + mChannels.push_back(worldChannel); + + mCurrentChannelIndex = 0; + mCurrentChannel = mChannels[mCurrentChannelIndex]; + + ProgramType program1; + program1.identifier = chip::CharSpan::fromCharString("progid-abc1"); + program1.channel = abc; + program1.title = chip::CharSpan::fromCharString("ABC Title1"); + program1.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle1")); + program1.startTime = 0; + program1.endTime = 30 * 60; + + mPrograms.push_back(program1); + + ProgramType program_pbs1; + program_pbs1.identifier = chip::CharSpan::fromCharString("progid-pbs1"); + program_pbs1.channel = pbs; + program_pbs1.title = chip::CharSpan::fromCharString("PBS Title1"); + program_pbs1.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle1")); + program_pbs1.startTime = 0; + program_pbs1.endTime = 30 * 60; + + mPrograms.push_back(program_pbs1); + + ProgramType program2; + program2.identifier = chip::CharSpan::fromCharString("progid-abc2"); + program2.channel = abc; + program2.title = chip::CharSpan::fromCharString("My Program Title2"); + program2.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle2")); + program2.startTime = 30 * 60; + program2.endTime = 60 * 60; + + mPrograms.push_back(program2); + + ProgramType program3; + program3.identifier = chip::CharSpan::fromCharString("progid-abc3"); + program3.channel = abc; + program3.title = chip::CharSpan::fromCharString("My Program Title3"); + program3.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle3")); + program3.startTime = 0; + program3.endTime = 60 * 60; + + mPrograms.push_back(program3); +} + +CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder) +{ + return aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR { + for (auto const & channel : ChannelManager().mChannels) + { + ReturnErrorOnFailure(encoder.Encode(channel)); + } + return CHIP_NO_ERROR; + }); +} + +CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder) +{ + LineupInfoType lineup; + lineup.operatorName = chip::CharSpan::fromCharString("Comcast"); + lineup.lineupName = MakeOptional(chip::CharSpan::fromCharString("Comcast King County")); + lineup.postalCode = MakeOptional(chip::CharSpan::fromCharString("98052")); + lineup.lineupInfoType = chip::app::Clusters::Channel::LineupInfoTypeEnum::kMso; + + return aEncoder.Encode(lineup); +} + +CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEncoder) +{ + return aEncoder.Encode(mCurrentChannel); +} + +bool ChannelManager::isChannelMatched(const ChannelInfoType & channel, const chip::CharSpan & match) +{ + std::stringstream ss; + ss << channel.majorNumber << "." << channel.minorNumber; + std::string number = ss.str(); + + auto isMatch = [&match](const Optional & a) { return a.HasValue() && a.Value().data_equal(match); }; + + return isMatch(channel.name) || isMatch(channel.affiliateCallSign) || isMatch(channel.callSign) || + match.data_equal(chip::CharSpan::fromCharString(number.c_str())); +} + +void ChannelManager::HandleChangeChannel(CommandResponseHelper & helper, const CharSpan & match) +{ + int iMatchedChannel = -1; + ChangeChannelResponseType response; + + for (uint16_t i = 0; i < mChannels.size(); i++) + { + // verify if CharSpan matches channel name + // or callSign or affiliateCallSign or majorNumber.minorNumber + if (isChannelMatched(mChannels[i], match)) + { + if (iMatchedChannel != -1) + { + // Error: Found multiple matches + response.status = chip::app::Clusters::Channel::StatusEnum::kMultipleMatches; + helper.Success(response); + return; + } + iMatchedChannel = i; + } + } + + if (iMatchedChannel == -1) + { + // Error: Found no match + response.status = chip::app::Clusters::Channel::StatusEnum::kNoMatches; + helper.Success(response); + } + else + { + response.status = chip::app::Clusters::Channel::StatusEnum::kSuccess; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + mCurrentChannel = mChannels[iMatchedChannel]; + mCurrentChannelIndex = iMatchedChannel; + helper.Success(response); + } +} + +bool ChannelManager::HandleChangeChannelByNumber(const uint16_t & majorNumber, const uint16_t & minorNumber) +{ + bool channelChanged = false; + uint16_t index = 0; + for (auto const & channel : mChannels) + { + // verify if major & minor matches one of the channel from the list + if (channel.minorNumber == minorNumber && channel.majorNumber == majorNumber) + { + // verify if channel changed by comparing values of current channel with the requested channel + if (channel.minorNumber != mCurrentChannel.minorNumber || channel.majorNumber != mCurrentChannel.majorNumber) + { + channelChanged = true; + mCurrentChannelIndex = index; + mCurrentChannel = channel; + return channelChanged; + } + } + index++; + } + return channelChanged; +} + +bool ChannelManager::HandleSkipChannel(const int16_t & count) +{ + int32_t newChannelIndex = static_cast(count) + static_cast(mCurrentChannelIndex); + uint16_t channelsSize = static_cast(mChannels.size()); + + // handle newChannelIndex out of range. + newChannelIndex = newChannelIndex % channelsSize; + + if (newChannelIndex < 0) + { + newChannelIndex = newChannelIndex + channelsSize; + } + + mCurrentChannelIndex = static_cast(newChannelIndex); + mCurrentChannel = mChannels[mCurrentChannelIndex]; + return true; +} + +void ChannelManager::HandleGetProgramGuide( + CommandResponseHelper & helper, const chip::Optional & startTime, + const chip::Optional & endTime, + const chip::Optional> & channelList, + const chip::Optional & pageToken, const chip::Optional> & recordingFlag, + const chip::Optional> & externalIdList, + const chip::Optional & data) +{ + + // 1. Decode received parameters + // 2. Perform search + // 3. Return results + + // PageTokenType paging; + // paging.limit = MakeOptional(static_cast(10)); + // paging.after = MakeOptional(chip::CharSpan::fromCharString("after-token")); + // paging.before = MakeOptional(chip::CharSpan::fromCharString("before-token")); + + // ChannelPagingStructType channelPaging; + // channelPaging.nextToken = MakeOptional>(paging); + + std::vector matches; + for (auto const & program : mPrograms) + { + if (startTime.ValueOr(0) > program.startTime) + { + continue; + } + if (endTime.ValueOr(0) < program.endTime) + { + continue; + } + if (channelList.HasValue()) + { + auto iter = channelList.Value().begin(); + bool match = false; + int listCount = 0; + while (iter.Next() && !match) + { + listCount++; + auto & channel = iter.GetValue(); + if (channel.minorNumber != program.channel.minorNumber || channel.majorNumber != program.channel.majorNumber) + { + continue; + } + // this sample code does not currently check OTT + match = true; + } + if (!match && listCount > 0) + { + continue; + } + } + // this sample code does not currently filter on external id list + matches.push_back(program); + } + + ProgramGuideResponseType response; + response.programList = DataModel::List(matches.data(), matches.size()); + helper.Success(response); +} + +bool ChannelManager::HandleRecordProgram(const chip::CharSpan & programIdentifier, bool shouldRecordSeries, + const DataModel::DecodableList & externalIdList, + const chip::ByteSpan & data) +{ + // Start recording + std::string idString(programIdentifier.data(), programIdentifier.size()); + for (auto & program : mPrograms) + { + std::string nextIdString(program.identifier.data(), program.identifier.size()); + if (nextIdString == idString) + { + program.recordingFlag = MakeOptional( + static_cast(shouldRecordSeries ? RecordingFlagBitmap::kRecordSeries : RecordingFlagBitmap::kScheduled)); + } + } + + return true; +} + +bool ChannelManager::HandleCancelRecordProgram(const chip::CharSpan & programIdentifier, bool shouldRecordSeries, + const DataModel::DecodableList & externalIdList, + const chip::ByteSpan & data) +{ + // Cancel recording + std::string idString(programIdentifier.data(), programIdentifier.size()); + for (auto & program : mPrograms) + { + std::string nextIdString(program.identifier.data(), program.identifier.size()); + if (nextIdString == idString) + { + program.recordingFlag = MakeOptional(0); + } + } + return true; +} + +uint32_t ChannelManager::GetFeatureMap(chip::EndpointId endpoint) +{ + if (endpoint >= MATTER_DM_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT) + { + return mDynamicEndpointFeatureMap; + } + + uint32_t featureMap = 0; + Attributes::FeatureMap::Get(endpoint, &featureMap); + return featureMap; +} + +uint16_t ChannelManager::GetClusterRevision(chip::EndpointId endpoint) +{ + if (endpoint >= MATTER_DM_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT) + { + return kClusterRevision; + } + + uint16_t clusterRevision = 0; + bool success = (Attributes::ClusterRevision::Get(endpoint, &clusterRevision) == EMBER_ZCL_STATUS_SUCCESS); + if (!success) + { + ChipLogError(Zcl, "ChannelManager::GetClusterRevision error reading cluster revision"); + } + return clusterRevision; +} +#endif // MATTER_DM_PLUGIN_CHANNEL_SERVER diff --git a/examples/chef/common/clusters/channel/ChannelManager.h b/examples/chef/common/clusters/channel/ChannelManager.h new file mode 100644 index 00000000000000..91a9dd45140d05 --- /dev/null +++ b/examples/chef/common/clusters/channel/ChannelManager.h @@ -0,0 +1,78 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +class ChannelManager : public chip::app::Clusters::Channel::Delegate +{ + using RecordingFlagBitmap = chip::app::Clusters::Channel::RecordingFlagBitmap; + using ChangeChannelResponseType = chip::app::Clusters::Channel::Commands::ChangeChannelResponse::Type; + using ProgramGuideResponseType = chip::app::Clusters::Channel::Commands::ProgramGuideResponse::Type; + using ChannelInfoType = chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type; + using AdditionalInfoType = chip::app::Clusters::Channel::Structs::AdditionalInfoStruct::Type; + using LineupInfoType = chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type; + using PageTokenType = chip::app::Clusters::Channel::Structs::PageTokenStruct::Type; + using ProgramType = chip::app::Clusters::Channel::Structs::ProgramStruct::Type; + using ChannelPagingType = chip::app::Clusters::Channel::Structs::ChannelPagingStruct::Type; + using Feature = chip::app::Clusters::Channel::Feature; + +public: + ChannelManager(); + + CHIP_ERROR HandleGetChannelList(chip::app::AttributeValueEncoder & aEncoder) override; + CHIP_ERROR HandleGetLineup(chip::app::AttributeValueEncoder & aEncoder) override; + CHIP_ERROR HandleGetCurrentChannel(chip::app::AttributeValueEncoder & aEncoder) override; + + void HandleChangeChannel(chip::app::CommandResponseHelper & helper, + const chip::CharSpan & match) override; + bool HandleChangeChannelByNumber(const uint16_t & majorNumber, const uint16_t & minorNumber) override; + bool HandleSkipChannel(const int16_t & count) override; + void HandleGetProgramGuide(chip::app::CommandResponseHelper & helper, + const chip::Optional & startTime, const chip::Optional & endTime, + const chip::Optional> & channelList, + const chip::Optional & pageToken, + const chip::Optional> & recordingFlag, + const chip::Optional> & externalIdList, + const chip::Optional & data) override; + + bool HandleRecordProgram(const chip::CharSpan & programIdentifier, bool shouldRecordSeries, + const chip::app::DataModel::DecodableList & externalIdList, + const chip::ByteSpan & data) override; + + bool HandleCancelRecordProgram(const chip::CharSpan & programIdentifier, bool shouldRecordSeries, + const chip::app::DataModel::DecodableList & externalIdList, + const chip::ByteSpan & data) override; + + uint32_t GetFeatureMap(chip::EndpointId endpoint) override; + uint16_t GetClusterRevision(chip::EndpointId endpoint) override; + +protected: + uint16_t mCurrentChannelIndex; + ChannelInfoType mCurrentChannel; + std::vector mChannels; + std::vector mPrograms; + +private: + bool isChannelMatched(const ChannelInfoType & channel, const chip::CharSpan & match); + static constexpr uint32_t mDynamicEndpointFeatureMap = + static_cast(chip::BitMask(Feature::kChannelList, Feature::kLineupInfo).Raw()); + static constexpr uint16_t kClusterRevision = 2; +}; diff --git a/examples/chef/common/clusters/keypad-input/KeypadInputManager.cpp b/examples/chef/common/clusters/keypad-input/KeypadInputManager.cpp new file mode 100644 index 00000000000000..dc941cf65e4dfa --- /dev/null +++ b/examples/chef/common/clusters/keypad-input/KeypadInputManager.cpp @@ -0,0 +1,115 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifdef MATTER_DM_PLUGIN_KEYPAD_INPUT_SERVER +#include "KeypadInputManager.h" +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters::KeypadInput; + +using chip::app::CommandResponseHelper; + +void KeypadInputManager::HandleSendKey(CommandResponseHelper & helper, const CecKeyCodeType & keycCode) +{ + Commands::SendKeyResponse::Type response; + + switch (keycCode) + { + case CecKeyCodeType::kUp: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kDown: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kLeft: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kRight: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kSelect: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kBackward: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kExit: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kRootMenu: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kSetupMenu: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kEnter: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumber0OrNumber10: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers1: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers2: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers3: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers4: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers5: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers6: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers7: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers8: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + case CecKeyCodeType::kNumbers9: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kSuccess; + break; + default: + response.status = chip::app::Clusters::KeypadInput::StatusEnum::kUnsupportedKey; + } + + helper.Success(response); +} + +uint32_t KeypadInputManager::GetFeatureMap(chip::EndpointId endpoint) +{ + if (endpoint >= MATTER_DM_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT) + { + return mDynamicEndpointFeatureMap; + } + + uint32_t featureMap = 0; + Attributes::FeatureMap::Get(endpoint, &featureMap); + return featureMap; +} +#endif // MATTER_DM_PLUGIN_KEYPAD_INPUT_SERVER diff --git a/examples/chef/common/clusters/keypad-input/KeypadInputManager.h b/examples/chef/common/clusters/keypad-input/KeypadInputManager.h new file mode 100644 index 00000000000000..d9194e8b0f47fc --- /dev/null +++ b/examples/chef/common/clusters/keypad-input/KeypadInputManager.h @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +class KeypadInputManager : public chip::app::Clusters::KeypadInput::Delegate +{ + using SendKeyResponseType = chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::Type; + using CecKeyCodeType = chip::app::Clusters::KeypadInput::CECKeyCodeEnum; + using Feature = chip::app::Clusters::KeypadInput::Feature; + +public: + void HandleSendKey(chip::app::CommandResponseHelper & helper, const CecKeyCodeType & keyCode) override; + + uint32_t GetFeatureMap(chip::EndpointId endpoint) override; + +private: + static constexpr uint32_t mDynamicEndpointFeatureMap = static_cast( + chip::BitMask(Feature::kNavigationKeyCodes, Feature::kLocationKeys, Feature::kNumberKeys).Raw()); +}; diff --git a/examples/chef/common/clusters/low-power/LowPowerManager.cpp b/examples/chef/common/clusters/low-power/LowPowerManager.cpp new file mode 100644 index 00000000000000..1926d0c7150ddd --- /dev/null +++ b/examples/chef/common/clusters/low-power/LowPowerManager.cpp @@ -0,0 +1,28 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifdef MATTER_DM_PLUGIN_LOW_POWER_SERVER +#include "LowPowerManager.h" + +bool LowPowerManager::HandleSleep() +{ + ChipLogProgress(Zcl, "LowPowerManager::HandleSleep"); + return true; +} +#endif // MATTER_DM_PLUGIN_LOW_POWER_SERVER diff --git a/examples/chef/common/clusters/low-power/LowPowerManager.h b/examples/chef/common/clusters/low-power/LowPowerManager.h new file mode 100644 index 00000000000000..92bb1417be514d --- /dev/null +++ b/examples/chef/common/clusters/low-power/LowPowerManager.h @@ -0,0 +1,27 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +class LowPowerManager : public chip::app::Clusters::LowPower::Delegate +{ +public: + bool HandleSleep() override; +}; diff --git a/examples/chef/common/clusters/media-input/MediaInputManager.cpp b/examples/chef/common/clusters/media-input/MediaInputManager.cpp new file mode 100644 index 00000000000000..f4d5eb970eba64 --- /dev/null +++ b/examples/chef/common/clusters/media-input/MediaInputManager.cpp @@ -0,0 +1,111 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifdef MATTER_DM_PLUGIN_MEDIA_INPUT_SERVER +#include "MediaInputManager.h" + +using namespace std; +using namespace chip; +using namespace chip::app::Clusters::MediaInput; + +MediaInputManager::MediaInputManager() +{ + mCurrentInput = 1; + + for (int i = 1; i < mTotalInput; ++i) + { + InputInfoType inputInfo; + inputInfo.description = chip::CharSpan::fromCharString("High-Definition Multimedia Interface"); + inputInfo.name = chip::CharSpan::fromCharString("HDMI"); + inputInfo.inputType = chip::app::Clusters::MediaInput::InputTypeEnum::kHdmi; + inputInfo.index = static_cast(i); + mInputs.push_back(inputInfo); + } +} + +CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncoder & aEncoder) +{ + return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR { + for (auto const & inputInfo : this->mInputs) + { + ReturnErrorOnFailure(encoder.Encode(inputInfo)); + } + return CHIP_NO_ERROR; + }); +} + +uint8_t MediaInputManager::HandleGetCurrentInput() +{ + return mCurrentInput; +} + +bool MediaInputManager::HandleSelectInput(const uint8_t index) +{ + bool mediaInputSelected = false; + for (InputInfoType & input : mInputs) + { + if (input.index == index) + { + mediaInputSelected = true; + mCurrentInput = index; + return mediaInputSelected; + } + } + + return mediaInputSelected; +} + +bool MediaInputManager::HandleShowInputStatus() +{ + ChipLogProgress(Zcl, " MediaInputManager::HandleShowInputStatus()"); + for (auto const & inputInfo : this->mInputs) + { + string name(inputInfo.name.data(), inputInfo.name.size()); + string desc(inputInfo.description.data(), inputInfo.description.size()); + ChipLogProgress(Zcl, " [%d] type=%d selected=%d name=%s desc=%s", inputInfo.index, + static_cast(inputInfo.inputType), (mCurrentInput == inputInfo.index ? 1 : 0), name.c_str(), + desc.c_str()); + } + return true; +} + +bool MediaInputManager::HandleHideInputStatus() +{ + ChipLogProgress(Zcl, " MediaInputManager::HandleHideInputStatus()"); + return true; +} + +bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharSpan & name) +{ + bool mediaInputRenamed = false; + + for (InputInfoType & input : mInputs) + { + if (input.index == index) + { + mediaInputRenamed = true; + const size_t len = std::min(mBufMax, name.size()); + memcpy(this->Data(index), name.data(), len); + input.name = chip::CharSpan(this->Data(index), name.size()); + return mediaInputRenamed; + } + } + + return mediaInputRenamed; +} +#endif // MATTER_DM_PLUGIN_MEDIA_INPUT_SERVER diff --git a/examples/chef/common/clusters/media-input/MediaInputManager.h b/examples/chef/common/clusters/media-input/MediaInputManager.h new file mode 100644 index 00000000000000..5c37f48bdf61d7 --- /dev/null +++ b/examples/chef/common/clusters/media-input/MediaInputManager.h @@ -0,0 +1,49 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +class MediaInputManager : public chip::app::Clusters::MediaInput::Delegate +{ + using InputInfoType = chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type; + +public: + MediaInputManager(); + + CHIP_ERROR HandleGetInputList(chip::app::AttributeValueEncoder & aEncoder) override; + uint8_t HandleGetCurrentInput() override; + bool HandleSelectInput(const uint8_t index) override; + bool HandleShowInputStatus() override; + bool HandleHideInputStatus() override; + bool HandleRenameInput(const uint8_t index, const chip::CharSpan & name) override; + char * Data(uint8_t index) { return mCharDataBuffer[index]; } + +protected: + uint8_t mCurrentInput; + std::vector mInputs; + // Magic numbers are here on purpose, please allocate memory + static constexpr size_t mBufMax = 32; + char mCharDataBuffer[10][mBufMax]; + +private: + static constexpr int mTotalInput = 3; +}; diff --git a/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp new file mode 100644 index 00000000000000..145e2ce935f4f2 --- /dev/null +++ b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp @@ -0,0 +1,338 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifdef MATTER_DM_PLUGIN_MEDIA_PLAYBACK_SERVER +#include "MediaPlaybackManager.h" +#include +#include + +using namespace std; +using namespace chip::app::DataModel; +using namespace chip::app::Clusters::MediaPlayback; +using namespace chip::Uint8; + +using chip::CharSpan; +using chip::app::AttributeValueEncoder; +using chip::app::CommandResponseHelper; + +PlaybackStateEnum MediaPlaybackManager::HandleGetCurrentState() +{ + return mCurrentState; +} + +uint64_t MediaPlaybackManager::HandleGetStartTime() +{ + return mStartTime; +} + +uint64_t MediaPlaybackManager::HandleGetDuration() +{ + return mDuration; +} + +CHIP_ERROR MediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncoder & aEncoder) +{ + return aEncoder.Encode(mPlaybackPosition); +} + +float MediaPlaybackManager::HandleGetPlaybackSpeed() +{ + return mPlaybackSpeed; +} + +uint64_t MediaPlaybackManager::HandleGetSeekRangeStart() +{ + return mStartTime; +} + +uint64_t MediaPlaybackManager::HandleGetSeekRangeEnd() +{ + return mDuration; +} + +CHIP_ERROR MediaPlaybackManager::HandleGetActiveAudioTrack(AttributeValueEncoder & aEncoder) +{ + return aEncoder.Encode(mActiveAudioTrack); +} + +CHIP_ERROR MediaPlaybackManager::HandleGetAvailableAudioTracks(AttributeValueEncoder & aEncoder) +{ + return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR { + for (auto const & audioTrack : mAvailableAudioTracks) + { + ReturnErrorOnFailure(encoder.Encode(audioTrack)); + } + return CHIP_NO_ERROR; + }); +} + +CHIP_ERROR MediaPlaybackManager::HandleGetActiveTextTrack(AttributeValueEncoder & aEncoder) +{ + return aEncoder.Encode(mActiveTextTrack); +} + +CHIP_ERROR MediaPlaybackManager::HandleGetAvailableTextTracks(AttributeValueEncoder & aEncoder) +{ + return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR { + for (auto const & textTrack : mAvailableTextTracks) + { + ReturnErrorOnFailure(encoder.Encode(textTrack)); + } + return CHIP_NO_ERROR; + }); +} + +void MediaPlaybackManager::HandlePlay(CommandResponseHelper & helper) +{ + mCurrentState = PlaybackStateEnum::kPlaying; + mPlaybackSpeed = 1; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandlePause(CommandResponseHelper & helper) +{ + mCurrentState = PlaybackStateEnum::kPaused; + mPlaybackSpeed = 0; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandleStop(CommandResponseHelper & helper) +{ + mCurrentState = PlaybackStateEnum::kNotPlaying; + mPlaybackSpeed = 0; + mPlaybackPosition = { 0, chip::app::DataModel::Nullable(0) }; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandleFastForward(CommandResponseHelper & helper, + const chip::Optional & audioAdvanceUnmuted) +{ + if (mPlaybackSpeed == kPlaybackMaxForwardSpeed) + { + // if already at max speed, return error + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSpeedOutOfRange; + helper.Success(response); + return; + } + + mCurrentState = PlaybackStateEnum::kPlaying; + mPlaybackSpeed = (mPlaybackSpeed <= 0 ? 1 : mPlaybackSpeed * 2); + if (mPlaybackSpeed > kPlaybackMaxForwardSpeed) + { + // don't exceed max speed + mPlaybackSpeed = kPlaybackMaxForwardSpeed; + } + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandlePrevious(CommandResponseHelper & helper) +{ + mCurrentState = PlaybackStateEnum::kPlaying; + mPlaybackSpeed = 1; + mPlaybackPosition = { 0, chip::app::DataModel::Nullable(0) }; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandleRewind(CommandResponseHelper & helper, + const chip::Optional & audioAdvanceUnmuted) +{ + if (mPlaybackSpeed == kPlaybackMaxRewindSpeed) + { + // if already at max speed in reverse, return error + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSpeedOutOfRange; + helper.Success(response); + return; + } + + mCurrentState = PlaybackStateEnum::kPlaying; + mPlaybackSpeed = (mPlaybackSpeed >= 0 ? -1 : mPlaybackSpeed * 2); + if (mPlaybackSpeed < kPlaybackMaxRewindSpeed) + { + // don't exceed max rewind speed + mPlaybackSpeed = kPlaybackMaxRewindSpeed; + } + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandleSkipBackward(CommandResponseHelper & helper, + const uint64_t & deltaPositionMilliseconds) +{ + uint64_t newPosition = (mPlaybackPosition.position.Value() > deltaPositionMilliseconds + ? mPlaybackPosition.position.Value() - deltaPositionMilliseconds + : 0); + mPlaybackPosition = { 0, chip::app::DataModel::Nullable(newPosition) }; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandleSkipForward(CommandResponseHelper & helper, + const uint64_t & deltaPositionMilliseconds) +{ + uint64_t newPosition = mPlaybackPosition.position.Value() + deltaPositionMilliseconds; + newPosition = newPosition > mDuration ? mDuration : newPosition; + mPlaybackPosition = { 0, chip::app::DataModel::Nullable(newPosition) }; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandleSeek(CommandResponseHelper & helper, + const uint64_t & positionMilliseconds) +{ + if (positionMilliseconds > mDuration) + { + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSeekOutOfRange; + helper.Success(response); + } + else + { + mPlaybackPosition = { 0, chip::app::DataModel::Nullable(positionMilliseconds) }; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); + } +} + +void MediaPlaybackManager::HandleNext(CommandResponseHelper & helper) +{ + mCurrentState = PlaybackStateEnum::kPlaying; + mPlaybackSpeed = 1; + mPlaybackPosition = { 0, chip::app::DataModel::Nullable(0) }; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +void MediaPlaybackManager::HandleStartOver(CommandResponseHelper & helper) +{ + mPlaybackPosition = { 0, chip::app::DataModel::Nullable(0) }; + + Commands::PlaybackResponse::Type response; + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +bool MediaPlaybackManager::HandleActivateAudioTrack(const chip::CharSpan & trackId, const uint8_t & audioOutputIndex) +{ + std::string idString(trackId.data(), trackId.size()); + for (auto const & availableAudioTrack : mAvailableAudioTracks) + { + std::string nextIdString(availableAudioTrack.id.data(), availableAudioTrack.id.size()); + if (nextIdString == idString) + { + mActiveAudioTrack = availableAudioTrack; + return true; + } + } + return false; +} + +bool MediaPlaybackManager::HandleActivateTextTrack(const chip::CharSpan & trackId) +{ + std::string idString(trackId.data(), trackId.size()); + for (auto const & availableTextTrack : mAvailableTextTracks) + { + std::string nextIdString(availableTextTrack.id.data(), availableTextTrack.id.size()); + if (nextIdString == idString) + { + mActiveTextTrack = availableTextTrack; + return true; + } + } + return false; +} + +bool MediaPlaybackManager::HandleDeactivateTextTrack() +{ + // Handle Deactivate Text Track + if (mActiveTextTrack.id.data() != nullptr) + { + mActiveTextTrack = {}; + } + return true; +} + +uint32_t MediaPlaybackManager::GetFeatureMap(chip::EndpointId endpoint) +{ + if (endpoint >= MATTER_DM_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT) + { + return mDynamicEndpointFeatureMap; + } + + uint32_t featureMap = 0; + Attributes::FeatureMap::Get(endpoint, &featureMap); + return featureMap; +} + +uint16_t MediaPlaybackManager::GetClusterRevision(chip::EndpointId endpoint) +{ + if (endpoint >= MATTER_DM_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT) + { + return kClusterRevision; + } + + uint16_t clusterRevision = 0; + bool success = (Attributes::ClusterRevision::Get(endpoint, &clusterRevision) == EMBER_ZCL_STATUS_SUCCESS); + if (!success) + { + ChipLogError(Zcl, "MediaPlaybackManager::GetClusterRevision error reading cluster revision"); + } + return clusterRevision; +} + +#endif /// MATTER_DM_PLUGIN_MEDIA_PLAYBACK_SERVER diff --git a/examples/chef/common/clusters/media-playback/MediaPlaybackManager.h b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.h new file mode 100644 index 00000000000000..af7bff4cbe8e29 --- /dev/null +++ b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.h @@ -0,0 +1,117 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +class MediaPlaybackManager : public chip::app::Clusters::MediaPlayback::Delegate +{ + using PlaybackResponseType = chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::Type; + using PlaybackPositionType = chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Type; + using TrackType = chip::app::Clusters::MediaPlayback::Structs::TrackStruct::Type; + using TrackAttributesType = chip::app::Clusters::MediaPlayback::Structs::TrackAttributesStruct::Type; + using Feature = chip::app::Clusters::MediaPlayback::Feature; + +public: + chip::app::Clusters::MediaPlayback::PlaybackStateEnum HandleGetCurrentState() override; + uint64_t HandleGetStartTime() override; + uint64_t HandleGetDuration() override; + CHIP_ERROR HandleGetSampledPosition(chip::app::AttributeValueEncoder & aEncoder) override; + float HandleGetPlaybackSpeed() override; + uint64_t HandleGetSeekRangeStart() override; + uint64_t HandleGetSeekRangeEnd() override; + CHIP_ERROR HandleGetActiveAudioTrack(chip::app::AttributeValueEncoder & aEncoder) override; + CHIP_ERROR HandleGetAvailableAudioTracks(chip::app::AttributeValueEncoder & aEncoder) override; + CHIP_ERROR HandleGetActiveTextTrack(chip::app::AttributeValueEncoder & aEncoder) override; + CHIP_ERROR HandleGetAvailableTextTracks(chip::app::AttributeValueEncoder & aEncoder) override; + + void HandlePlay(chip::app::CommandResponseHelper & helper) override; + void HandlePause(chip::app::CommandResponseHelper & helper) override; + void HandleStop(chip::app::CommandResponseHelper & helper) override; + void HandleFastForward(chip::app::CommandResponseHelper & helper, + const chip::Optional & audioAdvanceUnmuted) override; + void HandlePrevious(chip::app::CommandResponseHelper & helper) override; + void HandleRewind(chip::app::CommandResponseHelper & helper, + const chip::Optional & audioAdvanceUnmuted) override; + void HandleSkipBackward(chip::app::CommandResponseHelper & helper, + const uint64_t & deltaPositionMilliseconds) override; + void HandleSkipForward(chip::app::CommandResponseHelper & helper, + const uint64_t & deltaPositionMilliseconds) override; + void HandleSeek(chip::app::CommandResponseHelper & helper, + const uint64_t & positionMilliseconds) override; + void HandleNext(chip::app::CommandResponseHelper & helper) override; + void HandleStartOver(chip::app::CommandResponseHelper & helper) override; + bool HandleActivateAudioTrack(const chip::CharSpan & trackId, const uint8_t & audioOutputIndex) override; + bool HandleActivateTextTrack(const chip::CharSpan & trackId) override; + bool HandleDeactivateTextTrack() override; + + uint32_t GetFeatureMap(chip::EndpointId endpoint) override; + uint16_t GetClusterRevision(chip::EndpointId endpoint) override; + +protected: + // NOTE: it does not make sense to have default state of playing with a speed of 0, but + // the CI test cases expect these values, and need to be fixed. + chip::app::Clusters::MediaPlayback::PlaybackStateEnum mCurrentState = + chip::app::Clusters::MediaPlayback::PlaybackStateEnum::kPlaying; + PlaybackPositionType mPlaybackPosition = { 0, chip::app::DataModel::Nullable(0) }; + TrackType mActiveAudioTrack = { chip::CharSpan("activeAudioTrackId_0", 20), + chip::app::DataModel::Nullable( + { chip::CharSpan("languageCode1", 13), + chip::Optional>( + { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) }; + std::vector mAvailableAudioTracks = { + { chip::CharSpan("activeAudioTrackId_0", 20), + chip::app::DataModel::Nullable( + { chip::CharSpan("languageCode1", 13), + chip::Optional>( + { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) }, + { chip::CharSpan("activeAudioTrackId_1", 20), + chip::app::DataModel::Nullable( + { chip::CharSpan("languageCode2", 13), + chip::Optional>( + { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName2", 12)) }) }) } + }; + TrackType mActiveTextTrack = {}; + std::vector mAvailableTextTracks = { + { chip::CharSpan("activeTextTrackId_0", 19), + chip::app::DataModel::Nullable( + { chip::CharSpan("languageCode1", 13), + chip::Optional>( + { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) }, + { chip::CharSpan("activeTextTrackId_1", 19), + chip::app::DataModel::Nullable( + { chip::CharSpan("languageCode2", 13), + chip::Optional>( + { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName2", 12)) }) }) } + }; + float mPlaybackSpeed = 1.0; + uint64_t mStartTime = 0; + // Magic number for testing. + uint64_t mDuration = 80000; + bool mAudioAdvanceMuted = false; + + static const int kPlaybackMaxForwardSpeed = 10; + static const int kPlaybackMaxRewindSpeed = -10; + +private: + static constexpr uint32_t mDynamicEndpointFeatureMap = + static_cast(chip::BitMask(Feature::kAdvancedSeek, Feature::kVariableSpeed).Raw()); + static constexpr uint16_t kClusterRevision = 2; +}; diff --git a/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp b/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp new file mode 100644 index 00000000000000..de216cda46971e --- /dev/null +++ b/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp @@ -0,0 +1,93 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifdef MATTER_DM_PLUGIN_TARGET_NAVIGATOR_SERVER +#include "TargetNavigatorManager.h" +#include + +using namespace std; +using namespace chip::app; +using namespace chip::app::Clusters::TargetNavigator; + +using chip::CharSpan; +using chip::app::AttributeValueEncoder; +using chip::app::CommandResponseHelper; + +TargetNavigatorManager::TargetNavigatorManager(std::list targets, uint8_t currentTarget) +{ + mTargets = targets; + mCurrentTarget = currentTarget; +} + +CHIP_ERROR TargetNavigatorManager::HandleGetTargetList(AttributeValueEncoder & aEncoder) +{ + // NOTE: the ids for each target start at 1 so that we can reserve 0 as "no current target" + return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR { + int i = 0; + for (std::string & entry : mTargets) + { + Structs::TargetInfoStruct::Type outputInfo; + outputInfo.identifier = static_cast(i + 1); + outputInfo.name = CharSpan::fromCharString(entry.c_str()); + ReturnErrorOnFailure(encoder.Encode(outputInfo)); + i++; + } + return CHIP_NO_ERROR; + }); +} + +uint8_t TargetNavigatorManager::HandleGetCurrentTarget() +{ + return mCurrentTarget; +} + +void TargetNavigatorManager::HandleNavigateTarget(CommandResponseHelper & helper, + const uint64_t & target, const CharSpan & data) +{ + NavigateTargetResponseType response; + if (target == kNoCurrentTarget || target > mTargets.size()) + { + response.data = chip::MakeOptional(CharSpan::fromCharString("error")); + response.status = StatusEnum::kTargetNotFound; + helper.Success(response); + return; + } + mCurrentTarget = static_cast(target); + + response.data = chip::MakeOptional(CharSpan::fromCharString("data response")); + response.status = StatusEnum::kSuccess; + helper.Success(response); +} + +uint16_t TargetNavigatorManager::GetClusterRevision(chip::EndpointId endpoint) +{ + if (endpoint >= MATTER_DM_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT) + { + return kClusterRevision; + } + + uint16_t clusterRevision = 0; + bool success = (Attributes::ClusterRevision::Get(endpoint, &clusterRevision) == EMBER_ZCL_STATUS_SUCCESS); + if (!success) + { + ChipLogError(Zcl, "TargetNavigatorManager::GetClusterRevision error reading cluster revision"); + } + + return clusterRevision; +} +#endif // MATTER_DM_PLUGIN_TARGET_NAVIGATOR_SERVER diff --git a/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.h b/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.h new file mode 100644 index 00000000000000..21a08b9595cd82 --- /dev/null +++ b/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.h @@ -0,0 +1,45 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +class TargetNavigatorManager : public chip::app::Clusters::TargetNavigator::Delegate +{ + using TargetInfoType = chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type; + using NavigateTargetResponseType = chip::app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::Type; + +public: + TargetNavigatorManager() : TargetNavigatorManager({ "exampleName", "exampleName" }, kNoCurrentTarget){}; + TargetNavigatorManager(std::list targets, uint8_t currentTarget); + + CHIP_ERROR HandleGetTargetList(chip::app::AttributeValueEncoder & aEncoder) override; + uint8_t HandleGetCurrentTarget() override; + void HandleNavigateTarget(chip::app::CommandResponseHelper & responser, const uint64_t & target, + const chip::CharSpan & data) override; + uint16_t GetClusterRevision(chip::EndpointId endpoint) override; + +protected: + // NOTE: the ids for each target start at 1 so that we can reserve 0 as "no current target" + static const uint8_t kNoCurrentTarget = 0; + std::list mTargets; + uint8_t mCurrentTarget; + +private: + static constexpr uint16_t kClusterRevision = 2; +}; diff --git a/examples/chef/common/clusters/wake-on-lan/WakeOnLanManager.cpp b/examples/chef/common/clusters/wake-on-lan/WakeOnLanManager.cpp new file mode 100644 index 00000000000000..5f4e2e1ec7b6e2 --- /dev/null +++ b/examples/chef/common/clusters/wake-on-lan/WakeOnLanManager.cpp @@ -0,0 +1,68 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#ifdef MATTER_DM_PLUGIN_WAKE_ON_LAN_SERVER +#include "WakeOnLanManager.h" +#include +#include +#include +#include +#include + +constexpr char kNullHexMACAddress[] = "000000000000"; + +using namespace chip; +using namespace chip::app::Clusters::WakeOnLan; + +std::string getMacAddress() +{ + uint8_t macBuffer[chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength]; + MutableByteSpan mac(macBuffer); + if (chip::DeviceLayer::ConfigurationMgr().GetPrimaryMACAddress(mac) != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "WakeOnLanManager::getMacAddress no primary MAC configured by DeviceLayer"); + return kNullHexMACAddress; + } + + char macStr[chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength * 2 + 1] = { 0 }; // added null char + if (BytesToHex(&macBuffer[0], sizeof(macBuffer), &macStr[0], sizeof(macBuffer) * 2u, chip::Encoding::HexFlags::kUppercase) != + CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "WakeOnLanManager::getMacAddress hex conversion failed"); + return kNullHexMACAddress; + } + + return std::string(macStr); +} + +CHIP_ERROR WakeOnLanManager::HandleGetMacAddress(chip::app::AttributeValueEncoder & aEncoder) +{ + ChipLogProgress(Zcl, "WakeOnLanManager::HandleGetMacAddress"); + + // Spec REQUIRES 48-bit mac addresses. This means at least Thread devices will + // fail here. + if (chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength != 6) + { + ChipLogError(Zcl, "WakeOnLanManager: primary MAC address is not 48-bit"); + return CHIP_ERROR_BUFFER_TOO_SMALL; + } + + return aEncoder.Encode(CharSpan::fromCharString(getMacAddress().c_str())); +} +#endif // MATTER_DM_PLUGIN_WAKE_ON_LAN_SERVER diff --git a/examples/chef/common/clusters/wake-on-lan/WakeOnLanManager.h b/examples/chef/common/clusters/wake-on-lan/WakeOnLanManager.h new file mode 100644 index 00000000000000..63217020e9ab11 --- /dev/null +++ b/examples/chef/common/clusters/wake-on-lan/WakeOnLanManager.h @@ -0,0 +1,27 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +class WakeOnLanManager : public chip::app::Clusters::WakeOnLan::Delegate +{ +public: + CHIP_ERROR HandleGetMacAddress(chip::app::AttributeValueEncoder & aEncoder) override; +}; diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index cff7ffdee4679f..48c48620c98fb0 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -22,6 +22,8 @@ using chip::app::DataModel::Nullable; using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, @@ -341,14 +343,127 @@ bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t cr #endif /* MATTER_DM_PLUGIN_DOOR_LOCK_SERVER */ +void emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId) {} + +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) +{ + ClusterId clusterId = attributePath.mClusterId; + AttributeId attributeId = attributePath.mAttributeId; + ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); + + if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id) + { + ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", ChipLogValueMEI(attributeId), + type, *value, size); + } + else if (clusterId == LevelControl::Id) + { + ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", + ChipLogValueMEI(attributeId), type, *value, size); + + // WIP Apply attribute change to Light + } +} + +/** @brief OnOff Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + * TODO Issue #3841 + * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster + * attributes to the default value. + * The logic here expects something similar to the deprecated Plugins callback + * emberAfPluginOnOffClusterServerPostInitCallback. + * + */ +void emberAfOnOffClusterInitCallback(EndpointId endpoint) {} + +#ifdef MATTER_DM_PLUGIN_AUDIO_OUTPUT_SERVER +#include "audio-output/AudioOutputManager.h" +static AudioOutputManager audioOutputManager; + +void emberAfAudioOutputClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: AudioOutput::SetDefaultDelegate"); + AudioOutput::SetDefaultDelegate(endpoint, &audioOutputManager); +} +#endif + #ifdef MATTER_DM_PLUGIN_CHANNEL_SERVER -#include +#include "channel/ChannelManager.h" +static ChannelManager channelManager; void emberAfChannelClusterInitCallback(EndpointId endpoint) { - app::Clusters::Channel::SetDefaultDelegate(endpoint, - static_cast(&(ChefChannelManager::Instance()))); + ChipLogProgress(Zcl, "TV Linux App: Channel::SetDefaultDelegate"); + Channel::SetDefaultDelegate(endpoint, &channelManager); } -#endif // MATTER_DM_PLUGIN_CHANNEL_SERVER +#endif -void emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId) {} +#ifdef MATTER_DM_PLUGIN_KEYPAD_INPUT_SERVER +#include "keypad-input/KeypadInputManager.h" +static KeypadInputManager keypadInputManager; + +void emberAfKeypadInputClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: KeypadInput::SetDefaultDelegate"); + KeypadInput::SetDefaultDelegate(endpoint, &keypadInputManager); +} +#endif + +#ifdef MATTER_DM_PLUGIN_LOW_POWER_SERVER +#include "low-power/LowPowerManager.h" +static LowPowerManager lowPowerManager; + +void emberAfLowPowerClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: LowPower::SetDefaultDelegate"); + LowPower::SetDefaultDelegate(endpoint, &lowPowerManager); +} +#endif + +#ifdef MATTER_DM_PLUGIN_MEDIA_INPUT_SERVER +#include "media-input/MediaInputManager.h" +static MediaInputManager mediaInputManager; +void emberAfMediaInputClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: MediaInput::SetDefaultDelegate"); + MediaInput::SetDefaultDelegate(endpoint, &mediaInputManager); +} +#endif + +#ifdef MATTER_DM_PLUGIN_MEDIA_PLAYBACK_SERVER +#include "media-playback/MediaPlaybackManager.h" +static MediaPlaybackManager mediaPlaybackManager; + +void emberAfMediaPlaybackClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: MediaPlayback::SetDefaultDelegate"); + MediaPlayback::SetDefaultDelegate(endpoint, &mediaPlaybackManager); +} +#endif + +#ifdef MATTER_DM_PLUGIN_TARGET_NAVIGATOR_SERVER +#include "target-navigator/TargetNavigatorManager.h" +static TargetNavigatorManager targetNavigatorManager; + +void emberAfTargetNavigatorClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: TargetNavigator::SetDefaultDelegate"); + TargetNavigator::SetDefaultDelegate(endpoint, &targetNavigatorManager); +} +#endif + +#ifdef MATTER_DM_PLUGIN_WAKE_ON_LAN_SERVER +#include "wake-on-lan/WakeOnLanManager.h" +static WakeOnLanManager wakeOnLanManager; + +void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: WakeOnLanManager::SetDefaultDelegate"); + WakeOnLan::SetDefaultDelegate(endpoint, &wakeOnLanManager); +} +#endif diff --git a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter index c5c71d597ebe74..d8fb307e9d8579 100644 --- a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter +++ b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter @@ -1,6 +1,56 @@ // This IDL was generated automatically by ZAP. // It is for view/code review purposes only. +/** Attributes and commands for putting a device into Identification mode (e.g. flashing a light). */ +cluster Identify = 3 { + revision 4; + + enum EffectIdentifierEnum : enum8 { + kBlink = 0; + kBreathe = 1; + kOkay = 2; + kChannelChange = 11; + kFinishEffect = 254; + kStopEffect = 255; + } + + enum EffectVariantEnum : enum8 { + kDefault = 0; + } + + enum IdentifyTypeEnum : enum8 { + kNone = 0; + kLightOutput = 1; + kVisibleIndicator = 2; + kAudibleBeep = 3; + kDisplay = 4; + kActuator = 5; + } + + attribute int16u identifyTime = 0; + readonly attribute IdentifyTypeEnum identifyType = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct IdentifyRequest { + int16u identifyTime = 0; + } + + request struct TriggerEffectRequest { + EffectIdentifierEnum effectIdentifier = 0; + EffectVariantEnum effectVariant = 1; + } + + /** Command description for Identify */ + command access(invoke: manage) Identify(IdentifyRequest): DefaultSuccess = 0; + /** Command description for TriggerEffect */ + command access(invoke: manage) TriggerEffect(TriggerEffectRequest): DefaultSuccess = 64; +} + /** Attributes and commands for switching devices between 'On' and 'Off' states. */ cluster OnOff = 6 { revision 6; @@ -73,6 +123,131 @@ cluster OnOff = 6 { command OnWithTimedOff(OnWithTimedOffRequest): DefaultSuccess = 66; } +/** Attributes and commands for controlling devices that can be set to a level between fully 'On' and fully 'Off.' */ +cluster LevelControl = 8 { + revision 5; + + enum MoveModeEnum : enum8 { + kUp = 0; + kDown = 1; + } + + enum StepModeEnum : enum8 { + kUp = 0; + kDown = 1; + } + + bitmap Feature : bitmap32 { + kOnOff = 0x1; + kLighting = 0x2; + kFrequency = 0x4; + } + + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + kCoupleColorTempToLevel = 0x2; + } + + readonly attribute nullable int8u currentLevel = 0; + readonly attribute optional int16u remainingTime = 1; + readonly attribute optional int8u minLevel = 2; + readonly attribute optional int8u maxLevel = 3; + readonly attribute optional int16u currentFrequency = 4; + readonly attribute optional int16u minFrequency = 5; + readonly attribute optional int16u maxFrequency = 6; + attribute OptionsBitmap options = 15; + attribute optional int16u onOffTransitionTime = 16; + attribute nullable int8u onLevel = 17; + attribute optional nullable int16u onTransitionTime = 18; + attribute optional nullable int16u offTransitionTime = 19; + attribute optional nullable int8u defaultMoveRate = 20; + attribute access(write: manage) optional nullable int8u startUpCurrentLevel = 16384; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToLevelRequest { + int8u level = 0; + nullable int16u transitionTime = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct MoveRequest { + MoveModeEnum moveMode = 0; + nullable int8u rate = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct StepRequest { + StepModeEnum stepMode = 0; + int8u stepSize = 1; + nullable int16u transitionTime = 2; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; + } + + request struct StopRequest { + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; + } + + request struct MoveToLevelWithOnOffRequest { + int8u level = 0; + nullable int16u transitionTime = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct MoveWithOnOffRequest { + MoveModeEnum moveMode = 0; + nullable int8u rate = 1; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; + } + + request struct StepWithOnOffRequest { + StepModeEnum stepMode = 0; + int8u stepSize = 1; + nullable int16u transitionTime = 2; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; + } + + request struct StopWithOnOffRequest { + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; + } + + request struct MoveToClosestFrequencyRequest { + int16u frequency = 0; + } + + /** Command description for MoveToLevel */ + command MoveToLevel(MoveToLevelRequest): DefaultSuccess = 0; + /** Command description for Move */ + command Move(MoveRequest): DefaultSuccess = 1; + /** Command description for Step */ + command Step(StepRequest): DefaultSuccess = 2; + /** Command description for Stop */ + command Stop(StopRequest): DefaultSuccess = 3; + /** Command description for MoveToLevelWithOnOff */ + command MoveToLevelWithOnOff(MoveToLevelWithOnOffRequest): DefaultSuccess = 4; + /** Command description for MoveWithOnOff */ + command MoveWithOnOff(MoveWithOnOffRequest): DefaultSuccess = 5; + /** Command description for StepWithOnOff */ + command StepWithOnOff(StepWithOnOffRequest): DefaultSuccess = 6; + /** Command description for StopWithOnOff */ + command StopWithOnOff(StopWithOnOffRequest): DefaultSuccess = 7; + /** Change the currrent frequency to the provided one, or a close + approximation if the exact provided one is not possible. */ + command MoveToClosestFrequency(MoveToClosestFrequencyRequest): DefaultSuccess = 8; +} + /** The Descriptor Cluster is meant to replace the support from the Zigbee Device Object (ZDO) for describing a node, its endpoints and clusters. */ cluster Descriptor = 29 { revision 2; @@ -449,50 +624,6 @@ cluster LocalizationConfiguration = 43 { readonly attribute int16u clusterRevision = 65533; } -/** Nodes should be expected to be deployed to any and all regions of the world. These global regions - may have differing preferences for how dates and times are conveyed. As such, Nodes that visually - or audibly convey time information need a mechanism by which they can be configured to use a - user’s preferred format. */ -cluster TimeFormatLocalization = 44 { - revision 1; // NOTE: Default/not specifically set - - enum CalendarTypeEnum : enum8 { - kBuddhist = 0; - kChinese = 1; - kCoptic = 2; - kEthiopian = 3; - kGregorian = 4; - kHebrew = 5; - kIndian = 6; - kIslamic = 7; - kJapanese = 8; - kKorean = 9; - kPersian = 10; - kTaiwanese = 11; - kUseActiveLocale = 255; - } - - enum HourFormatEnum : enum8 { - k12hr = 0; - k24hr = 1; - kUseActiveLocale = 255; - } - - bitmap Feature : bitmap32 { - kCalendarFormat = 0x1; - } - - attribute access(write: manage) HourFormatEnum hourFormat = 0; - attribute access(write: manage) optional CalendarTypeEnum activeCalendarType = 1; - readonly attribute optional CalendarTypeEnum supportedCalendarTypes[] = 2; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; -} - /** This cluster is used to manage global aspects of the Commissioning flow. */ cluster GeneralCommissioning = 48 { revision 1; // NOTE: Default/not specifically set @@ -1942,14 +2073,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; } - server cluster TimeFormatLocalization { - persist attribute hourFormat default = 0; - persist attribute activeCalendarType default = 0; - callback attribute supportedCalendarTypes; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } - server cluster GeneralCommissioning { ram attribute breadcrumb default = 0x0000000000000000; callback attribute basicCommissioningInfo; @@ -2031,7 +2154,7 @@ endpoint 0 { callback attribute windowStatus; callback attribute adminFabricIndex; callback attribute adminVendorId; - ram attribute featureMap default = 0; + ram attribute featureMap default = 1; ram attribute clusterRevision default = 0x0001; handle command OpenCommissioningWindow; @@ -2096,7 +2219,7 @@ endpoint 1 { callback attribute eventList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 4; + ram attribute clusterRevision default = 6; handle command Off; handle command On; @@ -2117,6 +2240,7 @@ endpoint 1 { } server cluster WakeOnLan { + ram attribute MACAddress; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; @@ -2143,7 +2267,9 @@ endpoint 1 { } server cluster TargetNavigator { + emits event TargetUpdated; callback attribute targetList; + ram attribute currentTarget default = 0; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; @@ -2156,18 +2282,33 @@ endpoint 1 { } server cluster MediaPlayback { + emits event StateChanged; ram attribute currentState default = 0x00; + ram attribute startTime default = 0x00; + ram attribute duration default = 0; + callback attribute sampledPosition; + ram attribute playbackSpeed default = 0; + ram attribute seekRangeEnd; + ram attribute seekRangeStart; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; + ram attribute featureMap default = 3; ram attribute clusterRevision default = 1; handle command Play; handle command Pause; handle command Stop; + handle command StartOver; + handle command Previous; + handle command Next; + handle command Rewind; + handle command FastForward; + handle command SkipForward; + handle command SkipBackward; handle command PlaybackResponse; + handle command Seek; } server cluster MediaInput { @@ -2177,12 +2318,13 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; + ram attribute featureMap default = 1; ram attribute clusterRevision default = 1; handle command SelectInput; handle command ShowInputStatus; handle command HideInputStatus; + handle command RenameInput; } server cluster LowPower { @@ -2201,7 +2343,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; + ram attribute featureMap default = 7; ram attribute clusterRevision default = 1; handle command SendKey; @@ -2215,10 +2357,79 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0; + ram attribute featureMap default = 1; ram attribute clusterRevision default = 1; handle command SelectOutput; + handle command RenameOutput; + } +} +endpoint 2 { + device type ma_speaker = 34, version 1; + + + server cluster Identify { + ram attribute identifyTime default = 0x0; + ram attribute identifyType default = 0x00; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 4; + + handle command Identify; + handle command TriggerEffect; + } + + server cluster OnOff { + ram attribute onOff default = 0; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 6; + + handle command Off; + handle command On; + handle command Toggle; + } + + server cluster LevelControl { + ram attribute currentLevel default = 0x00; + ram attribute minLevel default = 0x00; + ram attribute maxLevel default = 0xFE; + ram attribute options default = 0x00; + ram attribute onLevel default = 0xFE; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 5; + + handle command MoveToLevel; + handle command Move; + handle command Step; + handle command Stop; + handle command MoveToLevelWithOnOff; + handle command MoveWithOnOff; + handle command StepWithOnOff; + handle command StopWithOnOff; + } + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + callback attribute featureMap; + callback attribute clusterRevision; } } diff --git a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.zap b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.zap index 245f7ee38016e5..92cb592ebd3407 100644 --- a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.zap +++ b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.zap @@ -1002,96 +1002,6 @@ } ] }, - { - "name": "Time Format Localization", - "code": 44, - "mfgCode": null, - "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ - { - "name": "HourFormat", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "HourFormatEnum", - "included": 1, - "storageOption": "NVM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ActiveCalendarType", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "CalendarTypeEnum", - "included": 1, - "storageOption": "NVM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "SupportedCalendarTypes", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, { "name": "General Commissioning", "code": 48, @@ -1989,7 +1899,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2632,7 +2542,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "4", + "defaultValue": "6", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2818,6 +2728,22 @@ "side": "server", "enabled": 1, "attributes": [ + { + "name": "MACAddress", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, @@ -3146,6 +3072,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "CurrentTarget", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, @@ -3242,6 +3184,15 @@ "maxInterval": 65534, "reportableChange": 0 } + ], + "events": [ + { + "name": "TargetUpdated", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + } ] }, { @@ -3276,6 +3227,62 @@ "isIncoming": 1, "isEnabled": 1 }, + { + "name": "StartOver", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Previous", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Next", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Rewind", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "FastForward", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "SkipForward", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "SkipBackward", + "code": 9, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, { "name": "PlaybackResponse", "code": 10, @@ -3283,6 +3290,14 @@ "source": "server", "isIncoming": 0, "isEnabled": 1 + }, + { + "name": "Seek", + "code": 11, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 } ], "attributes": [ @@ -3303,43 +3318,43 @@ "reportableChange": 0 }, { - "name": "GeneratedCommandList", - "code": 65528, + "name": "StartTime", + "code": 1, "mfgCode": null, "side": "server", - "type": "array", + "type": "epoch_us", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "0x00", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "AcceptedCommandList", - "code": 65529, + "name": "Duration", + "code": 2, "mfgCode": null, "side": "server", - "type": "array", + "type": "int64u", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "EventList", - "code": 65530, + "name": "SampledPosition", + "code": 3, "mfgCode": null, "side": "server", - "type": "array", + "type": "PlaybackPositionStruct", "included": 1, "storageOption": "External", "singleton": 0, @@ -3351,74 +3366,179 @@ "reportableChange": 0 }, { - "name": "AttributeList", - "code": 65531, + "name": "PlaybackSpeed", + "code": 4, "mfgCode": null, "side": "server", - "type": "array", + "type": "single", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "FeatureMap", - "code": 65532, + "name": "SeekRangeEnd", + "code": 5, "mfgCode": null, "side": "server", - "type": "bitmap32", + "type": "int64u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "SeekRangeStart", + "code": 6, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "int64u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Media Input", - "code": 1287, - "mfgCode": null, - "define": "MEDIA_INPUT_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ + }, { - "name": "SelectInput", - "code": 0, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 }, { - "name": "ShowInputStatus", - "code": 1, + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StateChanged", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Media Input", + "code": 1287, + "mfgCode": null, + "define": "MEDIA_INPUT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "SelectInput", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ShowInputStatus", + "code": 1, "mfgCode": null, "source": "client", "isIncoming": 1, @@ -3431,6 +3551,14 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "RenameInput", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 } ], "attributes": [ @@ -3540,7 +3668,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3780,7 +3908,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "7", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3819,6 +3947,14 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "RenameOutput", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 } ], "attributes": [ @@ -3928,7 +4064,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3953,21 +4089,783 @@ ] } ] - } - ], - "endpoints": [ - { - "endpointTypeName": "MA-rootdevice", - "endpointTypeIndex": 0, - "profileId": 259, - "endpointId": 0, - "networkId": 0 }, { - "endpointTypeName": "Anonymous Endpoint Type", - "endpointTypeIndex": 1, - "profileId": 259, - "endpointId": 1, + "id": 3, + "name": "Anonymous Endpoint Type", + "deviceTypeRef": { + "code": 34, + "profileId": 259, + "label": "MA-speaker", + "name": "MA-speaker" + }, + "deviceTypes": [ + { + "code": 34, + "profileId": 259, + "label": "MA-speaker", + "name": "MA-speaker" + } + ], + "deviceVersions": [ + 1 + ], + "deviceIdentifiers": [ + 34 + ], + "deviceTypeName": "MA-speaker", + "deviceTypeCode": 34, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "IdentifyTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "IdentifyType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "IdentifyTypeEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "6", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "CurrentLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MinLevel", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxLevel", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "OptionsBitmap", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnLevel", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + } + ] + } + ], + "endpoints": [ + { + "endpointTypeName": "MA-rootdevice", + "endpointTypeIndex": 0, + "profileId": 259, + "endpointId": 0, + "networkId": 0 + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 1, + "profileId": 259, + "endpointId": 1, + "networkId": 0 + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 2, + "profileId": 259, + "endpointId": 2, "networkId": 0 } ] diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt index e6ab518f3494a9..8278cf9a735675 100644 --- a/examples/chef/esp32/main/CMakeLists.txt +++ b/examples/chef/esp32/main/CMakeLists.txt @@ -33,6 +33,7 @@ set(PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/third_party/nlio/repo/include" "${CMAKE_SOURCE_DIR}/../" "${CMAKE_SOURCE_DIR}/../common" + "${CMAKE_SOURCE_DIR}/../common/clusters" "${CMAKE_SOURCE_DIR}/main/include/" ) @@ -62,6 +63,14 @@ set(SRC_DIRS_LIST ${SRC_DIRS_LIST} "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/../common" + "${CMAKE_SOURCE_DIR}/../common/clusters/media-input/" + "${CMAKE_SOURCE_DIR}/../common/clusters/low-power/" + "${CMAKE_SOURCE_DIR}/../common/clusters/media-playback/" + "${CMAKE_SOURCE_DIR}/../common/clusters/target-navigator/" + "${CMAKE_SOURCE_DIR}/../common/clusters/wake-on-lan/" + "${CMAKE_SOURCE_DIR}/../common/clusters/channel/" + "${CMAKE_SOURCE_DIR}/../common/clusters/keypad-input/" + "${CMAKE_SOURCE_DIR}/../common/clusters/audio-output/" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" diff --git a/examples/chef/linux/BUILD.gn b/examples/chef/linux/BUILD.gn index a25c1f5ffa11ce..a119f832e051db 100644 --- a/examples/chef/linux/BUILD.gn +++ b/examples/chef/linux/BUILD.gn @@ -43,12 +43,19 @@ chip_data_model("chef-data-model") { executable("${sample_name}") { sources = [ "${project_dir}/common/chef-air-quality.cpp", - "${project_dir}/common/chef-channel-manager.cpp", "${project_dir}/common/chef-concentration-measurement.cpp", "${project_dir}/common/chef-fan-control-manager.cpp", "${project_dir}/common/chef-resource-monitoring-delegates.cpp", "${project_dir}/common/chef-rvc-mode-delegate.cpp", "${project_dir}/common/chef-rvc-operational-state-delegate.cpp", + "${project_dir}/common/clusters/audio-output/AudioOutputManager.cpp", + "${project_dir}/common/clusters/channel/ChannelManager.cpp", + "${project_dir}/common/clusters/keypad-input/KeypadInputManager.cpp", + "${project_dir}/common/clusters/low-power/LowPowerManager.cpp", + "${project_dir}/common/clusters/media-input/MediaInputManager.cpp", + "${project_dir}/common/clusters/media-playback/MediaPlaybackManager.cpp", + "${project_dir}/common/clusters/target-navigator/TargetNavigatorManager.cpp", + "${project_dir}/common/clusters/wake-on-lan/WakeOnLanManager.cpp", "${project_dir}/common/stubs.cpp", "${project_dir}/linux/main.cpp", ] @@ -63,6 +70,7 @@ executable("${sample_name}") { include_dirs = [ "include", "${project_dir}/common", + "${project_dir}/common/clusters", ] if (chip_enable_pw_rpc) { diff --git a/examples/chef/nrfconnect/CMakeLists.txt b/examples/chef/nrfconnect/CMakeLists.txt index 17556ef398b27a..0a408e829dd04f 100644 --- a/examples/chef/nrfconnect/CMakeLists.txt +++ b/examples/chef/nrfconnect/CMakeLists.txt @@ -60,6 +60,7 @@ target_include_directories(app PRIVATE ${GEN_DIR} ${CHEF} ${CHEF}/common + ${CHEF}/common/clusters/ ${GEN_DIR}/../ ${CHIP_ROOT}/src ${CHIP_ROOT}/examples/shell/shell_common/include @@ -81,12 +82,19 @@ endif() target_sources(app PRIVATE ${CHEF}/common/chef-air-quality.cpp - ${CHEF}/common/chef-channel-manager.cpp ${CHEF}/common/chef-concentration-measurement.cpp ${CHEF}/common/chef-fan-control-manager.cpp ${CHEF}/common/chef-resource-monitoring-delegates.cpp ${CHEF}/common/chef-rvc-mode-delegate.cpp ${CHEF}/common/chef-rvc-operational-state-delegate.cpp + ${CHEF}/common/clusters/media-input/MediaInputManager.cpp + ${CHEF}/common/clusters/low-power/LowPowerManager.cpp + ${CHEF}/common/clusters/media-playback/MediaPlaybackManager.cpp + ${CHEF}/common/clusters/target-navigator/TargetNavigatorManager.cpp + ${CHEF}/common/clusters/wake-on-lan/WakeOnLanManager.cpp + ${CHEF}/common/clusters/channel/ChannelManager.cpp + ${CHEF}/common/clusters/keypad-input/KeypadInputManager.cpp + ${CHEF}/common/clusters/audio-output/AudioOutputManager.cpp ${CHEF}/common/stubs.cpp ${CHEF}/nrfconnect/main.cpp )