From 30222e8538d7aafe6596a932af7e11fefa740114 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Mon, 2 Jul 2018 10:44:09 -0500 Subject: [PATCH] [radio] rename CcaEnabled to CsmaCaEnabled (#2844) --- examples/platforms/nrf52840/radio.c | 2 +- include/openthread/platform/radio.h | 8 ++++---- src/core/api/link_raw_api.cpp | 2 +- src/core/mac/mac.cpp | 14 +++++++++----- src/core/mac/mac_frame.hpp | 6 +++--- src/core/openthread-core-default-config.h | 8 ++++---- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/examples/platforms/nrf52840/radio.c b/examples/platforms/nrf52840/radio.c index 99b42c654..4e38eaaf9 100644 --- a/examples/platforms/nrf52840/radio.c +++ b/examples/platforms/nrf52840/radio.c @@ -343,7 +343,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) nrf_802154_channel_set(aFrame->mChannel); - if (aFrame->mInfo.mTxInfo.mIsCcaEnabled) + if (aFrame->mInfo.mTxInfo.mCsmaCaEnabled) { nrf_802154_transmit_csma_ca_raw(&aFrame->mPsdu[-1]); } diff --git a/include/openthread/platform/radio.h b/include/openthread/platform/radio.h index f5d754310..1d5aa9829 100644 --- a/include/openthread/platform/radio.h +++ b/include/openthread/platform/radio.h @@ -124,10 +124,10 @@ typedef struct otRadioFrame */ struct { - uint8_t mMaxTxAttempts; ///< Max number of transmit attempts for an outbound frame. - 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. - const uint8_t *mAesKey; ///< The key used for frame encryption and authentication (AES CCM). + uint8_t mMaxTxAttempts; ///< Max number of transmit attempts for an outbound frame. + 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. + const uint8_t *mAesKey; ///< The key used for AES-CCM frame security. } mTxInfo; /** diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp index e71584cff..e4cf2905c 100644 --- a/src/core/api/link_raw_api.cpp +++ b/src/core/api/link_raw_api.cpp @@ -230,7 +230,7 @@ otError LinkRaw::Transmit(otRadioFrame *aFrame, otLinkRawTransmitDone aCallback) #endif // OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT #if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_CSMA_BACKOFF - if (aFrame->mInfo.mTxInfo.mIsCcaEnabled) + if (aFrame->mInfo.mTxInfo.mCsmaCaEnabled) { // Start the transmission backoff logic StartCsmaBackoff(); diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 566d7a8ea..fc1348bd3 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -1027,6 +1027,12 @@ void Mac::StartCsmaBackoff(void) // If the radio supports CSMA back off logic, immediately schedule the send. BeginTransmit(); } +#if OPENTHREAD_CONFIG_DISABLE_CSMA_CA_ON_LAST_ATTEMPT + else if (mTransmitAttempts == (sendFrame.GetMaxTxAttempts() - 1)) + { + BeginTransmit(); + } +#endif else { uint32_t backoffExponent = kMinBE + mTransmitAttempts + mCsmaAttempts; @@ -1137,17 +1143,15 @@ void Mac::BeginTransmit(void) VerifyOrExit(mEnabled, error = OT_ERROR_ABORT); -#if OPENTHREAD_CONFIG_DISABLE_CCA_ON_LAST_ATTEMPT - - // Disable CCA for the last attempt +#if OPENTHREAD_CONFIG_DISABLE_CSMA_CA_ON_LAST_ATTEMPT if (mTransmitAttempts == (sendFrame.GetMaxTxAttempts() - 1)) { - sendFrame.SetIsCcaEnabled(false); + sendFrame.SetCsmaCaEnabled(false); } else #endif { - sendFrame.SetIsCcaEnabled(true); + sendFrame.SetCsmaCaEnabled(true); } if (mCsmaAttempts == 0 && mTransmitAttempts == 0) diff --git a/src/core/mac/mac_frame.hpp b/src/core/mac/mac_frame.hpp index 44a45a1e2..2c67c195a 100644 --- a/src/core/mac/mac_frame.hpp +++ b/src/core/mac/mac_frame.hpp @@ -1030,12 +1030,12 @@ public: void SetDidTx(bool aDidTx) { mDidTx = aDidTx; } /** - * This method sets the CCA enabled attribute. + * This method sets the CSMA-CA enabled attribute. * - * @param[in] aIsCcaEnabled TRUE if CCA must be enabled for this packet, FALSE otherwise. + * @param[in] aCsmaCaEnabled TRUE if CSMA-CA must be enabled for this packet, FALSE otherwise. * */ - void SetIsCcaEnabled(bool aIsCcaEnabled) { mInfo.mTxInfo.mIsCcaEnabled = aIsCcaEnabled; } + void SetCsmaCaEnabled(bool aCsmaCaEnabled) { mInfo.mTxInfo.mCsmaCaEnabled = aCsmaCaEnabled; } /** * This method returns the key used for frame encryption and authentication (AES CCM). diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h index 19416c534..771fc1eb9 100644 --- a/src/core/openthread-core-default-config.h +++ b/src/core/openthread-core-default-config.h @@ -1605,13 +1605,13 @@ #endif /** - * @def OPENTHREAD_CONFIG_DISABLE_CCA_ON_LAST_ATTEMPT + * @def OPENTHREAD_CONFIG_DISABLE_CSMA_CA_ON_LAST_ATTEMPT * - * Define as 1 to disable CCA on the last transmit attempt + * Define as 1 to disable CSMA-CA on the last transmit attempt * */ -#ifndef OPENTHREAD_CONFIG_DISABLE_CCA_ON_LAST_ATTEMPT -#define OPENTHREAD_CONFIG_DISABLE_CCA_ON_LAST_ATTEMPT 0 +#ifndef OPENTHREAD_CONFIG_DISABLE_CSMA_CA_ON_LAST_ATTEMPT +#define OPENTHREAD_CONFIG_DISABLE_CSMA_CA_ON_LAST_ATTEMPT 0 #endif /**