From 2d101cfe2821d0797786938803e681c9e6f7bd47 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 16 Mar 2021 08:34:25 -0700 Subject: [PATCH] [radio-spinel] perform "RestoreDatasetFromNcp()" with single OT instance config (#6277) This commit changes the `RestoreDatasetFromNcp()` to be performed on single OT instance config and to be skipped when multiple OT instance config is enabled. This change ensures that the `RadioSpinel` module can be compiled with `MULTIPLE_INSTANCE_ENABLE` config. Note that the "restore data set from NCP" mechanism is performed during platform initialization from `RadioSpinel::Init()` which happens before any OT instance is allocated or initialized (all platform layer components/drivers should be initialized before OT instance). So the "restore dataset from NCP" feature only makes sense under since OT instance case. --- src/lib/spinel/radio_spinel_impl.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib/spinel/radio_spinel_impl.hpp b/src/lib/spinel/radio_spinel_impl.hpp index d11a2e568..e563d00ac 100644 --- a/src/lib/spinel/radio_spinel_impl.hpp +++ b/src/lib/spinel/radio_spinel_impl.hpp @@ -248,7 +248,9 @@ void RadioSpinel::Init(bool aResetRadio, if (aRestoreDatasetFromNcp) { +#if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE exitCode = (RestoreDatasetFromNcp() == OT_ERROR_NONE) ? OT_EXIT_SUCCESS : OT_EXIT_FAILURE; +#endif } DieNow(exitCode); @@ -412,6 +414,7 @@ exit: return error; } +#if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE template otError RadioSpinel::RestoreDatasetFromNcp(void) { @@ -429,6 +432,7 @@ exit: Instance::Get().template Get().Deinit(); return error; } +#endif template void RadioSpinel::Deinit(void) @@ -585,6 +589,7 @@ exit: LogIfFail("Error processing response", error); } +#if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE template otError RadioSpinel::ThreadDatasetHandler(const uint8_t *aBuffer, uint16_t aLength) { @@ -738,6 +743,7 @@ otError RadioSpinel::ThreadDatasetHandler(con exit: return error; } +#endif // #if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE template void RadioSpinel::HandleWaitingResponse(uint32_t aCommand, @@ -2268,8 +2274,12 @@ void RadioSpinel::RestoreProperties(void) sizeof(otMacKey))); } - SuccessOrDie(Instance::Get().template Get().ReadNetworkInfo(networkInfo)); - SuccessOrDie(Set(SPINEL_PROP_RCP_MAC_FRAME_COUNTER, SPINEL_DATATYPE_UINT32_S, networkInfo.GetMacFrameCounter())); + if (mInstance != nullptr) + { + SuccessOrDie(static_cast(mInstance)->template Get().ReadNetworkInfo(networkInfo)); + SuccessOrDie( + Set(SPINEL_PROP_RCP_MAC_FRAME_COUNTER, SPINEL_DATATYPE_UINT32_S, networkInfo.GetMacFrameCounter())); + } for (int i = 0; i < mSrcMatchShortEntryCount; ++i) {