Skip to content
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

[thread] delay scanning for Sleepy End Devices #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LuDuda
Copy link
Owner

@LuDuda LuDuda commented Jan 29, 2023

When SED changes its mode from RxOffWhenIdle to RxOnWhenIdle (by sending Child Update Request) and immediately starts the Thread Discovery procedure (on all channels) it is not able to receive the Child Update Response from its parent. This causes a lot of retransmissions from the parent side and even sporadic re-attachments.

This PR adds a small 300-ms delay to allow the child to receive the Child Update Response.

@LuDuda LuDuda force-pushed the pr/discovery-delay branch from f62215b to f785a82 Compare January 30, 2023 00:08
@@ -1918,7 +1952,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_RequestSEDActiv
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::SEDUpdateMode()
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::SEDUpdateMode(void)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Those are not C++-idiomatic. People are moving void arguments in other Matter components, so let's not move in the opposite direction :)

{
if (mpScanCallback != nullptr)
{
mpScanCallback->OnFinished(NetworkCommissioning::Status::kUnknownError, CharSpan(), nullptr);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the callback triggers building CHIP response, so it should be run on the CHIP thread, e.g. using DeviceLayer::SystemLayer().ScheduleLambda([this]() {, right?

@@ -411,12 +411,14 @@ GenericThreadStackManagerImpl_OpenThread<ImplClass>::_StartThreadScan(NetworkCom
mTemporaryRxOnWhenIdle = true;
linkMode.mRxOnWhenIdle = true;
otThreadSetLinkMode(mOTInst, linkMode);

// Delay Thread scanning to allow Child Update Request/Response transaction to finish.
DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(kThreadScanDelayMs), RequestThreadDiscovery, this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(kThreadScanDelayMs), RequestThreadDiscovery, this);
error = DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(kThreadScanDelayMs), RequestThreadDiscovery, this);

error = MapOpenThreadError(otThreadDiscover(mOTInst, 0, /* all channels */
OT_PANID_BROADCAST, false, false, /* disable PAN ID, EUI64 and Joiner filtering */
_OnNetworkScanFinished, this));
error = StartThreadDiscovery();

exit:
Impl()->UnlockThreadStack();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be good to add code for restoring RxOnWhenIdle to cover the case that DeviceLayer::SystemLayer().StartTimer (or anything else) returns an error.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ahh.. Good point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants