[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.
This commit is contained in:
Abtin Keshavarzian
2021-03-16 08:34:25 -07:00
committed by GitHub
parent 7dca56e982
commit 2d101cfe28
+12 -2
View File
@@ -248,7 +248,9 @@ void RadioSpinel<InterfaceType, ProcessContextType>::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 <typename InterfaceType, typename ProcessContextType>
otError RadioSpinel<InterfaceType, ProcessContextType>::RestoreDatasetFromNcp(void)
{
@@ -429,6 +432,7 @@ exit:
Instance::Get().template Get<SettingsDriver>().Deinit();
return error;
}
#endif
template <typename InterfaceType, typename ProcessContextType>
void RadioSpinel<InterfaceType, ProcessContextType>::Deinit(void)
@@ -585,6 +589,7 @@ exit:
LogIfFail("Error processing response", error);
}
#if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
template <typename InterfaceType, typename ProcessContextType>
otError RadioSpinel<InterfaceType, ProcessContextType>::ThreadDatasetHandler(const uint8_t *aBuffer, uint16_t aLength)
{
@@ -738,6 +743,7 @@ otError RadioSpinel<InterfaceType, ProcessContextType>::ThreadDatasetHandler(con
exit:
return error;
}
#endif // #if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
template <typename InterfaceType, typename ProcessContextType>
void RadioSpinel<InterfaceType, ProcessContextType>::HandleWaitingResponse(uint32_t aCommand,
@@ -2268,8 +2274,12 @@ void RadioSpinel<InterfaceType, ProcessContextType>::RestoreProperties(void)
sizeof(otMacKey)));
}
SuccessOrDie(Instance::Get().template Get<Settings>().ReadNetworkInfo(networkInfo));
SuccessOrDie(Set(SPINEL_PROP_RCP_MAC_FRAME_COUNTER, SPINEL_DATATYPE_UINT32_S, networkInfo.GetMacFrameCounter()));
if (mInstance != nullptr)
{
SuccessOrDie(static_cast<Instance *>(mInstance)->template Get<Settings>().ReadNetworkInfo(networkInfo));
SuccessOrDie(
Set(SPINEL_PROP_RCP_MAC_FRAME_COUNTER, SPINEL_DATATYPE_UINT32_S, networkInfo.GetMacFrameCounter()));
}
for (int i = 0; i < mSrcMatchShortEntryCount; ++i)
{