mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 10:47:46 +00:00
Implement otIsDiscoverInProgress. (#415)
This commit is contained in:
@@ -258,11 +258,12 @@ typedef void (*otHandleActiveScanResult)(otActiveScanResult *aResult);
|
||||
ThreadError otActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, otHandleActiveScanResult aCallback);
|
||||
|
||||
/**
|
||||
* This function determines if an IEEE 802.15.4 Active Scan is currently in progress.
|
||||
* This function indicates whether or not an IEEE 802.15.4 Active Scan is currently in progress.
|
||||
*
|
||||
* @returns true if an IEEE 802.15.4 Active Scan is in progress, false otherwise.
|
||||
*
|
||||
* @returns true if an active scan is in progress.
|
||||
*/
|
||||
bool otActiveScanInProgress(void);
|
||||
bool otIsActiveScanInProgress(void);
|
||||
|
||||
/**
|
||||
* This function starts a Thread Discovery scan.
|
||||
@@ -280,11 +281,12 @@ ThreadError otDiscover(uint32_t aScanChannels, uint16_t aScanDuration, uint16_t
|
||||
otHandleActiveScanResult aCallback);
|
||||
|
||||
/**
|
||||
* This function determines if an MLE Thread Discovery is currently in progress.
|
||||
* This function indicates whether or not an MLE Thread Discovery is currently in progress.
|
||||
*
|
||||
* @returns true if an MLE Thread Discovery is in progress, false otherwise.
|
||||
*
|
||||
* @returns true if an active scan is in progress.
|
||||
*/
|
||||
bool otDiscoverInProgress(void);
|
||||
bool otIsDiscoverInProgress(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -935,7 +935,7 @@ ThreadError otActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, otHandl
|
||||
reinterpret_cast<void *>(aCallback));
|
||||
}
|
||||
|
||||
bool otActiveScanInProgress(void)
|
||||
bool otIsActiveScanInProgress(void)
|
||||
{
|
||||
return sThreadNetif->GetMac().IsActiveScanInProgress();
|
||||
}
|
||||
@@ -990,6 +990,11 @@ ThreadError otDiscover(uint32_t aScanChannels, uint16_t aScanDuration, uint16_t
|
||||
reinterpret_cast<void *>(aCallback));
|
||||
}
|
||||
|
||||
bool otIsDiscoverInProgress(void)
|
||||
{
|
||||
return sThreadNetif->GetMle().IsDiscoverInProgress();
|
||||
}
|
||||
|
||||
void HandleMleDiscover(otActiveScanResult *aResult, void *aContext)
|
||||
{
|
||||
otHandleActiveScanResult handler = reinterpret_cast<otHandleActiveScanResult>(aContext);
|
||||
|
||||
@@ -103,6 +103,13 @@ ThreadError MeshForwarder::Stop()
|
||||
mPollTimer.Stop();
|
||||
mReassemblyTimer.Stop();
|
||||
|
||||
if (mScanning)
|
||||
{
|
||||
mMac.SetChannel(mRestoreChannel);
|
||||
mScanning = false;
|
||||
mMle.HandleDiscoverComplete();
|
||||
}
|
||||
|
||||
while ((message = mSendQueue.GetHead()) != NULL)
|
||||
{
|
||||
mSendQueue.Dequeue(*message);
|
||||
|
||||
+15
-1
@@ -148,6 +148,8 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
mAssignLinkQuality = 0;
|
||||
mAssignLinkMargin = 0;
|
||||
memset(&mAddr64, 0, sizeof(mAddr64));
|
||||
|
||||
mIsDiscoverInProgress = false;
|
||||
}
|
||||
|
||||
ThreadError Mle::Enable(void)
|
||||
@@ -218,12 +220,14 @@ ThreadError Mle::Discover(uint32_t aScanChannels, uint16_t aScanDuration, uint16
|
||||
DiscoverHandler aCallback, void *aContext)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
Message *message;
|
||||
Message *message = NULL;
|
||||
Ip6::Address destination;
|
||||
Tlv tlv;
|
||||
MeshCoP::DiscoveryRequestTlv discoveryRequest;
|
||||
uint16_t startOffset;
|
||||
|
||||
VerifyOrExit(!mIsDiscoverInProgress, error = kThreadError_Busy);
|
||||
|
||||
mDiscoverHandler = aCallback;
|
||||
mDiscoverContext = aContext;
|
||||
mMesh.SetDiscoverParameters(aScanChannels, aScanDuration);
|
||||
@@ -253,6 +257,8 @@ ThreadError Mle::Discover(uint32_t aScanChannels, uint16_t aScanDuration, uint16
|
||||
destination.mFields.m16[7] = HostSwap16(0x0002);
|
||||
SuccessOrExit(error = SendMessage(*message, destination));
|
||||
|
||||
mIsDiscoverInProgress = true;
|
||||
|
||||
otLogInfoMle("Sent discovery request\n");
|
||||
|
||||
exit:
|
||||
@@ -265,8 +271,14 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
bool Mle::IsDiscoverInProgress(void)
|
||||
{
|
||||
return mIsDiscoverInProgress;
|
||||
}
|
||||
|
||||
void Mle::HandleDiscoverComplete(void)
|
||||
{
|
||||
mIsDiscoverInProgress = false;
|
||||
mDiscoverHandler(NULL, mDiscoverContext);
|
||||
}
|
||||
|
||||
@@ -2232,6 +2244,8 @@ ThreadError Mle::HandleDiscoveryResponse(const Message &aMessage, const Ip6::Mes
|
||||
|
||||
otLogInfoMle("Handle discovery response\n");
|
||||
|
||||
VerifyOrExit(mIsDiscoverInProgress, error = kThreadError_Drop);
|
||||
|
||||
offset = aMessage.GetOffset();
|
||||
end = aMessage.GetLength();
|
||||
|
||||
|
||||
@@ -420,6 +420,14 @@ public:
|
||||
ThreadError Discover(uint32_t aScanChannels, uint16_t aScanDuration, uint16_t aPanId,
|
||||
DiscoverHandler aCallback, void *aContext);
|
||||
|
||||
/**
|
||||
* This method indicates whether or not an MLE Thread Discovery is currently in progress.
|
||||
*
|
||||
* @returns true if an MLE Thread Discovery is in progress, false otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsDiscoverInProgress(void);
|
||||
|
||||
/**
|
||||
* This method is called by the MeshForwarder to indicate that discovery is complete.
|
||||
*
|
||||
@@ -1146,6 +1154,7 @@ private:
|
||||
|
||||
DiscoverHandler mDiscoverHandler;
|
||||
void *mDiscoverContext;
|
||||
bool mIsDiscoverInProgress;
|
||||
|
||||
Ip6::NetifUnicastAddress mLinkLocal16;
|
||||
Ip6::NetifUnicastAddress mLinkLocal64;
|
||||
|
||||
@@ -1317,7 +1317,7 @@ ThreadError NcpBase::GetPropertyHandler_MAC_SCAN_STATE(uint8_t header, spinel_pr
|
||||
{
|
||||
ThreadError errorCode = kThreadError_None;
|
||||
|
||||
if (otActiveScanInProgress())
|
||||
if (otIsActiveScanInProgress())
|
||||
{
|
||||
errorCode = SendPropertyUpdate(
|
||||
header,
|
||||
|
||||
Reference in New Issue
Block a user