Skip to content

Commit 4d1de40

Browse files
ksperling-appleStephaneGUELEC
authored andcommitted
Make the TBRM tests work (project-chip#34864)
* Add files via upload Add yaml test script for TBRM * Update TEST_TC_TBRM_2.2.yaml * Update TEST_TC_TBRM_2.3.yaml * Update TEST_TC_TBRM_2.4.yaml * Implement TBRM PanChange support in the network-manager-app example * Make the TC_TBRM tests work Test 2.4 has been merged into 2.2 as this makes it easier to test. Test 2.5 has been removed because SetPendingDataset does not require FailSafe. * Rename test files to match naming convention * Restyle * Start without an active dataset in TC_TBRM_2_3 This is so the test passes when running against the example app in CI. * Tweaks based on feedback from Stephane * Align with test plan --------- Co-authored-by: StephaneGUELEC <94045077+StephaneGUELEC@users.noreply.github.com>
1 parent 4c77971 commit 4d1de40

File tree

9 files changed

+366
-4
lines changed

9 files changed

+366
-4
lines changed

examples/network-manager-app/linux/tbrm.cpp

+23-3
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,23 @@ class FakeBorderRouterDelegate final : public ThreadBorderRouterManagement::Dele
9494

9595
mActivateDatasetCallback = callback;
9696
mActivateDatasetSequence = sequenceNum;
97-
DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(3000), CompleteDatasetActivation, this);
97+
DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(1000), ActivateActiveDataset, this);
9898
}
9999

100100
CHIP_ERROR CommitActiveDataset() override { return CHIP_NO_ERROR; }
101101
CHIP_ERROR RevertActiveDataset() override { return CHIP_ERROR_NOT_IMPLEMENTED; }
102-
CHIP_ERROR SetPendingDataset(const Thread::OperationalDataset & pendingDataset) override { return CHIP_ERROR_NOT_IMPLEMENTED; }
102+
103+
CHIP_ERROR SetPendingDataset(const Thread::OperationalDataset & pendingDataset) override
104+
{
105+
ReturnErrorOnFailure(mPendingDataset.Init(pendingDataset.AsByteSpan()));
106+
uint32_t delayTimerMillis;
107+
ReturnErrorOnFailure(mPendingDataset.GetDelayTimer(delayTimerMillis));
108+
DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(delayTimerMillis), ActivatePendingDataset, this);
109+
return CHIP_NO_ERROR;
110+
}
103111

104112
private:
105-
static void CompleteDatasetActivation(System::Layer *, void * context)
113+
static void ActivateActiveDataset(System::Layer *, void * context)
106114
{
107115
auto * self = static_cast<FakeBorderRouterDelegate *>(context);
108116
auto * callback = self->mActivateDatasetCallback;
@@ -111,6 +119,18 @@ class FakeBorderRouterDelegate final : public ThreadBorderRouterManagement::Dele
111119
callback->OnActivateDatasetComplete(sequenceNum, CHIP_NO_ERROR);
112120
}
113121

122+
static void ActivatePendingDataset(System::Layer *, void * context)
123+
{
124+
auto * self = static_cast<FakeBorderRouterDelegate *>(context);
125+
self->mActiveDataset.Init(self->mPendingDataset.AsByteSpan());
126+
self->mPendingDataset.Clear();
127+
// This could just call MatterReportingAttributeChangeCallback directly
128+
self->mAttributeChangeCallback->ReportAttributeChanged(
129+
ThreadBorderRouterManagement::Attributes::ActiveDatasetTimestamp::Id);
130+
self->mAttributeChangeCallback->ReportAttributeChanged(
131+
ThreadBorderRouterManagement::Attributes::PendingDatasetTimestamp::Id);
132+
}
133+
114134
AttributeChangeCallback * mAttributeChangeCallback;
115135
Thread::OperationalDataset mActiveDataset;
116136
Thread::OperationalDataset mPendingDataset;

examples/network-manager-app/network-manager-common/network-manager-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,7 @@ endpoint 1 {
18921892
handle command GetPendingDatasetRequest;
18931893
handle command DatasetResponse;
18941894
handle command SetActiveDatasetRequest;
1895+
handle command SetPendingDatasetRequest;
18951896
}
18961897

18971898
server cluster ThreadNetworkDirectory {

examples/network-manager-app/network-manager-common/network-manager-app.zap

+9-1
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,14 @@
34073407
"source": "client",
34083408
"isIncoming": 1,
34093409
"isEnabled": 1
3410+
},
3411+
{
3412+
"name": "SetPendingDatasetRequest",
3413+
"code": 4,
3414+
"mfgCode": null,
3415+
"source": "client",
3416+
"isIncoming": 1,
3417+
"isEnabled": 1
34103418
}
34113419
],
34123420
"attributes": [
@@ -3500,7 +3508,7 @@
35003508
"storageOption": "External",
35013509
"singleton": 0,
35023510
"bounded": 0,
3503-
"defaultValue": "",
3511+
"defaultValue": null,
35043512
"reportable": 1,
35053513
"minInterval": 1,
35063514
"maxInterval": 65534,

src/app/tests/suites/certification/PICS.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -10298,6 +10298,17 @@ PICS:
1029810298
- label: "Does the device implement the ActiveEndpoints attribute?"
1029910299
id: PWRTL.S.A0001
1030010300

10301+
#
10302+
# Thread Border Router Management Cluster
10303+
#
10304+
- label:
10305+
"Does the device implement the Thread Border Router Management cluster
10306+
as a server?"
10307+
id: TBRM.S
10308+
10309+
- label: "Does the device support the PanChange feature?"
10310+
id: TBRM.S.F00
10311+
1030110312
#
1030210313
# Thread Network Directory Cluster
1030310314
#
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: "[TC-TBRM-2.2] Initial Dataset configuration of Thread Border Router"
16+
17+
PICS:
18+
- TBRM.S
19+
20+
config:
21+
nodeId: 0x12344321
22+
cluster: Thread Border Router Management
23+
endpoint: 1
24+
PIXIT.TBRM.THREAD_ACTIVE_DATASET:
25+
type: octet_string
26+
defaultValue: "hex:0e080000000000010000000300001235060004001fffe002082ad51c02fe8f64f20708fddb8af85255f93a051083e2b9b2cc609b00125adbf823ea2ab20102c4d904100a133626c411d7de02a570ca3c3d80470c0402a0f7f8031054687265616441637469766554657374"
27+
# Active Timestamp ----^^^^^^^^^^^^^^^^
28+
PIXIT.TBRM.THREAD_ACTIVE_DATASET.ACTIVE_TIMESTAMP: 0x10000
29+
PIXIT.TBRM.THREAD_INVALID_DATASET:
30+
type: octet_string
31+
defaultValue: "hex:00112233"
32+
33+
# Precondition:
34+
# The DUT does not have an Active Dataset
35+
36+
tests:
37+
- label: "Wait for the commissioned device to be retrieved"
38+
cluster: DelayCommands
39+
command: WaitForCommissionee
40+
arguments:
41+
values:
42+
- name: nodeId
43+
value: nodeId
44+
45+
- label: "TH reads the ActiveDatasetTimestamp attribute from the DUT"
46+
command: readAttribute
47+
attribute: ActiveDatasetTimestamp
48+
response:
49+
value: null
50+
51+
- label: "TH reads the PendingDatasetTimestamp attribute from the DUT"
52+
command: readAttribute
53+
attribute: PendingDatasetTimestamp
54+
response:
55+
value: null
56+
57+
- label:
58+
"TH sends a valid ActiveDatasetRequest command to the DUT without
59+
having armed the fail-safe"
60+
command: SetActiveDatasetRequest
61+
arguments:
62+
values:
63+
- name: ActiveDataset
64+
value: PIXIT.TBRM.THREAD_ACTIVE_DATASET
65+
response:
66+
error: FAILSAFE_REQUIRED
67+
68+
- label: "TH sends ArmFailSafe command to the DUT"
69+
cluster: General Commissioning
70+
command: ArmFailSafe
71+
endpoint: 0
72+
arguments:
73+
values:
74+
- name: ExpiryLengthSeconds
75+
value: 60
76+
- name: Breadcrumb
77+
value: 1
78+
79+
- label: "TH sends an invalid ActiveDatasetRequest command to the DUT"
80+
command: SetActiveDatasetRequest
81+
arguments:
82+
values:
83+
- name: ActiveDataset
84+
value: PIXIT.TBRM.THREAD_INVALID_DATASET
85+
response:
86+
error: INVALID_COMMAND
87+
88+
- label: "TH sends a valid ActiveDatasetRequest command to the DUT"
89+
command: SetActiveDatasetRequest
90+
arguments:
91+
values:
92+
- name: ActiveDataset
93+
value: PIXIT.TBRM.THREAD_ACTIVE_DATASET
94+
95+
- label: "TH reads the InterfaceEnabled attribute from the DUT"
96+
command: readAttribute
97+
attribute: InterfaceEnabled
98+
response:
99+
value: true
100+
101+
- label: "TH reads the ActiveDatasetTimestamp attribute from the DUT"
102+
command: readAttribute
103+
attribute: ActiveDatasetTimestamp
104+
response:
105+
value: PIXIT.TBRM.THREAD_ACTIVE_DATASET.ACTIVE_TIMESTAMP
106+
constraints:
107+
type: int64u
108+
109+
- label: "TH sends a valid GetActiveDatasetRequest command to the DUT"
110+
command: GetActiveDatasetRequest
111+
response:
112+
values:
113+
- name: Dataset
114+
value: PIXIT.TBRM.THREAD_ACTIVE_DATASET
115+
constraints:
116+
type: octet_string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: "[TC-TBRM-2.3] Change dataset configuration of Thread Border Router"
16+
17+
PICS:
18+
- TBRM.S
19+
- TBRM.S.F00
20+
21+
config:
22+
nodeId: 0x12344321
23+
cluster: Thread Border Router Management
24+
endpoint: 1
25+
PIXIT.TBRM.THREAD_ACTIVE_DATASET:
26+
type: octet_string
27+
defaultValue: "hex:0e080000000000010000000300001235060004001fffe002082ad51c02fe8f64f20708fddb8af85255f93a051083e2b9b2cc609b00125adbf823ea2ab20102c4d904100a133626c411d7de02a570ca3c3d80470c0402a0f7f8031054687265616441637469766554657374"
28+
PIXIT.TBRM.THREAD_PENDING_DATASET:
29+
type: octet_string
30+
defaultValue: "hex:0e08000000000002000033080000000000010000340400004e2035060004001fffe002082ad51c02fe8f64f20708fddb8af85255f93a051083e2b9b2cc609b00125adbf823ea2ab20102c4d904100a133626c411d7de02a570ca3c3d80470c0402a0f7f8030d54687265616450656e64696e67000300000c"
31+
# Active Timestamp ----^^^^^^^^^^^^^^^^
32+
# Pending Timestamp -----------------------^^^^^^^^^^^^^^^^
33+
# Delay Timer -------------------------------------------------^^^^^^^^ == 20000ms Note: waitForReport has a hard-coded 30 second timeout
34+
35+
tests:
36+
- label: "Wait for the commissioned device to be retrieved"
37+
cluster: DelayCommands
38+
command: WaitForCommissionee
39+
arguments:
40+
values:
41+
- name: nodeId
42+
value: nodeId
43+
# Step 1
44+
- label: "TH reads the ActiveDatasetTimestamp attribute from the DUT"
45+
command: readAttribute
46+
attribute: ActiveDatasetTimestamp
47+
response:
48+
saveAs: initialActiveTimestamp
49+
constraints:
50+
type: int64u
51+
52+
- label: "If the ActiveDatasetTimestamp attribute not null, go to step 4"
53+
cluster: EqualityCommands
54+
command: UnsignedNumberEquals
55+
arguments:
56+
values:
57+
- name: Value1
58+
value: initialActiveTimestamp
59+
- name: Value2
60+
value: null
61+
response:
62+
- values:
63+
- name: Equals
64+
saveAs: noActiveDataset
65+
66+
# Step 2
67+
- label: "TH sends ArmFailSafe command to the DUT"
68+
runIf: noActiveDataset
69+
cluster: General Commissioning
70+
command: ArmFailSafe
71+
endpoint: 0
72+
arguments:
73+
values:
74+
- name: ExpiryLengthSeconds
75+
value: 60
76+
- name: Breadcrumb
77+
value: 1
78+
79+
# Step 3
80+
- label: "TH sends a valid ActiveDatasetRequest command to the DUT"
81+
runIf: noActiveDataset
82+
command: SetActiveDatasetRequest
83+
arguments:
84+
values:
85+
- name: ActiveDataset
86+
value: PIXIT.TBRM.THREAD_ACTIVE_DATASET
87+
88+
# Step 4
89+
- label: "TH reads the PendingDatasetTimestamp attribute from the DUT"
90+
command: readAttribute
91+
attribute: PendingDatasetTimestamp
92+
response:
93+
saveAs: initialPendingTimestamp
94+
constraints:
95+
type: int64u
96+
97+
# Step 5
98+
- label: "TH sends a SetPendingDatasetRequest command to the DUT"
99+
command: SetPendingDatasetRequest
100+
arguments:
101+
values:
102+
- name: PendingDataset
103+
value: PIXIT.TBRM.THREAD_PENDING_DATASET
104+
105+
# Step 6
106+
- label: "TH sends a GetPendingDatasetRequest command to the DUT"
107+
command: GetPendingDatasetRequest
108+
response:
109+
values:
110+
- name: Dataset
111+
constraints:
112+
type: octet_string
113+
# TODO: This should be PIXIT.TBRM.THREAD_PENDING_DATASET but ignoring the Delay Timer element if present
114+
115+
# Step 7
116+
- label: "TH reads the PendingDatasetTimestamp attribute from the DUT"
117+
command: readAttribute
118+
attribute: PendingDatasetTimestamp
119+
response:
120+
constraints:
121+
type: int64u
122+
notValue: initialPendingTimestamp
123+
124+
# Step 8
125+
- label:
126+
"TH subscribes to the ActiveDatasetTimestamp attribute from the DUT"
127+
command: subscribeAttribute
128+
attribute: ActiveDatasetTimestamp
129+
minInterval: 1
130+
maxInterval: 70
131+
response:
132+
constraints:
133+
type: int64u
134+
hasValue: true # not null
135+
136+
- label: "TH waits for an ActiveDatasetTimestamp report"
137+
command: waitForReport
138+
attribute: ActiveDatasetTimestamp
139+
# TODO: waitForReport uses a hard-coded timeout of 30s, should be configurable?
140+
response:
141+
constraints:
142+
hasValue: true
143+
144+
# Step 9
145+
- label: "TH reads the PendingDatasetTimestamp attribute from the DUT"
146+
command: readAttribute
147+
attribute: PendingDatasetTimestamp
148+
response:
149+
value: null
150+
151+
# Step 10
152+
- label: "TH sends a valid GetActiveDatasetRequest command to the DUT"
153+
command: GetActiveDatasetRequest
154+
response:
155+
values:
156+
- name: Dataset
157+
# TODO: This should be PIXIT.TBRM.THREAD_PENDING_DATASET without the Delay Timer and Pending Timestamp elements
158+
constraints:
159+
type: octet_string
160+
161+
# Step 11
162+
- label: "TH reads the InterfaceEnabled attribute from the DUT"
163+
command: readAttribute
164+
attribute: InterfaceEnabled
165+
response:
166+
value: true

src/app/tests/suites/certification/ci-pics-values

+4
Original file line numberDiff line numberDiff line change
@@ -3017,6 +3017,10 @@ PWRTL.S.F01=0
30173017
PWRTL.S.F02=1
30183018
PWRTL.S.F03=1
30193019

3020+
# Thread Border Router Management Cluster
3021+
TBRM.S=1
3022+
TBRM.S.F00=1
3023+
30203024
# Thread Network Directory Cluster
30213025
THNETDIR.S=1
30223026

0 commit comments

Comments
 (0)