mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 11:17:46 +00:00
[radio] add API for resetting CSL parameters (#9772)
Add `ResetCsl` and `otPlatRadioResetCsl` This allows handling stack reset as separate call instead of using `kShortAddrInvalid` as `otShortAddress` and `nullptr` as `otExtAddress` which can be difficult to handle on vendor's side. Default implementation still calls `otPlatRadioEnableCsl(aInstance,0, Mac::kShortAddrInvalid, nullptr)` So no action is needed if vendor has already implemented handling this case. Signed-off-by: Maciej Baczmanski <[email protected]>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 *)
|
||||
|
||||
Reference in New Issue
Block a user