From 35905c1cd223f9fbef7f5435b518dc34acfd3bef Mon Sep 17 00:00:00 2001 From: janhauer Date: Thu, 30 Apr 2009 13:23:48 +0000 Subject: [PATCH] Energy scan returned wrong status code if EnergyDetectList array size was equal to number of scanned channels (as pointed out by D. Santos). This is now fixed. --- tos/lib/mac/tkn154/ScanP.nc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tos/lib/mac/tkn154/ScanP.nc b/tos/lib/mac/tkn154/ScanP.nc index a92fc5ac..37ac03b6 100644 --- a/tos/lib/mac/tkn154/ScanP.nc +++ b/tos/lib/mac/tkn154/ScanP.nc @@ -272,21 +272,23 @@ implementation uint32_t unscannedChannels = 0; if (m_terminateScan){ - // scan operation terminated prematurely because the max. - // number of PAN descriptors/ED samples was reached - result = IEEE154_LIMIT_REACHED; - - // mark the channel on which we received the last beacon - // as unscanned, because it was not completely scanned + // Scan operation terminated because the max. + // number of PAN descriptors/ED samples was reached. + // Check if there are channels that were unscanned. + // In active/passive scan we consider a channel + // unscanned if it was not completely scanned. if (m_scanType == PASSIVE_SCAN || m_scanType == ACTIVE_SCAN) - currentChannelBit >>= 1; + currentChannelBit >>= 1; // last (partially) scanned channel while (!(currentChannelBit & INVALID_CHANNEL_BITMASK) && (m_scanChannels & currentChannelBit)){ unscannedChannels |= currentChannelBit; currentChannelBit <<= 1; } + if (unscannedChannels) // some channels were not (completely) scanned + result = IEEE154_LIMIT_REACHED; } else if (m_scanType != ENERGY_DETECTION_SCAN && !m_resultIndex) result = IEEE154_NO_BEACON; + if (m_scanType == PASSIVE_SCAN || m_scanType == ACTIVE_SCAN) call MLME_SET.macPANId(m_PANID); if (m_txFrame != NULL) { -- 2.39.2