Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete emberAfFindClusterServerEndpointIndex and replace by emberAfGe… #27051

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/tv-app/android/java/LevelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ void emberAfLevelControlClusterInitCallback(EndpointId endpoint)
void LevelManager::NewManager(jint endpoint, jobject manager)
{
ChipLogProgress(Zcl, "TV Android App: LevelManager::NewManager");
uint16_t ep = emberAfFindClusterServerEndpointIndex(static_cast<chip::EndpointId>(endpoint), app::Clusters::LevelControl::Id);
uint16_t ep = emberAfGetClusterServerEndpointIndex(static_cast<chip::EndpointId>(endpoint), app::Clusters::LevelControl::Id,
EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT);
VerifyOrReturn(ep != kEmberInvalidEndpointIndex && ep < kLevelManagerTableSize,
ChipLogError(Zcl, "TV Android App::Level::NewManager: endpoint %d not found", endpoint));

Expand All @@ -65,8 +66,9 @@ void LevelManager::NewManager(jint endpoint, jobject manager)

LevelManager * GetLevelManager(EndpointId endpoint)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, app::Clusters::LevelControl::Id);
return ((ep == kEmberInvalidEndpointIndex || ep >= kLevelManagerTableSize) ? nullptr : gLevelManagerTable[ep]);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, app::Clusters::LevelControl::Id,
EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT);
return (ep >= kLevelManagerTableSize) ? nullptr : gLevelManagerTable[ep]);
}

void LevelManager::PostLevelChanged(chip::EndpointId endpoint, uint8_t value)
Expand Down
13 changes: 7 additions & 6 deletions examples/tv-app/android/java/OnOffManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ void emberAfOnOffClusterInitCallback(EndpointId endpoint)
void OnOffManager::NewManager(jint endpoint, jobject manager)
{
ChipLogProgress(Zcl, "TV Android App: OnOffManager::NewManager");
uint16_t ep = emberAfFindClusterServerEndpointIndex(static_cast<chip::EndpointId>(endpoint), app::Clusters::OnOff::Id);
VerifyOrReturn(ep != kEmberInvalidEndpointIndex && ep < EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT,
uint16_t ep = emberAfGetClusterServerEndpointIndex(static_cast<chip::EndpointId>(endpoint), app::Clusters::OnOff::Id,
EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT);

VerifyOrReturn(ep != kEmberInvalidEndpointIndex && ep < kOnffManagerTableSize,
ChipLogError(Zcl, "TV Android App::OnOff::NewManager: endpoint %d not found", endpoint));

VerifyOrReturn(gOnOffManagerTable[ep] == nullptr,
Expand All @@ -65,10 +67,9 @@ void OnOffManager::NewManager(jint endpoint, jobject manager)

OnOffManager * GetOnOffManager(EndpointId endpoint)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, app::Clusters::OnOff::Id);
return ((ep == kEmberInvalidEndpointIndex || ep >= EMBER_AF_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT)
? nullptr
: gOnOffManagerTable[ep]);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, app::Clusters::OnOff::Id, EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep >= kOnffManagerTableSize) ? nullptr : gOnOffManagerTable[ep]);
}

void OnOffManager::PostOnOffChanged(chip::EndpointId endpoint, bool value)
Expand Down
14 changes: 6 additions & 8 deletions src/app/clusters/account-login-server/account-login-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ Delegate * GetDelegate(EndpointId endpoint)
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogProgress(Zcl, "AccountLogin NOT returning ContentApp delegate for endpoint:%u", endpoint);

uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, AccountLogin::Id);
return ((ep == 0xFFFF || ep >= EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT) ? nullptr : gDelegateTable[ep]);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, AccountLogin::Id, EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep >= kAccountLoginDeletageTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -88,15 +89,12 @@ namespace AccountLogin {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, AccountLogin::Id);
// if endpoint is found and is not a dynamic endpoint
if (ep != 0xFFFF && ep < EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT)
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, AccountLogin::Id, EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep < kAccountLoginDeletageTableSize)
{
gDelegateTable[ep] = delegate;
}
else
{
}
}

} // namespace AccountLogin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ Delegate * GetDelegate(EndpointId endpoint)
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogProgress(Zcl, "ApplicationBasic NOT returning ContentApp delegate for endpoint:%u", endpoint);

uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::ApplicationBasic::Id);
return ((ep == 0xFFFF || ep >= EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT) ? nullptr : gDelegateTable[ep]);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, chip::app::Clusters::ApplicationBasic::Id),
EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT;
return ((ep >= kApplicationBasicDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -89,15 +90,12 @@ namespace ApplicationBasic {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ApplicationBasic::Id);
// if endpoint is found and is not a dynamic endpoint
if (ep != 0xFFFF && ep < EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT)
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, chip::app::Clusters::ApplicationBasic::Id),
EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT;
if (ep < kApplicationBasicDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
else
{
}
}

Delegate * GetDefaultDelegate(EndpointId endpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ Delegate * GetDelegate(EndpointId endpoint)
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogProgress(Zcl, "ApplicationLauncher NOT returning ContentApp delegate for endpoint:%u", endpoint);

uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ApplicationLauncher::Id);
return ((ep == 0xFFFF || ep >= EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT) ? nullptr : gDelegateTable[ep]);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ApplicationLauncher::Id,
EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep >= kApplicationLauncherDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -96,15 +97,12 @@ namespace ApplicationLauncher {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ApplicationLauncher::Id);
// if endpoint is found and is not a dynamic endpoint
if (ep != 0xFFFF && ep < EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT)
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ApplicationLauncher::Id,
EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep < kApplicationLauncherDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
else
{
}
}

bool HasFeature(chip::EndpointId endpoint, Feature feature)
Expand Down
13 changes: 6 additions & 7 deletions src/app/clusters/audio-output-server/audio-output-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ Delegate * gDelegateTable[kAudioOutputDelegateTableSize] = { nullptr };

Delegate * GetDelegate(EndpointId endpoint)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::AudioOutput::Id);
return (ep == 0xFFFF ? nullptr : gDelegateTable[ep]);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, chip::app::Clusters::AudioOutput::Id,
EMBER_AF_AUDIO_OUTPUT_CLUSTER_SERVER_ENDPOINT_COUNT);
return (ep >= kAudioOutputDelegateTableSize ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -74,14 +75,12 @@ namespace AudioOutput {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::AudioOutput::Id);
if (ep != 0xFFFF)
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, chip::app::Clusters::AudioOutput::Id,
EMBER_AF_AUDIO_OUTPUT_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep < kAudioOutputDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
else
{
}
}

bool HasFeature(chip::EndpointId endpoint, Feature feature)
Expand Down
12 changes: 4 additions & 8 deletions src/app/clusters/channel-server/channel-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Delegate * GetDelegate(EndpointId endpoint)
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogProgress(Zcl, "Channel NOT returning ContentApp delegate for endpoint:%u", endpoint);

uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, Channel::Id);
return ((ep == 0xFFFF || ep >= EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT) ? nullptr : gDelegateTable[ep]);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Channel::Id, EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT);
return (ep >= kChannelDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -83,15 +83,11 @@ namespace Channel {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, Channel::Id);
// if endpoint is found and is not a dynamic endpoint
if (ep != 0xFFFF && ep < EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT)
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Channel::Id, EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep < kChannelDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
else
{
}
}

bool Delegate::HasFeature(chip::EndpointId endpoint, Feature feature)
Expand Down
14 changes: 6 additions & 8 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ uint16_t ColorControlServer::computeTransitionTimeFromStateAndRate(ColorControlS
*/
EmberEventControl * ColorControlServer::getEventControl(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
EmberEventControl * event = nullptr;

uint16_t index = emberAfGetClusterServerEndpointIndex(endpoint, ColorControl::Id, kColorControlFixedEndpointCount);
if (index < ArraySize(eventControls))
{
event = &eventControls[index];
Expand Down Expand Up @@ -424,9 +424,8 @@ bool ColorControlServer::computeNewColor16uValue(ColorControlServer::Color16uTra
*/
ColorControlServer::ColorHueTransitionState * ColorControlServer::getColorHueTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
ColorHueTransitionState * state = nullptr;

uint16_t index = emberAfGetClusterServerEndpointIndex(endpoint, ColorControl::Id, kColorControlFixedEndpointCount);
if (index < ArraySize(colorHueTransitionStates))
{
state = &colorHueTransitionStates[index];
Expand All @@ -442,9 +441,8 @@ ColorControlServer::ColorHueTransitionState * ColorControlServer::getColorHueTra
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getSaturationTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
Color16uTransitionState * state = nullptr;

uint16_t index = emberAfGetClusterServerEndpointIndex(endpoint, ColorControl::Id, kColorControlFixedEndpointCount);
if (index < ArraySize(colorSatTransitionStates))
{
state = &colorSatTransitionStates[index];
Expand Down Expand Up @@ -1680,7 +1678,7 @@ void ColorControlServer::updateHueSatCommand(EndpointId endpoint)
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getXTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
uint16_t index = emberAfGetClusterServerEndpointIndex(endpoint, ColorControl::Id, kColorControlFixedEndpointCount);

Color16uTransitionState * state = nullptr;
if (index < ArraySize(colorXtransitionStates))
Expand All @@ -1699,7 +1697,7 @@ ColorControlServer::Color16uTransitionState * ColorControlServer::getXTransition
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getYTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
uint16_t index = emberAfGetClusterServerEndpointIndex(endpoint, ColorControl::Id, kColorControlFixedEndpointCount);

Color16uTransitionState * state = nullptr;
if (index < ArraySize(colorYtransitionStates))
Expand Down Expand Up @@ -2026,7 +2024,7 @@ void ColorControlServer::updateXYCommand(EndpointId endpoint)
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getTempTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
uint16_t index = emberAfGetClusterServerEndpointIndex(endpoint, ColorControl::Id, kColorControlFixedEndpointCount);

Color16uTransitionState * state = nullptr;
if (index < ArraySize(colorTempTransitionStates))
Expand Down
15 changes: 9 additions & 6 deletions src/app/clusters/color-control-server/color-control-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,25 @@ class ColorControlServer
* Attributes Declaration
*********************************************************/
static ColorControlServer instance;
static constexpr size_t kColorControlFixedEndpointCount = EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT;
static constexpr size_t kColorControlMaxEnpointCount =
kColorControlFixedEndpointCount + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT;

#ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_HSV
ColorHueTransitionState colorHueTransitionStates[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];
Color16uTransitionState colorSatTransitionStates[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];
ColorHueTransitionState colorHueTransitionStates[kColorControlMaxEnpointCount];
Color16uTransitionState colorSatTransitionStates[kColorControlMaxEnpointCount];
#endif

#ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_XY
Color16uTransitionState colorXtransitionStates[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];
Color16uTransitionState colorYtransitionStates[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];
Color16uTransitionState colorXtransitionStates[kColorControlMaxEnpointCount];
Color16uTransitionState colorYtransitionStates[kColorControlMaxEnpointCount];
#endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_XY

#ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP
Color16uTransitionState colorTempTransitionStates[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];
Color16uTransitionState colorTempTransitionStates[kColorControlMaxEnpointCount];
#endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP

EmberEventControl eventControls[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];
EmberEventControl eventControls[kColorControlMaxEnpointCount];
};

/**********************************************************
Expand Down
14 changes: 6 additions & 8 deletions src/app/clusters/content-launch-server/content-launch-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ Delegate * GetDelegate(EndpointId endpoint)
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogProgress(Zcl, "Content Launcher NOT returning ContentApp delegate for endpoint:%u", endpoint);

uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ContentLauncher::Id);
return ((ep == 0xFFFF || ep >= EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT) ? nullptr : gDelegateTable[ep]);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ContentLauncher::Id,
EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep >= kContentLaunchDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -88,15 +89,12 @@ namespace ContentLauncher {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ContentLauncher::Id);
// if endpoint is found and is not a dynamic endpoint
if (ep != 0xFFFF && ep < EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT)
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ContentLauncher::Id,
EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep < kContentLaunchDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
else
{
}
}

bool Delegate::HasFeature(chip::EndpointId endpoint, Feature feature)
Expand Down
4 changes: 2 additions & 2 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3295,8 +3295,8 @@ CHIP_ERROR DoorLockServer::sendClusterResponse(chip::app::CommandHandler * comma

EmberAfDoorLockEndpointContext * DoorLockServer::getContext(chip::EndpointId endpointId)
{
auto index = emberAfFindClusterServerEndpointIndex(endpointId, ::Id);
if (index != 0xFFFF)
auto index = emberAfGetClusterServerEndpointIndex(endpointId, ::Id, EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT);
if (index < kDoorLockMaxEnpointCount)
{
return &mEndpointCtx[index];
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/clusters/door-lock-server/door-lock-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,9 @@ class DoorLockServer
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DoorLock::Commands::ClearYearDaySchedule::DecodableType & commandData);

std::array<EmberAfDoorLockEndpointContext, EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT> mEndpointCtx;
static constexpr size_t kDoorLockMaxEnpointCount =
EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT;
std::array<EmberAfDoorLockEndpointContext, kDoorLockMaxEnpointCount> mEndpointCtx;

static DoorLockServer instance;
};
Expand Down
14 changes: 6 additions & 8 deletions src/app/clusters/keypad-input-server/keypad-input-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ Delegate * GetDelegate(EndpointId endpoint)
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogProgress(Zcl, "KeypadInput NOT returning ContentApp delegate for endpoint:%u", endpoint);

uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, KeypadInput::Id);
return ((ep == 0xFFFF || ep >= EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT) ? nullptr : gDelegateTable[ep]);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, KeypadInput::Id, EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep >= kKeypadInputDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -91,15 +92,12 @@ namespace KeypadInput {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, KeypadInput::Id);
// if endpoint is found and is not a dynamic endpoint
if (ep != 0xFFFF && ep < EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT)
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, KeypadInput::Id, EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep < kKeypadInputDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
else
{
}
}

bool Delegate::HasFeature(EndpointId endpoint, Feature feature)
Expand Down
6 changes: 4 additions & 2 deletions src/app/clusters/level-control/level-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ static void cancelEndpointTimerCallback(EndpointId endpoint)

static EmberAfLevelControlState * getState(EndpointId endpoint)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, LevelControl::Id);
return (ep == 0xFFFF ? nullptr : &stateTable[ep]);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, LevelControl::Id, EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT);

return (ep >= kLevelControlStateTableSize ? nullptr : &stateTable[ep]);
}

#if !defined(IGNORE_LEVEL_CONTROL_CLUSTER_OPTIONS) && defined(EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP)
Expand Down
Loading