|
| 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() |
0 commit comments