Skip to content

Commit

Permalink
Merge branch 'master' into add-water-heater-management-to-all-cluster…
Browse files Browse the repository at this point in the history
…s-app
  • Loading branch information
PeterC1965 authored Jul 25, 2024
2 parents 1976356 + 1b1340f commit 13bfff9
Show file tree
Hide file tree
Showing 14 changed files with 379 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ CHIP_ERROR OpenCommissioningWindowCommand::RunCommand()
VerifyOrReturnError(mSalt.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
return mWindowOpener->OpenCommissioningWindow(Controller::CommissioningWindowVerifierParams()
.SetNodeId(mNodeId)
.SetEndpointId(mEndpointId)
.SetTimeout(mCommissioningWindowTimeout)
.SetIteration(mIteration)
.SetDiscriminator(mDiscriminator)
Expand All @@ -50,6 +51,7 @@ CHIP_ERROR OpenCommissioningWindowCommand::RunCommand()
SetupPayload ignored;
return mWindowOpener->OpenCommissioningWindow(Controller::CommissioningWindowPasscodeParams()
.SetNodeId(mNodeId)
.SetEndpointId(mEndpointId)
.SetTimeout(mCommissioningWindowTimeout)
.SetIteration(mIteration)
.SetDiscriminator(mDiscriminator)
Expand Down
18 changes: 18 additions & 0 deletions examples/shell/nrfconnect/sysbuild.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2024 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.
#

SB_CONFIG_MATTER=y
SB_CONFIG_MATTER_OTA=n
9 changes: 5 additions & 4 deletions examples/tv-casting-app/linux/simple-app-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool gCommissionerGeneratedPasscodeFlowRunning = false;

DiscoveryDelegateImpl * DiscoveryDelegateImpl::_discoveryDelegateImpl = nullptr;
bool gAwaitingCommissionerPasscodeInput = false;
LinuxCommissionableDataProvider gSimpleAppCommissionableDataProvider;
std::shared_ptr<matter::casting::core::CastingPlayer> targetCastingPlayer;

DiscoveryDelegateImpl * DiscoveryDelegateImpl::GetInstance()
Expand Down Expand Up @@ -470,9 +471,8 @@ CHIP_ERROR CommandHandler(int argc, char ** argv)
// Commissioner-generated passcode, and then update the CastigApp's AppParameters to update the commissioning session's
// passcode.
LinuxDeviceOptions::GetInstance().payload.setUpPINCode = userEnteredPasscode;
LinuxCommissionableDataProvider gCommissionableDataProvider;
CHIP_ERROR err = CHIP_NO_ERROR;
err = InitCommissionableDataProvider(gCommissionableDataProvider, LinuxDeviceOptions::GetInstance());
CHIP_ERROR err = CHIP_NO_ERROR;
err = InitCommissionableDataProvider(gSimpleAppCommissionableDataProvider, LinuxDeviceOptions::GetInstance());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer,
Expand All @@ -482,7 +482,8 @@ CHIP_ERROR CommandHandler(int argc, char ** argv)
}
// Update the CommissionableDataProvider stored in this CastingApp's AppParameters and the CommissionableDataProvider to
// be used for the commissioning session.
err = matter::casting::core::CastingApp::GetInstance()->UpdateCommissionableDataProvider(&gCommissionableDataProvider);
err = matter::casting::core::CastingApp::GetInstance()->UpdateCommissionableDataProvider(
&gSimpleAppCommissionableDataProvider);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
{ (uint16_t) 0xBB8, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* MaxHeatSetpointLimit */ \
{ (uint16_t) 0x640, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* MinCoolSetpointLimit */ \
{ (uint16_t) 0xC80, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* MaxCoolSetpointLimit */ \
{ (uint16_t) 0x19, (uint16_t) 0x0, (uint16_t) 0x19 }, /* MinSetpointDeadBand */ \
{ (uint16_t) 0x19, (uint16_t) 0x0, (uint16_t) 0x7F }, /* MinSetpointDeadBand */ \
{ (uint16_t) 0x4, (uint16_t) 0x0, (uint16_t) 0x5 }, /* ControlSequenceOfOperation */ \
{ (uint16_t) 0x1, (uint16_t) 0x0, (uint16_t) 0x9 }, /* SystemMode */ \
\
Expand Down
35 changes: 35 additions & 0 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ void UpdateModeBaseCurrentModeToOnMode(EndpointId endpoint)

#endif // MATTER_DM_PLUGIN_MODE_BASE

template <typename EnumType>
bool IsKnownEnumValue(EnumType value)
{
return (EnsureKnownEnumValue(value) != EnumType::kUnknownEnumValue);
}

} // namespace

#ifdef MATTER_DM_PLUGIN_LEVEL_CONTROL
Expand Down Expand Up @@ -609,6 +615,35 @@ bool OnOffServer::offWithEffectCommand(app::CommandHandler * commandObj, const a
chip::EndpointId endpoint = commandPath.mEndpointId;
Status status = Status::Success;

if (effectId != EffectIdentifierEnum::kUnknownEnumValue)
{
// Depending on effectId value, effectVariant enum type varies.
// The following check validates that effectVariant value is valid in relation to the applicable enum type.
// DelayedAllOffEffectVariantEnum or DyingLightEffectVariantEnum
if (effectId == EffectIdentifierEnum::kDelayedAllOff &&
!IsKnownEnumValue(static_cast<DelayedAllOffEffectVariantEnum>(effectVariant)))
{
// The server does not support the given variant, it SHALL use the default variant.
effectVariant = to_underlying(DelayedAllOffEffectVariantEnum::kDelayedOffFastFade);
}
else if (effectId == EffectIdentifierEnum::kDyingLight &&
!IsKnownEnumValue(static_cast<DyingLightEffectVariantEnum>(effectVariant)))
{
// The server does not support the given variant, it SHALL use the default variant.
effectVariant = to_underlying(DyingLightEffectVariantEnum::kDyingLightFadeOff);
}
}
else
{
status = Status::ConstraintError;
}

if (status != Status::Success)
{
commandObj->AddStatus(commandPath, status);
return true;
}

if (SupportsLightingApplications(endpoint))
{
#ifdef MATTER_DM_PLUGIN_SCENES_MANAGEMENT
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/thermostat-server/thermostat-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
requested = *value;
if (!AutoSupported)
return imcode::UnsupportedAttribute;
if (requested < 0 || requested > 25)
if (requested < 0 || requested > 127)
return imcode::InvalidValue;
return imcode::Success;
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/tests/suites/certification/Test_TC_TSTAT_2_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ tests:
response:
constraints:
type: int8s
minValue: -25
maxValue: 25
minValue: -127
maxValue: 127

- label: "Step 13a: TH reads attribute OccupiedCoolingSetpoint from the DUT"
PICS: TSTAT.S.F01 && TSTAT.S.A0017 && TSTAT.S.A0018
Expand Down Expand Up @@ -426,7 +426,7 @@ tests:
constraints:
type: int8s
minValue: 0
maxValue: 25
maxValue: 127

- label: "Step 22: TH reads the RemoteSensing attribute from the DUT"
PICS: TSTAT.S.A001a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ limitations under the License.
<access op="read" privilege="view"/>
<access op="write" privilege="manage"/>
</attribute>
<attribute side="server" code="0x0010" define="LOCAL_TEMPERATURE_CALIBRATION" type="int8s" min="0xE7" max="0x19" writable="true" default="0x00" optional="true">
<attribute side="server" code="0x0010" define="LOCAL_TEMPERATURE_CALIBRATION" type="int8s" min="-127" max="127" writable="true" default="0x00" optional="true">
<description>LocalTemperatureCalibration</description>
<access op="write" privilege="manage"/>
</attribute>
Expand All @@ -361,7 +361,7 @@ limitations under the License.
<description>MaxCoolSetpointLimit</description>
<access op="write" privilege="manage"/>
</attribute>
<attribute side="server" code="0x0019" define="MIN_SETPOINT_DEAD_BAND" type="int8s" min="0" max="25" writable="true" default="25" optional="true">
<attribute side="server" code="0x0019" define="MIN_SETPOINT_DEAD_BAND" type="int8s" min="0" max="127" writable="true" default="25" optional="true">
<description>MinSetpointDeadBand</description>
<access op="write" privilege="manage"/>
</attribute>
Expand Down
6 changes: 3 additions & 3 deletions src/controller/CommissioningWindowOpener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const Commissionin
mCommissioningWindowVerifierCallback = nullptr;
mNodeId = params.GetNodeId();
mCommissioningWindowTimeout = params.GetTimeout();
mTargetEndpointId = params.GetEndpointId();

if (params.GetReadVIDPIDAttributes())
{
Expand Down Expand Up @@ -162,6 +163,7 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const Commissionin
mPBKDFIterations = params.GetIteration();
mCommissioningWindowOption = CommissioningWindowOption::kTokenWithProvidedPIN;
mDiscriminator.SetLongValue(params.GetDiscriminator());
mTargetEndpointId = params.GetEndpointId();

mNextStep = Step::kOpenCommissioningWindow;

Expand All @@ -173,9 +175,7 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindowInternal(Messaging:
{
ChipLogProgress(Controller, "OpenCommissioningWindow for device ID 0x" ChipLogFormatX64, ChipLogValueX64(mNodeId));

constexpr EndpointId kAdministratorCommissioningClusterEndpoint = 0;

ClusterBase cluster(exchangeMgr, sessionHandle, kAdministratorCommissioningClusterEndpoint);
ClusterBase cluster(exchangeMgr, sessionHandle, mTargetEndpointId);

if (mCommissioningWindowOption != CommissioningWindowOption::kOriginalSetupCode)
{
Expand Down
3 changes: 2 additions & 1 deletion src/controller/CommissioningWindowOpener.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ class CommissioningWindowOpener
Callback::Callback<OnOpenBasicCommissioningWindow> * mBasicCommissioningWindowCallback = nullptr;
SetupPayload mSetupPayload;
SetupDiscriminator mDiscriminator{};
NodeId mNodeId = kUndefinedNodeId;
NodeId mNodeId = kUndefinedNodeId;
EndpointId mTargetEndpointId = kRootEndpointId; // Default endpoint for Administrator Commissioning Cluster
System::Clock::Seconds16 mCommissioningWindowTimeout = System::Clock::kZero;
CommissioningWindowOption mCommissioningWindowOption = CommissioningWindowOption::kOriginalSetupCode;
Crypto::Spake2pVerifier mVerifier; // Used for non-basic commissioning.
Expand Down
9 changes: 9 additions & 0 deletions src/controller/CommissioningWindowParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <lib/core/CHIPCallback.h>
#include <lib/core/CHIPError.h>
#include <lib/core/DataModelTypes.h>
#include <lib/core/NodeId.h>
#include <lib/core/Optional.h>
#include <lib/support/Span.h>
Expand Down Expand Up @@ -53,6 +54,13 @@ class CommissioningWindowCommonParams
return static_cast<Derived &>(*this);
}

EndpointId GetEndpointId() const { return mEndpointId; }
Derived & SetEndpointId(EndpointId endpointId)
{
mEndpointId = endpointId;
return static_cast<Derived &>(*this);
}

System::Clock::Seconds16 GetTimeout() const { return mTimeout; }
// The duration for which the commissioning window should remain open.
Derived & SetTimeout(System::Clock::Seconds16 timeout)
Expand Down Expand Up @@ -82,6 +90,7 @@ class CommissioningWindowCommonParams

private:
NodeId mNodeId = kUndefinedNodeId;
EndpointId mEndpointId = kRootEndpointId; // Default endpoint for Administrator Commissioning Cluster
System::Clock::Seconds16 mTimeout = System::Clock::Seconds16(300); // Defaulting
uint32_t mIteration = 1000; // Defaulting
Optional<uint16_t> mDiscriminator = NullOptional; // Using optional type to avoid picking a sentinnel in valid range
Expand Down
14 changes: 13 additions & 1 deletion src/python_testing/TC_DeviceConformance.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import chip.clusters as Clusters
from basic_composition_support import BasicCompositionTests
from chip.tlv import uint
from choice_conformance_support import (evaluate_attribute_choice_conformance, evaluate_command_choice_conformance,
evaluate_feature_choice_conformance)
from conformance_support import ConformanceDecision, conformance_allowed
from global_attribute_ids import GlobalAttributeIds
from matter_testing_support import (AttributePathLocation, ClusterPathLocation, CommandPathLocation, MatterBaseTest, ProblemNotice,
Expand Down Expand Up @@ -188,7 +190,17 @@ def check_spec_conformance_for_commands(command_type: CommandType):
check_spec_conformance_for_commands(CommandType.ACCEPTED)
check_spec_conformance_for_commands(CommandType.GENERATED)

# TODO: Add choice checkers
feature_choice_problems = evaluate_feature_choice_conformance(
endpoint_id, cluster_id, self.xml_clusters, feature_map, attribute_list, all_command_list)
attribute_choice_problems = evaluate_attribute_choice_conformance(
endpoint_id, cluster_id, self.xml_clusters, feature_map, attribute_list, all_command_list)
command_choice_problem = evaluate_command_choice_conformance(
endpoint_id, cluster_id, self.xml_clusters, feature_map, attribute_list, all_command_list)

if feature_choice_problems or attribute_choice_problems or command_choice_problem:
success = False
problems.extend(feature_choice_problems + attribute_choice_problems + command_choice_problem)

print(f'success = {success}')
return success, problems

Expand Down
Loading

0 comments on commit 13bfff9

Please sign in to comment.