Skip to content

Comments

Fixing pairing failure, where auto commissioner, when used back to back will fail pairings for devices on the network already#43251

Open
woody-apple wants to merge 2 commits intoproject-chip:masterfrom
woody-apple:bug-fix-commissioning
Open

Fixing pairing failure, where auto commissioner, when used back to back will fail pairings for devices on the network already#43251
woody-apple wants to merge 2 commits intoproject-chip:masterfrom
woody-apple:bug-fix-commissioning

Conversation

@woody-apple
Copy link
Contributor

@woody-apple woody-apple commented Feb 23, 2026

Summary

The mNeedsNetworkSetup flag never Gets Reset in CleanupCommissioning()

Location: connectedhomeip/src/controller/AutoCommissioner.cpp:781-790

void AutoCommissioner::CleanupCommissioning()
{
ResetNetworkAttemptType();
mPAI.Free();
mDAC.Free();
mCommissioneeDeviceProxy = nullptr;
mOperationalDeviceProxy = OperationalDeviceProxy();
mDeviceCommissioningInfo = ReadCommissioningInfo();
mNeedsDST = false;
// ❌ mNeedsNetworkSetup is NOT reset here!
}

This may be possible given that there was a previous pairing attempt to a device over BLE, which might have setup mNeedsNetworkSetup.

Testing

Ran through manual testing of pairing of two devices.

Readability checklist

The checklist below will help the reviewer finish PR review in time and keep the
code readable:

  • PR title is
    descriptive
  • Apply the
    “When in Rome…”
    rule (coding style)
  • PR size is short
  • Try to avoid "squashing" and "force-update" in commit history
  • CI time didn't increase

See: Pull Request Guidelines

…ck will fail pairings for devices on the network already
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

The pull request correctly addresses a state leakage issue in the AutoCommissioner class where the mNeedsNetworkSetup flag was not being reset during the commissioning cleanup process. This fix is essential for ensuring that back-to-back commissioning attempts are reliable and do not inherit state from previous sessions. The implementation follows the prevailing coding style of the file. I have suggested resetting a few additional state-tracking flags in the same function to further improve the robustness of the cleanup logic and prevent similar issues in the future.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the AutoCommissioner where the mNeedsNetworkSetup flag was not being reset in the CleanupCommissioning() method, causing back-to-back pairing attempts to fail when the AutoCommissioner is reused. The flag is used to determine whether network setup is needed during commissioning (set when transport type is BLE, NFC, or WiFiPAF), and if not cleared, could cause incorrect commissioning flow for subsequent devices.

Changes:

  • Added reset of mNeedsNetworkSetup flag to false in AutoCommissioner::CleanupCommissioning()

@github-actions
Copy link

github-actions bot commented Feb 23, 2026

PR #43251: Size comparison from 7f6dd32 to ca1f22f

Full report (31 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section 7f6dd32 ca1f22f change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1108494 1108494 0 0.0
RAM 178746 178746 0 0.0
bl702 lighting-app bl702+eth FLASH 663574 663574 0 0.0
RAM 134753 134753 0 0.0
bl702+wifi FLASH 839276 839276 0 0.0
RAM 124293 124293 0 0.0
bl706+mfd+rpc+littlefs FLASH 1073508 1073508 0 0.0
RAM 117205 117205 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 906130 906130 0 0.0
RAM 105828 105828 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 986574 986574 0 0.0
RAM 109692 109692 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 779224 779224 0 0.0
RAM 103384 103384 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 786900 786900 0 0.0
RAM 108584 108584 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 731948 731948 0 0.0
RAM 97324 97324 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 716468 716468 0 0.0
RAM 97524 97524 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 557516 557516 0 0.0
RAM 204512 204512 0 0.0
lock CC3235SF_LAUNCHXL FLASH 591864 591864 0 0.0
RAM 204808 204808 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 955828 955828 0 0.0
RAM 162281 162281 0 0.0
nxp contact mcxw71+release FLASH 747472 747472 0 0.0
RAM 66976 66976 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1703236 1703236 0 0.0
RAM 214036 214036 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1604132 1604132 0 0.0
RAM 210892 210892 0 0.0
light cy8ckit_062s2_43012 FLASH 1470636 1470636 0 0.0
RAM 197040 197040 0 0.0
lock cy8ckit_062s2_43012 FLASH 1497812 1497812 0 0.0
RAM 224792 224792 0 0.0
qpg lighting-app qpg6200+debug FLASH 840572 840572 0 0.0
RAM 127844 127844 0 0.0
lock-app qpg6200+debug FLASH 779216 779216 0 0.0
RAM 118792 118792 0 0.0
realtek light-switch-app rtl8777g FLASH 705928 705928 0 0.0
RAM 113536 113536 0 0.0
lighting-app rtl8777g FLASH 752464 752464 0 0.0
RAM 114744 114744 0 0.0
stm32 light STM32WB5MM-DK FLASH 478336 478336 0 0.0
RAM 141392 141392 0 0.0
telink bridge-app tl7218x FLASH 726712 726712 0 0.0
RAM 95800 95800 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 852298 852298 0 0.0
RAM 44244 44244 0 0.0
tl7218x FLASH 843696 843696 0 0.0
RAM 99632 99632 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 725272 725272 0 0.0
RAM 55832 55832 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 787898 787898 0 0.0
RAM 75016 75016 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725272 725272 0 0.0
RAM 33312 33312 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 614890 614890 0 0.0
RAM 118292 118292 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 842546 842550 4 0.0
RAM 97340 97340 0 0.0

@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.73%. Comparing base (7f6dd32) to head (ca1f22f).

Files with missing lines Patch % Lines
src/controller/AutoCommissioner.cpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43251      +/-   ##
==========================================
- Coverage   53.73%   53.73%   -0.01%     
==========================================
  Files        1530     1530              
  Lines      105861   105866       +5     
  Branches    13312    13312              
==========================================
  Hits        56884    56884              
- Misses      48977    48982       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant