mirror of
https://github.com/espressif/openthread.git
synced 2026-09-06 17:20:09 +00:00
[low-power] add csl feature for Thread 1.2 (#4557)
This commit implements the CSL feature in Thread 1.2. - Add macro definitions for low power to control the compiling of source code. - Add data and methods for running CSL in Mac and SubMac. This mainly includes setting CSL parameters, starting/stopping CSL, and the timer handling process. - Add otPlatTimeGetAPI and implementation. - Add CSL transmission implementation. CSL transmission is a new kind of transmission, the related definition and implementaion for the whole transmitting process is added. - Add calling of start/stop CSL in certain cases. - Implement CSL synchronization maintainence. If a CSL cordinator didn't get a frame containing CSL IE for CSLTimeout, the CSL receiver is regarded as de-synchronized. - Add Cli interface for using CSL. - Implement enhanced Ack with IE. The original code can only generate auto ack for Imm-Ack. As CSL requires CSL IE included in enhanced ack. This PR implements it. - Add basic functional test for CSL transmission. More tests corresponding to test plan would be added later.
This commit is contained in:
@@ -52,6 +52,7 @@ extern "C" {
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
#define OT_US_PER_TEN_SYMBOLS 160 ///< The microseconds per 10 symbols.
|
||||
|
||||
/**
|
||||
* This structure represents link-specific information for messages received from the Thread radio.
|
||||
@@ -1004,6 +1005,72 @@ bool otLinkIsPromiscuous(otInstance *aInstance);
|
||||
*/
|
||||
otError otLinkSetPromiscuous(otInstance *aInstance, bool aPromiscuous);
|
||||
|
||||
/**
|
||||
* This function gets the CSL channel.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The CSL channel.
|
||||
*
|
||||
*/
|
||||
uint8_t otLinkCslGetChannel(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function sets the CSL channel.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aChannel The CSL sample channel.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the CSL parameters.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid @p aChannel.
|
||||
*
|
||||
*/
|
||||
otError otLinkCslSetChannel(otInstance *aInstance, uint8_t aChannel);
|
||||
|
||||
/**
|
||||
* This function gets the CSL period.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The CSL period in units of 10 symbols.
|
||||
*
|
||||
*/
|
||||
uint16_t otLinkCslGetPeriod(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function sets the CSL period.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPeriod The CSL period in units of 10 symbols.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the CSL period.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid CSL period.
|
||||
*
|
||||
*/
|
||||
otError otLinkCslSetPeriod(otInstance *aInstance, uint16_t aPeriod);
|
||||
|
||||
/**
|
||||
* This function gets the CSL timeout.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns The CSL timeout in seconds.
|
||||
*
|
||||
*/
|
||||
uint32_t otLinkCslGetTimeout(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function sets the CSL timeout.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aTimeout The CSL timeout in seconds.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the CSL timeout.
|
||||
* @retval OT_ERROR_INVALID_ARGS Invalid CSL timeout.
|
||||
*
|
||||
*/
|
||||
otError otLinkCslSetTimeout(otInstance *aInstance, uint32_t aTimeout);
|
||||
|
||||
/**
|
||||
* This function returns the current CCA (Clear Channel Assessment) failure rate.
|
||||
*
|
||||
|
||||
@@ -143,6 +143,17 @@ typedef uint16_t otShortAddress;
|
||||
|
||||
#define OT_EXT_ADDRESS_SIZE 8 ///< Size of an IEEE 802.15.4 Extended Address (bytes)
|
||||
|
||||
/**
|
||||
* This enumeration defines constants about size of header IE in ACK.
|
||||
*
|
||||
*/
|
||||
enum
|
||||
{
|
||||
OT_IE_HEADER_IE_SIZE = 2, ///< Size of IE header in bytes.
|
||||
OT_CSL_IE_SIZE = 4, ///< Size of CSL IE content in bytes.
|
||||
OT_ACK_IE_MAX_SIZE = 16, ///< Max length for header IE in ACK.
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct otExtAddress
|
||||
*
|
||||
@@ -213,10 +224,13 @@ typedef struct otRadioFrame
|
||||
{
|
||||
const otMacKey *mAesKey; ///< The key used for AES-CCM frame security.
|
||||
otRadioIeInfo * mIeInfo; ///< The pointer to the Header IE(s) related information.
|
||||
uint16_t mPeriod; ///< The transmit time period.
|
||||
uint16_t mPhase; ///< The transmit time phase.
|
||||
uint8_t mMaxCsmaBackoffs; ///< Maximum number of backoffs attempts before declaring CCA failure.
|
||||
uint8_t mMaxFrameRetries; ///< Maximum number of retries allowed after a transmission failure.
|
||||
bool mIsARetx : 1; ///< True if this frame is a retransmission (ignored by radio driver).
|
||||
bool mCsmaCaEnabled : 1; ///< Set to true to enable CSMA-CA for this packet, false otherwise.
|
||||
bool mCslPresent : 1; ///< Set to true if CSL header ie is present.
|
||||
bool mIsSecurityProcessed : 1; ///< True if SubMac should skip the AES processing of this frame.
|
||||
} mTxInfo;
|
||||
|
||||
@@ -866,6 +880,32 @@ bool otPlatRadioIsCoexEnabled(otInstance *aInstance);
|
||||
*/
|
||||
otError otPlatRadioGetCoexMetrics(otInstance *aInstance, otRadioCoexMetrics *aCoexMetrics);
|
||||
|
||||
/**
|
||||
* Enable or disable CSL receiver.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aCslPeriod CSL period, 0 for disabling CSL.
|
||||
* @param[in] aExtAddr The extended source address of CSL receiver's parent device (when the platforms generate
|
||||
* enhanced ack, platforms may need to know acks to which address should include CSL IE).
|
||||
*
|
||||
* @retval OT_ERROR_NOT_SUPPORTED 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, uint32_t aCslPeriod, const otExtAddress *aExtAddr);
|
||||
|
||||
/**
|
||||
* Update CSL sample time in radio driver.
|
||||
*
|
||||
* Sample time is stored in radio driver as a copy to calculate phase when sending ACK with CSL IE.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aCslSampleTime The latest sample time.
|
||||
*
|
||||
*/
|
||||
void otPlatRadioUpdateCslSampleTime(otInstance *aInstance, uint32_t aCslSampleTime);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user