-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Don't stop trying BLE if mDNS commissioning fails #fixes 43364 #43527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
woody-apple
wants to merge
8
commits into
project-chip:master
Choose a base branch
from
woody-apple:issue/43364
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+255
−12
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4c8895d
Initial commit
woody-apple 239c702
Fixed edge case and added unit tests
jtung-apple f50bfdb
Fix edge case
jtung-apple 1a44f1d
Merge branch 'master' into issue/43364
jtung-apple 3731169
Fixed StopDiscoveryOverDNSSD in OnPairingComplete causing immediate f…
jtung-apple 85ece64
Restyled
jtung-apple 781bad7
Additional unit tests
jtung-apple 2aa13fd
Restyled
jtung-apple File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2025 Project CHIP Authors | ||
| * All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <controller/SetUpCodePairer.h> | ||
|
|
||
| namespace chip { | ||
| namespace Testing { | ||
|
|
||
| // Provides access to private members of SetUpCodePairer for testing. | ||
| class SetUpCodePairerTestAccess | ||
| { | ||
| public: | ||
| SetUpCodePairerTestAccess() = delete; | ||
| explicit SetUpCodePairerTestAccess(Controller::SetUpCodePairer * pairer) : mPairer(pairer) {} | ||
|
|
||
| // Re-export private transport type indices for use in tests. | ||
| static constexpr int kBLETransport = Controller::SetUpCodePairer::kBLETransport; | ||
| static constexpr int kIPTransport = Controller::SetUpCodePairer::kIPTransport; | ||
| static constexpr int kWiFiPAFTransport = Controller::SetUpCodePairer::kWiFiPAFTransport; | ||
|
|
||
| bool GetWaitingForDiscovery(int transport) const { return mPairer->mWaitingForDiscovery[transport]; } | ||
| void SetWaitingForDiscovery(int transport, bool val) { mPairer->mWaitingForDiscovery[transport] = val; } | ||
|
|
||
| bool GetWaitingForPASE() const { return mPairer->mWaitingForPASE; } | ||
| void SetWaitingForPASE(bool val) { mPairer->mWaitingForPASE = val; } | ||
|
|
||
| NodeId GetRemoteId() const { return mPairer->mRemoteId; } | ||
| void SetRemoteId(NodeId id) { mPairer->mRemoteId = id; } | ||
|
|
||
| void FireTimeoutCallback() { Controller::SetUpCodePairer::OnDeviceDiscoveredTimeoutCallback(nullptr, mPairer); } | ||
|
|
||
| private: | ||
| Controller::SetUpCodePairer * mPairer = nullptr; | ||
| }; | ||
|
|
||
| } // namespace Testing | ||
| } // namespace chip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2025 Project CHIP Authors | ||
| * All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include <controller/CHIPDeviceController.h> | ||
| #include <controller/SetUpCodePairer.h> | ||
| #include <controller/tests/SetUpCodePairerTestAccess.h> | ||
| #include <lib/core/CHIPError.h> | ||
|
|
||
| using namespace chip; | ||
| using namespace chip::Controller; | ||
| using PairerAccess = chip::Testing::SetUpCodePairerTestAccess; | ||
|
|
||
| namespace { | ||
|
|
||
| class TestSetUpCodePairer : public ::testing::Test | ||
| { | ||
| public: | ||
| static void SetUpTestSuite() { ASSERT_EQ(Platform::MemoryInit(), CHIP_NO_ERROR); } | ||
| static void TearDownTestSuite() { Platform::MemoryShutdown(); } | ||
|
|
||
| protected: | ||
| DeviceCommissioner commissioner; | ||
| SetUpCodePairer pairer{ &commissioner }; | ||
| PairerAccess access{ &pairer }; | ||
| }; | ||
|
|
||
| // When the discovery timeout fires while a PASE attempt is in progress, | ||
| // DNS-SD should be stopped (it runs indefinitely) but other transports | ||
| // (BLE, Wi-Fi PAF, NFC) should be left alone since they self-terminate. | ||
| TEST_F(TestSetUpCodePairer, TimeoutDuringPASE_StopsDNSSD_PreservesOtherTransports) | ||
| { | ||
| access.SetRemoteId(1); | ||
| access.SetWaitingForPASE(true); | ||
| access.SetWaitingForDiscovery(PairerAccess::kIPTransport, true); | ||
| access.SetWaitingForDiscovery(PairerAccess::kBLETransport, true); | ||
|
|
||
| access.FireTimeoutCallback(); | ||
|
|
||
| // DNS-SD must be stopped to prevent DiscoveryInProgress() from being stuck true. | ||
| EXPECT_FALSE(access.GetWaitingForDiscovery(PairerAccess::kIPTransport)); | ||
| // BLE must be preserved — it may still discover a commissionee. | ||
| EXPECT_TRUE(access.GetWaitingForDiscovery(PairerAccess::kBLETransport)); | ||
| // PASE state must not be disturbed. | ||
| EXPECT_TRUE(access.GetWaitingForPASE()); | ||
| } | ||
|
|
||
| // When the discovery timeout fires with no PASE in progress, | ||
| // all transports should be stopped and failure reported. | ||
| TEST_F(TestSetUpCodePairer, TimeoutNoPASE_StopsAllTransports) | ||
| { | ||
| access.SetRemoteId(1); | ||
| access.SetWaitingForPASE(false); | ||
| access.SetWaitingForDiscovery(PairerAccess::kIPTransport, true); | ||
| access.SetWaitingForDiscovery(PairerAccess::kBLETransport, true); | ||
|
|
||
| access.FireTimeoutCallback(); | ||
|
|
||
| EXPECT_FALSE(access.GetWaitingForDiscovery(PairerAccess::kIPTransport)); | ||
| EXPECT_FALSE(access.GetWaitingForDiscovery(PairerAccess::kBLETransport)); | ||
| // StopPairingIfTransportsExhausted should have reported failure and cleared mRemoteId. | ||
| EXPECT_EQ(access.GetRemoteId(), kUndefinedNodeId); | ||
| } | ||
|
|
||
| } // namespace |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.