From e54e83e9fc69159edde9725edac04dbd14f51043 Mon Sep 17 00:00:00 2001 From: Robert Quattlebaum Date: Fri, 13 May 2016 18:41:14 -0700 Subject: [PATCH] core: mac: Added new method: `Mac::IsActiveScanInProgress()` (#29) * core: mac: Added new method: `Mac::IsActiveScanInProgress()` * core: Add `otActiveScanInProgress()` for checking if a scan is in progress. --- include/openthread.h | 7 +++++++ src/core/mac/mac.cpp | 6 ++++++ src/core/mac/mac.hpp | 6 ++++++ src/core/openthread.cpp | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/include/openthread.h b/include/openthread.h index 0729507b7..1609d8642 100644 --- a/include/openthread.h +++ b/include/openthread.h @@ -182,6 +182,13 @@ typedef void (*otHandleActiveScanResult)(otActiveScanResult *aResult); */ ThreadError otActiveScan(uint16_t aScanChannels, uint16_t aScanDuration, otHandleActiveScanResult aCallback); +/** + * This function determines if an IEEE 802.15.4 Active Scan is currently in progress. + * + * @returns true if an active scan is in progress. + */ +bool otActiveScanInProgress(void); + /** * @} * diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index f847db324..025f4814d 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -209,6 +209,12 @@ exit: return error; } +bool Mac::IsActiveScanInProgress(void) +{ + return (mState == kStateActiveScan) || mActiveScanRequest; +} + + ThreadError Mac::RegisterReceiver(Receiver &aReceiver) { assert(mReceiveTail != &aReceiver && aReceiver.mNext == NULL); diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index 92150744b..854623a03 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -385,6 +385,12 @@ public: */ static void TransmitDoneTask(void *aContext); + /** + * This method returns if an active scan is in progress. + * + */ + bool IsActiveScanInProgress(void); + private: void GenerateNonce(const ExtAddress &aAddress, uint32_t aFrameCounter, uint8_t aSecurityLevel, uint8_t *aNonce); void NextOperation(void); diff --git a/src/core/openthread.cpp b/src/core/openthread.cpp index 385ff8097..d35f927a4 100644 --- a/src/core/openthread.cpp +++ b/src/core/openthread.cpp @@ -478,6 +478,11 @@ ThreadError otActiveScan(uint16_t aScanChannels, uint16_t aScanDuration, otHandl reinterpret_cast(aCallback)); } +bool otActiveScanInProgress(void) +{ + return sThreadNetif->GetMac().IsActiveScanInProgress(); +} + void HandleActiveScanResult(void *aContext, Mac::Frame *aFrame) { otHandleActiveScanResult handler = reinterpret_cast(aContext);