[instance] improve shutdown sequence in Instance::Finalize() (#11706)

This commit enhances the instance shutdown sequence by explicitly
disabling the Border Agent in `Instance::Finalize()`.

Additionally, direct calls to the OpenThread C API, such as
`otThreadSetEnabled()`, are replaced with their corresponding C++
method calls, like `Get<Mle::Mle>().Stop()`.
This commit is contained in:
Abtin Keshavarzian
2025-07-10 18:15:11 -07:00
committed by GitHub
parent 8f67c5e72d
commit a9c2001bf1
+6 -4
View File
@@ -430,10 +430,12 @@ void Instance::Finalize(void)
mIsInitialized = false;
#if OPENTHREAD_MTD || OPENTHREAD_FTD
IgnoreError(otThreadSetEnabled(this, false));
IgnoreError(otIp6SetEnabled(this, false));
IgnoreError(otLinkSetEnabled(this, false));
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
Get<MeshCoP::BorderAgent>().SetEnabled(false);
#endif
Get<Mle::Mle>().Stop();
Get<ThreadNetif>().Down();
Get<Mac::Mac>().SetEnabled(false);
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
Get<KeyManager>().DestroyTemporaryKeys();
#endif