Skip to content

Commit

Permalink
Add ReplacementProductList to Resource Monitoring Cluster
Browse files Browse the repository at this point in the history
This adds the implementation to fetch the replacement product list from
the aliased resource-monitoring-cluster. It adds support for Hepa and
Activated Carbon filter examples.

Closes out issues project-chip#27802, project-chip#27801, project-chip#27577

### Testing

I tested this using both the all-clusters-app as well as the
resource-monitoring-example-app

```
>>>> hepafiltermonitoring read replacement-product-list 0x1 0x1

DataVersion = 0xd31d0b60,
AttributePathIB =
{
        Endpoint = 0x1,
        Cluster = 0x71,
        Attribute = 0x0000_0005,
}

Data = [

        {
                0x0 = 0,
                0x1 = "upc12xhepaxx" (13 chars),
        },
        {
                0x0 = 1,
                0x1 = "gtin8xhe" (9 chars),
        },
        {
                0x0 = 2,
                0x1 = "ean13xhepaxxx" (14 chars),
        },
],

>>>> activatedcarbonfiltermonitoring read replacement-product-list 0x1 0x1

DataVersion = 0xfd145260,
AttributePathIB =
{
        Endpoint = 0x1,
        Cluster = 0x72,
        Attribute = 0x0000_0005,
}

Data = [

        {
                0x0 = 0,
                0x1 = "upc12xcarbon" (13 chars),
        },
        {
                0x0 = 1,
                0x1 = "gtin8xca" (9 chars),
        },
        {
                0x0 = 2,
                0x1 = "ean13xacarbon" (14 chars),
        },
],
```
  • Loading branch information
cliffamzn committed Jul 19, 2023
1 parent 4a5f438 commit 8344787
Show file tree
Hide file tree
Showing 36 changed files with 1,905 additions and 1,126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2735,6 +2735,7 @@ server cluster HepaFilterMonitoring = 113 {
bitmap Feature : BITMAP32 {
kCondition = 0x1;
kWarning = 0x2;
kReplacementProductList = 0x3;
}

struct ReplacementProductStruct {
Expand All @@ -2747,6 +2748,7 @@ server cluster HepaFilterMonitoring = 113 {
readonly attribute ChangeIndicationEnum changeIndication = 2;
readonly attribute boolean inPlaceIndicator = 3;
attribute nullable epoch_s lastChangedTime = 4;
readonly attribute nullable ReplacementProductStruct replacementProductList[] = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -2781,6 +2783,7 @@ server cluster ActivatedCarbonFilterMonitoring = 114 {
bitmap Feature : BITMAP32 {
kCondition = 0x1;
kWarning = 0x2;
kReplacementProductList = 0x3;
}

struct ReplacementProductStruct {
Expand All @@ -2793,6 +2796,7 @@ server cluster ActivatedCarbonFilterMonitoring = 114 {
readonly attribute ChangeIndicationEnum changeIndication = 2;
readonly attribute boolean inPlaceIndicator = 3;
attribute nullable epoch_s lastChangedTime = 4;
readonly attribute nullable ReplacementProductStruct replacementProductList[] = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -6294,6 +6298,7 @@ endpoint 1 {
callback attribute changeIndication default = 0;
callback attribute inPlaceIndicator;
callback attribute lastChangedTime;
callback attribute replacementProductList;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
Expand All @@ -6308,6 +6313,7 @@ endpoint 1 {
callback attribute changeIndication default = 0;
callback attribute inPlaceIndicator;
callback attribute lastChangedTime;
callback attribute replacementProductList;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
Expand Down
54 changes: 43 additions & 11 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 @@ -14498,7 +14498,7 @@
"code": 4,
"mfgCode": null,
"side": "server",
"type": "OperationalStateStruct",
"type": "OperationalStateEnum",
"included": 1,
"storageOption": "External",
"singleton": 0,
Expand Down Expand Up @@ -14770,10 +14770,26 @@
"side": "server",
"type": "epoch_s",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ReplacementProductList",
"code": 5,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -15008,10 +15024,26 @@
"side": "server",
"type": "epoch_s",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ReplacementProductList",
"code": 5,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,38 @@
#include <app-common/zap-generated/ids/Clusters.h>
#include <instances/ActivatedCarbonFilterMonitoring.h>
#include <instances/HepaFilterMonitoring.h>
#include <instances/StaticActivatedCarbonFilterReplacementProductListManager.h>
#include <instances/StaticHepaFilterReplacementProductListManager.h>

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ResourceMonitoring;

constexpr std::bitset<4> gHepaFilterFeatureMap{ static_cast<uint32_t>(Feature::kCondition) |
static_cast<uint32_t>(Feature::kWarning) };
static_cast<uint32_t>(Feature::kWarning) |
static_cast<uint32_t>(Feature::kReplacementProductList) };
constexpr std::bitset<4> gActivatedCarbonFeatureMap{ static_cast<uint32_t>(Feature::kCondition) |
static_cast<uint32_t>(Feature::kWarning) };
static_cast<uint32_t>(Feature::kWarning) |
static_cast<uint32_t>(Feature::kReplacementProductList) };

static HepaFilterMonitoringInstance * gHepafilterInstance;
static HepaFilterMonitoringInstance * gHepaFilterInstance;
static ActivatedCarbonFilterMonitoringInstance * gActivatedCarbonFilterInstance;

StaticHepaFilterReplacementProductListManager gHepaFilterReplacementProductListManager;
StaticActivatedCarbonFilterReplacementProductListManager gActivatedCarbonFilterReplacementProductListManager;

void emberAfActivatedCarbonFilterMonitoringClusterInitCallback(chip::EndpointId endpoint)
{
gActivatedCarbonFilterInstance = new ActivatedCarbonFilterMonitoringInstance(
endpoint, static_cast<uint32_t>(gActivatedCarbonFeatureMap.to_ulong()), DegradationDirectionEnum::kDown, true);
gActivatedCarbonFilterInstance->Init();
gActivatedCarbonFilterInstance->SetReplacementProductListManagerInstance(&gActivatedCarbonFilterReplacementProductListManager);
}
void emberAfHepaFilterMonitoringClusterInitCallback(chip::EndpointId endpoint)
{
gHepafilterInstance = new HepaFilterMonitoringInstance(endpoint, static_cast<uint32_t>(gHepaFilterFeatureMap.to_ulong()),
gHepaFilterInstance = new HepaFilterMonitoringInstance(endpoint, static_cast<uint32_t>(gHepaFilterFeatureMap.to_ulong()),
DegradationDirectionEnum::kDown, true);
gHepafilterInstance->Init();
gHepaFilterInstance->Init();
gHepaFilterInstance->SetReplacementProductListManagerInstance(&gHepaFilterReplacementProductListManager);
}
3 changes: 3 additions & 0 deletions examples/all-clusters-app/linux/main-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#include <transport/SessionManager.h>
#include <transport/raw/PeerAddress.h>

#include <instances/ActivatedCarbonFilterMonitoring.h>
#include <instances/HepaFilterMonitoring.h>

#include <Options.h>

using namespace chip;
Expand Down
30 changes: 21 additions & 9 deletions examples/resource-monitoring-app/linux/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <bitset>
#include <instances/ActivatedCarbonFilterMonitoring.h>
#include <instances/HepaFilterMonitoring.h>
#include <instances/StaticActivatedCarbonFilterReplacementProductListManager.h>
#include <instances/StaticHepaFilterReplacementProductListManager.h>
#include <stdint.h>

using namespace chip;
Expand All @@ -29,20 +31,30 @@ using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ResourceMonitoring;

constexpr std::bitset<4> gHepaFilterFeatureMap{ static_cast<uint32_t>(Feature::kCondition) |
static_cast<uint32_t>(Feature::kWarning) };
static_cast<uint32_t>(Feature::kWarning) |
static_cast<uint32_t>(Feature::kReplacementProductList) };
constexpr std::bitset<4> gActivatedCarbonFeatureMap{ static_cast<uint32_t>(Feature::kCondition) |
static_cast<uint32_t>(Feature::kWarning) };
static_cast<uint32_t>(Feature::kWarning) |
static_cast<uint32_t>(Feature::kReplacementProductList) };

static HepaFilterMonitoringInstance HepafilterInstance(0x1, static_cast<uint32_t>(gHepaFilterFeatureMap.to_ulong()),
DegradationDirectionEnum::kDown, true);
static ActivatedCarbonFilterMonitoringInstance
ActivatedCarbonFilterInstance(0x1, static_cast<uint32_t>(gActivatedCarbonFeatureMap.to_ulong()),
DegradationDirectionEnum::kDown, true);
static HepaFilterMonitoringInstance * gHepaFilterInstance;
static ActivatedCarbonFilterMonitoringInstance * gActivatedCarbonFilterInstance;

StaticHepaFilterReplacementProductListManager gHepaFilterReplacementProductListManager;
StaticActivatedCarbonFilterReplacementProductListManager gActivatedCarbonFilterReplacementProductListManager;

void ApplicationInit()
{
HepafilterInstance.Init();
ActivatedCarbonFilterInstance.Init();
gHepaFilterInstance = new HepaFilterMonitoringInstance(0x1, static_cast<uint32_t>(gHepaFilterFeatureMap.to_ulong()),
DegradationDirectionEnum::kDown, true);
gActivatedCarbonFilterInstance = new ActivatedCarbonFilterMonitoringInstance(
0x1, static_cast<uint32_t>(gActivatedCarbonFeatureMap.to_ulong()), DegradationDirectionEnum::kDown, true);

gHepaFilterInstance->Init();
gActivatedCarbonFilterInstance->Init();

gHepaFilterInstance->SetReplacementProductListManagerInstance(&gHepaFilterReplacementProductListManager);
gActivatedCarbonFilterInstance->SetReplacementProductListManagerInstance(&gActivatedCarbonFilterReplacementProductListManager);
}

int main(int argc, char * argv[])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <app/clusters/resource-monitoring-server/replacement-product-list-manager.h>
#include <app/util/af.h>
#include <app/util/config.h>

using namespace chip::app::Clusters;

namespace chip {
namespace app {
namespace Clusters {
namespace ResourceMonitoring {

static const uint8_t kActivatedCarbonFilterReplacementProductListSize = 3;

/**
* This implementation statically defines the options.
*/

class StaticActivatedCarbonFilterReplacementProductListManager
: public ReplacementProductListManager<ActivatedCarbonFilterMonitoring::Structs::ReplacementProductStruct::Type>
{
public:
uint8_t Size() override { return kActivatedCarbonFilterReplacementProductListSize; };

CHIP_ERROR Next(ActivatedCarbonFilterMonitoring::Structs::ReplacementProductStruct::Type & item) override;

~StaticActivatedCarbonFilterReplacementProductListManager() {}
};

} // namespace ResourceMonitoring
} // namespace Clusters
} // namespace app
} // namespace chip
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <app/clusters/resource-monitoring-server/replacement-product-list-manager.h>
#include <app/util/af.h>
#include <app/util/config.h>

using namespace chip::app::Clusters;

namespace chip {
namespace app {
namespace Clusters {
namespace ResourceMonitoring {

static const uint8_t kHepaFilterReplacementProductListSize = 3;

/**
* This implementation statically defines the options.
*/

class StaticHepaFilterReplacementProductListManager
: public ReplacementProductListManager<HepaFilterMonitoring::Structs::ReplacementProductStruct::Type>
{
public:
uint8_t Size() override { return kHepaFilterReplacementProductListSize; };

CHIP_ERROR Next(HepaFilterMonitoring::Structs::ReplacementProductStruct::Type & item) override;

~StaticHepaFilterReplacementProductListManager() {}
};

} // namespace ResourceMonitoring
} // namespace Clusters
} // namespace app
} // namespace chip
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@ server cluster HepaFilterMonitoring = 113 {
bitmap Feature : BITMAP32 {
kCondition = 0x1;
kWarning = 0x2;
kReplacementProductList = 0x3;
}

struct ReplacementProductStruct {
Expand All @@ -1531,6 +1532,7 @@ server cluster HepaFilterMonitoring = 113 {
readonly attribute ChangeIndicationEnum changeIndication = 2;
readonly attribute boolean inPlaceIndicator = 3;
attribute nullable epoch_s lastChangedTime = 4;
readonly attribute nullable ReplacementProductStruct replacementProductList[] = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -1565,6 +1567,7 @@ server cluster ActivatedCarbonFilterMonitoring = 114 {
bitmap Feature : BITMAP32 {
kCondition = 0x1;
kWarning = 0x2;
kReplacementProductList = 0x3;
}

struct ReplacementProductStruct {
Expand All @@ -1577,6 +1580,7 @@ server cluster ActivatedCarbonFilterMonitoring = 114 {
readonly attribute ChangeIndicationEnum changeIndication = 2;
readonly attribute boolean inPlaceIndicator = 3;
attribute nullable epoch_s lastChangedTime = 4;
readonly attribute nullable ReplacementProductStruct replacementProductList[] = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -1984,6 +1988,7 @@ endpoint 1 {
callback attribute changeIndication default = 0;
callback attribute inPlaceIndicator;
callback attribute lastChangedTime;
callback attribute replacementProductList;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
Expand All @@ -1998,6 +2003,7 @@ endpoint 1 {
callback attribute changeIndication default = 0;
callback attribute inPlaceIndicator;
callback attribute lastChangedTime;
callback attribute replacementProductList;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
Expand Down
Loading

0 comments on commit 8344787

Please sign in to comment.