From 163c54537f1a62d1c953851e6717032d7a833335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Mi=C5=9B?= Date: Mon, 20 Mar 2017 17:38:07 +0100 Subject: [PATCH] Add API function to check if MAC layer is during transmission operation. (#1447) --- include/openthread/link.h | 14 ++++++++++++++ src/core/api/link_api.cpp | 4 ++++ src/core/mac/mac.cpp | 5 +++++ src/core/mac/mac.hpp | 10 ++++++++++ 4 files changed, 33 insertions(+) diff --git a/include/openthread/link.h b/include/openthread/link.h index de0f3b6ca..b49d8a1ae 100644 --- a/include/openthread/link.h +++ b/include/openthread/link.h @@ -136,6 +136,20 @@ OTAPI bool OTCALL otLinkIsEnergyScanInProgress(otInstance *aInstance); */ OTAPI ThreadError OTCALL otLinkSendDataRequest(otInstance *aInstance); +/** + * This function indicates whether or not an IEEE 802.15.4 MAC is in the transmit state. + * + * MAC module is in the transmit state during CSMA/CA procedure, CCA, Data, Beacon or Data Request frame transmission + * and receiving an ACK of a transmitted frame. MAC module is not in the transmit state during transmission of an ACK + * frame or a Beacon Request frame. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns true if an IEEE 802.15.4 MAC is in the transmit state, false otherwise. + * + */ +OTAPI bool OTCALL otLinkIsInTransmitState(otInstance *aInstance); + /** * Get the IEEE 802.15.4 channel. * diff --git a/src/core/api/link_api.cpp b/src/core/api/link_api.cpp index acb132a60..8b0517abf 100644 --- a/src/core/api/link_api.cpp +++ b/src/core/api/link_api.cpp @@ -355,6 +355,10 @@ bool otLinkIsEnergyScanInProgress(otInstance *aInstance) return aInstance->mThreadNetif.GetMac().IsEnergyScanInProgress(); } +bool otLinkIsInTransmitState(otInstance *aInstance) +{ + return aInstance->mThreadNetif.GetMac().IsInTransmitState(); +} #ifdef __cplusplus diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index d39caa859..43edd78b7 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -257,6 +257,11 @@ bool Mac::IsEnergyScanInProgress(void) return (mState == kStateEnergyScan) || (mPendingScanRequest == kScanTypeEnergy); } +bool Mac::IsInTransmitState(void) +{ + return (mState == kStateTransmitData) || (mState == kStateTransmitBeacon); +} + void Mac::StartEnergyScan(void) { mState = kStateEnergyScan; diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index deecebbaa..b195b3a66 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -502,6 +502,16 @@ public: */ bool IsEnergyScanInProgress(void); + /** + * This method returns if the MAC layer is in transmit state. + * + * The MAC layer is in transmit state during CSMA/CA, CCA, transmission of Data, Beacon or Data Request frames and + * receiving of ACK frames. The MAC layer is not in transmit state during transmission of ACK frames or Beacon + * Requests. + * + */ + bool IsInTransmitState(void); + /** * This method registers a callback to provide received raw IEEE 802.15.4 frames. *