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] NameSupport Feature #29639

Merged
Merged
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
53 changes: 41 additions & 12 deletions src/app/clusters/scenes-server/scenes-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,35 @@ CHIP_ERROR ScenesServer::Init()

for (auto endpoint : EnabledEndpointsWithServerCluster(Id))
{
// Explicit AttributeValuePairs is mandatory for matter so we force it here, ScenesName is not but it is forced for now
// TODO: We currently force SceneNames on but this needs to be modified to read the value generated from Zap instead.
uint32_t featureMap = to_underlying(Feature::kExplicit) | to_underlying(Feature::kSceneNames);
EmberAfStatus status = Attributes::FeatureMap::Set(endpoint, featureMap);
if (EMBER_ZCL_STATUS_SUCCESS != status)
uint32_t featureMap = 0;
EmberAfStatus status = Attributes::FeatureMap::Get(endpoint, &featureMap);
if (EMBER_ZCL_STATUS_SUCCESS == status)
{
ChipLogDetail(Zcl, "ERR: setting the scenes FeatureMap on Endpoint %hu Status: %x", endpoint, status);
// Setting NameSupport attribute value to 0x80 if the feature bit is set
// The bit of 7 (0x80) the NameSupport attribute indicates whether or not scene names are supported
//
// According to spec, bit 7 (Scene Names) MUST match feature bit 0 (Scene Names)
uint8_t nameSupport =
(featureMap & to_underlying(Feature::kSceneNames)) ? static_cast<uint8_t>(0x80) : static_cast<uint8_t>(0x00);
status = Attributes::NameSupport::Set(endpoint, nameSupport);
if (EMBER_ZCL_STATUS_SUCCESS != status)
{
ChipLogDetail(Zcl, "ERR: setting NameSupport on Endpoint %hu Status: %x", endpoint, status);
}
}
// The bit of 7 the NameSupport attribute indicates whether or not scene names are supported
//
// According to spec, bit 7 (Scene Names) MUST match feature bit 0 (Scene Names)
status = Attributes::NameSupport::Set(endpoint, 0x80);
else
{
ChipLogDetail(Zcl, "ERR: getting the scenes FeatureMap on Endpoint %hu Status: %x", endpoint, status);
}

// Explicit AttributeValuePairs is mandatory for matter so we force it here
featureMap |= to_underlying(Feature::kExplicit);
status = Attributes::FeatureMap::Set(endpoint, featureMap);
if (EMBER_ZCL_STATUS_SUCCESS != status)
{
ChipLogDetail(Zcl, "ERR: setting NameSupport on Endpoint %hu Status: %x", endpoint, status);
ChipLogDetail(Zcl, "ERR: setting the scenes FeatureMap on Endpoint %hu Status: %x", endpoint, status);
}

status = Attributes::LastConfiguredBy::SetNull(endpoint);
if (EMBER_ZCL_STATUS_SUCCESS != status)
{
Expand Down Expand Up @@ -197,7 +210,15 @@ void AddSceneParse(CommandHandlerInterface::HandlerContext & ctx, const CommandD
auto fieldSetIter = req.extensionFieldSets.begin();

uint8_t EFSCount = 0;
SceneData storageData(req.sceneName, transitionTimeMs);

uint32_t featureMap = 0;
ReturnOnFailure(AddResponseOnError(ctx, response, Attributes::FeatureMap::Get(ctx.mRequestPath.mEndpointId, &featureMap)));
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved

SceneData storageData(CharSpan(), transitionTimeMs);
if (featureMap & to_underlying(Feature::kSceneNames))
{
storageData.SetName(req.sceneName);
}

// Goes through all EFS in command
while (fieldSetIter.Next() && EFSCount < scenes::kMaxClustersPerScene)
Expand Down Expand Up @@ -372,6 +393,14 @@ CHIP_ERROR StoreSceneParse(const FabricIndex & fabricIdx, const EndpointId & end
}
else
{
uint32_t featureMap = 0;
ReturnErrorOnFailure(
StatusIB(ToInteractionModelStatus(Attributes::FeatureMap::Get(endpointID, &featureMap))).ToChipError());
// Check if we still support scenes name in case an OTA changed that, if we don't, set name to empty
if (!(featureMap & to_underlying(Feature::kSceneNames)))
{
scene.mStorageData.SetName(CharSpan());
}
scene.mStorageData.mExtensionFieldSets.Clear();
}

Expand Down
Loading