Skip to content

Commit

Permalink
Added missing checks on feature map for name support attribute in init
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs committed Oct 27, 2023
1 parent 02e7647 commit bfae161
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down Expand Up @@ -205,7 +209,7 @@ provisional server cluster Scenes = 5 {
}

request struct CopySceneRequest {
ScenesCopyMode mode = 0;
CopyModeBitmap mode = 0;
group_id groupIdentifierFrom = 1;
int8u sceneIdentifierFrom = 2;
group_id groupIdentifierTo = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional client cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down Expand Up @@ -307,7 +311,7 @@ provisional client cluster Scenes = 5 {
}

request struct CopySceneRequest {
ScenesCopyMode mode = 0;
CopyModeBitmap mode = 0;
group_id groupIdentifierFrom = 1;
int8u sceneIdentifierFrom = 2;
group_id groupIdentifierTo = 3;
Expand Down
10 changes: 7 additions & 3 deletions examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down Expand Up @@ -205,7 +209,7 @@ provisional server cluster Scenes = 5 {
}

request struct CopySceneRequest {
ScenesCopyMode mode = 0;
CopyModeBitmap mode = 0;
group_id groupIdentifierFrom = 1;
int8u sceneIdentifierFrom = 2;
group_id groupIdentifierTo = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down Expand Up @@ -205,7 +209,7 @@ provisional server cluster Scenes = 5 {
}

request struct CopySceneRequest {
ScenesCopyMode mode = 0;
CopyModeBitmap mode = 0;
group_id groupIdentifierFrom = 1;
int8u sceneIdentifierFrom = 2;
group_id groupIdentifierTo = 3;
Expand Down
10 changes: 7 additions & 3 deletions examples/lighting-app/silabs/data_model/lighting-wifi-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down Expand Up @@ -205,7 +209,7 @@ provisional server cluster Scenes = 5 {
}

request struct CopySceneRequest {
ScenesCopyMode mode = 0;
CopyModeBitmap mode = 0;
group_id groupIdentifierFrom = 1;
int8u sceneIdentifierFrom = 2;
group_id groupIdentifierTo = 3;
Expand Down
8 changes: 6 additions & 2 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down
8 changes: 6 additions & 2 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down
8 changes: 6 additions & 2 deletions examples/thermostat/nxp/zap/thermostat_matter_thread.matter
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down
8 changes: 6 additions & 2 deletions examples/thermostat/nxp/zap/thermostat_matter_wifi.matter
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ server cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional server cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down
14 changes: 6 additions & 8 deletions src/app/clusters/scenes-server/scenes-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,11 @@ CHIP_ERROR ScenesServer::Init()
EmberAfStatus status = Attributes::FeatureMap::Get(endpoint, &featureMap);
if (EMBER_ZCL_STATUS_SUCCESS == 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);
// According to spec, bit 7 MUST match feature bit 0 (SceneNames)
BitMask<NameSupportBitmap> nameSupport = (featureMap & to_underlying(Feature::kSceneNames))
? BitMask<NameSupportBitmap>(NameSupportBitmap::kSceneNames)
: BitMask<NameSupportBitmap>();
status = Attributes::NameSupport::Set(endpoint, nameSupport.Raw());
if (EMBER_ZCL_STATUS_SUCCESS != status)
{
ChipLogDetail(Zcl, "ERR: setting NameSupport on Endpoint %hu Status: %x", endpoint, status);
Expand Down Expand Up @@ -851,7 +849,7 @@ void ScenesServer::HandleCopyScene(HandlerContext & ctx, const Commands::CopySce
sceneTable->GetRemainingCapacity(ctx.mCommandHandler.GetAccessingFabricIndex(), capacity)));

// Checks if we copy a single scene or all of them
if (req.mode.GetField(app::Clusters::Scenes::ScenesCopyMode::kCopyAllScenes))
if (req.mode.GetField(app::Clusters::Scenes::CopyModeBitmap::kCopyAllScenes))
{
// Scene Table interface data
SceneId scenesInGroup[scenes::kMaxScenesPerFabric];
Expand Down
9 changes: 7 additions & 2 deletions src/app/zap-templates/zcl/data-model/chip/scene.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<configurator>
<bitmap name="ScenesCopyMode" type="bitmap8">
<bitmap name="NameSupportBitmap" type="BITMAP8">
<cluster code="0x0005"/>
<field name="SceneNames" mask="0x80"/>
</bitmap>

<bitmap name="CopyModeBitmap" type="BITMAP8">
<cluster code="0x0005"/>
<field name="CopyAllScenes" mask="0x01"/>
</bitmap>
Expand Down Expand Up @@ -134,7 +139,7 @@ limitations under the License.
<description>
Allows a client to efficiently copy scenes from one group/scene identifier pair to another group/scene identifier pair.
</description>
<arg name="Mode" type="ScenesCopyMode"/>
<arg name="Mode" type="CopyModeBitmap"/>
<arg name="GroupIdentifierFrom" type="group_id"/>
<arg name="SceneIdentifierFrom" type="int8u"/>
<arg name="GroupIdentifierTo" type="group_id"/>
Expand Down
10 changes: 7 additions & 3 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,19 @@ client cluster Groups = 4 {

/** Attributes and commands for scene configuration and manipulation. */
provisional client cluster Scenes = 5 {
bitmap CopyModeBitmap : bitmap8 {
kCopyAllScenes = 0x1;
}

bitmap Feature : bitmap32 {
kSceneNames = 0x1;
kExplicit = 0x2;
kTableSize = 0x4;
kFabricScenes = 0x8;
}

bitmap ScenesCopyMode : bitmap8 {
kCopyAllScenes = 0x1;
bitmap NameSupportBitmap : bitmap8 {
kSceneNames = 0x80;
}

struct AttributeValuePair {
Expand Down Expand Up @@ -267,7 +271,7 @@ provisional client cluster Scenes = 5 {
}

request struct CopySceneRequest {
ScenesCopyMode mode = 0;
CopyModeBitmap mode = 0;
group_id groupIdentifierFrom = 1;
int8u sceneIdentifierFrom = 2;
group_id groupIdentifierTo = 3;
Expand Down
7 changes: 5 additions & 2 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bfae161

Please sign in to comment.