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

Update rvc mode cluters with new mode restrictions #31560

Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
62ecf35
Updated step 3 in TC 1.1 for RvcRunMode and RvcCleanMode
hicklin Jan 19, 2024
2c00c99
Updated TC 1.2 for RvcRunMode and RvcCleanMode cluters.
hicklin Jan 19, 2024
7227a80
Added TC 2.2 for the RvcCleanMode cluster.
hicklin Jan 19, 2024
76cbde1
Restyled by autopep8
restyled-commits Jan 19, 2024
d3ffb58
Merge branch 'master' into update_rvc_mode_cluters_with_new_mode_rest…
hicklin Jan 22, 2024
cc5e3ed
Added TC 2.2 for the RvcRunMode cluster.
hicklin Jan 22, 2024
5dde47b
Merge branch 'master' into update_rvc_mode_cluters_with_new_mode_rest…
hicklin Jan 22, 2024
647d4f7
Removed unused imports.
hicklin Jan 22, 2024
423daf4
Regenerated zap files.
hicklin Jan 22, 2024
754d8de
Added the PICS provider methods to the new python tests.
hicklin Jan 22, 2024
a97b2c5
Merge branch 'master' into update_rvc_mode_cluters_with_new_mode_rest…
hicklin Jan 22, 2024
cf781ab
Changed the features supported by the RVC mode cluters in the all-clu…
hicklin Jan 23, 2024
41a67ae
Merge branch 'master' into update_rvc_mode_cluters_with_new_mode_rest…
hicklin Jan 23, 2024
d508cbc
Added the mapping mode tag to the all-clusters-app example
hicklin Jan 23, 2024
e08330c
Changed the response returned by the RVC clean mode's handler of the …
hicklin Jan 24, 2024
48ace96
Updated TC_RVCCLEAN_2_2 to remove incorrect type checks.
hicklin Jan 24, 2024
18f5040
Apply suggestions from code review
hicklin Jan 24, 2024
9cd3186
Updated the RVC run ChangeToMode handler in the all-clusters-app to m…
hicklin Jan 24, 2024
8a122a1
Updated the cl-pics-values for the RVC Run and Clean clusters.
hicklin Jan 24, 2024
1a89bae
Future proofed the enum to text function and change to using the --en…
hicklin Jan 24, 2024
ddd30b6
Fixed retrival of the endpoint setting.
hicklin Jan 24, 2024
1d066c4
Simplified some of the test code following review.
hicklin Jan 24, 2024
45505e4
Removed test steps to match the test plan.
hicklin Jan 24, 2024
7f2861c
Changed the capture of the endpoint for the RVC run and RVC clean tes…
hicklin Jan 24, 2024
4e49153
Restyled by clang-format
restyled-commits Jan 24, 2024
a8f10e6
Restyled by autopep8
restyled-commits Jan 24, 2024
d77738f
Merge branch 'master' into update_rvc_mode_cluters_with_new_mode_rest…
hicklin Jan 24, 2024
dc2f6ef
Regenerated zap files.
hicklin Jan 24, 2024
e46137d
Removed duplicate RVCRUNM PICS from the ci-pics-values.
hicklin Jan 25, 2024
f7ea7f5
Updated PICS.yaml to reflect the new PICS requirements for the RvcRun…
hicklin Jan 25, 2024
861434b
Made all RVC python tests consistent regarding the capture of the end…
hicklin Jan 25, 2024
98b544f
Apply typo suggestions from code review
hicklin Jan 25, 2024
31b6df2
Fixed the RVC clean handle change to mode in the all-clusters-app.
hicklin Jan 25, 2024
421186b
Merge branch 'update_rvc_mode_cluters_with_new_mode_restrictions' of …
hicklin Jan 25, 2024
7b08a3a
Restyled by clang-format
restyled-commits Jan 25, 2024
8329b67
Merge branch 'master' into update_rvc_mode_cluters_with_new_mode_rest…
hicklin Jan 25, 2024
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 @@ -41,6 +41,7 @@ class RvcRunModeDelegate : public ModeBase::Delegate
using ModeTagStructType = detail::Structs::ModeTagStruct::Type;
ModeTagStructType ModeTagsIdle[1] = { { .value = to_underlying(ModeTag::kIdle) } };
ModeTagStructType ModeTagsCleaning[1] = { { .value = to_underlying(ModeTag::kCleaning) } };
ModeTagStructType ModeTagsMapping[1] = { { .value = to_underlying(ModeTag::kMapping) } };

const detail::Structs::ModeOptionStruct::Type kModeOptions[3] = {
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Idle"),
Expand All @@ -49,10 +50,9 @@ class RvcRunModeDelegate : public ModeBase::Delegate
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Cleaning"),
.mode = ModeCleaning,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsCleaning) },
detail::Structs::ModeOptionStruct::Type{
.label = CharSpan::fromCharString("Mapping"),
.mode = ModeMapping,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsIdle) }, // todo set to no mode tags
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Mapping"),
.mode = ModeMapping,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsMapping) },
};

CHIP_ERROR Init() override;
Expand Down
10 changes: 4 additions & 6 deletions examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands:
// Our business logic states that we can only switch into the mapping state from the idle state.
if (NewMode == RvcRunMode::ModeMapping && currentMode != RvcRunMode::ModeIdle)
{
response.status = to_underlying(ModeBase::StatusCode::kGenericFailure);
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to the mapping mode is only allowed from idle"));
return;
}
Expand Down Expand Up @@ -112,8 +112,7 @@ void emberAfRvcRunModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
VerifyOrDie(gRvcRunModeDelegate == nullptr && gRvcRunModeInstance == nullptr);
gRvcRunModeDelegate = new RvcRunMode::RvcRunModeDelegate;
gRvcRunModeInstance =
new ModeBase::Instance(gRvcRunModeDelegate, 0x1, RvcRunMode::Id, chip::to_underlying(RvcRunMode::Feature::kOnOff));
gRvcRunModeInstance = new ModeBase::Instance(gRvcRunModeDelegate, 0x1, RvcRunMode::Id, 0);
gRvcRunModeInstance->Init();
}

Expand All @@ -132,7 +131,7 @@ void RvcCleanModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Command

if (rvcRunCurrentMode == RvcRunMode::ModeCleaning)
{
response.status = to_underlying(RvcCleanMode::StatusCode::kCleaningInProgress);
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
hicklin marked this conversation as resolved.
Show resolved Hide resolved
response.statusText.SetValue(chip::CharSpan::fromCharString("Cannot change the cleaning mode during a clean"));
return;
}
Expand Down Expand Up @@ -201,7 +200,6 @@ void emberAfRvcCleanModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
hicklin marked this conversation as resolved.
Show resolved Hide resolved
VerifyOrDie(gRvcCleanModeDelegate == nullptr && gRvcCleanModeInstance == nullptr);
gRvcCleanModeDelegate = new RvcCleanMode::RvcCleanModeDelegate;
gRvcCleanModeInstance =
new ModeBase::Instance(gRvcCleanModeDelegate, 0x1, RvcCleanMode::Id, chip::to_underlying(RvcCleanMode::Feature::kOnOff));
gRvcCleanModeInstance = new ModeBase::Instance(gRvcCleanModeDelegate, 0x1, RvcCleanMode::Id, 0);
gRvcCleanModeInstance->Init();
}
34 changes: 0 additions & 34 deletions src/app/tests/suites/certification/Test_TC_RVCCLEANM_1_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,13 @@ tests:
type: int16u

- label: "Step 3: TH reads from the DUT the FeatureMap attribute."
PICS: " !RVCCLEANM.S.F00 "
command: "readAttribute"
attribute: "FeatureMap"
response:
value: 0
constraints:
type: bitmap32

- label:
"Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the
correct bit set"
PICS: RVCCLEANM.S.F00
command: "readAttribute"
attribute: "FeatureMap"
response:
constraints:
type: bitmap32
hasMasksSet: [0x1]

plauric marked this conversation as resolved.
Show resolved Hide resolved
- label: "Step 4a: TH reads from the DUT the AttributeList attribute."
PICS: PICS_EVENT_LIST_ENABLED
command: "readAttribute"
Expand All @@ -79,28 +67,6 @@ tests:
type: list
contains: [0, 1, 65528, 65529, 65531, 65532, 65533]

- label:
"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF)
and optional attribute(OnMode) is in AttributeList from the DUT"
PICS: RVCCLEANM.S.F00
command: "readAttribute"
attribute: "AttributeList"
response:
constraints:
type: list
contains: [3]

- label:
"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF)
and optional attribute(OnMode) is not in AttributeList from the DUT"
PICS: " !RVCCLEANM.S.F00 "
command: "readAttribute"
attribute: "AttributeList"
response:
constraints:
type: list
excludes: [3]

- label: "Step 5: TH reads from the DUT the EventList attribute."
PICS: PICS_EVENT_LIST_ENABLED
command: "readAttribute"
Expand Down
36 changes: 1 addition & 35 deletions src/app/tests/suites/certification/Test_TC_RVCRUNM_1_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,14 @@ tests:
constraints:
type: int16u

- label: "Step 3a: TH reads from the DUT the FeatureMap attribute."
PICS: " !RVCRUNM.S.F00 "
- label: "Step 3: TH reads from the DUT the FeatureMap attribute."
command: "readAttribute"
attribute: "FeatureMap"
response:
value: 0
constraints:
type: bitmap32

- label:
"Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the
correct bit set"
PICS: RVCRUNM.S.F00
command: "readAttribute"
attribute: "FeatureMap"
response:
constraints:
type: bitmap32
hasMasksSet: [0x1]

plauric marked this conversation as resolved.
Show resolved Hide resolved
- label: "Step 4a: TH reads from the DUT the AttributeList attribute."
PICS: PICS_EVENT_LIST_ENABLED
command: "readAttribute"
Expand All @@ -79,28 +67,6 @@ tests:
type: list
contains: [0, 1, 65528, 65529, 65531, 65532, 65533]

- label:
"Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and
optional attribute(OnMode) is in AttributeList from the DUT"
PICS: RVCRUNM.S.F00
command: "readAttribute"
attribute: "AttributeList"
response:
constraints:
type: list
contains: [3]

- label:
"Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and
optional attribute(OnMode) is not in AttributeList from the DUT"
PICS: " !RVCRUNM.S.F00 "
command: "readAttribute"
attribute: "AttributeList"
response:
constraints:
type: list
excludes: [3]

- label: "Step 5: TH reads from the DUT the EventList attribute."
PICS: PICS_EVENT_LIST_ENABLED
command: "readAttribute"
Expand Down
9 changes: 3 additions & 6 deletions src/app/tests/suites/certification/ci-pics-values
Original file line number Diff line number Diff line change
Expand Up @@ -2438,11 +2438,9 @@ RVCCLEANM.S=1
#Server
RVCCLEANM.S.A0000=1
RVCCLEANM.S.A0001=1
RVCCLEANM.S.A0002=0
RVCCLEANM.S.A0003=1

#Feature
RVCCLEANM.S.F00=1
RVCCLEANM.S.F00=0

#commands
RVCCLEANM.S.C00.Rsp=1
Expand Down Expand Up @@ -2506,19 +2504,18 @@ RVCOPSTATE.C.C04.Tx=1

# RVC RUN MODE CLUSTER
RVCRUNM.S=1
RVCRUNM.S.F00=1
RVCRUNM.S.F00=0

#Server
RVCRUNM.S.A0000=1
RVCRUNM.S.A0001=1
RVCRUNM.S.A0002=0
RVCRUNM.S.A0003=1

#Commands
RVCRUNM.S.C00.Rsp=1
RVCRUNM.S.C01.Tx=1

RVCRUNM.S.M.CAN_TEST_MODE_FAILURE=1
RVCRUNM.S.M.CAN_MANUALLY_CONTROLLED=1

#PIXIT
PIXIT.RVCRUNM.MODE_CHANGE_FAIL=1
Expand Down
104 changes: 57 additions & 47 deletions src/python_testing/TC_RVCCLEANM_1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,26 @@
import logging

import chip.clusters as Clusters
from chip.clusters.Types import NullValue
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
from mobly import asserts

# This test requires several additional command line arguments
# run with
# --int-arg PIXIT_ENDPOINT:<endpoint>


class TC_RVCCLEANM_1_2(MatterBaseTest):
def __init__(self, *args):
super().__init__(*args)
self.endpoint = 0
self.commonTags = {0x0: 'Auto',
0x1: 'Quick',
0x2: 'Quiet',
0x3: 'LowNoise',
0x4: 'LowEnergy',
0x5: 'Vacation',
0x6: 'Min',
0x7: 'Max',
0x8: 'Night',
0x9: 'Day'}
self.cleanTags = [tag.value for tag in Clusters.RvcCleanMode.Enums.ModeTag]
self.supported_modes_dut = []

async def read_mod_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.RvcCleanMode
Expand All @@ -38,12 +48,7 @@ def pics_TC_RVCCLEANM_1_2(self) -> list[str]:

@async_test_body
async def test_TC_RVCCLEANM_1_2(self):

asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params,
"PIXIT_ENDPOINT must be included on the command line in "
"the --int-arg flag as PIXIT_ENDPOINT:<endpoint>")

self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT']
self.endpoint = self.matter_test_config.endpoint

attributes = Clusters.RvcCleanMode.Attributes

Expand All @@ -55,64 +60,69 @@ async def test_TC_RVCCLEANM_1_2(self):

logging.info("SupportedModes: %s" % (supported_modes))

# Verify that the list has at least 2 and at most 255 entries
asserts.assert_greater_equal(len(supported_modes), 2, "SupportedModes must have at least 2 entries!")
asserts.assert_less_equal(len(supported_modes), 255, "SupportedModes must have at most 255 entries!")

modes = []
# Verify that each ModeOptionsStruct entry has a unique Mode field value
hicklin marked this conversation as resolved.
Show resolved Hide resolved
for m in supported_modes:
if m.mode in modes:
if m.mode in self.supported_modes_dut:
asserts.fail("SupportedModes must have unique mode values!")
else:
modes.append(m.mode)
self.supported_modes_dut.append(m.mode)

# Verify that each ModeOptionsStruct entry has a unique Label field value
labels = []
for m in supported_modes:
if m.label in labels:
asserts.fail("SupportedModes must have unique mode label values!")
else:
labels.append(m.label)

# common mode tags
commonTags = {0x0: 'Auto',
0x1: 'Quick',
0x2: 'Quiet',
0x3: 'LowNoise',
0x4: 'LowEnergy',
0x5: 'Vacation',
0x6: 'Min',
0x7: 'Max',
0x8: 'Night',
0x9: 'Day'}

cleanTags = [tag.value for tag in Clusters.RvcCleanMode.Enums.ModeTag
if tag is not Clusters.RvcCleanMode.Enums.ModeTag.kUnknownEnumValue]

# Verify that each ModeOptionsStruct entry's ModeTags field has:
for m in supported_modes:
# * at least one entry
if len(m.modeTags) == 0:
asserts.fail("SupportedModes must have at least one mode tag!")

at_least_one_common_or_clean_tag = False
for t in m.modeTags:
is_mfg = (0x8000 <= t.value and t.value <= 0xBFFF)
asserts.assert_true(t.value in commonTags.keys() or t.value in cleanTags or is_mfg,
"Found a SupportedModes entry with invalid mode tag value!")
# * the values of the Value fields that are not larger than 16 bits
if t.value > 0xFFFF or t.value < 0:
asserts.fail("Mode tag values must not be larger than 16 bits!")

# * for each Value field: {isCommonOrDerivedOrMfgTagsVal}
is_mfg = (0x8000 <= t.value <= 0xBFFF)
if (t.value not in self.commonTags and
t.value not in self.cleanTags and
not is_mfg):
asserts.fail("Mode tag value is not a common tag, clean tag or vendor tag!")

# * for at least one Value field: {isCommonOrDerivedTagsVal}
if not is_mfg:
at_least_one_common_or_clean_tag = True

if not at_least_one_common_or_clean_tag:
asserts.fail("At least one mode tag must be a common tag or clean tag!")

# Verify that at least one ModeOptionsStruct entry includes either the
# Vacuum(0x4001) mode tag or the Mop(0x4002)mode tag in the ModeTags field
vacuum_mop_tags = [Clusters.RvcCleanMode.Enums.ModeTag.kVacuum, Clusters.RvcCleanMode.Enums.ModeTag.kMop]
has_vacuum_or_mop_mode_tag = False
cecille marked this conversation as resolved.
Show resolved Hide resolved
for m in supported_modes:
has_vacuum_or_mop_mode_tag = any(t.value in vacuum_mop_tags for t in m.modeTags)
if has_vacuum_or_mop_mode_tag:
break

asserts.assert_true(has_vacuum_or_mop_mode_tag,
"At least one ModeOptionsStruct entry must include either the ")
hicklin marked this conversation as resolved.
Show resolved Hide resolved

if self.check_pics("RVCCLEANM.S.A0001"):
self.print_step(3, "Read CurrentMode attribute")
current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)

logging.info("CurrentMode: %s" % (current_mode))
asserts.assert_true(current_mode in modes, "CurrentMode is not a supported mode!")

if self.check_pics("RVCCLEANM.S.A0003"):
self.print_step(4, "Read OnMode attribute")
on_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.OnMode)

logging.info("OnMode: %s" % (on_mode))
asserts.assert_true(on_mode in modes or on_mode == NullValue, "OnMode is not a supported mode!")

if self.check_pics("RVCCLEANM.S.A0002"):
self.print_step(5, "Read StartUpMode attribute")
startup_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.StartUpMode)

logging.info("StartUpMode: %s" % (startup_mode))
asserts.assert_true(startup_mode in modes or startup_mode == NullValue, "StartUpMode is not a supported mode!")
asserts.assert_true(current_mode in self.supported_modes_dut, "CurrentMode is not a supported mode!")


if __name__ == "__main__":
Expand Down
Loading
Loading