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

Modifying ReplacementProductListManager to be generic #28185

Merged
merged 36 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
58f7a50
Modifying ReplacementProductListManager to be generic
cliffamzn Jul 21, 2023
53c50eb
Restyled by whitespace
restyled-commits Jul 21, 2023
f9ed8b9
Restyled by clang-format
restyled-commits Jul 21, 2023
3bbb797
Passing error back up
cliffamzn Jul 22, 2023
138de15
Merge branch 'master' into replacement-product-fix
cliffamzn Jul 22, 2023
3e0a655
Apply @bzbarsky-apple's suggestions from code review
cliffamzn Jul 25, 2023
f131838
Merge branch 'project-chip:master' into replacement-product-fix
cliffamzn Jul 25, 2023
60586e3
Integrating Borris' comments into ReplacementProductStruct
cliffamzn Jul 25, 2023
debbe5e
Restyled by whitespace
restyled-commits Jul 25, 2023
42d0d18
Restyled by clang-format
restyled-commits Jul 25, 2023
72a588a
Restyled by prettier-yaml
restyled-commits Jul 25, 2023
9de8518
Adding Tests for ResourceMonitor to ci tests list
cliffamzn Jul 25, 2023
623b42c
Restyled by prettier-yaml
restyled-commits Jul 25, 2023
399ff30
Adding newly generated zap files
cliffamzn Jul 25, 2023
73e8a95
Replaced the use of std::set with IntrusiveList in ModeBase. (#28163)
hicklin Jul 25, 2023
1c2f26d
Remove unwanted "\" at line 156 from DA-1.4 test (#28252)
manjunath-grl Jul 25, 2023
baa4eb0
Remove zap development install. (#28223)
mikaelhm Jul 25, 2023
b598ad6
[feature]Add dishwasher-app example for ASR platform (#28207)
mideayanghui Jul 25, 2023
0c25d18
[ Java] Decouple generated API in build option (#27624)
joonhaengHeo Jul 25, 2023
37f7188
Revert "[ Java] Decouple generated API in build option (#27624)" (#28…
andy31415 Jul 25, 2023
9a6feb4
[ASR] update device manager (#28251)
tx2rx Jul 25, 2023
aef213a
Add RVC device type to XML + fix RVC Clean/Run XML issue (#28239)
plauric Jul 25, 2023
a55fbb4
Make C++17 the default everywhere (#28269)
andy31415 Jul 25, 2023
4963c26
Add ipv6only build for rpc target, to not run out of ram when linking…
andy31415 Jul 25, 2023
ae10124
Attempting to fix error ` error: 'ReplacementProductStruct' was not
cliffamzn Jul 25, 2023
a20f485
Merge branch 'project-chip:master' into replacement-product-fix
cliffamzn Jul 25, 2023
f6d1305
Modifying the placeholder app to have example output
cliffamzn Jul 26, 2023
11802f7
Moved around the ReplacementProductStruct to the ResourceMonitoring
cliffamzn Jul 26, 2023
aa6e303
Restyled by whitespace
restyled-commits Jul 26, 2023
8e91c35
Restyled by clang-format
restyled-commits Jul 26, 2023
84ccb8e
Removing commented out code
cliffamzn Jul 26, 2023
64b5316
Changing DynamicReplacementProductListManager to an
cliffamzn Jul 26, 2023
cc9622a
Overriding the = operation to always do a copy
cliffamzn Jul 26, 2023
021040a
Restyled by whitespace
restyled-commits Jul 26, 2023
4c34b66
Restyled by clang-format
restyled-commits Jul 26, 2023
26ef1aa
Adding back the instance of the ReplacementProductList so that it can be
cliffamzn Jul 27, 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 @@ -58,20 +58,20 @@ class HepaFilterMonitoringInstance : public chip::app::Clusters::ResourceMonitor
class StaticReplacementProductListManager : public chip::app::Clusters::ResourceMonitoring::ReplacementProductListManager
{
public:
uint8_t Size() override { return mReplacementProductListSize; };

CHIP_ERROR Next(chip::app::Clusters::ResourceMonitoring::Attributes::ReplacementProductStruct::Type & item) override;
CHIP_ERROR
Next(chip::app::Clusters::ResourceMonitoring::Attributes::GenericReplacementProductStruct::GenericType & item) override;

~StaticReplacementProductListManager() {}
StaticReplacementProductListManager(
chip::app::Clusters::ResourceMonitoring::Attributes::ReplacementProductStruct::Type * aReplacementProductsList,
chip::app::Clusters::ResourceMonitoring::Attributes::GenericReplacementProductStruct::GenericType *
aReplacementProductsList,
uint8_t aReplacementProductListSize)
{
mReplacementProductsList = aReplacementProductsList;
mReplacementProductListSize = aReplacementProductListSize;
}

private:
chip::app::Clusters::ResourceMonitoring::Attributes::ReplacementProductStruct::Type * mReplacementProductsList;
chip::app::Clusters::ResourceMonitoring::Attributes::GenericReplacementProductStruct::GenericType * mReplacementProductsList;
uint8_t mReplacementProductListSize;
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ResourceMonitoring;
using namespace ResourceMonitoring::Attributes::GenericReplacementProductStruct;
using chip::Protocols::InteractionModel::Status;

constexpr std::bitset<4> gHepaFilterFeatureMap{ static_cast<uint32_t>(Feature::kCondition) |
Expand All @@ -37,16 +38,12 @@ constexpr std::bitset<4> gActivatedCarbonFeatureMap{ static_cast<uint32_t>(Featu
static HepaFilterMonitoringInstance * gHepaFilterInstance = nullptr;
static ActivatedCarbonFilterMonitoringInstance * gActivatedCarbonFilterInstance = nullptr;

static ResourceMonitoring::Attributes::ReplacementProductStruct::Type sReplacementProductsList[] = {
{ .productIdentifierType = ProductIdentifierTypeEnum::kUpc,
.productIdentifierValue = CharSpan::fromCharString("111112222233") },
{ .productIdentifierType = ProductIdentifierTypeEnum::kGtin8, .productIdentifierValue = CharSpan::fromCharString("gtin8xxx") },
{ .productIdentifierType = ProductIdentifierTypeEnum::kEan,
.productIdentifierValue = CharSpan::fromCharString("4444455555666") },
{ .productIdentifierType = ProductIdentifierTypeEnum::kGtin14,
.productIdentifierValue = CharSpan::fromCharString("gtin14xxxxxxxx") },
{ .productIdentifierType = ProductIdentifierTypeEnum::kOem,
.productIdentifierValue = CharSpan::fromCharString("oem20xxxxxxxxxxxxxxx") },
static GenericType sReplacementProductsList[] = {
GenericType(ProductIdentifierTypeEnum::kUpc, CharSpan::fromCharString("111112222233")),
GenericType(ProductIdentifierTypeEnum::kGtin8, CharSpan::fromCharString("gtin8xxx")),
GenericType(ProductIdentifierTypeEnum::kEan, CharSpan::fromCharString("4444455555666")),
GenericType(ProductIdentifierTypeEnum::kGtin14, CharSpan::fromCharString("gtin14xxxxxxxx")),
GenericType(ProductIdentifierTypeEnum::kOem, CharSpan::fromCharString("oem20xxxxxxxxxxxxxxx")),
};
StaticReplacementProductListManager sReplacementProductListManager(&sReplacementProductsList[0],
ArraySize(sReplacementProductsList));
Expand Down Expand Up @@ -105,7 +102,7 @@ void emberAfHepaFilterMonitoringClusterInitCallback(chip::EndpointId endpoint)
gHepaFilterInstance->Init();
}

CHIP_ERROR StaticReplacementProductListManager::Next(Attributes::ReplacementProductStruct::Type & item)
CHIP_ERROR StaticReplacementProductListManager::Next(Attributes::GenericReplacementProductStruct::GenericType & item)
{
if (mIndex < mReplacementProductListSize)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,18 @@ namespace ResourceMonitoring {
class StaticReplacementProductListManager : public ReplacementProductListManager
{
public:
uint8_t Size() override { return mReplacementProductListSize; };

CHIP_ERROR Next(Attributes::ReplacementProductStruct::Type & item) override;
CHIP_ERROR Next(Attributes::GenericReplacementProductStruct::GenericType & item) override;

~StaticReplacementProductListManager() {}
StaticReplacementProductListManager(Attributes::ReplacementProductStruct::Type * aReplacementProductsList,
StaticReplacementProductListManager(Attributes::GenericReplacementProductStruct::GenericType * aReplacementProductsList,
uint8_t aReplacementProductListSize)
{
mReplacementProductsList = aReplacementProductsList;
mReplacementProductListSize = aReplacementProductListSize;
}

private:
Attributes::ReplacementProductStruct::Type * mReplacementProductsList;
Attributes::GenericReplacementProductStruct::GenericType * mReplacementProductsList;
uint8_t mReplacementProductListSize;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ResourceMonitoring;

CHIP_ERROR StaticReplacementProductListManager::Next(Attributes::ReplacementProductStruct::Type & item)
CHIP_ERROR StaticReplacementProductListManager::Next(Attributes::GenericReplacementProductStruct::GenericType & item)
{
if (mIndex < mReplacementProductListSize)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,17 @@ using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ActivatedCarbonFilterMonitoring;
using namespace chip::app::Clusters::ResourceMonitoring;
using namespace ResourceMonitoring::Attributes::GenericReplacementProductStruct;
using chip::Protocols::InteractionModel::Status;

static ResourceMonitoring::Attributes::ReplacementProductStruct::Type sActivatedCarbonFilterReplacementProductsList[] = {
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kUpc,
.productIdentifierValue = CharSpan::fromCharString("111112222233") },
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kGtin8,
.productIdentifierValue = CharSpan::fromCharString("gtin8xca") },
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kEan,
.productIdentifierValue = CharSpan::fromCharString("4444455555666") },
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kGtin14,
.productIdentifierValue = CharSpan::fromCharString("gtin14xcarbonx") },
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kOem,
.productIdentifierValue = CharSpan::fromCharString("oem20xcarbonxxxxxxxx") },
};
static ResourceMonitoring::Attributes::GenericReplacementProductStruct::GenericType
sActivatedCarbonFilterReplacementProductsList[] = {
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kUpc, CharSpan::fromCharString("111112222233")),
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kGtin8, CharSpan::fromCharString("gtin8xca")),
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kEan, CharSpan::fromCharString("4444455555666")),
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kGtin14, CharSpan::fromCharString("gtin14xcarbonx")),
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kOem, CharSpan::fromCharString("oem20xcarbonxxxxxxxx")),
};
StaticReplacementProductListManager
sActivatedCarbonFilterReplacementProductListManager(&sActivatedCarbonFilterReplacementProductsList[0],
ArraySize(sActivatedCarbonFilterReplacementProductsList));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,15 @@
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ResourceMonitoring;
using namespace ResourceMonitoring::Attributes::GenericReplacementProductStruct;
using chip::Protocols::InteractionModel::Status;

static ResourceMonitoring::Attributes::ReplacementProductStruct::Type sHepaFilterReplacementProductsList[] = {
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kUpc,
.productIdentifierValue = CharSpan::fromCharString("111112222233") },
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kGtin8,
.productIdentifierValue = CharSpan::fromCharString("gtin8xhe") },
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kEan,
.productIdentifierValue = CharSpan::fromCharString("4444455555666") },
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kGtin14,
.productIdentifierValue = CharSpan::fromCharString("gtin14xhepaxxx") },
{ .productIdentifierType = ResourceMonitoring::ProductIdentifierTypeEnum::kOem,
.productIdentifierValue = CharSpan::fromCharString("oem20xhepaxxxxxxxxxx") },
static GenericType sHepaFilterReplacementProductsList[] = {
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kUpc, CharSpan::fromCharString("111112222233")),
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kGtin8, CharSpan::fromCharString("gtin8xhe")),
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kEan, CharSpan::fromCharString("4444455555666")),
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kGtin14, CharSpan::fromCharString("gtin14xhepaxxx")),
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum::kOem, CharSpan::fromCharString("oem20xhepaxxxxxxxxxx")),
};
StaticReplacementProductListManager sHepaFilterReplacementProductListManager(&sHepaFilterReplacementProductsList[0],
ArraySize(sHepaFilterReplacementProductsList));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ class ReplacementProductListManager

void Reset() { mIndex = 0; }

// Returns total size of Replacement Products List.
virtual uint8_t Size() = 0;

virtual CHIP_ERROR Next(Attributes::ReplacementProductStruct::Type & item) = 0;
virtual CHIP_ERROR Next(Attributes::GenericReplacementProductStruct::GenericType & item) = 0;
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved

protected:
uint8_t mIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
} // namespace Commands

namespace Attributes {
namespace ReplacementProductStruct {
namespace GenericReplacementProductStruct {

CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const
CHIP_ERROR GenericType::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const
{
TLV::TLVType outer;
ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer));
Expand All @@ -57,7 +57,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const
return CHIP_NO_ERROR;
}

} // namespace ReplacementProductStruct
} // namespace GenericReplacementProductStruct
} // namespace Attributes

} // namespace ResourceMonitoring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,37 +141,39 @@ struct TypeInfo
};
} // namespace LastChangedTime

namespace ReplacementProductStruct {
namespace GenericReplacementProductStruct {
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
enum class Fields : uint8_t
{
kProductIdentifierType = 0,
kProductIdentifierValue = 1,
};
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved

struct Type
class GenericType : protected app::Clusters::HepaFilterMonitoring::Structs::ReplacementProductStruct::Type
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
{
public:
ProductIdentifierTypeEnum productIdentifierType = static_cast<ProductIdentifierTypeEnum>(0);
private:
ResourceMonitoring::ProductIdentifierTypeEnum productIdentifierType;
chip::CharSpan productIdentifierValue;
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved

CHIP_ERROR Decode(TLV::TLVReader & reader);

public:
GenericType() {}
GenericType(ResourceMonitoring::ProductIdentifierTypeEnum aProductIdentifierType, chip::CharSpan aProductIdentifierValue)
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
{
productIdentifierType = aProductIdentifierType;
productIdentifierValue = aProductIdentifierValue;
}
virtual ~GenericType() = default;
static constexpr bool kIsFabricScoped = false;

CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const;
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
};

using DecodableType = Type;

} // namespace ReplacementProductStruct
} // namespace GenericReplacementProductStruct
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved

namespace ReplacementProductList {
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
static constexpr AttributeId Id = 0x00000005;
struct TypeInfo
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
{
using Type = chip::app::DataModel::List<const ReplacementProductStruct::Type>;
using DecodableType = chip::app::DataModel::DecodableList<ReplacementProductStruct::Type>;
using DecodableArgType = const chip::app::DataModel::DecodableList<ReplacementProductStruct::Type> &;
using Type = chip::app::DataModel::List<const GenericReplacementProductStruct::GenericType>;
using DecodableType = chip::app::DataModel::DecodableList<GenericReplacementProductStruct::GenericType>;
using DecodableArgType = const chip::app::DataModel::DecodableList<GenericReplacementProductStruct::GenericType> &;

static constexpr AttributeId GetAttributeId() { return Attributes::ReplacementProductList::Id; }
static constexpr bool MustUseTimedWrite() { return false; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ Status Instance::OnResetCondition()
}
}

ReplacementProductListManager * productListManagerInstance = Instance::GetReplacementProductListManagerInstance();
if (nullptr != productListManagerInstance)
{
productListManagerInstance->Reset();
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
}

// call application specific post reset logic
status = PostResetCondition();
return status;
Expand Down Expand Up @@ -244,8 +250,8 @@ CHIP_ERROR Instance::EnumerateAcceptedCommands(const ConcreteClusterPath & clust

CHIP_ERROR Instance::ReadReplacableProductList(AttributeValueEncoder & aEncoder)
{
CHIP_ERROR err;
if (Instance::HasFeature(ResourceMonitoring::Feature::kReplacementProductList))
CHIP_ERROR err = CHIP_NO_ERROR;
if (HasFeature(ResourceMonitoring::Feature::kReplacementProductList))
{
ReplacementProductListManager * productListManagerInstance = Instance::GetReplacementProductListManagerInstance();
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
if (nullptr == productListManagerInstance)
Expand All @@ -257,15 +263,17 @@ CHIP_ERROR Instance::ReadReplacableProductList(AttributeValueEncoder & aEncoder)
productListManagerInstance->Reset();

err = aEncoder.EncodeList([&](const auto & encoder) -> CHIP_ERROR {
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
Attributes::ReplacementProductStruct::Type replacementProductStruct;
while (productListManagerInstance->Next(replacementProductStruct) == CHIP_NO_ERROR)
Attributes::GenericReplacementProductStruct::GenericType replacementProductStruct;
CHIP_ERROR iteratorError = CHIP_NO_ERROR;
while (CHIP_NO_ERROR == iteratorError)
{
ReturnErrorOnFailure(encoder.Encode(replacementProductStruct));
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved
iteratorError = productListManagerInstance->Next(replacementProductStruct);
}
return CHIP_NO_ERROR;
return (CHIP_ERROR_PROVIDER_LIST_EXHAUSTED != iteratorError) ? iteratorError : CHIP_NO_ERROR;
});
}
return CHIP_NO_ERROR;
return err;
}

// Implements the read functionality for non-standard attributes.
Expand Down