diff --git a/examples/chef/common/chef-channel-manager.cpp b/examples/chef/common/chef-channel-manager.cpp index 0a80da7c9a6128..4ccccfc6528780 100644 --- a/examples/chef/common/chef-channel-manager.cpp +++ b/examples/chef/common/chef-channel-manager.cpp @@ -18,8 +18,10 @@ #include #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 EMBER_AF_PLUGIN_CHANNEL_SERVER #include @@ -120,15 +122,17 @@ CHIP_ERROR ChefChannelManager::HandleGetCurrentChannel(app::AttributeValueEncode void ChefChannelManager::HandleChangeChannel(CommandResponseHelper & helper, const chip::CharSpan & match) { - std::vector matchedChannels; + 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.push_back(channel); + matchedChannels[totalMatchedChannels++] = (channel); } else if (matchedChannels.size() == 0) { diff --git a/examples/chef/common/chef-channel-manager.h b/examples/chef/common/chef-channel-manager.h index d12415b688bbde..864e22bf22f786 100644 --- a/examples/chef/common/chef-channel-manager.h +++ b/examples/chef/common/chef-channel-manager.h @@ -19,19 +19,8 @@ #pragma once #include -#include -using chip::CharSpan; -using chip::app::AttributeValueEncoder; -using chip::app::CommandResponseHelper; -using ChannelDelegate = chip::app::Clusters::Channel::Delegate; -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; - -#define CHEF_CHANNEL_MANAGER_MAX_CHANNELS 10 - -class ChefChannelManager : public ChannelDelegate +class ChefChannelManager : public chip::app::Clusters::Channel::Delegate { public: @@ -41,7 +30,8 @@ class ChefChannelManager : public ChannelDelegate CHIP_ERROR HandleGetLineup(chip::app::AttributeValueEncoder & aEncoder); CHIP_ERROR HandleGetCurrentChannel(chip::app::AttributeValueEncoder & aEncoder); - void HandleChangeChannel(CommandResponseHelper & helper, const chip::CharSpan & match); + 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); @@ -57,7 +47,8 @@ class ChefChannelManager : public ChannelDelegate ~ChefChannelManager() = default; protected: + static constexpr size_t kMaxChannels = 10; uint16_t mCurrentChannelIndex{ 0 }; uint16_t mTotalChannels{ 0 }; - std::array mChannels; + std::array mChannels; };