-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
f62215b
to
f785a82
Compare
@@ -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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh.. Good point!
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.