Skip to content

Commit

Permalink
Refactored the name in the code so it can compile and run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs committed Dec 14, 2023
1 parent dc07b64 commit ac245f7
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,72 +8,81 @@ using namespace chip::FlatTree;
using namespace chip::TLV;

const Entry<ItemInfo> _OnOff[] = {
{ { AttributeTag(0), "onOff", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::boolean
{ { AttributeTag(65532), "featureMap", ItemType::kBitmap }, 8 }, // OnOff::OnOffFeature
{ { AttributeTag(65533), "clusterRevision", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::int16u
{ { CommandTag(0), "Off", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::Off::()
{ { CommandTag(1), "On", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::On::()
{ { CommandTag(2), "Toggle", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::Toggle::()
{ { AttributeTag(0), "onOff", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::boolean
{ { AttributeTag(65532), "featureMap", ItemType::kBitmap }, 8 }, // OnOff::OnOffFeature
{ { AttributeTag(65533), "clusterRevision", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::int16u
{ { CommandTag(0), "Off", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::Off::()
{ { CommandTag(1), "On", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::On::()
{ { CommandTag(2), "Toggle", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::Toggle::()
};

const Entry<ItemInfo> _OnOff_DelayedAllOffEffectVariantEnum[] = {
{ { ConstantValueTag(0x0), "kDelayedOffFastFade", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::DelayedAllOffEffectVariantEnum::kDelayedOffFastFade
{ { ConstantValueTag(0x1), "kNoFade", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::DelayedAllOffEffectVariantEnum::kNoFade
{ { ConstantValueTag(0x2), "kDelayedOffSlowFade", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::DelayedAllOffEffectVariantEnum::kDelayedOffSlowFade
{ { ConstantValueTag(0x0), "kDelayedOffFastFade", ItemType::kDefault },
kInvalidNodeIndex }, // OnOff::DelayedAllOffEffectVariantEnum::kDelayedOffFastFade
{ { ConstantValueTag(0x1), "kNoFade", ItemType::kDefault },
kInvalidNodeIndex }, // OnOff::DelayedAllOffEffectVariantEnum::kNoFade
{ { ConstantValueTag(0x2), "kDelayedOffSlowFade", ItemType::kDefault },
kInvalidNodeIndex }, // OnOff::DelayedAllOffEffectVariantEnum::kDelayedOffSlowFade
};

const Entry<ItemInfo> _OnOff_DyingLightEffectVariantEnum[] = {
{ { ConstantValueTag(0x0), "kDyingLightFadeOff", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::DyingLightEffectVariantEnum::kDyingLightFadeOff
{ { ConstantValueTag(0x0), "kDyingLightFadeOff", ItemType::kDefault },
kInvalidNodeIndex }, // OnOff::DyingLightEffectVariantEnum::kDyingLightFadeOff
};

const Entry<ItemInfo> _OnOff_EffectIdentifierEnum[] = {
{ { ConstantValueTag(0x0), "kDelayedAllOff", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::EffectIdentifierEnum::kDelayedAllOff
{ { ConstantValueTag(0x1), "kDyingLight", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::EffectIdentifierEnum::kDyingLight
{ { ConstantValueTag(0x0), "kDelayedAllOff", ItemType::kDefault },
kInvalidNodeIndex }, // OnOff::EffectIdentifierEnum::kDelayedAllOff
{ { ConstantValueTag(0x1), "kDyingLight", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::EffectIdentifierEnum::kDyingLight
};

const Entry<ItemInfo> _OnOff_StartUpOnOffEnum[] = {
{ { ConstantValueTag(0x0), "kOff", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::StartUpOnOffEnum::kOff
{ { ConstantValueTag(0x1), "kOn", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::StartUpOnOffEnum::kOn
{ { ConstantValueTag(0x2), "kToggle", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::StartUpOnOffEnum::kToggle
{ { ConstantValueTag(0x0), "kOff", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::StartUpOnOffEnum::kOff
{ { ConstantValueTag(0x1), "kOn", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::StartUpOnOffEnum::kOn
{ { ConstantValueTag(0x2), "kToggle", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::StartUpOnOffEnum::kToggle
};

const Entry<ItemInfo> _OnOff_OnOffControl[] = {
{ { ConstantValueTag(0x1), "kAcceptOnlyWhenOn", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::OnOffControl::kAcceptOnlyWhenOn
{ { ConstantValueTag(0x1), "kAcceptOnlyWhenOn", ItemType::kDefault },
kInvalidNodeIndex }, // OnOff::OnOffControl::kAcceptOnlyWhenOn
};

const Entry<ItemInfo> _OnOff_OnOffFeature[] = {
{ { ConstantValueTag(0x1), "kLighting", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::OnOffFeature::kLighting
{ { ConstantValueTag(0x1), "kLighting", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::OnOffFeature::kLighting
};

const Entry<ItemInfo> _OnOff_ScenesFeature[] = {
{ { ConstantValueTag(0x1), "kSceneNames", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::ScenesFeature::kSceneNames
{ { ConstantValueTag(0x1), "kSceneNames", ItemType::kDefault }, kInvalidNodeIndex }, // OnOff::MatterScenesFeature::kSceneNames
};

const Entry<ItemInfo> _all_clusters[] = {
{ { ClusterTag(0x06), "OnOff", ItemType::kDefault }, 2 },
{ { ClusterTag(0x06), "OnOff", ItemType::kDefault }, 2 },

};

// For any non-structure list like u64[] or similar.
const Entry<ItemInfo> _primitive_type_list[] = {
{ { AnonymousTag(), "Anonymous<>", ItemType::kDefault }, kInvalidNodeIndex },
{ { AnonymousTag(), "Anonymous<>", ItemType::kDefault }, kInvalidNodeIndex },
};

} // namespace

#define _ENTRY(n) { sizeof(n) / sizeof(n[0]), n}
#define _ENTRY(n) \
{ \
sizeof(n) / sizeof(n[0]), n \
}

const std::array<const Node<ItemInfo>, 8 + 2> clusters_meta = { {
_ENTRY(_all_clusters), // 0
_ENTRY(_primitive_type_list), // 1
_ENTRY(_OnOff), // 2
_ENTRY(_OnOff_DelayedAllOffEffectVariantEnum), // 3
_ENTRY(_OnOff_DyingLightEffectVariantEnum), // 4
_ENTRY(_OnOff_EffectIdentifierEnum), // 5
_ENTRY(_OnOff_StartUpOnOffEnum), // 6
_ENTRY(_OnOff_OnOffControl), // 7
_ENTRY(_OnOff_OnOffFeature), // 8
_ENTRY(_OnOff_ScenesFeature), // 9
_ENTRY(_all_clusters), // 0
_ENTRY(_primitive_type_list), // 1
_ENTRY(_OnOff), // 2
_ENTRY(_OnOff_DelayedAllOffEffectVariantEnum), // 3
_ENTRY(_OnOff_DyingLightEffectVariantEnum), // 4
_ENTRY(_OnOff_EffectIdentifierEnum), // 5
_ENTRY(_OnOff_StartUpOnOffEnum), // 6
_ENTRY(_OnOff_OnOffControl), // 7
_ENTRY(_OnOff_OnOffFeature), // 8
_ENTRY(_OnOff_ScenesFeature), // 9
} };

} // namespace TLVMeta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
case app::Clusters::RelativeHumidityMeasurement::Id:
emberAfRelativeHumidityMeasurementClusterInitCallback(endpoint);
break;
case app::Clusters::Scenes::Id:
case app::Clusters::MatterScenes::Id:
emberAfScenesClusterInitCallback(endpoint);
break;
case app::Clusters::SoftwareDiagnostics::Id:
Expand Down
54 changes: 27 additions & 27 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <platform/CHIPDeviceLayer.h>
#include <platform/PlatformManager.h>

#ifdef EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
#include <app/clusters/scenes-server/scenes-server.h>
#endif

Expand Down Expand Up @@ -59,7 +59,7 @@ constexpr uint8_t kExecuteIfOff = 1;
} // namespace app
} // namespace chip

#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
#if defined(EMBER_AF_PLUGIN_MATTER_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
{
public:
Expand Down Expand Up @@ -99,7 +99,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
/// @return CHIP_NO_ERROR if successfully serialized the data, CHIP_ERROR_INVALID_ARGUMENT otherwise
CHIP_ERROR SerializeSave(EndpointId endpoint, ClusterId cluster, MutableByteSpan & serializedBytes) override
{
using AttributeValuePair = Scenes::Structs::AttributeValuePair::Type;
using AttributeValuePair = MatterScenes::Structs::AttributeValuePair::Type;

AttributeValuePair pairs[kColorControlScenableAttributesCount];

Expand Down Expand Up @@ -194,7 +194,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
CHIP_ERROR ApplyScene(EndpointId endpoint, ClusterId cluster, const ByteSpan & serializedBytes,
scenes::TransitionTimeMs timeMs) override
{
app::DataModel::DecodableList<Scenes::Structs::AttributeValuePair::DecodableType> attributeValueList;
app::DataModel::DecodableList<MatterScenes::Structs::AttributeValuePair::DecodableType> attributeValueList;

ReturnErrorOnFailure(DecodeAttributeValueList(serializedBytes, attributeValueList));

Expand Down Expand Up @@ -371,7 +371,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
}
}

void AddAttributeValuePair(Scenes::Structs::AttributeValuePair::Type * pairs, AttributeId id, uint32_t value,
void AddAttributeValuePair(MatterScenes::Structs::AttributeValuePair::Type * pairs, AttributeId id, uint32_t value,
size_t & attributeCount)
{
pairs[attributeCount].attributeID = id;
Expand All @@ -380,7 +380,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
}
};
static DefaultColorControlSceneHandler sColorControlSceneHandler;
#endif // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
#endif // defined(EMBER_AF_PLUGIN_MATTER_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS

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

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

bool ColorControlServer::HasFeature(chip::EndpointId endpoint, Feature feature)
Expand Down Expand Up @@ -1607,9 +1607,9 @@ bool ColorControlServer::moveToHueAndSaturationCommand(app::CommandHandler * com
return true;
}
Status status = moveToHueAndSaturation(hue, saturation, transitionTime, isEnhanced, commandPath.mEndpointId);
#ifdef EMBER_AF_PLUGIN_SCENES
Scenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId);
#endif // EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
MatterScenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId);
#endif // EMBER_AF_PLUGIN_MATTER_SCENES
commandObj->AddStatus(commandPath, status);
return true;
}
Expand Down Expand Up @@ -1812,9 +1812,9 @@ bool ColorControlServer::moveToSaturationCommand(app::CommandHandler * commandOb
return true;
}
Status status = moveToSaturation(commandData.saturation, commandData.transitionTime, commandPath.mEndpointId);
#ifdef EMBER_AF_PLUGIN_SCENES
Scenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId);
#endif // EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
MatterScenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId);
#endif // EMBER_AF_PLUGIN_MATTER_SCENES
commandObj->AddStatus(commandPath, status);
return true;
}
Expand Down Expand Up @@ -1996,9 +1996,9 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
}

exit:
#ifdef EMBER_AF_PLUGIN_SCENES
Scenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(endpoint);
#endif // EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
MatterScenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(endpoint);
#endif // EMBER_AF_PLUGIN_MATTER_SCENES
commandObj->AddStatus(commandPath, status);
return true;
}
Expand Down Expand Up @@ -2205,9 +2205,9 @@ bool ColorControlServer::moveToColorCommand(app::CommandHandler * commandObj, co
}

Status status = moveToColor(commandData.colorX, commandData.colorY, commandData.transitionTime, commandPath.mEndpointId);
#ifdef EMBER_AF_PLUGIN_SCENES
Scenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId);
#endif // EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
MatterScenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId);
#endif // EMBER_AF_PLUGIN_MATTER_SCENES
commandObj->AddStatus(commandPath, status);
return true;
}
Expand Down Expand Up @@ -2732,9 +2732,9 @@ bool ColorControlServer::moveToColorTempCommand(app::CommandHandler * commandObj
}

Status status = moveToColorTemp(commandPath.mEndpointId, commandData.colorTemperatureMireds, commandData.transitionTime);
#ifdef EMBER_AF_PLUGIN_SCENES
Scenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId);
#endif // EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
MatterScenes::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId);
#endif // EMBER_AF_PLUGIN_MATTER_SCENES
commandObj->AddStatus(commandPath, status);
return true;
}
Expand Down Expand Up @@ -3084,11 +3084,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
#if defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
#if defined(EMBER_AF_PLUGIN_MATTER_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 // defined(EMBER_AF_PLUGIN_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
app::Clusters::MatterScenes::ScenesServer::Instance().RegisterSceneHandler(endpoint,
ColorControlServer::Instance().GetSceneHandler());
#endif // defined(EMBER_AF_PLUGIN_MATTER_SCENES) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
}

void MatterColorControlClusterServerShutdownCallback(EndpointId endpoint)
Expand Down
15 changes: 8 additions & 7 deletions src/app/clusters/groups-server/groups-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include <inttypes.h>
#include <lib/support/CodeUtils.h>

#ifdef EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
#include <app/clusters/scenes-server/scenes-server.h>
#endif // EMBER_AF_PLUGIN_SCENES
#endif // EMBER_AF_PLUGIN_MATTER_SCENES

using namespace chip;
using namespace app::Clusters;
Expand Down Expand Up @@ -287,9 +287,9 @@ bool emberAfGroupsClusterRemoveGroupCallback(app::CommandHandler * commandObj, c
auto fabricIndex = commandObj->GetAccessingFabricIndex();
Groups::Commands::RemoveGroupResponse::Type response;

#ifdef EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
// If a group is removed the scenes associated with that group SHOULD be removed.
Scenes::ScenesServer::Instance().GroupWillBeRemoved(fabricIndex, commandPath.mEndpointId, commandData.groupID);
MatterScenes::ScenesServer::Instance().GroupWillBeRemoved(fabricIndex, commandPath.mEndpointId, commandData.groupID);
#endif
response.groupID = commandData.groupID;
response.status = GroupRemove(fabricIndex, commandPath.mEndpointId, commandData.groupID);
Expand All @@ -307,7 +307,7 @@ bool emberAfGroupsClusterRemoveAllGroupsCallback(app::CommandHandler * commandOb

VerifyOrExit(nullptr != provider, status = Status::Failure);

#ifdef EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_MATTER_SCENES
{
GroupDataProvider::EndpointIterator * iter = provider->IterateEndpoints(fabricIndex);
GroupDataProvider::GroupEndpoint mapping;
Expand All @@ -317,11 +317,12 @@ bool emberAfGroupsClusterRemoveAllGroupsCallback(app::CommandHandler * commandOb
{
if (commandPath.mEndpointId == mapping.endpoint_id)
{
Scenes::ScenesServer::Instance().GroupWillBeRemoved(fabricIndex, mapping.endpoint_id, mapping.group_id);
MatterScenes::ScenesServer::Instance().GroupWillBeRemoved(fabricIndex, mapping.endpoint_id, mapping.group_id);
}
}
iter->Release();
Scenes::ScenesServer::Instance().GroupWillBeRemoved(fabricIndex, commandPath.mEndpointId, ZCL_SCENES_GLOBAL_SCENE_GROUP_ID);
MatterScenes::ScenesServer::Instance().GroupWillBeRemoved(fabricIndex, commandPath.mEndpointId,
ZCL_SCENES_GLOBAL_SCENE_GROUP_ID);
}
#endif

Expand Down
Loading

0 comments on commit ac245f7

Please sign in to comment.