Skip to content

Commit

Permalink
[spinel] add an API to enable/disable the RCP restoration feature (op…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglongxia authored Dec 10, 2024
1 parent fe7d34f commit 124f050
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/spinel/radio_spinel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ RadioSpinel::RadioSpinel(void)
, mSrcMatchShortEntryCount(0)
, mSrcMatchExtEntryCount(0)
, mSrcMatchEnabled(false)
, mRcpRestorationEnabled(true)
, mMacKeySet(false)
, mCcaEnergyDetectThresholdSet(false)
, mTransmitPowerSet(false)
Expand Down Expand Up @@ -2039,6 +2040,8 @@ void RadioSpinel::RecoverFromRcpFailure(void)
State recoveringState = mState;
bool skipReset = false;

VerifyOrExit(mRcpRestorationEnabled);

if (mRcpFailure == kRcpFailureNone)
{
ExitNow();
Expand Down
10 changes: 10 additions & 0 deletions src/lib/spinel/radio_spinel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,15 @@ class RadioSpinel : private Logger
*/
void SetTimeSyncState(bool aOn) { mTimeSyncOn = aOn; }

#if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0
/**
* Enables or disables the RCP restoration feature.
*
* @param[in] aEnabled TRUE to enable the RCP restoration feature, FALSE otherwise.
*/
void SetRcpRestorationEnabled(bool aEnabled) { mRcpRestorationEnabled = aEnabled; }
#endif

private:
enum
{
Expand Down Expand Up @@ -1283,6 +1292,7 @@ class RadioSpinel : private Logger
int8_t mFemLnaGain;
bool mCoexEnabled : 1;
bool mSrcMatchEnabled : 1;
bool mRcpRestorationEnabled : 1;

bool mMacKeySet : 1; ///< Whether MAC key has been set.
bool mCcaEnergyDetectThresholdSet : 1; ///< Whether CCA energy detect threshold has been set.
Expand Down
7 changes: 7 additions & 0 deletions src/posix/platform/include/openthread/openthread-system.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ void otSysTrelInit(const char *aInterfaceName);
*/
void otSysTrelDeinit(void);

/**
* Enables or disables the RCP restoration feature.
*
* @param[in] aEnabled TRUE to enable the RCP restoration feature, FALSE otherwise.
*/
void otSysSetRcpRestorationEnabled(bool aEnabled);

#ifdef __cplusplus
} // end of extern "C"
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/posix/platform/radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,3 +1070,7 @@ const otRcpInterfaceMetrics *otSysGetRcpInterfaceMetrics(void)
{
return sRadio.GetSpinelInterface().GetRcpInterfaceMetrics();
}

#if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0
void otSysSetRcpRestorationEnabled(bool aEnabled) { return GetRadioSpinel().SetRcpRestorationEnabled(aEnabled); }
#endif

0 comments on commit 124f050

Please sign in to comment.