diff --git a/examples/platforms/simulation/radio.c b/examples/platforms/simulation/radio.c index 6ba2a5dcf..03808b5af 100644 --- a/examples/platforms/simulation/radio.c +++ b/examples/platforms/simulation/radio.c @@ -1331,11 +1331,18 @@ otError otPlatRadioEnableCsl(otInstance *aInstance, OT_UNUSED_VARIABLE(aShortAddr); OT_UNUSED_VARIABLE(aExtAddr); - otError error = OT_ERROR_NONE; - sCslPeriod = aCslPeriod; - return error; + return OT_ERROR_NONE; +} + +otError otPlatRadioResetCsl(otInstance *aInstance) +{ + OT_UNUSED_VARIABLE(aInstance); + + sCslPeriod = 0; + + return OT_ERROR_NONE; } void otPlatRadioUpdateCslSampleTime(otInstance *aInstance, uint32_t aCslSampleTime) diff --git a/include/openthread/instance.h b/include/openthread/instance.h index 1a97f96e5..58f33e64d 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (389) +#define OPENTHREAD_API_VERSION (390) /** * @addtogroup api-instance diff --git a/include/openthread/platform/radio.h b/include/openthread/platform/radio.h index e2bc3db76..9f6bd31a6 100644 --- a/include/openthread/platform/radio.h +++ b/include/openthread/platform/radio.h @@ -1132,9 +1132,9 @@ otError otPlatRadioGetCoexMetrics(otInstance *aInstance, otRadioCoexMetrics *aCo * * @note Platforms should use CSL peer addresses to include CSL IE when generating enhanced acks. * - * @retval kErrorNotImplemented Radio driver doesn't support CSL. - * @retval kErrorFailed Other platform specific errors. - * @retval kErrorNone Successfully enabled or disabled CSL. + * @retval OT_ERROR_NOT_IMPLEMENTED Radio driver doesn't support CSL. + * @retval OT_ERROR_FAILED Other platform specific errors. + * @retval OT_ERROR_NONE Successfully enabled or disabled CSL. * */ otError otPlatRadioEnableCsl(otInstance *aInstance, @@ -1142,6 +1142,20 @@ otError otPlatRadioEnableCsl(otInstance *aInstance, otShortAddress aShortAddr, const otExtAddress *aExtAddr); +/** + * Reset CSL receiver in the platform. + * + * @note Defaults to `otPlatRadioEnableCsl(aInstance,0, Mac::kShortAddrInvalid, nullptr);` + * + * @param[in] aInstance The OpenThread instance structure. + * + * @retval OT_ERROR_NOT_IMPLEMENTED Radio driver doesn't support CSL. + * @retval OT_ERROR_FAILED Other platform specific errors. + * @retval OT_ERROR_NONE Successfully disabled CSL. + * + */ +otError otPlatRadioResetCsl(otInstance *aInstance); + /** * Update CSL sample time in radio driver. * diff --git a/src/core/radio/radio.cpp b/src/core/radio/radio.cpp index bd9c8d83a..2356e1418 100644 --- a/src/core/radio/radio.cpp +++ b/src/core/radio/radio.cpp @@ -53,7 +53,7 @@ void Radio::Init(void) { #if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE - SuccessOrAssert(EnableCsl(0, Mac::kShortAddrInvalid, nullptr)); + SuccessOrAssert(ResetCsl()); #endif EnableSrcMatch(false); diff --git a/src/core/radio/radio.hpp b/src/core/radio/radio.hpp index fb587563e..18051615d 100644 --- a/src/core/radio/radio.hpp +++ b/src/core/radio/radio.hpp @@ -523,7 +523,8 @@ public: */ Error ReceiveAt(uint8_t aChannel, uint32_t aStart, uint32_t aDuration); - /** Enables CSL sampling in radio. + /** + * Enables CSL sampling in radio. * * @param[in] aCslPeriod CSL period, 0 for disabling CSL. * @param[in] aShortAddr The short source address of CSL receiver's peer. @@ -537,6 +538,16 @@ public: * */ Error EnableCsl(uint32_t aCslPeriod, otShortAddress aShortAddr, const otExtAddress *aExtAddr); + + /** + * Resets CSL receiver in radio. + * + * @retval kErrorNotImplemented Radio driver doesn't support CSL. + * @retval kErrorFailed Other platform specific errors. + * @retval kErrorNone Successfully disabled CSL. + * + */ + Error ResetCsl(void); #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE @@ -958,6 +969,8 @@ inline Error Radio::EnableCsl(uint32_t aCslPeriod, otShortAddress aShortAddr, co { return otPlatRadioEnableCsl(GetInstancePtr(), aCslPeriod, aShortAddr, aExtAddr); } + +inline Error Radio::ResetCsl(void) { return otPlatRadioResetCsl(GetInstancePtr()); } #endif #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE @@ -1064,6 +1077,8 @@ inline Error Radio::EnableCsl(uint32_t, otShortAddress aShortAddr, const otExtAd { return kErrorNotImplemented; } + +inline Error Radio::ResetCsl(void) { return kErrorNotImplemented; } #endif #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE diff --git a/src/core/radio/radio_platform.cpp b/src/core/radio/radio_platform.cpp index b71a0fb0e..6dcb85de5 100644 --- a/src/core/radio/radio_platform.cpp +++ b/src/core/radio/radio_platform.cpp @@ -250,6 +250,13 @@ OT_TOOL_WEAK uint32_t otPlatRadioGetBusSpeed(otInstance *aInstance) return 0; } +#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE +OT_TOOL_WEAK otError otPlatRadioResetCsl(otInstance *aInstance) +{ + return otPlatRadioEnableCsl(aInstance, 0, Mac::kShortAddrInvalid, nullptr); +} +#endif + OT_TOOL_WEAK uint8_t otPlatRadioGetCslAccuracy(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); diff --git a/tests/unit/test_platform.cpp b/tests/unit/test_platform.cpp index 2ede8e8e8..43f6224cb 100644 --- a/tests/unit/test_platform.cpp +++ b/tests/unit/test_platform.cpp @@ -404,6 +404,8 @@ OT_TOOL_WEAK otError otPlatRadioEnableCsl(otInstance *, uint32_t, otShortAddress return OT_ERROR_NONE; } +OT_TOOL_WEAK otError otPlatRadioResetCsl(otInstance *) { return OT_ERROR_NONE; } + OT_TOOL_WEAK void otPlatRadioUpdateCslSampleTime(otInstance *, uint32_t) {} OT_TOOL_WEAK uint8_t otPlatRadioGetCslAccuracy(otInstance *)