Skip to content

Commit

Permalink
app: Fix clusters delegates table check
Browse files Browse the repository at this point in the history
  • Loading branch information
wqx6 committed May 29, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent cfb9994 commit e7c9d26
Showing 11 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ Delegate * GetDelegate(EndpointId endpoint)
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]);
return ((ep == 0xFFFF || ep >= kAccountLoginDeletageTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
@@ -90,7 +90,7 @@ 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)
if (ep != 0xFFFF && ep < kAccountLoginDeletageTableSize)
{
gDelegateTable[ep] = delegate;
}
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ Delegate * GetDelegate(EndpointId endpoint)
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]);
return ((ep == 0xFFFF || ep >= kApplicationBasicDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
@@ -91,7 +91,7 @@ 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)
if (ep != 0xFFFF && ep < kApplicationBasicDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ Delegate * GetDelegate(EndpointId endpoint)
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]);
return ((ep == 0xFFFF || ep >= kApplicationLauncherDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
@@ -98,7 +98,7 @@ 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)
if (ep != 0xFFFF && ep < kApplicationLauncherDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
4 changes: 2 additions & 2 deletions src/app/clusters/channel-server/channel-server.cpp
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ Delegate * GetDelegate(EndpointId endpoint)
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]);
return ((ep == 0xFFFF || ep >= kChannelDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
@@ -85,7 +85,7 @@ 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)
if (ep != 0xFFFF && ep < kChannelDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
14 changes: 8 additions & 6 deletions src/app/clusters/color-control-server/color-control-server.h
Original file line number Diff line number Diff line change
@@ -237,22 +237,24 @@ class ColorControlServer
* Attributes Declaration
*********************************************************/
static ColorControlServer instance;
static constexpr size_t kColorControlClusterServerMaxEndpointCount =
EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT + 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[kColorControlClusterServerMaxEndpointCount];
Color16uTransitionState colorSatTransitionStates[kColorControlClusterServerMaxEndpointCount];
#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[kColorControlClusterServerMaxEndpointCount];
Color16uTransitionState colorYtransitionStates[kColorControlClusterServerMaxEndpointCount];
#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[kColorControlClusterServerMaxEndpointCount];
#endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP

EmberEventControl eventControls[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT];
EmberEventControl eventControls[kColorControlClusterServerMaxEndpointCount];
};

/**********************************************************
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ Delegate * GetDelegate(EndpointId endpoint)
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]);
return ((ep == 0xFFFF || ep >= kContentLaunchDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
@@ -90,7 +90,7 @@ 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)
if (ep != 0xFFFF && ep < kContentLaunchDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
5 changes: 4 additions & 1 deletion src/app/clusters/door-lock-server/door-lock-server.h
Original file line number Diff line number Diff line change
@@ -553,7 +553,10 @@ 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 kDoorLockClusterServerMaxEndpointCount =
EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT;

std::array<EmberAfDoorLockEndpointContext, kDoorLockClusterServerMaxEndpointCount> mEndpointCtx;

static DoorLockServer instance;
};
4 changes: 2 additions & 2 deletions src/app/clusters/keypad-input-server/keypad-input-server.cpp
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ Delegate * GetDelegate(EndpointId endpoint)
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]);
return ((ep == 0xFFFF || ep >= kKeypadInputDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
@@ -93,7 +93,7 @@ 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)
if (ep != 0xFFFF && ep < kKeypadInputDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ Delegate * GetDelegate(EndpointId endpoint)
ChipLogError(Zcl, "MediaPlayback NOT returning ContentApp delegate for endpoint:%u", endpoint);

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

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

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

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
@@ -92,7 +92,7 @@ void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, TargetNavigator::Id);
// if endpoint is found and is not a dynamic endpoint
if (ep != 0xFFFF && ep < EMBER_AF_TARGET_NAVIGATOR_CLUSTER_SERVER_ENDPOINT_COUNT)
if (ep != 0xFFFF && ep < kTargetNavigatorDelegateTableSize)
{
gDelegateTable[ep] = delegate;
}
Original file line number Diff line number Diff line change
@@ -54,8 +54,7 @@ Delegate * gDelegateTable[kWindowCoveringDelegateTableSize] = { nullptr };
Delegate * GetDelegate(EndpointId endpoint)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, WindowCovering::Id);
return ((ep == kInvalidEndpointId || ep >= EMBER_AF_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT) ? nullptr
: gDelegateTable[ep]);
return ((ep == kInvalidEndpointId || ep >= kWindowCoveringDelegateTableSize) ? nullptr : gDelegateTable[ep]);
}

/*
@@ -598,7 +597,7 @@ void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate)
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, WindowCovering::Id);

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

0 comments on commit e7c9d26

Please sign in to comment.