Skip to content

Commit

Permalink
Merge branch 'master' into disable_eventlist_attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Jul 27, 2023
2 parents 1679f5b + 0a7cc29 commit d1616b6
Show file tree
Hide file tree
Showing 43 changed files with 4,180 additions and 325 deletions.
10 changes: 7 additions & 3 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ app:
- src/app/*
- src/app/**/*

icd:
- src/app/icd/*
- src/app/icd/**/*

transport:
- src/transport/*
- src/transport/**/*
Expand Down Expand Up @@ -185,9 +189,9 @@ darwin:
- examples/darwin-framework-tool/*
- examples/darwin-framework-tool/**/*

efr32:
- src/platform/efr32/*
- src/platform/efr32/**/*
silabs:
- src/platform/silabs/*
- src/platform/silabs/**/*

esp32:
- src/platform/ESP32/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,9 @@ class HepaFilterMonitoringInstance : public chip::app::Clusters::ResourceMonitor
aResetConditionCommandSupported){};
};

class StaticReplacementProductListManager : public chip::app::Clusters::ResourceMonitoring::ReplacementProductListManager
class ImmutableReplacementProductListManager : 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;

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

private:
chip::app::Clusters::ResourceMonitoring::Attributes::ReplacementProductStruct::Type * mReplacementProductsList;
uint8_t mReplacementProductListSize;
CHIP_ERROR
Next(chip::app::Clusters::ResourceMonitoring::ReplacementProductStruct & item) override;
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,7 @@ 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") },
};
StaticReplacementProductListManager sReplacementProductListManager(&sReplacementProductsList[0],
ArraySize(sReplacementProductsList));
static ImmutableReplacementProductListManager sReplacementProductListManager;

//-- Activated Carbon Filter Monitoring Instance methods
CHIP_ERROR ActivatedCarbonFilterMonitoringInstance::AppInit()
Expand Down Expand Up @@ -106,14 +93,40 @@ void emberAfHepaFilterMonitoringClusterInitCallback(chip::EndpointId endpoint)
gHepaFilterInstance->Init();
}

CHIP_ERROR StaticReplacementProductListManager::Next(Attributes::ReplacementProductStruct::Type & item)
CHIP_ERROR ImmutableReplacementProductListManager::Next(ReplacementProductStruct & item)
{
if (mIndex < mReplacementProductListSize)
if (mIndex >= kReplacementProductListMaxSize)
{
item = mReplacementProductsList[mIndex];
mIndex++;
return CHIP_NO_ERROR;
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
}

return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
switch (mIndex)
{
case 0: {
item.SetProductIdentifierType(ResourceMonitoring::ProductIdentifierTypeEnum::kUpc);
item.SetProductIdentifierValue(CharSpan::fromCharString("111112222233"));
break;
case 1:
item.SetProductIdentifierType(ResourceMonitoring::ProductIdentifierTypeEnum::kGtin8);
item.SetProductIdentifierValue(CharSpan::fromCharString("gtin8xxx"));
break;
case 2:
item.SetProductIdentifierType(ResourceMonitoring::ProductIdentifierTypeEnum::kEan);
item.SetProductIdentifierValue(CharSpan::fromCharString("4444455555666"));
break;
case 3:
item.SetProductIdentifierType(ResourceMonitoring::ProductIdentifierTypeEnum::kGtin14);
item.SetProductIdentifierValue(CharSpan::fromCharString("gtin14xxxxxxxx"));
break;
case 4:
item.SetProductIdentifierType(ResourceMonitoring::ProductIdentifierTypeEnum::kOem);
item.SetProductIdentifierValue(CharSpan::fromCharString("oem20xxxxxxxxxxxxxxx"));
break;
default:
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
break;
}
}
mIndex++;
return CHIP_NO_ERROR;
}
2 changes: 1 addition & 1 deletion examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AppCallbacks : public AppDelegate
public:
void OnCommissioningSessionEstablishmentStarted() {}
void OnCommissioningSessionStarted() override { bluetoothLED.Set(true); }
void OnCommissioningSessionStopped(CHIP_ERROR err) override
void OnCommissioningSessionStopped() override
{
bluetoothLED.Set(false);
pairingWindowLED.Set(false);
Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-minimal-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AppCallbacks : public AppDelegate
public:
void OnCommissioningSessionEstablishmentStarted() {}
void OnCommissioningSessionStarted() override { bluetoothLED.Set(true); }
void OnCommissioningSessionStopped(CHIP_ERROR err) override
void OnCommissioningSessionStopped() override
{
bluetoothLED.Set(false);
pairingWindowLED.Set(false);
Expand Down
14 changes: 5 additions & 9 deletions examples/darwin-framework-tool/templates/tests/ciTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,13 @@
"Test_TC_BINFO_2_2",
"Test_TC_ACL_2_5",
"Test_TC_ACL_2_6",
"Test_TC_SMOKECO_2_2",
"Test_TC_SMOKECO_2_3",
"Test_TC_SMOKECO_2_4",
"Test_TC_SMOKECO_2_5",
"Disabled because the power source configuration cluster is now deprecated and not present in all-clusters",
"Test_TC_PSCFG_1_1",
"Test_TC_PSCFG_2_1",
"Test_TC_PSCFG_2_2",
"Disabled due to SmokeCOAlarm not being enabled in Matter.framework for now:",
"Test_TC_SMCO_1_1",
"Test_TC_SMCO_2_1",
"Test_TC_SMCO_2_2",
"Test_TC_SMCO_2_3",
"Test_TC_SMCO_2_4",
"Test_TC_SMCO_2_5",
"Test_TC_SMCO_2_6"
"Test_TC_PSCFG_2_2"
]
}
1 change: 1 addition & 0 deletions examples/lock-app/silabs/include/LockManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class LockManager

bool Lock(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);
bool Unlock(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);
bool Unbolt(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err);

bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user);
bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier,
Expand Down
5 changes: 5 additions & 0 deletions examples/lock-app/silabs/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ bool LockManager::Unlock(chip::EndpointId endpointId, const Optional<chip::ByteS
return setLockState(endpointId, DlLockState::kUnlocked, pin, err);
}

bool LockManager::Unbolt(chip::EndpointId endpointId, const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err)
{
return setLockState(endpointId, DlLockState::kUnlocked, pin, err);
}

bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user)
{
VerifyOrReturnValue(userIndex > 0, false); // indices are one-indexed
Expand Down
20 changes: 18 additions & 2 deletions examples/lock-app/silabs/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
*/
void emberAfDoorLockClusterInitCallback(EndpointId endpoint) {}

bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional<ByteSpan> & pinCode,
bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
const Nullable<chip::NodeId> & nodeId, const Optional<chip::ByteSpan> & pinCode,
OperationErrorEnum & err)
{
ChipLogProgress(Zcl, "Door Lock App: Lock Command endpoint=%d", endpointId);
Expand All @@ -70,7 +71,8 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const O
return status;
}

bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional<ByteSpan> & pinCode,
bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
const Nullable<chip::NodeId> & nodeId, const Optional<chip::ByteSpan> & pinCode,
OperationErrorEnum & err)
{
ChipLogProgress(Zcl, "Door Lock App: Unlock Command endpoint=%d", endpointId);
Expand All @@ -82,6 +84,20 @@ bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const

return status;
}
// TODO : Add helper function to call from the Unlock command if we establish Unbolt doesn't need a different behaviour than Unlock
bool emberAfPluginDoorLockOnDoorUnboltCommand(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
const Nullable<chip::NodeId> & nodeId, const Optional<ByteSpan> & pinCode,
OperationErrorEnum & err)
{
ChipLogProgress(Zcl, "Door Lock App: Unbolt Command endpoint=%d", endpointId);
bool status = LockMgr().Unlock(endpointId, pinCode, err);
if (status == true)
{
LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::UNLOCK_ACTION);
}

return status;
}

bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType,
EmberAfPluginDoorLockCredentialInfo & credential)
Expand Down
1 change: 1 addition & 0 deletions examples/placeholder/linux/apps/app1/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ source_set("app1") {
]

sources = [
"../../resource-monitoring-instances.cpp",
"../../src/bridged-actions-stub.cpp",
"../../static-supported-modes-manager.cpp",
]
Expand Down
1 change: 1 addition & 0 deletions examples/placeholder/linux/apps/app2/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ source_set("app2") {
]

sources = [
"../../resource-monitoring-instances.cpp",
"../../src/bridged-actions-stub.cpp",
"../../static-supported-modes-manager.cpp",
]
Expand Down
63 changes: 63 additions & 0 deletions examples/placeholder/linux/include/resource-monitoring-instances.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* 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.
*/

#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/clusters/resource-monitoring-server/resource-monitoring-cluster-objects.h>
#include <app/clusters/resource-monitoring-server/resource-monitoring-server.h>

/// This is an application level Instance to handle ActivatedCarbonfilterMonitoringInstance commands according to the specific
/// business logic.
class ActivatedCarbonFilterMonitoringInstance : public chip::app::Clusters::ResourceMonitoring::Instance
{
private:
CHIP_ERROR AppInit() override;
chip::Protocols::InteractionModel::Status PreResetCondition() override;
chip::Protocols::InteractionModel::Status PostResetCondition() override;

public:
ActivatedCarbonFilterMonitoringInstance(
chip::EndpointId aEndpointId, uint32_t aFeature,
chip::app::Clusters::ResourceMonitoring::Attributes::DegradationDirection::TypeInfo::Type aDegradationDirection,
bool aResetConditionCommandSupported) :
Instance(aEndpointId, chip::app::Clusters::ActivatedCarbonFilterMonitoring::Id, aFeature, aDegradationDirection,
aResetConditionCommandSupported){};
};

/// This is an application level instance to handle HepaFilterMonitoringInstance commands according to the specific business logic.
class HepaFilterMonitoringInstance : public chip::app::Clusters::ResourceMonitoring::Instance
{
private:
CHIP_ERROR AppInit() override;
chip::Protocols::InteractionModel::Status PreResetCondition() override;
chip::Protocols::InteractionModel::Status PostResetCondition() override;

public:
HepaFilterMonitoringInstance(
chip::EndpointId aEndpointId, uint32_t aFeature,
chip::app::Clusters::ResourceMonitoring::Attributes::DegradationDirection::TypeInfo::Type aDegradationDirection,
bool aResetConditionCommandSupported) :
Instance(aEndpointId, chip::app::Clusters::HepaFilterMonitoring::Id, aFeature, aDegradationDirection,
aResetConditionCommandSupported){};
};

class ImmutableReplacementProductListManager : public chip::app::Clusters::ResourceMonitoring::ReplacementProductListManager
{
public:
CHIP_ERROR
Next(chip::app::Clusters::ResourceMonitoring::ReplacementProductStruct & item) override;
};
Loading

0 comments on commit d1616b6

Please sign in to comment.