Skip to content

[thread] delay scanning for Sleepy End Devices#62

Open
LuDuda wants to merge 1 commit intomasterfrom
pr/discovery-delay
Open

[thread] delay scanning for Sleepy End Devices#62
LuDuda wants to merge 1 commit intomasterfrom
pr/discovery-delay

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

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?

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 = 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

Comments