diff --git a/include/openthread/platform/radio.h b/include/openthread/platform/radio.h index 15ea5c360..d216a5046 100644 --- a/include/openthread/platform/radio.h +++ b/include/openthread/platform/radio.h @@ -107,6 +107,7 @@ typedef struct otRadioFrame bool mSecurityValid: 1; ///< Security Enabled flag is set and frame passes security checks. bool mDidTX: 1; ///< Set to true if this frame sent from the radio. Ignored by radio driver. bool mIsARetx: 1; ///< Set to true if this frame is a retransmission. Should be ignored by radio driver. + bool mIsCcaEnabled: 1; ///< Set to true if CCA must be enabled for this packet. False otherwise. /** * The timestamp when the frame was received (milliseconds). diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 72748c898..97d9d719b 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -868,6 +868,19 @@ void Mac::HandleBeginTransmit(void) Frame &sendFrame(*mTxFrame); otError error = OT_ERROR_NONE; +#if OPENTHREAD_CONFIG_DISABLE_CCA_ON_LAST_ATTEMPT + + // Disable CCA for the last attempt + if (mTransmitAttempts == (sendFrame.GetMaxTxAttempts() - 1)) + { + sendFrame.mIsCcaEnabled = false; + } + else +#endif + { + sendFrame.mIsCcaEnabled = true; + } + if (mCsmaAttempts == 0 && mTransmitAttempts == 0) { sendFrame.SetPower(mMaxTransmitPower); diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h index a315ea3ac..37e83fcf0 100644 --- a/src/core/openthread-core-default-config.h +++ b/src/core/openthread-core-default-config.h @@ -1008,4 +1008,14 @@ #define OPENTHREAD_CONFIG_ENABLE_DYNAMIC_MPL_INTERVAL 0 #endif +/** + * @def OPENTHREAD_CONFIG_DISABLE_CCA_ON_LAST_ATTEMPT + * + * Define as 1 to disable CCA on the last transmit attempt + * + */ +#ifndef OPENTHREAD_CONFIG_DISABLE_CCA_ON_LAST_ATTEMPT +#define OPENTHREAD_CONFIG_DISABLE_CCA_ON_LAST_ATTEMPT 0 +#endif + #endif // OPENTHREAD_CORE_DEFAULT_CONFIG_H_