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

[Scenes] Default Scene Handler Config #30517

Merged
Show file tree
Hide file tree
Changes from 5 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
12 changes: 6 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 @@ -34,7 +34,7 @@ using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ColorControl;
using chip::Protocols::InteractionModel::Status;

#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
{
public:
Expand Down Expand Up @@ -354,7 +354,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
}
};
static DefaultColorControlSceneHandler sColorControlSceneHandler;
#endif // EMBER_AF_PLUGIN_SCENES
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS

/**********************************************************
* Matter timer scheduling glue logic
Expand Down Expand Up @@ -408,11 +408,11 @@ ColorControlServer & ColorControlServer::Instance()
chip::scenes::SceneHandler * ColorControlServer::GetSceneHandler()
{

#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
return &sColorControlSceneHandler;
#else
return nullptr;
#endif // EMBER_AF_PLUGIN_SCENES
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
}

bool ColorControlServer::HasFeature(chip::EndpointId endpoint, Feature feature)
Expand Down Expand Up @@ -3057,11 +3057,11 @@ void emberAfColorControlClusterServerInitCallback(EndpointId endpoint)
#ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP
ColorControlServer::Instance().startUpColorTempCommand(endpoint);
#endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP
#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
// Registers Scene handlers for the color control cluster on the server
app::Clusters::Scenes::ScenesServer::Instance().RegisterSceneHandler(endpoint,
ColorControlServer::Instance().GetSceneHandler());
#endif
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
}

void MatterColorControlClusterServerShutdownCallback(EndpointId endpoint)
Expand Down
12 changes: 6 additions & 6 deletions src/app/clusters/level-control/level-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void writeRemainingTime(EndpointId endpoint, uint16_t remainingTimeMs);
static bool shouldExecuteIfOff(EndpointId endpoint, CommandId commandId, chip::Optional<chip::BitMask<OptionsBitmap>> optionsMask,
chip::Optional<chip::BitMask<OptionsBitmap>> optionsOverride);

#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
class DefaultLevelControlSceneHandler : public scenes::DefaultSceneHandlerImpl
{
public:
Expand Down Expand Up @@ -256,7 +256,7 @@ class DefaultLevelControlSceneHandler : public scenes::DefaultSceneHandlerImpl
};
static DefaultLevelControlSceneHandler sLevelControlSceneHandler;

#endif // EMBER_AF_PLUGIN_SCENES
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS

#if !defined(IGNORE_LEVEL_CONTROL_CLUSTER_OPTIONS) && defined(EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP)
static void reallyUpdateCoupledColorTemp(EndpointId endpoint);
Expand Down Expand Up @@ -610,11 +610,11 @@ Status MoveToLevel(EndpointId endpointId, const Commands::MoveToLevel::Decodable

chip::scenes::SceneHandler * GetSceneHandler()
{
#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
return &sLevelControlSceneHandler;
#else
return nullptr;
#endif // EMBER_AF_PLUGIN_SCENES
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
}

} // namespace LevelControlServer
Expand Down Expand Up @@ -1446,10 +1446,10 @@ void emberAfLevelControlClusterServerInitCallback(EndpointId endpoint)
}
}

#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
// Registers Scene handlers for the level control cluster on the server
app::Clusters::Scenes::ScenesServer::Instance().RegisterSceneHandler(endpoint, LevelControlServer::GetSceneHandler());
#endif
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS

emberAfPluginLevelControlClusterServerPostInitCallback(endpoint);
}
Expand Down
12 changes: 6 additions & 6 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static bool LevelControlWithOnOffFeaturePresent(EndpointId endpoint)
static constexpr size_t kOnOffMaxEnpointCount =
EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT;

#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
static void sceneOnOffCallback(EndpointId endpoint);
using OnOffEndPointPair = scenes::DefaultSceneHandlerImpl::EndpointStatePair<bool>;
using OnOffTransitionTimeInterface =
Expand Down Expand Up @@ -232,7 +232,7 @@ static void sceneOnOffCallback(EndpointId endpoint)
OnOffServer::Instance().setOnOffValue(endpoint, command, false);
ReturnOnFailure(sOnOffSceneHandler.mSceneEndpointStatePairs.RemovePair(endpoint));
}
#endif // EMBER_AF_PLUGIN_SCENES
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS

/**********************************************************
* Attributes Definition
Expand Down Expand Up @@ -300,11 +300,11 @@ OnOffServer & OnOffServer::Instance()
chip::scenes::SceneHandler * OnOffServer::GetSceneHandler()
{

#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
return &sOnOffSceneHandler;
#else
return nullptr;
#endif // EMBER_AF_PLUGIN_SCENES
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
}

bool OnOffServer::HasFeature(chip::EndpointId endpoint, Feature feature)
Expand Down Expand Up @@ -499,10 +499,10 @@ void OnOffServer::initOnOffServer(chip::EndpointId endpoint)
status = setOnOffValue(endpoint, onOffValueForStartUp, true);
}

#ifdef EMBER_AF_PLUGIN_SCENES
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
// Registers Scene handlers for the On/Off cluster on the server
app::Clusters::Scenes::ScenesServer::Instance().RegisterSceneHandler(endpoint, OnOffServer::Instance().GetSceneHandler());
#endif
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS

#ifdef EMBER_AF_PLUGIN_MODE_SELECT
// If OnMode is not a null value, then change the current mode to it.
Expand Down
13 changes: 12 additions & 1 deletion src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
#endif

/**
* @ def CHIP_CONFIG_MAX_SCENES_TABLE_SIZE
* @def CHIP_CONFIG_MAX_SCENES_TABLE_SIZE
*
* @brief This defines how many scenes a single endpoint is allowed to allocate in flash memory. This value MUST at least 16
* per spec and MUST be increased to allow for configuring a greater scene table size from Zap.
Expand All @@ -1457,6 +1457,17 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
#endif // CHIP_CONFIG_TEST
#endif // CHIP_CONFIG_MAX_SCENES_TABLE_SIZE

/**
* @def CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
*
* @brief This define enables the automatic registration of the default scene handlers in the scene table for each sceneable
* cluster. If a user wants to use their own scene handlers, they can disable this flag and implement their own handlers. They can
* use ScenesServer::Instance().RegisterSceneHandler() to have their handlers called when a scene is recalled or stored.
*/
#ifndef CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
#define CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS 1
#endif // CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS

/**
* @def CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE
*
Expand Down
Loading