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

update mStagingNetwork to the dataset in NVS after thread panid changed #31597

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CHIP_ERROR GenericThreadDriver::Init(Internal::BaseDriver::NetworkStatusChangeCa
{
ThreadStackMgrImpl().SetNetworkStatusChangeCallback(statusChangeCallback);
ThreadStackMgrImpl().GetThreadProvision(mStagingNetwork);
ReturnErrorOnFailure(PlatformMgr().AddEventHandler(OnThreadStateChangeHandler, reinterpret_cast<intptr_t>(this)));

// If the network configuration backup exists, it means that the device has been rebooted with
// the fail-safe armed. Since OpenThread persists all operational dataset changes, the backup
Expand All @@ -56,6 +57,16 @@ CHIP_ERROR GenericThreadDriver::Init(Internal::BaseDriver::NetworkStatusChangeCa
return CHIP_NO_ERROR;
}

void GenericThreadDriver::OnThreadStateChangeHandler(const ChipDeviceEvent * event, intptr_t arg)
{
if ((event->Type == DeviceEventType::kThreadStateChange) &&
(event->ThreadStateChange.OpenThread.Flags & OT_CHANGED_THREAD_PANID))
{
// Update the mStagingNetwork when thread panid changed
ThreadStackMgrImpl().GetThreadProvision(reinterpret_cast<GenericThreadDriver *>(arg)->mStagingNetwork);
}
}

void GenericThreadDriver::Shutdown()
{
ThreadStackMgrImpl().SetNetworkStatusChangeCallback(nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class GenericThreadDriver final : public ThreadDriver
private:
uint8_t scanNetworkTimeoutSeconds;
uint8_t connectNetworkTimeout;
static void OnThreadStateChangeHandler(const ChipDeviceEvent * event, intptr_t arg);
Status MatchesNetworkId(const Thread::OperationalDataset & dataset, const ByteSpan & networkId) const;
CHIP_ERROR BackupConfiguration();

Expand Down
Loading