Skip to content

adding backend support for nfc-wifi command#293

Closed
ArnoldBraine wants to merge 144 commits intoproject-chip:mainfrom
ArnoldBraine:nfc-wifi-work
Closed

adding backend support for nfc-wifi command#293
ArnoldBraine wants to merge 144 commits intoproject-chip:mainfrom
ArnoldBraine:nfc-wifi-work

Conversation

@ArnoldBraine
Copy link

rquidute and others added 30 commits October 22, 2024 21:11
* Updated package-dependency-list.txt

* Updated missing dependencies
* Reverting the BR_VARIANT option to the otbr start script

* Adding TODO to the script

* Adding missing comment char

* Updating Script Comment Year

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>

* Adding switch parameters options to the script

---------

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>
* replace erro with warning

* Update test_collections/matter/sdk_tests/support/python_testing/models/python_test_parser.py

Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>

* black error fix

* pr review

---------

Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>
* Fixing intermittent problem with Python's Base Manager

Creating the manager now only once in the SDK Container Init

* Refactoring and updating the unit tests with related mocks
* Updated python_testing references after sdk refactoring

* Removed no wanted file changes

* Updated matter_testing references

* Fixed line too long

* Fixed code - black

* Updated SDK SHA

* Removed commented code
* Isolate SDK docker pull script

* Changes after code review

---------

Co-authored-by: Romulo Quidute Filho <rquidute@apple.com>
* Isolate SDK docker pull script

* Rebasing

* Apply suggestions from code review

Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>

* Move call tp update-pull-sdk-docker-image.sh from setup.sh to update-sample-apps.sh

* Changes after code review

* Fixed CI issues

* Code review fixes

* Fixed unit tests

* Fixed mypy

---------

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>
Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>
Co-authored-by: Romulo Quidute Filho <rquidute@apple.com>
* Implemented changes for custom python test

* code review

* Code review

* Code reviewd

* Fixed code violations

* Chanegs after code review

* Remove unused import
* Fixed some python tests not listed

* code review
* Implement support to export project config

* Fix mypy

* Changed the returned schema and service endpoint name

* Added import project config

* Apply suggestions from code review

Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>

* code review

---------

Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>
* Added support to negated PICS

* Fixed flake

* Code review. No consider negatives PICS

* Update app/pics_applicable_test_cases.py

* Code review
* Remove unused file

* Updated cspell
* Fix CI issues from v2.12 branch

* Fixed merge

* Fix test case

* Updated SDK_DOCKER_IMAGE url

* Updated SDK_DOCKER_IMAGE url
…ing (#173)

* Add support for configuring terms and conditions in device commissioning

This commit introduces a new `enhanced_setup_flow` configuration
property to the test harness backend, allowing device manufacturers to
define the terms and conditions (T&C) that must be acknowledged and set
during device commissioning. These values are critical for supporting
the Terms and Conditions Certification Test Suite.

Key changes include:
- Added the `EnhancedSetupFlowConfig` class to `DutConfig`, which allows
  specifying the T&C version and user response required during
  commissioning.
- Updated `generate_command_arguments` in `utils.py` to append the
  necessary arguments for T&C validation and the device's commissioning
  method.
- Adjusted model validation to ensure the `enhanced_setup_flow` field is
  processed correctly within `DutConfig`.

These changes ensure the test harness can enforce manufacturer-specific
T&C values during the commissioning process, aligning with the broader
requirements of T&C validation.

* * Ran ./scripts/format.sh

* Update test_collections/matter/test_environment_config.py

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>

* Update app/user_prompt_support/uploaded_file_support.py

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>

* Update test_collections/matter/sdk_tests/support/performance_tests/utils.py

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>

* Update test_collections/matter/sdk_tests/support/python_testing/models/utils.py

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>

* Update test_collections/matter/sdk_tests/support/python_testing/models/utils.py

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>

* Update test_collections/matter/sdk_tests/support/python_testing/__init__.py

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>

* Revert changes to test_collections/matter/sdk_tests/support/performance_tests/utils.py

* Restyle test_environment_config.py

* test: Add in-test-commissioning-method parameter for manual commissioning validation

Add new parameter to control commissioning flow during tests, allowing manual
validation of the commissioning process instead of auto-commissioning. This
enables test cases to verify terms and conditions acknowledgements during the
commissioning flow.

- Add in-test-commissioning-method parameter to test flags
- Support manual commissioning flow validation
- Enable testing of T&C acknowledgement scenarios

* Add new field "enhanced_setup_flow" to exception message

* Cherry-pick test_python_parser.py from origin/main

* Cherry-pick python_test_parser.py from origin/main

* Revert "Cherry-pick python_test_parser.py from origin/main"

This reverts commit 5d65ce5.

* Revert "Cherry-pick test_python_parser.py from origin/main"

This reverts commit 2cd99b7.

* Removed broken test `test_python_parser.py`

* Revert "Removed broken test `test_python_parser.py`"

This reverts commit 48c0e32.

---------

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>
Updated Node.js installation source from setup_18.x to setup_20.x to
align with Ubuntu 22.04 base image requirements
* First implementation

* Implement prompt and copy files from/to contanier

* Unit tests

* Updated SKA SHA

* Unit test typo fixes

* Mypy flake8 fixes

* Mypy fixes

* Update test_collections/matter/sdk_tests/support/python_testing/models/utils.py

Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>

* Update test_collections/matter/sdk_tests/support/utils.py

Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>

* Code review

* Review fixes

* Remove unused import

---------

Co-authored-by: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com>
* Add logs for project config

* Updated cspell.json

* Update app/test_engine/test_runner.py

Co-authored-by: hiltonlima <116589806+hiltonlima@users.noreply.github.com>

* Fixed unit test

* Unit test

* Unit test

---------

Co-authored-by: hiltonlima <116589806+hiltonlima@users.noreply.github.com>
rquidute and others added 21 commits October 21, 2025 15:41
* Improve test_harness_client by using argparse

* Code review
* Added commissioning logs

* Update test_collections/matter/sdk_tests/support/python_testing/models/utils.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update test_collections/matter/sdk_tests/support/python_testing/models/utils.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Flake8

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Add equivalent shell command when using docker api

* Update app/container_manager/docker_shell_commands.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update app/container_manager/docker_shell_commands.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update app/container_manager/docker_shell_commands.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update test_collections/matter/sdk_tests/support/sdk_container.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update app/container_manager/docker_shell_commands.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update app/container_manager/docker_shell_commands.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Code review

* Flake8

* Code review

* Code review

* Code review

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Created shared constants script and added two Enums to the file

* Adding MessageKeysEnum as shared, removed original and changing all related imports

* Adding TestStateEnum and changing all relevant imports

* Exchanging for a app relative import in the models' init file

* Updating Copyright's Date Year

* Reverting python_tests SHA since it's not ready yet

* Updating Matter test scripts SHA
* Creating test manager and updating code logic to improve Python Testing initialization

* Updating file's year and removing Optional import from test manager

* Removing code duplication

* Adding forward reference type hint to Python Testing init

* Removing unnecessary imports and changing a too long line error from the test manager

* Removing unnecessary comment
* Updated SDK version to 68e03c17300eb42c0d3946130aa2a8f7a2a06632 for v1.5 final release

* Updated SDK_SHA to ca9d1118e097fe947b2aec1ba84f265d6cf2447e

* Update .version_information

Co-authored-by: antonio-amjr <116589331+antonio-amjr@users.noreply.github.com>

---------

Co-authored-by: antonio-amjr <116589331+antonio-amjr@users.noreply.github.com>
* Updated SDK version to 68e03c17300eb42c0d3946130aa2a8f7a2a06632 for v1.5 final release

* Updated SDK_SHA to ca9d1118e097fe947b2aec1ba84f265d6cf2447e

* Implement code to make log synchronization configurable

* Run black

* Code review

* Updated python_tests submodule

* Code review
* Fixing Custom Name for presentation and adding symbolic links for easy access to the custom folders

* Gemini's suggestion: Improving readability for the custom suffix variable processing logic
* Fixing Backend's API for the CLI Test Run Execution

* Gemini suggestions: Updating logic for efficiency

Also avoiding modifying external variable.

* Solve flake8 error in singleton.py file
…ng directories (#285)

* Fix update-paa-certs.sh permission error

* Code review
* Adding chip-server information API

* Updating endpoint to use Chip Server Info schema
…rds without pagination (#286)

* Add sort_order to GET test_run_execution

* Add support to sort results and retrive all records from test_run_execution

* Update app/tests/crud/test_test_run_execution.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update app/crud/crud_test_run_execution.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update app/crud/crud_test_run_execution.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Improved logic to load json file, while launching. This avoids unpredicable unit tests failing due to race condition

* Flake8

* Code review - Mock read python test JSON file

* Code review - organize imports and remove useless code

* Code review - flake8

* Code review - flake8

* Code review - fix unit test

* Code revier

* Code review

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…g Code (#287)

* Updating CHIP Server Info endpoint to include Manual Pairing Code

* Gemini's Suggestion: Improving logic

* Adding break to leave out of the for loop as soon as possible
* Skip load custom tests step if no custom tests were found

* Update test_collections/matter/sdk_tests/support/python_testing/test_manager.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…#289)

* Adding support to the CLI's double dash extra arguments feature

* Improving logic and fixing comment

* Updating endpoint's comments

Adding note for the scenario where both configs are provided
…n logging (#290)

* Implemented configuration for enabling/disabling container information logging

* Code review - Gemini
…#291)

* Fixes for Python tests being loaded twice during Test Harness startup

* Code review
@CLAassistant
Copy link

CLAassistant commented Feb 4, 2026

CLA assistant check
All committers have signed the CLA.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ArnoldBraine, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces full backend support for NFC-WiFi commissioning, enabling devices to be paired using a combination of Near Field Communication and Wi-Fi. The changes integrate this new pairing mode across various utility functions, configuration enums, and testing frameworks, ensuring a robust and testable implementation for NFC-WiFi based device commissioning.

Highlights

  • New Pairing Mode: Added NFC_WIFI as a new device under test (DUT) pairing mode in the DutPairingModeEnum.
  • Backend Support for NFC-WiFi: Implemented comprehensive backend support for NFC-WiFi pairing, including handling WiFi SSID and passphrase arguments for commissioning commands.
  • MatterYAMLRunner Extension: Introduced a new pairing_nfc_wifi asynchronous method in MatterYAMLRunner to facilitate NFC-WiFi pairing commands.
  • Chip Suite Integration: Extended the chip_suite to correctly handle NFC-WiFi pairing, including disabling polkit for PCSC reader usage in Docker environments when this pairing mode is active.
  • New Test Cases: Added dedicated unit tests (test_generate_command_arguments_nfc_wifi and test_pairing_NFC_wifi_command_params) to ensure the correct functionality and parameter generation for NFC-WiFi pairing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • test_collections/matter/sdk_tests/support/python_testing/models/utils.py
    • Extended generate_command_arguments to include NFC_WIFI when appending WiFi SSID and passphrase arguments.
  • test_collections/matter/sdk_tests/support/tests/python_tests/test_utils.py
    • Added test_generate_command_arguments_nfc_wifi to verify command argument generation for NFC-WiFi pairing.
  • test_collections/matter/sdk_tests/support/tests/yaml_tests/test_matter_yaml_runner.py
    • Added test_pairing_NFC_wifi_command_params to validate the command parameters generated for NFC-WiFi pairing.
  • test_collections/matter/sdk_tests/support/yaml_tests/matter_yaml_runner.py
    • Defined PAIRING_MODE_NFC_WIFI constant.
    • Implemented the pairing_nfc_wifi asynchronous method to handle NFC-WiFi pairing logic.
  • test_collections/matter/sdk_tests/support/yaml_tests/models/chip_suite.py
    • Modified the setup method to disable polkit for NFC_WIFI pairing mode, similar to NFC_THREAD.
    • Updated __pair_with_dut to dispatch to the new __pair_with_dut_nfc_wifi method for NFC-WiFi pairing.
    • Added __pair_with_dut_nfc_wifi method to encapsulate the specific pairing logic for NFC-WiFi.
  • test_collections/matter/test_environment_config.py
    • Added NFC_WIFI to the DutPairingModeEnum enumeration.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds backend support for the nfc-wifi command, which is a good extension of the existing functionality. The changes are logical and cover configuration, command generation, and testing. I've identified a bug in one of the new tests where an incorrect value is being asserted, which needs to be fixed. Additionally, I've provided several suggestions to improve code readability, consistency, and maintainability by reducing code duplication and adhering to Python's style conventions. Addressing these points will enhance the overall quality of the code.

Comment on lines +85 to +88
if (
pairing_mode == DutPairingModeEnum.BLE_WIFI
or pairing_mode == DutPairingModeEnum.NFC_WIFI
):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved readability and conciseness, you can use the in operator with a tuple to check if pairing_mode is one of the specified values.

    if pairing_mode in (DutPairingModeEnum.BLE_WIFI, DutPairingModeEnum.NFC_WIFI):

chip_server._ChipServer__node_id = None

@pytest.mark.asyncio
async def test_pairing_NFC_wifi_command_params() -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to PEP 8 naming conventions, function names should be in snake_case. To maintain consistency with other tests in this file, please rename test_pairing_NFC_wifi_command_params.

Suggested change
async def test_pairing_NFC_wifi_command_params() -> None:
async def test_pairing_nfc_wifi_command_params() -> None:

setup_code,
discriminator,
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This blank line is unnecessary and can be removed for cleaner code.

Comment on lines +74 to +77
if (
self.config_matter.dut_config.pairing_mode is DutPairingModeEnum.NFC_THREAD
or self.config_matter.dut_config.pairing_mode is DutPairingModeEnum.NFC_WIFI
):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved readability and conciseness, you can use the in operator with a tuple to check if pairing_mode is one of the specified values.

        if self.config_matter.dut_config.pairing_mode in (DutPairingModeEnum.NFC_THREAD, DutPairingModeEnum.NFC_WIFI):

Comment on lines +168 to +177
async def __pair_with_dut_nfc_wifi(self) -> bool:
if self.config_matter.network.wifi is None:
raise DUTCommissioningError("Tool config is missing wifi config.")

return await self.runner.pairing_nfc_wifi(
ssid=self.config_matter.network.wifi.ssid,
password=self.config_matter.network.wifi.password,
setup_code=self.config_matter.dut_config.setup_code,
discriminator=self.config_matter.dut_config.discriminator,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This new method __pair_with_dut_nfc_wifi is very similar to __pair_with_dut_ble_wifi and __pair_with_dut_wifipaf_wifi, leading to code duplication. To improve maintainability, consider refactoring this logic into a shared private helper method.

For example, you could create a helper that takes the specific pairing function as an argument:

from typing import Callable

async def __pair_with_dut_wifi(self, pairing_method: Callable) -> bool:
    if self.config_matter.network.wifi is None:
        raise DUTCommissioningError("Tool config is missing wifi config.")

    return await pairing_method(
        ssid=self.config_matter.network.wifi.ssid,
        password=self.config_matter.network.wifi.password,
        setup_code=self.config_matter.dut_config.setup_code,
        discriminator=self.config_matter.dut_config.discriminator,
    )

Then, this method and the others could be simplified to:

async def __pair_with_dut_nfc_wifi(self) -> bool:
    return await self.__pair_with_dut_wifi(self.runner.pairing_nfc_wifi)

This would reduce code duplication and make the code easier to maintain. While this change would also affect other methods outside this diff, it's a good opportunity to consider this refactoring.

Copy link
Contributor

@antonio-amjr antonio-amjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ArnoldBraine,

Can you please rebase the PR to point to the appropriate release branch?
Since we're working on the Matter 1.6, the base should be v2.15-develop branch.

ArnoldBraine and others added 2 commits February 4, 2026 15:35
…est_utils.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ArnoldBraine
Copy link
Author

Hi @ArnoldBraine,

Can you please rebase the PR to point to the appropriate release branch? Since we're working on the Matter 1.6, the base should be v2.15-develop branch.

I had trouble with rebasing the PR, so i created a new one with the right base: #294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

Comments