Skip to content

Commit 8e5f3f8

Browse files
Added TC_DD_3_23.py Script (#41309)
* Added TC_DD_3_23.py Script * Update the script with latest Test plan, added extra argument checker for nfc reader index * FIx for None type iterable bug for int-arg check * FIx for None type iterable bug for int-arg check * FIx for None type iterable bug for int-arg check * implemented new logic for nfc and int-arg check * fixed exit logic for nfc_reader_index * fixed syntax erros suggested by co-pilot * removed duplicate code block in runner.py * log the data from nfc tag instead of matter_test * Restyled by autopep8 * Restyled by isort * fixed CI job of linux code lint and disabled the nfc build for python env by default * added missing libs for nfc interaction * changed the commissioning args in CI test * updated runner.py to be in sync with master and updated ci run args * added setuppincode for CI execution argumennts * Updated the code and comments for NFC code as per comments * added some checks for nfc reader index and max ndef data length * Restyled by autopep8 * TC_DD_3_24.py will be skipped and documentation is improved * Added check for qr_code presence in command line args * Added data types to function arguments * Restyled by prettier-yaml * Restyled by autopep8 * Updated the code changes to ignore the identifier code in nfc-tag data * resolved comments from co-pilot * fixed mypy error on CI * Restyled by autopep8 * fixed suggestions by co-pilot * Updated code to be more readable --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 79e4f9d commit 8e5f3f8

File tree

8 files changed

+450
-38
lines changed

8 files changed

+450
-38
lines changed

integrations/docker/images/chip-cert-bins/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ RUN case ${TARGETPLATFORM} in \
295295
*) ;; \
296296
esac
297297

298-
RUN source scripts/activate.sh && scripts/build_python.sh -m platform -d true -i out/python_env
298+
RUN source scripts/activate.sh && scripts/build_python.sh -m platform -d true --enable_nfc true -i out/python_env
299299

300300
# Stage 3: Copy relevant cert bins to a minimal image to reduce size.
301301
FROM ubuntu:24.04
302302
ENV TZ=Etc/UTC
303303
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
304304
RUN apt-get update -y
305-
RUN apt-get install -y libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev avahi-utils iproute2 libcairo2-dev libgirepository1.0-dev python3-pip libpcsclite1 pcscd libcurl4 libgstreamer1.0-0 libgstreamer-plugins-base1.0-0 libavformat60 libavcodec60 libavutil58
305+
RUN apt-get install -y libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev avahi-utils iproute2 libcairo2-dev libgirepository1.0-dev python3-pip libpcsclite-dev libpcsclite1 pcscd libcurl4 libgstreamer1.0-0 libgstreamer-plugins-base1.0-0 libavformat60 libavcodec60 libavutil58
306306
WORKDIR /root/
307307
COPY --from=chip-build-cert-bins /root/.sdk-sha-version .sdk-sha-version
308308
RUN mkdir apps

scripts/build_python.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ echo_bold_white() {
3737
CHIP_ROOT=$(_normpath "$(dirname "$0")/..")
3838

3939
declare enable_ble=true
40-
declare enable_nfc=true
40+
declare enable_nfc=false
4141
declare enable_ipv4=true
4242
declare wifi_paf_config=""
4343
declare chip_detail_logging=false

src/python_testing/TC_DD_3_23.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# Copyright (c) 2025 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
import logging
19+
20+
from mobly import asserts
21+
22+
from matter.setup_payload import SetupPayload
23+
from matter.testing.matter_nfc_interaction import connect_read_nfc_tag_data
24+
from matter.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
25+
26+
logger = logging.getLogger(__name__)
27+
28+
29+
class TC_DD_3_23(MatterBaseTest):
30+
def desc_TC_DD_3_23(self) -> str:
31+
return "[TC-DD-3.23] NFC-based commissioning [DUT as Commissionee]"
32+
33+
def steps_TC_DD_3_23(self) -> list[TestStep]:
34+
return [
35+
TestStep(1, "Detecting the NFC Tag and reading the Payload", is_commissioning=False),
36+
TestStep(2, 'Validate the NFC bit in payload and Perform the commissioning')
37+
]
38+
39+
@async_test_body
40+
async def test_TC_DD_3_23(self):
41+
42+
# Step 1: Here we check if the Tag is connected to the Host machine and read the NFC Tag data
43+
self.step(1)
44+
nfc_tag_data = connect_read_nfc_tag_data(self.user_params.get("NFC_Reader_index", 0))
45+
logger.info(f"NFC Tag data : '{nfc_tag_data}'")
46+
self.matter_test_config.qr_code_content.append(nfc_tag_data)
47+
48+
# Step 2: the NFC tag data is parsed and checked if the device supports NFC commissioning and commission begins
49+
self.step(2)
50+
payload = SetupPayload().ParseQrCode(nfc_tag_data)
51+
asserts.assert_true(payload.supports_nfc_commissioning, "Device does not Support NFC Commissioning")
52+
self.matter_test_config.commissioning_method = self.matter_test_config.in_test_commissioning_method
53+
commissioning_success = await self.commission_devices()
54+
asserts.assert_true(commissioning_success, "Device Commissioning using nfc transport has failed")
55+
56+
57+
if __name__ == "__main__":
58+
default_matter_test_main()

src/python_testing/matter_testing_infrastructure/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pw_python_package("matter-testing-module") {
5252
"matter/testing/global_stash.py",
5353
"matter/testing/matchers.py",
5454
"matter/testing/matter_asserts.py",
55+
"matter/testing/matter_nfc_interaction.py",
5556
"matter/testing/matter_stack_state.py",
5657
"matter/testing/matter_test_config.py",
5758
"matter/testing/matter_testing.py",

0 commit comments

Comments
 (0)