uint8_t m_coordAddressMode;
ieee154_macPANId_t m_coordPANID;
ieee154_PANDescriptor_t m_PANDescriptor;
- bool m_isPANDescriptorValid;
+ bool m_wasScanSuccessful;
void startApp();
event void Boot.booted() {
// through the MLME_BEACON_NOTIFY interface, i.e.
// we set the macAutoRequest attribute to FALSE
call MLME_SET.macAutoRequest(FALSE);
+ m_wasScanSuccessful = FALSE;
call MLME_SCAN.request (
PASSIVE_SCAN, // ScanType
channel, // ScanChannels
{
// received a beacon frame during SCAN
ieee154_phyCurrentPage_t page = call MLME_GET.phyCurrentPage();
- ieee154_macBSN_t beaconSequenceNumber = call BeaconFrame.getBSN(frame);
- if (beaconSequenceNumber & 1)
- call Leds.led2On();
- else
- call Leds.led2Off();
-
- if (!m_isPANDescriptorValid && call BeaconFrame.parsePANDescriptor(
+ if (!m_wasScanSuccessful && call BeaconFrame.parsePANDescriptor(
frame, RADIO_CHANNEL, page, &m_PANDescriptor) == SUCCESS){
// let's see if the beacon is from our coordinator...
if (m_PANDescriptor.CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
m_PANDescriptor.CoordPANId == PAN_ID &&
m_PANDescriptor.CoordAddress.shortAddress == COORDINATOR_ADDRESS){
// wait until SCAN is finished, then syncronize to beacons
- m_isPANDescriptorValid = TRUE;
+ m_wasScanSuccessful = TRUE;
}
}
return frame;
ieee154_PANDescriptor_t* PANDescriptorList
)
{
- if (m_isPANDescriptorValid){
+ if (m_wasScanSuccessful){
// set the macAutoRequest attribute to TRUE, so indirect
// transmissions are automatically carried through
call MLME_SET.macAutoRequest(TRUE);
ieee154_security_t *security)
{
call Leds.led1Off();
- startApp();
}
event message_t* MCPS_DATA.indication (message_t* frame)