Skip to content

Commit

Permalink
replace emberAfFindClusterServerEndpointIndex with emberAfGetClusterS…
Browse files Browse the repository at this point in the history
…erverEndpointIndex
  • Loading branch information
wqx6 committed May 31, 2023
1 parent 3cfd9e5 commit cccb6ff
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ 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);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, AccountLogin::Id, EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == 0xFFFF || ep >= kAccountLoginDeletageTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand All @@ -88,8 +89,9 @@ 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
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, AccountLogin::Id, EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT);
// if endpoint is found
if (ep != 0xFFFF && ep < kAccountLoginDeletageTableSize)
{
gDelegateTable[ep] = delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ 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);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, chip::app::Clusters::ApplicationBasic::Id,
EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == 0xFFFF || ep >= kApplicationBasicDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand All @@ -89,8 +90,9 @@ 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
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ApplicationBasic::Id,
EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT);
// if endpoint is found
if (ep != 0xFFFF && ep < kApplicationBasicDelegateTableSize)
{
gDelegateTable[ep] = delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ 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);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ApplicationLauncher::Id,
EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == 0xFFFF || ep >= kApplicationLauncherDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand All @@ -96,8 +97,9 @@ 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
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ApplicationLauncher::Id,
EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT);
// if endpoint is found
if (ep != 0xFFFF && ep < kApplicationLauncherDelegateTableSize)
{
gDelegateTable[ep] = delegate;
Expand Down
10 changes: 6 additions & 4 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 == 0xFFFF || ep >= kAudioOutputDelegateTableSize ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -74,8 +75,9 @@ 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 != 0xFFFF && ep < kAudioOutputDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/clusters/channel-server/channel-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ 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);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Channel::Id, EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == 0xFFFF || ep >= kChannelDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand All @@ -83,8 +83,8 @@ 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
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Channel::Id, EMBER_AF_CHANNEL_CLUSTER_SERVER_ENDPOINT_COUNT);
// if endpoint is found
if (ep != 0xFFFF && ep < kChannelDelegateTableSize)
{
gDelegateTable[ep] = delegate;
Expand Down
18 changes: 12 additions & 6 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ uint16_t ColorControlServer::computeTransitionTimeFromStateAndRate(ColorControlS
*/
EmberEventControl * ColorControlServer::getEventControl(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
uint16_t index =
emberAfGetClusterServerEndpointIndex(endpoint, ColorControl::Id, EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT);
EmberEventControl * event = nullptr;

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

if (index < ArraySize(colorHueTransitionStates))
Expand All @@ -442,7 +444,8 @@ ColorControlServer::ColorHueTransitionState * ColorControlServer::getColorHueTra
*/
ColorControlServer::Color16uTransitionState * ColorControlServer::getSaturationTransitionState(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, ColorControl::Id);
uint16_t index =
emberAfGetClusterServerEndpointIndex(endpoint, ColorControl::Id, EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT);
Color16uTransitionState * state = nullptr;

if (index < ArraySize(colorSatTransitionStates))
Expand Down Expand Up @@ -1680,7 +1683,8 @@ 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, EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT);

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

Color16uTransitionState * state = nullptr;
if (index < ArraySize(colorYtransitionStates))
Expand Down Expand Up @@ -2026,7 +2031,8 @@ 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, EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT);

Color16uTransitionState * state = nullptr;
if (index < ArraySize(colorTempTransitionStates))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ 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);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ContentLauncher::Id,
EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == 0xFFFF || ep >= kContentLaunchDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand All @@ -88,8 +89,9 @@ 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
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, ContentLauncher::Id,
EMBER_AF_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT);
// if endpoint is found
if (ep != 0xFFFF && ep < kContentLaunchDelegateTableSize)
{
gDelegateTable[ep] = delegate;
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 @@ -3284,8 +3284,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 != 0xFFFF && index < kDoorLockClusterServerMaxEndpointCount)
{
return &mEndpointCtx[index];
}
Expand Down
8 changes: 5 additions & 3 deletions src/app/clusters/keypad-input-server/keypad-input-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ 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);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, KeypadInput::Id, EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == 0xFFFF || ep >= kKeypadInputDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand All @@ -91,8 +92,9 @@ 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
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, KeypadInput::Id, EMBER_AF_KEYPAD_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT);
// if endpoint is found
if (ep != 0xFFFF && ep < kKeypadInputDelegateTableSize)
{
gDelegateTable[ep] = delegate;
Expand Down
5 changes: 3 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,9 @@ 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 == 0xFFFF || ep >= kLevelControlStateTableSize ? nullptr : &stateTable[ep]);
}

#if !defined(IGNORE_LEVEL_CONTROL_CLUSTER_OPTIONS) && defined(EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP)
Expand Down
11 changes: 7 additions & 4 deletions src/app/clusters/low-power-server/low-power-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <protocols/interaction_model/StatusCode.h>

using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::LowPower;

static constexpr size_t kLowPowerDelegateTableSize =
Expand All @@ -49,8 +50,9 @@ Delegate * gDelegateTable[kLowPowerDelegateTableSize] = { nullptr };

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

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -71,8 +73,9 @@ namespace LowPower {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::LowPower::Id);
if (ep != 0xFFFF)
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, chip::app::Clusters::LowPower::Id,
EMBER_AF_LOW_POWER_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep != 0xFFFF && ep < kLowPowerDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
Expand Down
10 changes: 6 additions & 4 deletions src/app/clusters/media-input-server/media-input-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ Delegate * gDelegateTable[kMediaInputDelegateTableSize] = { nullptr };

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

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -74,8 +75,9 @@ namespace MediaInput {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::MediaInput::Id);
if (ep != 0xFFFF)
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, MediaInput::Id, EMBER_AF_MEDIA_INPUT_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep != 0xFFFF && ep < kMediaInputDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Delegate * GetDelegate(EndpointId endpoint)
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogError(Zcl, "MediaPlayback NOT returning ContentApp delegate for endpoint:%u", endpoint);

uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, MediaPlayback::Id);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, MediaPlayback::Id, EMBER_AF_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == 0xFFFF || ep >= kMediaPlaybackDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand All @@ -91,8 +92,9 @@ namespace MediaPlayback {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, MediaPlayback::Id);
// if endpoint is found and is not a dynamic endpoint
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, MediaPlayback::Id, EMBER_AF_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT);
// if endpoint is found
if (ep != 0xFFFF && ep < kMediaPlaybackDelegateTableSize)
{
gDelegateTable[ep] = delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Delegate * GetDelegate(EndpointId endpoint)
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogProgress(Zcl, "TargetNavigator NOT returning ContentApp delegate for endpoint:%u", endpoint);

uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, TargetNavigator::Id);
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, TargetNavigator::Id,
EMBER_AF_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == 0xFFFF || ep >= kTargetNavigatorDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand All @@ -90,8 +91,9 @@ namespace TargetNavigator {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, TargetNavigator::Id);
// if endpoint is found and is not a dynamic endpoint
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, TargetNavigator::Id,
EMBER_AF_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT);
// if endpoint is found
if (ep != 0xFFFF && ep < kTargetNavigatorDelegateTableSize)
{
gDelegateTable[ep] = delegate;
Expand Down
8 changes: 4 additions & 4 deletions src/app/clusters/wake-on-lan-server/wake-on-lan-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Delegate * gDelegateTable[kWakeOnLanDelegateTableSize] = { nullptr };

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

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -73,8 +73,8 @@ namespace WakeOnLan {

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::WakeOnLan::Id);
if (ep != 0xFFFF)
uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, WakeOnLan::Id, EMBER_AF_WAKE_ON_LAN_CLUSTER_SERVER_ENDPOINT_COUNT);
if (ep != 0xFFFF && ep < kWakeOnLanDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ Delegate * gDelegateTable[kWindowCoveringDelegateTableSize] = { nullptr };

Delegate * GetDelegate(EndpointId endpoint)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, WindowCovering::Id);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, WindowCovering::Id, EMBER_AF_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT);
return ((ep == kInvalidEndpointId || ep >= kWindowCoveringDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

Expand Down Expand Up @@ -594,9 +595,10 @@ Status GetMotionLockStatus(chip::EndpointId endpoint)

void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, WindowCovering::Id);
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, WindowCovering::Id, EMBER_AF_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT);

// if endpoint is found and is not a dynamic endpoint
// if endpoint is found
if (ep != 0xFFFF && ep < kWindowCoveringDelegateTableSize)
{
gDelegateTable[ep] = delegate;
Expand Down

0 comments on commit cccb6ff

Please sign in to comment.