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

[Pump] Add feature map support #23824

Merged
merged 20 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d58c9b3
Added feature map to pump xml, updated server and zap regen all
ReneJosefsen Nov 30, 2022
3b392cf
Merge branch 'project-chip:master' into rjosefsen/PCC-add-featuremap
ReneJosefsen Dec 1, 2022
fdea6bd
Added namespace and minor refactoring
ReneJosefsen Dec 1, 2022
563a39a
Removed PumpConfigurationAndControlAttrAccess since it is not used
ReneJosefsen Dec 2, 2022
54a23eb
Merge remote-tracking branch 'upstream/master' into rjosefsen/PCC-add…
ReneJosefsen Dec 5, 2022
3115b68
Updated PCC cluster on all cluster apps
ReneJosefsen Dec 5, 2022
849630f
Merge branch 'project-chip:master' into rjosefsen/PCC-add-featuremap
ReneJosefsen Dec 5, 2022
cf79362
Merge branch 'master' into rjosefsen/PCC-add-featuremap
andy31415 Dec 12, 2022
646329a
Merge branch 'master' into rjosefsen/PCC-add-featuremap
ReneJosefsen Dec 14, 2022
1458678
Updated to latest featureLevel to match master
ReneJosefsen Jan 9, 2023
96fadbd
Merge branch 'master' into rjosefsen/PCC-add-featuremap
ReneJosefsen Jan 9, 2023
27e3046
Ran regen all on latest zap and master
ReneJosefsen Jan 9, 2023
add2923
Merge branch 'master' into rjosefsen/PCC-add-featuremap
ReneJosefsen Jan 17, 2023
054d7bf
zap regen all
ReneJosefsen Jan 17, 2023
59a8ede
Updated PCC test cases to use new feature PICS
ReneJosefsen Jan 18, 2023
390c702
Merge branch 'master' into rjosefsen/PCC-add-featuremap
ReneJosefsen Jan 18, 2023
cada0e8
Fixed PICS error in 1_1 and restyle
ReneJosefsen Jan 18, 2023
c96662f
Removed whitespaces
ReneJosefsen Jan 18, 2023
ec4fd4c
Try to fix CI failure
ReneJosefsen Jan 18, 2023
e003f28
Added missing PICS for TC-PCC-2.2
ReneJosefsen Jan 18, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2496,6 +2496,16 @@ server cluster PumpConfigurationAndControl = 512 {
kLocal = 3;
}

bitmap PumpFeature : BITMAP32 {
kConstantPressure = 0x1;
kCompensatedPressure = 0x2;
kConstantFlow = 0x4;
kConstantSpeed = 0x8;
kConstantTemperature = 0x10;
kAutomatic = 0x20;
kLocal = 0x40;
}

bitmap PumpStatus : BITMAP16 {
kDeviceFault = 0x1;
kSupplyfault = 0x2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,16 @@ server cluster PumpConfigurationAndControl = 512 {
kLocal = 3;
}

bitmap PumpFeature : BITMAP32 {
kConstantPressure = 0x1;
kCompensatedPressure = 0x2;
kConstantFlow = 0x4;
kConstantSpeed = 0x8;
kConstantTemperature = 0x10;
kAutomatic = 0x20;
kLocal = 0x40;
}

bitmap PumpStatus : BITMAP16 {
kDeviceFault = 0x1;
kSupplyfault = 0x2;
Expand Down
10 changes: 10 additions & 0 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,16 @@ server cluster PumpConfigurationAndControl = 512 {
kLocal = 3;
}

bitmap PumpFeature : BITMAP32 {
kConstantPressure = 0x1;
kCompensatedPressure = 0x2;
kConstantFlow = 0x4;
kConstantSpeed = 0x8;
kConstantTemperature = 0x10;
kAutomatic = 0x20;
kLocal = 0x40;
}

bitmap PumpStatus : BITMAP16 {
kDeviceFault = 0x1;
kSupplyfault = 0x2;
Expand Down
10 changes: 10 additions & 0 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,16 @@ server cluster PumpConfigurationAndControl = 512 {
kLocal = 3;
}

bitmap PumpFeature : BITMAP32 {
kConstantPressure = 0x1;
kCompensatedPressure = 0x2;
kConstantFlow = 0x4;
kConstantSpeed = 0x8;
kConstantTemperature = 0x10;
kAutomatic = 0x20;
kLocal = 0x40;
}

bitmap PumpStatus : BITMAP16 {
kDeviceFault = 0x1;
kSupplyfault = 0x2;
Expand Down
14 changes: 12 additions & 2 deletions examples/pump-app/pump-common/pump-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,16 @@ server cluster PumpConfigurationAndControl = 512 {
kLocal = 3;
}

bitmap PumpFeature : BITMAP32 {
kConstantPressure = 0x1;
kCompensatedPressure = 0x2;
kConstantFlow = 0x4;
kConstantSpeed = 0x8;
kConstantTemperature = 0x10;
kAutomatic = 0x20;
kLocal = 0x40;
}

bitmap PumpStatus : BITMAP16 {
kDeviceFault = 0x1;
kSupplyfault = 0x2;
Expand Down Expand Up @@ -1498,8 +1508,8 @@ endpoint 1 {
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap;
ram attribute clusterRevision default = 3;
ram attribute featureMap default = 31;
ram attribute clusterRevision default = 4;
}

server cluster TemperatureMeasurement {
Expand Down
11 changes: 6 additions & 5 deletions examples/pump-app/pump-common/pump-app.zap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"featureLevel": 81,
"featureLevel": 87,
"creator": "zap",
"keyValuePairs": [
{
Expand Down Expand Up @@ -6207,7 +6207,7 @@
"code": 15,
"mfgCode": null,
"side": "server",
"type": "bitmap8",
"type": "LevelControlOptions",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
Expand Down Expand Up @@ -7150,7 +7150,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"defaultValue": "31",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -7166,7 +7166,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "3",
"defaultValue": "4",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down Expand Up @@ -7914,5 +7914,6 @@
"endpointVersion": 1,
"deviceIdentifier": 771
}
]
],
"log": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,16 @@ client cluster PumpConfigurationAndControl = 512 {
kLocal = 3;
}

bitmap PumpFeature : BITMAP32 {
kConstantPressure = 0x1;
kCompensatedPressure = 0x2;
kConstantFlow = 0x4;
kConstantSpeed = 0x8;
kConstantTemperature = 0x10;
kAutomatic = 0x20;
kLocal = 0x40;
}

bitmap PumpStatus : BITMAP16 {
kDeviceFault = 0x1;
kSupplyfault = 0x2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static RemoteSensorType detectRemoteSensorConnected()
return RemoteSensorType::kNoSensor;
}

static void updateAttributeLinks(EndpointId endpoint)
static void setEffectiveOperationAndControlMode(EndpointId endpoint)
{
PumpControlMode controlMode;
PumpOperationMode operationMode;
Expand Down Expand Up @@ -271,80 +271,20 @@ CHIP_ERROR PumpConfigurationAndControlAttrAccess::Write(const ConcreteDataAttrib
}
} // namespace

// SDK Callbacks

template <typename T1, typename T2>
bool IsFeatureSupported(EndpointId endpoint, EmberAfStatus (*getFn1)(chip::EndpointId endpointId, T1 & value),
EmberAfStatus (*getFn2)(chip::EndpointId endpointId, T2 & value))
bool PumpHasFeature(EndpointId endpoint, PumpFeature feature)
ReneJosefsen marked this conversation as resolved.
Show resolved Hide resolved
{
EmberAfStatus status;

T1 value1;
T2 value2;

status = getFn1(endpoint, value1);
if (status == EMBER_ZCL_STATUS_SUCCESS)
{
if (!value1.IsNull())
{
status = getFn2(endpoint, value2);
if (status == EMBER_ZCL_STATUS_SUCCESS)
{
if (!value2.IsNull())
{
return true;
}
}
}
}
bool hasFeature;
uint32_t featureMap;
hasFeature = (Attributes::FeatureMap::Get(endpoint, &featureMap) == EMBER_ZCL_STATUS_SUCCESS);

return false;
return hasFeature ? ((featureMap & to_underlying(feature)) != 0) : false;
}

template <typename T1, typename T2>
const char * FeatureSupportedDebugString(EndpointId endpoint, EmberAfStatus (*getFn1)(chip::EndpointId endpointId, T1 & value),
EmberAfStatus (*getFn2)(chip::EndpointId endpointId, T2 & value))
{
return IsFeatureSupported(endpoint, getFn1, getFn2) ? "Supported" : "Not Supported";
}
// SDK Callbacks

void emberAfPumpConfigurationAndControlClusterServerInitCallback(EndpointId endpoint)
{
emberAfDebugPrintln("Initialize PCC Server Cluster [EP:%d]", endpoint);

// Determine the internal feature set of the pump, depending on the pump
// specific attributes available, and their values. This is a temporary
// implementation to get a kind of "pseudo-FeatureMap" until we get a real
// FeatureMap implementation in the PCC cluster. If an attribute is
// present/available, then there is a possibility for the associated
// feature being present as well. But we will have to distinguis between
// the attributes being available and null also. At this point (init)
// we can only examine the list of attributes available, and then detect
// if they each have a NonNull value. Later on, when the pump application
// has finished its init process, it might setup these attributevalues
// to something NonNull, and then we must re-calcualte the feature set.

emberAfDebugPrintln(
"Constant Pressure %s",
FeatureSupportedDebugString(endpoint, Attributes::MinConstPressure::Get, Attributes::MaxConstPressure::Get));
emberAfDebugPrintln("PCC Server: Constant Proportional Pressure %s",
FeatureSupportedDebugString(endpoint, Attributes::MinCompPressure::Get, Attributes::MaxCompPressure::Get));
emberAfDebugPrintln("PCC Server: Constant Flow %s",
FeatureSupportedDebugString(endpoint, Attributes::MinConstFlow::Get, Attributes::MaxConstFlow::Get));
emberAfDebugPrintln("PCC Server: Constant Temperature %s",
FeatureSupportedDebugString(endpoint, Attributes::MinConstTemp::Get, Attributes::MaxConstTemp::Get));
emberAfDebugPrintln("PCC Server: Constant Speed %s",
FeatureSupportedDebugString(endpoint, Attributes::MinConstSpeed::Get, Attributes::MaxConstSpeed::Get));

if (!emberAfContainsAttribute(endpoint, PumpConfigurationAndControl::Id, Attributes::ControlMode::Id))
{
emberAfDebugPrintln("PCC Server: ControlMode attribute not available");
}

if (!emberAfContainsAttribute(endpoint, PumpConfigurationAndControl::Id, Attributes::PumpStatus::Id))
{
emberAfDebugPrintln("PCC Server: PumpStatus attribute not available");
}
}

chip::Protocols::InteractionModel::Status MatterPumpConfigurationAndControlClusterServerPreAttributeChangedCallback(
Expand All @@ -365,38 +305,40 @@ chip::Protocols::InteractionModel::Status MatterPumpConfigurationAndControlClust
switch (controlMode)
{
case PumpControlMode::kConstantFlow:
if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinConstFlow::Get, Attributes::MaxConstFlow::Get))
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kConstantFlow))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpControlMode::kConstantPressure:
if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinConstPressure::Get,
Attributes::MaxConstPressure::Get))
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kConstantPressure))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpControlMode::kConstantSpeed:
if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinConstSpeed::Get, Attributes::MaxConstSpeed::Get))
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kConstantSpeed))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpControlMode::kConstantTemperature:
if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinConstTemp::Get, Attributes::MaxConstTemp::Get))
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kConstantTemperature))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpControlMode::kProportionalPressure:
if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinCompPressure::Get, Attributes::MaxCompPressure::Get))
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kCompensatedPressure))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpControlMode::kAutomatic:
status = Protocols::InteractionModel::Status::Success;
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kAutomatic))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpControlMode::kUnknownEnumValue:
status = Protocols::InteractionModel::Status::ConstraintError;
Expand All @@ -414,18 +356,23 @@ chip::Protocols::InteractionModel::Status MatterPumpConfigurationAndControlClust
switch (operationMode)
{
case PumpOperationMode::kMinimum:
if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinConstSpeed::Get, Attributes::MaxConstSpeed::Get))
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kConstantSpeed))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpOperationMode::kMaximum:
if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinConstSpeed::Get, Attributes::MaxConstSpeed::Get))
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kConstantSpeed))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpOperationMode::kLocal:
if (!PumpHasFeature(attributePath.mEndpointId, PumpFeature::kLocal))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpOperationMode::kNormal:
status = Protocols::InteractionModel::Status::Success;
break;
Expand All @@ -450,11 +397,11 @@ void MatterPumpConfigurationAndControlClusterServerAttributeChangedCallback(cons
switch (attributePath.mAttributeId)
{
case Attributes::ControlMode::Id: {
updateAttributeLinks(attributePath.mEndpointId);
setEffectiveOperationAndControlMode(attributePath.mEndpointId);
}
break;
case Attributes::OperationMode::Id: {
updateAttributeLinks(attributePath.mEndpointId);
setEffectiveOperationAndControlMode(attributePath.mEndpointId);
}
ReneJosefsen marked this conversation as resolved.
Show resolved Hide resolved
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,15 @@ limitations under the License.
<item name="Automatic" value="0x7"/>
</enum>

<bitmap name="PumpFeature" type="BITMAP32">
<cluster code="0x0200"/>
<field mask="0x01" name="ConstantPressure" />
<field mask="0x02" name="CompensatedPressure" />
<field mask="0x04" name="ConstantFlow"/>
<field mask="0x08" name="ConstantSpeed"/>
<field mask="0x10" name="ConstantTemperature"/>
<field mask="0x20" name="Automatic"/>
<field mask="0x40" name="Local"/>
</bitmap>

</configurator>
10 changes: 10 additions & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2791,6 +2791,16 @@ client cluster PumpConfigurationAndControl = 512 {
kLocal = 3;
}

bitmap PumpFeature : BITMAP32 {
kConstantPressure = 0x1;
kCompensatedPressure = 0x2;
kConstantFlow = 0x4;
kConstantSpeed = 0x8;
kConstantTemperature = 0x10;
kAutomatic = 0x20;
kLocal = 0x40;
}

bitmap PumpStatus : BITMAP16 {
kDeviceFault = 0x1;
kSupplyfault = 0x2;
Expand Down
10 changes: 10 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h

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

Loading