Skip to content

Commit

Permalink
Modified FAN TC 2_1 to have the new types, addressed syntax issues in…
Browse files Browse the repository at this point in the history
… fan control server
  • Loading branch information
mhazley committed Jun 23, 2023
1 parent d543ba5 commit 3462653
Show file tree
Hide file tree
Showing 20 changed files with 206 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3696,11 +3696,6 @@ server cluster FanControl = 514 {
kReverse = 1;
}

enum DirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

enum FanModeEnum : ENUM8 {
kOff = 0;
kLow = 1;
Expand All @@ -3720,6 +3715,11 @@ server cluster FanControl = 514 {
kOffOn = 5;
}

enum StepDirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

bitmap Feature : BITMAP32 {
kMultiSpeed = 0x1;
kAuto = 0x2;
Expand Down Expand Up @@ -3760,7 +3760,7 @@ server cluster FanControl = 514 {
readonly attribute int16u clusterRevision = 65533;

request struct StepRequest {
DirectionEnum direction = 0;
StepDirectionEnum direction = 0;
optional boolean wrap = 1;
optional boolean lowestOff = 2;
}
Expand Down Expand Up @@ -6466,12 +6466,12 @@ endpoint 1 {
ram attribute speedMax default = 100;
ram attribute speedSetting default = 0x00;
ram attribute speedCurrent default = 0x00;
ram attribute rockSupport default = 0x00;
ram attribute rockSupport default = 0x03;
ram attribute rockSetting default = 0x00;
ram attribute windSupport default = 0x00;
ram attribute windSupport default = 0x03;
ram attribute windSetting default = 0x00;
ram attribute airflowDirection default = 0;
ram attribute featureMap default = 0x0F;
ram attribute featureMap default = 0x3F;
ram attribute clusterRevision default = 2;
}

Expand Down
20 changes: 10 additions & 10 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
}
],
"package": [
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"version": "chip-v1"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/zcl/zcl-with-test-extensions.json",
"type": "zcl-properties",
"category": "matter",
"version": 1,
"description": "Matter SDK ZCL data with some extensions"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"version": "chip-v1"
}
],
"endpointTypes": [
Expand Down Expand Up @@ -18599,7 +18599,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x00",
"defaultValue": "0x03",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -18631,7 +18631,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x00",
"defaultValue": "0x03",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -18727,7 +18727,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0F",
"defaultValue": "0x3F",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -32125,4 +32125,4 @@
}
],
"log": []
}
}
19 changes: 12 additions & 7 deletions examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,18 @@ CHIP_ERROR FanAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attribut

void emberAfFanControlClusterInitCallback(EndpointId endpoint)
{
uint32_t featureMap = 0;

featureMap |= to_underlying(FanControl::Feature::kMultiSpeed);
featureMap |= to_underlying(FanControl::Feature::kMultiSpeed);
featureMap |= to_underlying(FanControl::Feature::kAuto);

FeatureMap::Set(endpoint, featureMap);
// uint32_t featureMap = 0;

// featureMap |= to_underlying(FanControl::Feature::kMultiSpeed);
// featureMap |= to_underlying(FanControl::Feature::kAuto);
// featureMap |= to_underlying(FanControl::Feature::kWind);
// featureMap |= to_underlying(FanControl::Feature::kStep);
// featureMap |= to_underlying(FanControl::Feature::kRocking);
// featureMap |= to_underlying(FanControl::Feature::kAirflowDirection);

// FeatureMap::Set(endpoint, featureMap);
// WindSupport::Set(endpoint, 3);
// RockSupport::Set(endpoint, 3);

registerAttributeAccessOverride(&gAttrAccess);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2792,11 +2792,6 @@ server cluster FanControl = 514 {
kReverse = 1;
}

enum DirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

enum FanModeEnum : ENUM8 {
kOff = 0;
kLow = 1;
Expand All @@ -2816,6 +2811,11 @@ server cluster FanControl = 514 {
kOffOn = 5;
}

enum StepDirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

bitmap Feature : BITMAP32 {
kMultiSpeed = 0x1;
kAuto = 0x2;
Expand Down
10 changes: 5 additions & 5 deletions examples/chef/devices/rootnode_fan_7N2TobIlOX.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,6 @@ server cluster FanControl = 514 {
kReverse = 1;
}

enum DirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

enum FanModeEnum : ENUM8 {
kOff = 0;
kLow = 1;
Expand All @@ -1234,6 +1229,11 @@ server cluster FanControl = 514 {
kOffOn = 5;
}

enum StepDirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

bitmap Feature : BITMAP32 {
kMultiSpeed = 0x1;
kAuto = 0x2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1523,11 +1523,6 @@ server cluster FanControl = 514 {
kReverse = 1;
}

enum DirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

enum FanModeEnum : ENUM8 {
kOff = 0;
kLow = 1;
Expand All @@ -1547,6 +1542,11 @@ server cluster FanControl = 514 {
kOffOn = 5;
}

enum StepDirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

bitmap Feature : BITMAP32 {
kMultiSpeed = 0x1;
kAuto = 0x2;
Expand Down
12 changes: 6 additions & 6 deletions examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1332,11 +1332,6 @@ client cluster FanControl = 514 {
kReverse = 1;
}

enum DirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

enum FanModeEnum : ENUM8 {
kOff = 0;
kLow = 1;
Expand All @@ -1356,6 +1351,11 @@ client cluster FanControl = 514 {
kOffOn = 5;
}

enum StepDirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

bitmap Feature : BITMAP32 {
kMultiSpeed = 0x1;
kAuto = 0x2;
Expand Down Expand Up @@ -1396,7 +1396,7 @@ client cluster FanControl = 514 {
readonly attribute int16u clusterRevision = 65533;

request struct StepRequest {
DirectionEnum direction = 0;
StepDirectionEnum direction = 0;
optional boolean wrap = 1;
optional boolean lowestOff = 2;
}
Expand Down
20 changes: 10 additions & 10 deletions src/app/clusters/fan-control-server/fan-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ MatterFanControlClusterServerPreAttributeChangedCallback(const ConcreteAttribute
}
case PercentSetting::Id: {
// Check if the PercentSetting is null.
if (NumericAttributeTraits<chip::Percent>::IsNullValue(*value))
if (NumericAttributeTraits<Percent>::IsNullValue(*value))
{
if (gWriteFromClusterLogic)
{
Expand All @@ -208,9 +208,9 @@ MatterFanControlClusterServerPreAttributeChangedCallback(const ConcreteAttribute
if (SupportsRocking(attributePath.mEndpointId))
{
chip::BitMask<RockBitmap> rockSupport;
EmberAfStatus status = RockSupport::Get(attributePath.mEndpointId, &rockSupport);
uint8_t rawRockSupport = rockSupport.Raw();
EmberAfStatus status = RockSupport::Get(attributePath.mEndpointId, &rockSupport);
VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, Status::ConstraintError);
auto rawRockSupport = rockSupport.Raw();
if ((*value & rawRockSupport) == *value)
{
res = Status::Success;
Expand All @@ -226,13 +226,13 @@ MatterFanControlClusterServerPreAttributeChangedCallback(const ConcreteAttribute
}
break;
}
case WindSupport::Id: {
case WindSetting::Id: {
if (SupportsWind(attributePath.mEndpointId))
{
chip::BitMask<WindBitmap> windSupport;
EmberAfStatus status = WindSupport::Get(attributePath.mEndpointId, &windSupport);
uint8_t rawWindSupport = windSupport.Raw();
EmberAfStatus status = WindSupport::Get(attributePath.mEndpointId, &windSupport);
VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, Status::ConstraintError);
auto rawWindSupport = windSupport.Raw();
if ((*value & rawWindSupport) == *value)
{
res = Status::Success;
Expand Down Expand Up @@ -320,7 +320,7 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt
break;
}
case PercentSetting::Id: {
DataModel::Nullable<chip::Percent> percentSetting;
DataModel::Nullable<Percent> percentSetting;
EmberAfStatus status = PercentSetting::Get(attributePath.mEndpointId, percentSetting);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status && !percentSetting.IsNull());

Expand Down Expand Up @@ -380,13 +380,13 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
ChipLogError(Zcl, "Failed to get SpeedMax with error: 0x%02x", status));

DataModel::Nullable<chip::Percent> currentPercentSetting;
DataModel::Nullable<Percent> currentPercentSetting;
status = PercentSetting::Get(attributePath.mEndpointId, currentPercentSetting);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
ChipLogError(Zcl, "Failed to get PercentSetting with error: 0x%02x", status));

float speed = speedSetting.Value();
chip::Percent percentSetting = static_cast<chip::Percent>(speed / speedMax * 100);
float speed = speedSetting.Value();
Percent percentSetting = static_cast<Percent>(speed / speedMax * 100);

if (currentPercentSetting.IsNull() || percentSetting != currentPercentSetting.Value())
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/suites/certification/Test_TC_FAN_2_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ tests:
attribute: "PercentSetting"
response:
constraints:
type: int8u
type: Percent
minValue: 0
maxValue: 100

Expand All @@ -67,6 +67,6 @@ tests:
attribute: "PercentCurrent"
response:
constraints:
type: int8u
type: Percent
minValue: 0
maxValue: 100
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ limitations under the License.
<field name="Natural Wind" mask="0x02" />
</bitmap>

<enum name="DirectionEnum" type="ENUM8">
<enum name="StepDirectionEnum" type="ENUM8">
<cluster code="0x0202"/>
<item name="Increase" value="0x00"/>
<item name="Decrease" value="0x01"/>
Expand Down Expand Up @@ -98,7 +98,7 @@ limitations under the License.

<command source="client" code="0x00" name="Step" optional="true">
<description>The Step command speeds up or slows down the fan, in steps.</description>
<arg name="Direction" type="DirectionEnum"/>
<arg name="Direction" type="StepDirectionEnum"/>
<arg name="Wrap" type="boolean" optional="true"/>
<arg name="LowestOff" type="boolean" optional="true"/>
</command>
Expand Down
12 changes: 6 additions & 6 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4871,11 +4871,6 @@ client cluster FanControl = 514 {
kReverse = 1;
}

enum DirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

enum FanModeEnum : ENUM8 {
kOff = 0;
kLow = 1;
Expand All @@ -4895,6 +4890,11 @@ client cluster FanControl = 514 {
kOffOn = 5;
}

enum StepDirectionEnum : ENUM8 {
kIncrease = 0;
kDecrease = 1;
}

bitmap Feature : BITMAP32 {
kMultiSpeed = 0x1;
kAuto = 0x2;
Expand Down Expand Up @@ -4935,7 +4935,7 @@ client cluster FanControl = 514 {
readonly attribute int16u clusterRevision = 65533;

request struct StepRequest {
DirectionEnum direction = 0;
StepDirectionEnum direction = 0;
optional boolean wrap = 1;
optional boolean lowestOff = 2;
}
Expand Down
Loading

0 comments on commit 3462653

Please sign in to comment.