+ } else if ((((ieee154_header_t*) frame->header)->mhr[0] & FC1_FRAMETYPE_MASK) == FC1_FRAMETYPE_BEACON) {
+
+ // PASSIVE_SCAN / ACTIVE_SCAN:
+ // A beacon frame containing a non-empty payload is always signalled
+ // to the next higher layer (regardless of the value of macAutoRequest);
+ // when macAutoRequest is set to TRUE, then the beacon is always
+ // stored in the PAN Descriptor list (see 7.1.11.2.1 - Table 68)
+
+ if (!call MLME_GET.macAutoRequest())
+ return signal MLME_BEACON_NOTIFY.indication (frame);
+ else if (m_resultIndex >= m_resultListNumEntries) {
+ m_terminateScan = TRUE;
+ call RadioOff.off();
+ } else if (call BeaconFrame.parsePANDescriptor(
+ frame,
+ m_currentChannelNum,
+ IEEE154_SUPPORTED_CHANNELPAGE,
+ &((ieee154_PANDescriptor_t*) m_resultList)[m_resultIndex]) == SUCCESS) {
+
+ // check uniqueness: PAN ID and source address must
+ // not be found in a previously received beacon
+ uint8_t i;
+ ieee154_PANDescriptor_t* descriptor = (ieee154_PANDescriptor_t*) m_resultList;
+
+ dbg_serial("ScanP", "Received beacon, source: 0x%lx, channel: %lu.\n",
+ (uint32_t) descriptor[m_resultIndex].CoordAddress.shortAddress, (uint32_t) m_currentChannelNum);
+ for (i=0; i<m_resultIndex; i++)
+ if (descriptor[i].CoordPANId == descriptor[m_resultIndex].CoordPANId &&
+ descriptor[i].CoordAddrMode == descriptor[m_resultIndex].CoordAddrMode)
+ if ((descriptor[i].CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
+ descriptor[i].CoordAddress.shortAddress ==
+ descriptor[m_resultIndex].CoordAddress.shortAddress) ||
+ (descriptor[i].CoordAddrMode == ADDR_MODE_EXTENDED_ADDRESS &&
+ descriptor[i].CoordAddress.extendedAddress ==
+ descriptor[m_resultIndex].CoordAddress.extendedAddress))
+ break; // not unique
+ if (i == m_resultIndex)
+ m_resultIndex++; // was unique